小编icf*_*cfy的帖子

如何从原始字节创建Scapy数据包

使用python数据包解析/嗅探工具Scapy,我想从原始字节串创建一个数据包.虽然我的具体用例的细节更加真实,但以下示例说明了我的问题以及我目前的尝试:

# Get an example packet (we won't really have an offline file in production.)
pkt = sniff(offline="./example_packets/example_packets2.pcap")

# Convert it to raw bytes -- oddly __str__ does this.
raw_packet = str(pkt)

# Current, broken, attempt to construct a new packet from the same bytes as the old.
# In truth, there are easier ways to copy packets from existing Scapy packets, but
# we are really just using that offline packet as a convenient example.
new_packet = Packet(_pkt=raw_packet)

# …
Run Code Online (Sandbox Code Playgroud)

python scapy

10
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×1

scapy ×1