为了更详细地解释TShark如何识别不同协议的数据包,并指出它内部调用的函数,我们需要深入到Wireshark(TShark 的图形界面版本)和 TShark 的源代码层面。以下是一些关键点和相关函数: 1. **初始化解析器**: -当 TShark 启动时,它会加载所有可用的解析器(dissectors)。这涉及到读取配置文件和注册解析器。 - 函数 `...
string_data=fpcap.read()#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'] = stri...
pcap_packet_header['MicroTime'] = string_data[i+4:i+8] pcap_packet_header['caplen'] = string_data[i+8:i+12] pcap_packet_header['len'] = string_data[i+12:i+16] #求出此包的包长len packet_len = struct.unpack('I',pcap_packet_header['len'])[0] #写入此包数据 packet_data.app...
pcap文件生成metadata #!/usr/bin/env python # -*- coding: utf-8 -*- import os import time, datetime import struct in_path = "/home/bonelee/dns_tunnel_tool/iodine_when_idle.pcap" tmp_dir = "/tmp" out_path = "/tmp/out_metadata.txt" tshark_path = "/usr/bin/tshark" os.system(...