pyshark - 来自 TCP 数据包的数据 [英] pyshark - data from TCP packet

查看:54
本文介绍了pyshark - 来自 TCP 数据包的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用 pyshark 获取 TCP 数据包的负载?

Is there anyway to get the payload of a TCP packet using pyshark?

我正在尝试比较多个 TCP 流中不同数据包的数据部分,但我找不到获取数据包数据的方法.pkt['tcp'].data 似乎不存在.

I am trying to compare the data sections of different packets across multiple TCP streams but I can't find a way to get at the data of the packet. pkt['tcp'].data does not seem to exist.

推荐答案

如果您使用的是 .pcap 文件,一旦您使用

If you are using a .pcap file, once you have read the file using

cap = pyshark.FileCapture('vox.pcap')

说,你想读取第二个数据包的数据,并且你确定存在这样的字段,请尝试:

and say, you want to read the data of the 2nd packet, and you are sure such a field exists, try:

pkt = cap[1]
print pkt.tcp.data

要查看可用于 pkt.tcp 的选项,请使用:

To see the options available for pkt.tcp, use:

dir(pkt.tcp)

它将返回 pkt.tcp 的所有可用选项

It will return all the available options for pkt.tcp

这篇关于pyshark - 来自 TCP 数据包的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆