Converting a sniffed scapy packet to bytes

后端 未结 2 1897
遥遥无期
遥遥无期 2021-01-21 05:57

When sniffing packets with scapy I can save them to a variable

sniffed = sniff(count=1)

Now I would like to see what\'s inside the packet by do

2条回答
  •  有刺的猬
    2021-01-21 06:12

    You are probably searching for scapy Hexdump(pkt) or hexraw(pkt) or repr(str(pkt)) for string encoded output. Note that sniff returns a list, not a single pkt.

    If you want to access serialized packet bytes one by one just serialize the layers str(pkt) to get a python (char/byte)-string.

    for b in str(pkt):
        print "char: %s ord/value: %d hex: %x"%(b,ord(b),ord(b))
    

提交回复
热议问题