91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 4.11KB
    文件類型: .py
    金幣: 1
    下載: 0 次
    發布日期: 2021-03-26
  • 語言: 其他
  • 標簽: 其他??

資源簡介


本代碼能對抓包工具抓下來的pcap包各個字段進行精確的解析,包括文件頭,報文頭,協議頭,數據內容等的解析。。

資源截圖

代碼片段和文件信息

#!/usr/bin/env?python
#?coding:?utf-8
‘‘‘
Created?on?2016年8月3日

@author:?dxl
‘‘‘

import?dpkt
import?os
import?socket
import?struct
#from?autotest.configure?import?filepath

tcp_or_udp?={}
tcp_or_udp[6]?=?‘tcp‘
tcp_or_udp[17]?=?‘udp‘
tcp_or_udp[1]?=?‘icmp‘
tcp_or_udp[2]?=?‘igmp‘

def?parseRadius(filepath):
????fpcap?=?open(filepath‘rb‘)
????source_pcap_name?=?os.path.basename(filepath).split(‘.‘)[0]
????string_data?=?fpcap.read()
????print?len(string_data)
????#pcap文件包頭解析
????pcap_header?=?{}
????pcap_header[‘magic_number‘]?=?string_data[0:4]
????pcap_header[‘version_major‘]?=?string_data[4:6]
????pcap_header[‘version_minor‘]?=?string_data[6:8]
????pcap_header[‘thiszone‘]?=?string_data[8:12]
????pcap_header[‘sigfigs‘]?=?string_data[12:16]
????pcap_header[‘snaplen‘]?=?string_data[16:20]
????pcap_header[‘linktype‘]?=?string_data[20:24]

????#pcap頭部長度?24字節????
????pcap_header_str?=?string_data[:24]
????print?pcap_header_str
????
????#pcap文件的數據包解析
?

評論

共有 條評論