如何使用Scapy提取原始TCP数据包 [英] How to extract Raw of TCP packet using Scapy

查看:1395
本文介绍了如何使用Scapy提取原始TCP数据包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用scapy模块的 sniff 函数。我的过滤器 prn 函数做得很好。但现在,我想提取 TCP数据包 Raw ,并使用十六进制或二进制格式处理它。 / p>

以下是文件 Packet Class in scapy。



我该怎么做?



我试过 print packet [Raw] 但它似乎被转换为ASCII或类似的东西。我想保留它在十六进制或二进制。

解决方案

您可以通过 STR(分组)。要以可读格式将它们打印到屏幕上,您可以执行 print str(packet).encode(HEX)


I use the sniff function of scapy module. My filter and prn function are doing a great job. But now, I would like to extract the Raw of the TCP packet and handle it using hexadecimal or binary format.

Here is the documentation of Packet Class in scapy.

How can I do that ?

I tried print packet[Raw] but it seems to be converted as ASCII or something like that. I want to keep it in hexadecimal or binary.

解决方案

You can get the raw bytes of the packet via str(packet). For printing them to the screen in a readable format you can execute print str(packet).encode("HEX").

这篇关于如何使用Scapy提取原始TCP数据包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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