Why am i getting the result expected in scapy?

Question:

import scapy.all as scapy

p = scapy.sniff(filter='tcp', count=1)
d = p.show()

print(scapy.hexraw(d))

RESULT:

AttributeError: module 'scapy.all' has no attribute 'hexraw'

Why am i getting this error

Asked By: Essence

||

Answers:

hexraw is a method of the PacketList class not a function of scapy.all. Moreover, the show method of the Packet class returns None: it prints something to the standard output but does not return anything. So doing d = p.show() does not make any sense. I don’t know what your goal initially was, but you could try instead:

p.show()  # print the packet list
p[0].show()  # print the first packet of the list
p.hexraw() # print a summary of the packet list with Raw layers being hexdumped
Answered By: qouify
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.