我正在处理一个网络项目,其中我有数据包的十六进制转储,我需要剖析该十六进制转储数据包以显示所有数据包信息。
例 : 数据包信息字段 -
source address
destination address
encapsulation type
frame number
frame length
FCS
data
epoch time
我们不应该使用文件作为输入和输出,因为它会增加内存利用率并可能导致服务器崩溃。
我尝试使用以下代码,但这在我的情况下不起作用:
# imports scapy Utility
from scapy.all import *
from scapy.utils import *
# variable to store hexdump
hexdump = '0000 49 47 87 95 4a 30 9e 9c f7 09 70 7f....'
# Initialize a 802.11 structure from raw bytes
packet = Dot11(bytearray.fromhex(hexdump))
#scapy function to view the info
packet.summary()
packet.show()
由于我是这项技术的新手,有什么建议可以实现这一目标吗?我可能缺乏一些正确的方向来解决这个问题。
您的hexdump
值似乎包含索引。删除它:
-
在斯卡皮>= 2.4rc:
data = hex_bytes('49 47 87 95 4a 30 9e 9c f7 09 70 7f [...]'.replace(' ', ''))
-
或者使用 Python 2 和 Scapy <= 2.3.3:
data = '49 47 87 95 4a 30 9e 9c f7 09 70 7f [...]'.replace(' ', '').decode('hex')
然后:
Dot11(data)