如何使用Scapy在保存的PCAP文件中读取TCP协议数据?

发布于 2025-01-28 08:55:13 字数 483 浏览 6 评论 0原文

读取PCAP文件

from scapy.all import *


logfile = rdpcap('./Pcap/112400.pcap')

print(logfile)

我正在尝试使用Scapy输出

pcap: TCP:0 UDP:0 ICMP:0 Other:313

时,当我在Wireshark中打开同一文件时,我可以在协议列TCP下看到&在以下数据存在的信息列中,

`309    14:48:49.054000 2409:4040:f11:6385::fca:8000    2405:200:1601:c6e2:49:40:6:206  TCP [TCP Keep-Alive ACK] 59275 → 1883 [ACK] Seq=329 Ack=9 Win=23032 Len=0

存在如何使用SCAPY PLZ指南捕获此信息?

I am trying to read a Pcap file using scapy

from scapy.all import *


logfile = rdpcap('./Pcap/112400.pcap')

print(logfile)

output

pcap: TCP:0 UDP:0 ICMP:0 Other:313

Now when I open the same file in wireshark I can see under protocol column TCP is present & under info column below data is present

`309    14:48:49.054000 2409:4040:f11:6385::fca:8000    2405:200:1601:c6e2:49:40:6:206  TCP [TCP Keep-Alive ACK] 59275 → 1883 [ACK] Seq=329 Ack=9 Win=23032 Len=0

How can I capture this info using scapy plz guide ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挥剑断情 2025-02-04 08:55:13

您想要的是创建一个列表,您可以在其中进一步处理单个数据包。

from scapy.all import *
from pprint import pprint


logfile = rdpcap('test.pcap')

pprint(list(logfile))

Scapy具有许多内置的功能。
scapy配方

希望它对和好运有助于和好运。

如果您有混合的协议,那么这可能有助于过滤您的AR寻找内容,并进一步用作如何访问数据包详细信息的示例。

for p in logfile:
    if TCP in p:
        print(p[TCP])

It may be that what you want is to create a list where you can further process the individual packets.

from scapy.all import *
from pprint import pprint


logfile = rdpcap('test.pcap')

pprint(list(logfile))

Scapy has alot of capabilities built in. Odds are whatever you are trying to do its built in.
Scapy recipes

Hope it helps and best of luck.

If you have mixed protocols then this may help with filtering what you ar looking for and further serve as an example of how to access packet details.

for p in logfile:
    if TCP in p:
        print(p[TCP])
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文