pcap文件格式及文件解析

上传人:汽*** 文档编号:498532730 上传时间:2023-06-23 格式:DOCX 页数:16 大小:258.25KB
返回 下载 相关 举报
pcap文件格式及文件解析_第1页
第1页 / 共16页
pcap文件格式及文件解析_第2页
第2页 / 共16页
pcap文件格式及文件解析_第3页
第3页 / 共16页
pcap文件格式及文件解析_第4页
第4页 / 共16页
pcap文件格式及文件解析_第5页
第5页 / 共16页
点击查看更多>>
资源描述

《pcap文件格式及文件解析》由会员分享,可在线阅读,更多相关《pcap文件格式及文件解析(16页珍藏版)》请在金锄头文库上搜索。

1、第一部分:PCAP包文件格式基本格式:文件头数据包头数据报数据包头数据报sturct pcap_file_headerDWORDmagic;DWORDversion_major;DWORDversion_minor;DWORDthiszone;DWORDsigfigs;DWORDsnaplen;DWORDlinktype;说明:1 、标识位: 32 位的,这个标识位的值是16 进制的 0xa1b2c3d4 。a 32-bit magic number ,The magic number has the value hex a1b2c3d4.2 、主版本号: 16 位, 默认值为 0x2 。a

2、16-bit major version number,The major version number should have the value 2.3 、副版本号: 16 位,默认值为 0x04 。a 16-bit minor version number,The minor version number should have the value 4.4、区域时间: 32 位,实际上该值并未使用,因此可以将该位设置为 0 。a 32-bit time zone offset field that actually not used, so you can (and probably s

3、hould) just make it 0;5 、精确时间戳: 32 位,实际上该值并未使用,因此可以将该值设置为 0 。a 32-bit time stamp accuracy field tha not actually used,so you can (andprobably should) just make it 0;6 、 数据包最大长度: 32 位,该值设置所抓获的数据包的最大长度,如果所有数据包都要抓获,将该值设置为 65535 ;例如:想获取数据包的前64 字节,可将该值设置为 64 。a 32-bit snapshot length" field;The snap

4、shot 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 位, 数据包的链路层包头决定了链路层的类型。a 32-bit link layer type field.The link-layer ty

5、pe depends on the type of link-layerheader that thepackets in the capture file have:以下是数据值与链路层类型的对应表0 BSD loopback devices, except for later OpenBSD1 Ethernet, and Linux loopback devices 以太网类型,大多数的数据包为这种类型。6 802.5 Token Ring7 ARCnet8 SLIP9 PPP10FDDI100LLC/SNAP-encapsulated ATM101raw IP, with no link

6、102BSD/OS SLIP103BSD/OS PPP104Cisco HDLC105802.11108 later OpenBSD loopback devices (with the AF_value in network byte order)113special Linux cooked capture114LocalTalkpacket数据包头:2) Packet包头(1SB)和Pa eke逾据组成struct pcap_pkthdrstruct timDWORDDWORDstruct timDWORDDWORDts;caplen;len;GMTtime;microTime说明:1

7、、时间戳,包括:秒计时: 32 位,一个 UNIX 格式的精确到秒时间值,用来记录数据包抓获的时间,记录方式是记录从格林尼治时间的 1970 年 1 月 1 日 00:00:00 到抓包时经过的秒数;微秒计时: 32 位, 抓取数据包时的微秒值。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

8、!);the number of microseconds since that second when the packet was captured;2 、数据包长度: 32 位 ,标识所抓获的数据包保存在 pcap 文件中的实际长度,以字节为单位。a 32-bit value giving the number of bytes of packet data that were captured;3 、数据包实际长度: 所抓获的数据包的真实长度,如果文件中保存不是完整的数据包,那么这个值可能要比前面的数据包长度的值大。a 32-bit value giving the actual le

9、ngth of the packet, in bytes (which may be greater than the previous number, if you are not saving the entire packet).四: packet 数据:即 Packet (通常就是链路层的数据帧)具体内容,长度就是Caplen ,这个长度的后面,就是当前PCAP 文件中存放的下一个Packet 数据包,也就是说: PCAP 文件里面并没有规定捕获的Packet 数据包之间有什么间隔字符串,下一组数据在文件中的起始位置。我们需要靠第一个Packet 包确定。 最后, Packet 数据部

10、分的格式其实就是标准的网路协议格式了 可以任何网络教材上找得到。前X个字节包为数提包包头,包含了一些文件言息+五:举例分析Offset(h) 00000000 OOOODOIO ooooDoza 00000030 CCUC&14O OOOODOSO 0000DO60 QQQgTQ OOOOOOBO “口口 H3J 口 COOO&:aO OGDO&OBO OOOOOOCO OQ-OOOODO ijC-GOlF jEO QODOOCiFO 00000100 00000110 00000120 00000130 GODOOH4Q 00DOalso OOOOD16G 00000170 oDooiao0

11、2 03 04 05 06 07 OS 09 OA OB 0C OD 0E CEGOOD OCI.LD CJQJD g却 KJ4l) W5 口 WtU ,00701U101D101D101O1O JI*7H-4C百口A4 S3 妙COE 3G60 BDDO 7腱国与工0 891o d- / 1 J fl- O 3 a_colf 守有 QfeQIZQIfe4 CHJ11CH0O1朝 c ip9 c J- D 37 o-匕工&-5 ft 40LJb聚 m&-mr 衣 M&lIH-&iMu: E4B力00 f a-1 6 & o 14 glL946 加ob8 A 5 1 o J TiQI QcrQ0

12、 6f J, so QO其 电r m C 43 OO小8 J5 Ofc 89 Ki g 01i Fraii 2 (14 b/rs on *1/电:146 byres capii tthermit uB src: Tel 1t D e o D- D e d i ctlcA。q_ 1Tj 0 5 10 d Qf q o 7 6E f * 曲* d 4- o i 11 0 5 12 J s c c w o c G Q BONO工 r (Hu 卜*。Ori口工 r- 1- I -I - I -i IFTSGDQ匿 &图中最开始的绿色部分就是24 Bytes的Pcap Header,接下来红色的16 B

13、ytes是第一个消息的Pcap Header 。后面的红色的 16 Bytes是第二个消息的 Pcap Header 。两块蓝色的部分分别是两个消息从链路层开始的完整内容。在网络上实际传输的数据包在数据链路层上每一个Packet开始都会有7个用于同步的字节和一个用于标识该Packet开始的字节,最后还会有四个 CRC校验字节;而PCAP文件中会把前8个字节和最后4个校验自己去掉, 因为这些信息对于协议分析是没有用的。用Wireshark打开一个PCAP数据包,每条消息的所有field会被解析出来并会按照协议层次折叠起来。第一层显示的是FrameXXX ,这一级别没有对应某层具体的协议,而是对本

14、条消息的一个概括性总结,描述了一些有用的概括性信息,比如从里面我们可以看到本条消 息各种协议的层次关系,展开其它协议层之后对应的是该协议的各个域,如下图所示:No,HrwSourceDestiratwnProtocol10.000000 3541281593&827sccp tint, itu)2出 Frane 1 194 bytws on wire, 194 bytes captured).i Ethernet II, Src : Tell caS0: a4 :93 (00:30 :f a: 80 : a4 : 93) , Dst: Tel i ca_80: + internet Protocol Src: 12114,2. 24 C12,114.36,241, Dst: 12114,24 + Stream carrtral Trartsmissior Prctacol f 5rc Part: 5B28 (5O32B), Dst Por 田 mtp J user Adaptation Layer+ signalling connection control Part刮 Dat

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 商业/管理/HR > 营销创新

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号