【发布时间】:2019-07-08 04:23:35
【问题描述】:
我正在尝试使用 Pyshark 读取 .pcap 文件中所有数据包的有效负载。我能够打开和读取文件,访问数据包及其其他信息,但我无法找到用于访问数据包有效负载的正确属性/方法。有什么建议 ?有没有其他方法可以使用 python for windows 10 读取 .pcap 文件中的数据包有效负载?
(我尝试使用 Scapy 代替 Pyshark,但显然在 Windows 上运行 Scapy 存在一些问题,它也不适用于我的系统)
我在 Internet 和 StackOverflow 上的 pyshark 项目的不同代码 sn-ps 中发现了这些行。我尝试了它们,但它们都不起作用:
import pyshark
cap = pyshark.FileCapture('file.pcap')
pkt = cap[1]
#for other information
print(pkt.tcp.flags_ack) #this works
print(pkt.tcp.flags_syn) #this works
print(pkt.tcp.flags_fin) #this works
#for payload
print(pkt.tcp.data) #does not work, AttributeError
print(pkt.tcp.payload) #does not work, AttributeError
print(pkt.data.data) #does not work, AttributeError
【问题讨论】:
标签: python-3.x pyshark