2024-06-11 16:53:33 发布
网友
我可以用pyshark读取.pcap文件。这是我的代码:
pyshark
.pcap
packets = pyshark.FileCapture(pcap_dir) # pcap_dir is the directory of my pcap file
要打印数据包,我使用print(packets[0])。我的问题是:如何将packets[0]转换为其二进制值?例如,如果我想再次将数据包发送到网络,这将非常有用
print(packets[0])
packets[0]
我能解决这个问题。我只是用了:
packets = pyshark.FileCapture( input_file=pcap_dir, use_json=True, include_raw=True )._packets_from_tshark_sync() # pcap_dir is the directory of my pcap file hex_packet = packets.__next__().frame_raw.value print(hex_packet) binary_packet = bytearray.fromhex(hex_packet) print(binary_packet)
另外,检查this
我能解决这个问题。我只是用了:
另外,检查this
相关问题 更多 >
编程相关推荐