0000 00 01 00 14 45 49 50 43 A8 2A 55 50 6F 72 74 20 [37m.[0m[37m.[0m[37m.[0m[37m.[0mEIPC[37m.[0m*UPort
0010 49 64 20 3D 20 34 33 30 35 30 2A 2A 2A 2A 2A 2A Id = 43050******
0020 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A ****************
0030 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A ****************
0040 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A ****************
0050 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A ****************
0060 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A ****************
0070 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A ****************
0080 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A ****************
这是我收到的数据包的十六进制转储,我只需要 -
UPort Id = 43050
******
****************
****************
****************
****************
****************
****************
****************
这基本上就是我的有效负载,我怎样才能得到它?
最佳答案
您可以使用 import_hexcap() 并将十六进制转储粘贴到标准输入中。将 IP() 替换为您要解析的任何数据包类别:
>>> pkt_hex = IP(import_hexcap())
0000 00 01 00 14 45 49 50 43 A8 2A 55 50 6F 72 74 20 [37m.[0m[37m.[0m[37m.[0m[37m.[0mEIPC[37m.[0m*UPort
0010 49 64 20 3D 20 34 33 30 35 30 2A 2A 2A 2A 2A 2A Id = 43050******
0020 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A ****************
0030 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A ****************
0040 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A ****************
0050 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A ****************
0060 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A ****************
0070 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A ****************
0080 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A ****************
>>> pkt_hex
<IP version=0L ihl=0L tos=0x1 len=20 id=17737 flags=DF frag=4163L ttl=168 proto=42 chksum=0x5550 src=111.114.116.32 dst=73.100.32.61 options=[<IPOption_EOL copy_flag=0L optclass=1L option=end_of_list |>, <IPOption_Router_Alert copy_flag=0L optclass=1L option=router_alert length=51 alert=12341 |>, <IPOption copy_flag=0L optclass=1L option=imi_traffic_descriptor length=42 value='****************************************' |>, <IPOption copy_flag=0L optclass=1L option=experimental_measurement length=42 value='****************************************' |>, <IPOption copy_flag=0L optclass=1L option=experimental_measurement length=42 value='*************' |>] |<Raw load='********************' |>>
>>>
关于python - 如何从 scapy 中的 hexdump 获取数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7121635/