信息對抗技術(shù)-ids.ppt_第1頁
信息對抗技術(shù)-ids.ppt_第2頁
信息對抗技術(shù)-ids.ppt_第3頁
信息對抗技術(shù)-ids.ppt_第4頁
信息對抗技術(shù)-ids.ppt_第5頁
已閱讀5頁,還剩63頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、信息對抗技術(shù),入侵檢測,入侵檢測系統(tǒng)定義,入侵檢測系統(tǒng)是通過諸如,數(shù)據(jù)審計(jì),網(wǎng)絡(luò)報(bào)文分析等手段,檢測各種入侵行為,保證網(wǎng)絡(luò)安全。英文是intrusion detection system (IDS)。,IDS的存在理由,網(wǎng)絡(luò)防護(hù)中僅使用防火墻、訪問控制、加解密技術(shù)并不能徹底解決安全問題。 因?yàn)槭紫热肭终呖蓪ふ曳阑饓驮L問控制背后敞開的后門; 其次防火墻完全不能阻止內(nèi)部襲擊; 第三,由于性能限制,防火墻通常不能提供實(shí)時(shí)入侵檢測能力,而訪問控制對取得根權(quán)限的入侵者束手無策。 另外,加解密認(rèn)證技術(shù)不能完全杜絕IP欺騙、重放攻擊(replay attack)等入侵。特別對于危害十分嚴(yán)重的緩沖區(qū)溢出(b

2、uffer overflow)攻擊,以上傳統(tǒng)技術(shù)均無有效防護(hù)措施。,IDS的歷史,在80年代就開展了早期基礎(chǔ)理論研究工作。隨著計(jì)算機(jī)系統(tǒng)軟、硬件飛速發(fā)展,以及網(wǎng)絡(luò)技術(shù)、分布式計(jì)算、系統(tǒng)工程、人工智能等計(jì)算機(jī)新興技術(shù)與理論的不斷完善,入侵檢測理論也在發(fā)展變化中,至今仍未形成比較成熟的理論體系,IDS的分類,根據(jù)檢測原理可分為異常入侵檢測,誤用入侵檢測。 根據(jù)數(shù)據(jù)來源和系統(tǒng)結(jié)構(gòu)可分為基于主機(jī)的入侵檢測和基于網(wǎng)絡(luò)的入侵檢測和分布式入侵檢測。,誤用入侵檢測,或稱為基于特征的入侵檢測系統(tǒng)(Signature-based IDS) 必須從一個(gè)或多個(gè)網(wǎng)絡(luò)數(shù)據(jù)包或?qū)徲?jì)數(shù)據(jù)中提取出特定模式。如果這些模式與已知入

3、侵模式匹配,系統(tǒng)就能檢測出攻擊,因此它只能鑒別已知模式,不能檢測新型攻擊。同時(shí),對特征錯(cuò)誤理解將產(chǎn)生誤報(bào)。獲取特征有多種方法,包括手工提取特征和用傳感器自動學(xué)習(xí)等。,Snort是誤用入侵檢測的代表,網(wǎng)站: 該軟件是開源軟件。其基本原理是將網(wǎng)卡設(shè)定為混雜模式,然后監(jiān)聽網(wǎng)絡(luò)上的報(bào)文,并將報(bào)文和用戶自定義的規(guī)則進(jìn)行比較,如果滿足規(guī)則,則會根據(jù)用戶要求將該次匹配命中的事件紀(jì)錄到日志。,一個(gè)簡單的規(guī)則如下: alert tcp any any - any 7026 (msg: “glacier”). 這條規(guī)則的意思是:凡是從任何機(jī)器的任何端口到任何機(jī)器的7026端口的tcp訪問

4、,就紀(jì)錄下來,而紀(jì)錄的名字為glacier. 因?yàn)楹箝T冰河的缺省端口實(shí)7026所以滿足該規(guī)則的就可能是冰河,紀(jì)錄下來的日志具有如下格式: * 1:0:0 glacier * Priority: 0 02/14-09:32:25.367646 11123- 47 7026 TCP TTL:255 TOS:0 x0 ID:46482 IpLen:20 DgmLen:60,Snort的規(guī)則中還有一個(gè)重要的選項(xiàng),就是content,它指出如果報(bào)文中包含指定的字符串就告警。 alert tcp any any - any any (content: “h

5、ell”). 比如上面的規(guī)則就表明,如果報(bào)文中包含hell字符串就告警。,很明顯,snort的準(zhǔn)確率依賴規(guī)則的準(zhǔn)確性,更為重要的是,其判斷依據(jù)往往會造成虛假告警或遺漏。 Snort也對其加以改進(jìn)。比如,它增加了一中規(guī)則叫動態(tài)規(guī)則,就是,當(dāng)一個(gè)規(guī)則滿足后,檢測另外一條規(guī)則。這里有一定專家系統(tǒng)的影子。,Snort在網(wǎng)絡(luò)抓包方面,使用了一種libpcap庫,這是unix上的一個(gè)抓包庫,再linux和windows上都有相關(guān)的版本,windows上叫winpcap。可以在winpcap網(wǎng)站上下載到相關(guān)軟件。,異常入侵檢測,基于異常的入侵檢測系統(tǒng)(Anomaly-based IDS),其思路如下:正常系

6、統(tǒng)有一“正常基準(zhǔn)”,如CPU利用率、磁盤活動、用戶注冊、文件活動等等。一旦偏離這一“正?;鶞?zhǔn)”,檢測系統(tǒng)將觸發(fā)?;诋惓z測的主要優(yōu)點(diǎn)是能識別新型攻擊。但正常操作產(chǎn)生變化時(shí)會導(dǎo)致誤報(bào),而入侵行為表現(xiàn)為正常又將導(dǎo)致漏報(bào),且系統(tǒng)很難確定攻擊類型。,檢測用戶行為模式是一種異常入侵檢測。 H. S. Javitz and A. Valdes. The SRI IDES statistical anomaly detector. In Proceedings of the 1991 IEEE Symposium on Security and Privacy, pages 316C326, Oaklan

7、d, California, May 20C22, 1991. IEEE Computer Society Press.,基于系統(tǒng)調(diào)用序列的免疫系統(tǒng),該系統(tǒng)認(rèn)為,對任何系統(tǒng)而言,存在一個(gè)基因庫,該庫中的基因是如下定義的:即一組系統(tǒng)調(diào)用序列,比如長度為45個(gè)系統(tǒng)調(diào)用。例如:socketbindlistenaccept.就是一個(gè)基因。 通過在正常無攻擊環(huán)境下運(yùn)行一個(gè)網(wǎng)絡(luò)服務(wù)程序,可以得到其基因庫。然后在檢測時(shí),比較這些庫,如果基因出現(xiàn)偏差,就意味著異常或攻擊發(fā)生。,參見相關(guān)文章 Stephanie Forrest, Steven Hofmeyer, A sense of self for UNXI

8、 processes. In Proceedings of the 1996 IEEE Symposium on Security and Privacy. 1996. Steven A. Hofmeyr, Stephanie Forrest, Intrusion Detection using Sequences of System Calls, Journal of Computer Security 1998.,按IDS結(jié)構(gòu)分類,基于主機(jī)的入侵檢測系統(tǒng) 基于主機(jī)的入侵檢測系統(tǒng)歷史最久,多用戶計(jì)算機(jī)系統(tǒng)出現(xiàn)不久已有雛形。最早用于審計(jì)用戶的活動,比如用戶的登陸、命令操作、應(yīng)用程序使用資源情況

9、等方面。此類系統(tǒng)一般使用操作系統(tǒng)的審計(jì)日志作為輸入,某些也會主動與主機(jī)系統(tǒng)交互獲得其它信息。收集的信息集中在系統(tǒng)調(diào)用和應(yīng)用層審計(jì)上,試圖從日志記錄中判斷出濫用和入侵事件的線索。典型的有NIDES和NetStat,基于網(wǎng)絡(luò)的入侵檢測系統(tǒng) 由于來自網(wǎng)絡(luò)的攻擊事件逐漸成為信息系統(tǒng)的最大威脅,因而基于網(wǎng)絡(luò)的入侵檢測系統(tǒng)具有重要價(jià)值。基于網(wǎng)絡(luò)的入侵檢測系統(tǒng)監(jiān)聽網(wǎng)絡(luò)原始流量,通過線路監(jiān)聽手段對捕獲的網(wǎng)絡(luò)報(bào)文進(jìn)行處理,從中獲取有用的信息?;诰W(wǎng)絡(luò)的入侵檢測系統(tǒng)通過流量分析提取特征模式,與已知攻擊特征匹配或與正常網(wǎng)絡(luò)行為原型比較識別出攻擊事件,如Snort、Bro。與基于主機(jī)的入侵檢測不同,基于網(wǎng)絡(luò)的IDS更

10、適用于檢測系統(tǒng)應(yīng)用層以下的底層攻擊事件,混合分布式入侵檢測系統(tǒng) 合分布式入侵檢測系統(tǒng)能從不同的主機(jī)、網(wǎng)絡(luò)組件、或通過網(wǎng)絡(luò)監(jiān)聽方式收集數(shù)據(jù),系統(tǒng)可利用網(wǎng)絡(luò)數(shù)據(jù)也可收集分析來自主機(jī)系統(tǒng)的高層事件發(fā)現(xiàn)可疑行為。,掌握libpcap,掌握libpcap可以為我們自主開發(fā)基于網(wǎng)絡(luò)的入侵檢測提供方便。,主要內(nèi)容: 一、Winpcap使用介紹 二、面象對象對Winpcap的封裝。,一、Winpcap介紹,Winpcap是UNIX下的libpcap移植到windows下的 產(chǎn)物,他是一個(gè)free and open source的項(xiàng)目。Winp- cap工作于驅(qū)動(Driver)層,所以能以很高的效率進(jìn) 行網(wǎng)絡(luò)

11、操作。一、Winpcap提供了以下強(qiáng)大的功能: 1捕獲原始的數(shù)據(jù)包 見源碼:CapturePacket 2設(shè)置filter,只捕獲自己感興趣的數(shù)據(jù)包,3方便的把捕獲的數(shù)據(jù)包輸出到文件和從文件輸入 見源碼:DumpToFile4發(fā)送原始的數(shù)據(jù)包 見源碼 SendPacket5統(tǒng)計(jì)網(wǎng)絡(luò)流量 見源碼:DisplayStatus,二、Winpcap的安裝使用方法,1到http:/winpcap.polito.it下載winpcap的安裝包, 程序員開發(fā)包。2執(zhí)行安裝包,運(yùn)行winpcap 程序3解壓開發(fā)包,在VC的option的include和lib中加 入winpcap的include和lib,4.

12、 在你的程序中加入#include ,#include .然后在工程的setting中加入預(yù)定義宏:WPCAP,HAV E_REMOTE.導(dǎo)入wpcap.lib, wsock32.lib庫5編寫wpcap程序,三、Winpcap的一些基本的功能的實(shí)現(xiàn),(一)捕獲數(shù)據(jù)包 1、. 枚舉所有的可用的設(shè)備pcap_findalldevs_ex (可選) 2. 通過名字打開一個(gè)設(shè)備pcap_open() 3、在這里可以打開一個(gè)文件,只是在打開這個(gè)文 件之前需要通過pcap_createsrcstr創(chuàng)建相應(yīng)的name string 4、設(shè)置Filterpcap_compile, pcap_setfilte

13、r (可選) 5、 捕獲數(shù)據(jù),有幾種捕獲數(shù)據(jù)的方法(捕獲數(shù)據(jù)的數(shù)據(jù)都是最原始的數(shù) 據(jù)包,即包含數(shù)據(jù)鏈路層的數(shù)據(jù)頭)a 是以回調(diào)的方式 pcap_loop,pcap_dispatch() . 這兩種方法基本相同,底層收集數(shù)據(jù)包,當(dāng)滿足一定的條件 (timeout 或者緩沖區(qū)滿),就會調(diào)用回調(diào)函數(shù),把收集到 的原始數(shù)據(jù)包s,交給用戶。他們返回的數(shù)據(jù)緩沖區(qū)包含多個(gè)包 例子見:CapturePacket b. pcap_next_ex()的方式每當(dāng)一個(gè)包到到達(dá)以后,pcap_next_ex就會返回,返回的 數(shù)據(jù)緩沖區(qū)里只包含一個(gè)包。,(二)發(fā)送數(shù)據(jù)包,Winpcap中有發(fā)送單個(gè)包和發(fā)送多個(gè)包的方法。這

14、里 只說說發(fā)送單個(gè)包1 通過名字打開一個(gè)設(shè)備pcap_open2 自己構(gòu)造一個(gè)原始數(shù)據(jù)包(這個(gè)數(shù)據(jù)包會不經(jīng)過 任何處理就發(fā)送出去,所以必須把包中的各個(gè)字段設(shè) 置好。另外這個(gè)數(shù)據(jù)包是包含數(shù)據(jù)鏈路層報(bào)頭的)3 使用pcap_sendpacket()發(fā)送數(shù)據(jù)包 見源碼SendPacket工程,(三)統(tǒng)計(jì)網(wǎng)絡(luò)流量,通過名字打開一個(gè)設(shè)備pcap_open通過 read_timeout來設(shè)置統(tǒng)計(jì)的時(shí)間間隔 設(shè)置filterpcap_compile, pcap_setfilter (可選) 設(shè)置設(shè)備的為統(tǒng)計(jì)模式 pcap_setmode(MODE _STAT); 4. 開始統(tǒng)計(jì),pcap_loop/pcap

15、_dispatch() 5在回調(diào)函數(shù)中的參數(shù)中就包含了統(tǒng)計(jì)信息,/下面是一個(gè)應(yīng)用winpcap寫的一個(gè)網(wǎng)絡(luò)流量統(tǒng)計(jì)的例子, 也可參見 源碼DisplayStatus工程/ nettraffic.cpp : Defines the entry point for the console /application.#include stdafx.h#include #include #include #include ,using namespace std;/-/-void dispatcher_handler(u_char* user_data, const struct pcap_pkthd

16、r * pkthdr, const u_char *pktdata);/-int main(int argc, char* argv)int i;pcap_if_t* alldevs;,pcap_if_t* dev;char errorbufPCAP_ERRBUF_SIZE;int choice;pcap_t* stathandle;WSADATA wsadata;struct timeval timestamp;if( WSAStartup( MAKEWORD(2,2), ,/enum all deviceif( pcap_findalldevs_ex( PCAP_SRC_IF_STRING

17、, NULL, ,for( i=0,dev = alldevs; dev != NULL; dev = dev-next )coutnameendl;if( i= 0 )WSACleanup();cerrno device found!endl;return (-2);,/let user choicewhile( 1)coutchoice;if( choice = 1 ,/move to the choosen devicefor( i=0, dev = alldevs; inext );if( (stathandle = pcap_open( dev-name, 100, PCAP_OPE

18、NFLAG_PROMISCUOUS, 500,NULL, errorbuf ) ) = NULL )cerrname errorbufendl;,pcap_freealldevs( alldevs );WSACleanup();return (-3);coutname .endl;pcap_freealldevs( alldevs );,pcap_setmode( stathandle, MODE_STAT );timestamp.tv_sec = 0;timestamp.tv_usec = 0;pcap_loop( stathandle, 0, dispatcher_handler,(uns

19、igned char*),/-void dispatcher_handler(u_char* user_data, const struct pcap_pkthdr * pkthdr, const u_char *pktdata)static struct timeval tstamp = *( (struct timeval*)user_data );LARGE_INTEGER Bps,Pps;unsigned long delay;char strtime32;delay = (pkthdr-ts.tv_sec - tstamp.tv_sec)*1000000 tstam p.tv_use

20、c + pkthdr-ts.tv_usec;Pps.QuadPart = (*(LONGLONG*)(pktdata) * 1000000 ) / delay;Bps.QuadPart = (*(LONGLONG*)(pktdata + 8) * 1000000 ) / delay;,struct tm* ltime = localtime( ,二、面象對象對Winpcap的封裝,1、封裝的原因: Winpcap提供的是C函數(shù),是面向過程的 對包進(jìn)行協(xié)議解析。 2、封裝的目標(biāo): 使對Winpcap的操作類似于對文件的操作。 register,open,close,3、封裝的申明,class C

21、Capture private: pcap_t * adhandle; char buff1536; CCapCallback * PCallbackObject; pcap_t * Open(int ); int GetPackets(pcap_t *adhandle,char * pbuf,int len,int packetcount,int ,class CCapCallback private: public: CCapCallback(); CCapCallback(); virtual HandlePacket(char * buff,int len) ; ;,/ / 這個(gè)文件包

22、括兩個(gè)類的實(shí)現(xiàn) CCapture CCapCallback / /*說明:CCapCallback是一個(gè)純虛類,不能直接使用,必須繼 /*承后才能使用,CCapCallback 作為類CCapture 的接口類,*/ #include stdafx.h #include WCapDll.h pcap_t * adhandle; struct tm *ltime; char timestr16; struct pcap_pkthdr *header; const u_char *pkt_data; int res; export_packet recvpacket; int decode_iph

23、(pexport_packet packet); int decode_eth(char *buff,const unsigned char *packetbuf,int len);,/ / 以下是CCapture 類的實(shí)現(xiàn)/ / CCapture:CCapture() CCapture:CCapture() int CCapture:CapRegister(CCapCallback * PCbObject) if (PCbObject) PCallbackObject=PCbObject; return 0; else return -1; ,int CCapture:CapOpen(int

24、 NIC) int result; int RealBytes; adhandle=Open(NIC); if (adhandle=NULL) return -1; while (1) result=GetPackets(adhandle,buff,1536,1,RealBytes); PCallbackObject-HandlePacket(buff,RealBytes); if (result!=1) break; return -1; ,int CCapture:CapClose() int res=0; res=Close(adhandle); return res; ,pcap_t

25、* CCapture: Open(int nic) /static pcap_t * adhandle; pcap_if_t *alldevs; pcap_if_t *d; int i=0; int NicTotal=0; char errbufPCAP_ERRBUF_SIZE; /* Retrieve the device list from the local machine */ if (pcap_findalldevs( ,/* Print the list */ for(d= alldevs; d != NULL; d= d-next) NicTotal+; / check the

26、paramer if (nicNicTotal-1) | (NicTotal=0) ) return NULL; for(d=alldevs, i=0; inext, i+);,/* Open the device */ if ( (adhandle= pcap_open_live(d-name, / name of /the device 8000, / portion of the packet to capture / 65536 guarantees that the whole packet will be /captured on all the link layers 1, /

27、promiscuous mode 1000, / read timeout errbuf / error buffer ) ) = NULL) fprintf(stderr,nUnable to open the adapter. %s is not supported by WinPcapn, d-name); /* Free the device list */ pcap_freealldevs(alldevs); return NULL; ,/* We dont need any more the device list. Free it */ pcap_freealldevs(alld

28、evs); /MessageBox(NULL,this is a test,example,MB_OK); #ifdef DEBUG printf(%sn,open succeed); #endif return adhandle; ,int CCapture:GetPackets(pcap_t *adhandle,char * pbuf, int len,int packetcount,int while(res = pcap_next_ex( adhandle, /36 reference to the size of the ethernet_frame if (retainlen=(h

29、eader-len+36) /resolve the packet decode_eth(pbuf,pkt_data,header-len); / decide whether to receive the next packet pbuf+=(sizeof(export_packet)+header-len); count+;,RealLen+=header-len+36; retainlen-=(sizeof(export_packet)+ header-len); if (retainlen=36) #ifdef DEBUG printf(%sn,memory size less tha

30、n 36 and exit); #endif return count; ,if (retainlenlen+36) #ifdef DEBUG printf(%sn,retainlen len+36 and exit); #endif return count; if (count=packetcount) #ifdef DEBUG printf(%sn, the count required have enough); #endif return count;, else if (retainlenlen+36) /at first /the buff is not enough to lo

31、ad a packet #ifdef DEBUG printf(%sn, retainlen less than (header-len+36) bytes and exit); #endif return count; if(res = -1) #ifdef DEBUG printf(Error reading the packets: %sn, pcap_geterr(adhandle); #endif return -1; return count; ,int decode_eth(char *buff,const unsigned char *packetbuf,int len) ex

32、port_packet * temp; memcpy(buff+36),packetbuf,len); temp = (export_packet *)buff; temp-buffer=buff+36; temp-totallen=len+36; temp-pethheader=(ethernet_frame *)(buff+36); ethernet_frame * tef=(ethernet_frame *)packetbuf; if (tef-h_type=0 x08 #endif temp-pipheader=(ip_header *)(temp-buffer+14); #ifdef DEBUG printf(n%d.%d.%d.%d-%d.%d.%d.%dn, temp-pipheader-saddr.byte1, temp-pipheader-saddr.byte2, temp-pipheader-saddr.byte3, temp-pipheader-saddr.byte4, temp-piphead

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論