PCAP文件格式分析(做抓包軟件之必備)
一、基本格式:
文件頭 數(shù)據(jù)包頭 數(shù)據(jù)報(bào) 數(shù)據(jù)包頭 數(shù)據(jù)報(bào)......
二、文件頭結(jié)構(gòu)體:
sturct pcap_file_header
{
DWORD magic;
WORD version_major;
WORD version_minor;
DWORD thiszone;
DWORD sigfigs;
DWORD snaplen;
DWORD linktype;
}
說明:
1、標(biāo)識位:32位的,這個(gè)標(biāo)識位的值是16進(jìn)制的 0xa1b2c3d4。
a 32-bit magic number ,The magic number has the value hex a1b2c3d4.
2、主版本號:16位, 默認(rèn)值為0x2。
a 16-bit major version number,The major version number should have the value 2.
3、副版本號:16位,默認(rèn)值為0x04。
a 16-bit minor version number,The minor version number should have the value 4.
4、區(qū)域時(shí)間:32位,實(shí)際上該值并未使用,因此可以將該位設(shè)置為0。
a 32-bit time zone offset field that actually not used, so you can (and probably should) just make it 0;
5、精確時(shí)間戳:32位,實(shí)際上該值并未使用,因此可以將該值設(shè)置為0。
a 32-bit time stamp accuracy field tha not actually used,so you can (and probably should) just make it 0;
6、數(shù)據(jù)包最大長度:32位,該值設(shè)置所抓獲的數(shù)據(jù)包的最大長度,如果所有數(shù)據(jù)包都要抓獲,將該值設(shè)置為65535; 例如:想獲取數(shù)據(jù)包的前64字節(jié),可將該值設(shè)置為64。
a 32-bit snapshot length" field;The snapshot length field should be the maximum number of bytes perpacket that will be captured. If the entire packet is captured, make it 65535; if you only capture, for example, the first 64 bytes of the packet, make it 64.
7、鏈路層類型:32位, 數(shù)據(jù)包的鏈路層包頭決定了鏈路層的類型。
a 32-bit link layer type field.The link-layer type depends on the type of link-layer header that the
packets in the capture file have:
以下是數(shù)據(jù)值與鏈路層類型的對應(yīng)表
0 BSD loopback devices, except for later OpenBSD
1 Ethernet, and Linux loopback devices 以太網(wǎng)類型,大多數(shù)的數(shù)據(jù)包為這種類型。
6 802.5 Token Ring
7 ARCnet
8 SLIP
9 PPP
10 FDDI
100 LLC/SNAP-encapsulated ATM
101 raw IP, with no link
102 BSD/OS SLIP
103 BSD/OS PPP
104 Cisco HDLC
105 802.11
108 later OpenBSD loopback devices (with the AF_value in network byte order)
113 special Linux cooked capture
114 LocalTalk
三、數(shù)據(jù)包頭結(jié)構(gòu)體:
struct pcap_pkthdr
{
struct timeval ts;
DWORD caplen;
DWORD len;
}
struct timeval
{
DWORD GMTtime;
DWORD microTime
}
說明:
1、時(shí)間戳,包括:
秒計(jì)時(shí):32位,一個(gè)UNIX格式的精確到秒時(shí)間值,用來記錄數(shù)據(jù)包抓獲的時(shí)間,記錄方式是記錄從格林尼治時(shí)間的1970年1月1日 00:00:00 到抓包時(shí)經(jīng)過的秒數(shù);
毫秒計(jì)時(shí):32位, 抓取數(shù)據(jù)包時(shí)的毫秒值。
a time stamp, consisting of:
a UNIX-format time-in-seconds when the packet was captured, i.e. the number of seconds since January 1,1970, 00:00:00 GMT (that GMT, *NOT* local time!);
the number of microseconds since that second when the packet was captured;
2、數(shù)據(jù)包長度:32位 ,標(biāo)識所抓獲的數(shù)據(jù)包保存在pcap文件中的實(shí)際長度,以字節(jié)為單位。
a 32-bit value giving the number of bytes of packet data that were captured;
3、數(shù)據(jù)包實(shí)際長度: 所抓獲的數(shù)據(jù)包的真實(shí)長度,如果文件中保存不是完整的數(shù)據(jù)包,那么這個(gè)值可能要比前面的數(shù)據(jù)包長度的值大。
a 32-bit value giving the actual length of the packet, in bytes (which may be greater than the previous number, if you are not saving the entire packet).
發(fā)表于 @ 2008年01月01日 21:12:00 | 評論( 2 ) | 編輯| 舉報(bào)| 收藏
舊一篇:Packed.Win32.NSAnti.a(svchoxt)分析報(bào)告 | 新一篇:延遲加載Dll的實(shí)現(xiàn)原理
相關(guān)文章
Table of Delphi data types and C++ typeswindows data typesMFC 數(shù)據(jù)類型ethereal文件格式libpcap如何知道可執(zhí)行文件是32-bit還是64-bitMAKELONG用法MultiMedia eXtensionstcpdump抓包命令swh326 發(fā)表于2009年7月27日 星期一 15:18:36 IP:舉報(bào)刪除
時(shí)間戳后面那個(gè)是毫秒么~?? 我看另一篇文章寫的microseconds呢anzijin 發(fā)表于2009年7月27日 星期一 18:05:07 IP:舉報(bào)刪除
是微秒,這里寫錯(cuò)了,非常感謝你的指正。
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請
點(diǎn)擊舉報(bào)。