How to extract Raw of TCP packet using Scapy

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 19:16:58

问题


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.


回答1:


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").



来源:https://stackoverflow.com/questions/27172789/how-to-extract-raw-of-tcp-packet-using-scapy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!