Skip to content Skip to sidebar Skip to footer

Saving Hexdump(packet) To List In Scapy

Is there any way I could save hexdump() to byte list so the list can be accessed by index. what I need is like this byte = hexdump(packet) for i in range(0, len(byte)): print %x by

Solution 1:

The byte content of the packet may be accessed by invoking str(packet), as follows:

content = str(packet) # decoded hex string, such as'\xde\xad\xbe\xef'
print content
forbytein content:
    pass # do something withbyte

EDIT -This answer specifies how this can be converted to a byte array, for example:

byte_array = map(ord, str(packet)) # list of numbers, such as [0xDE, 0xAD, 0xBE, 0xEF]print byte_array
for byte in byte_array:
    pass# do something with byte

Post a Comment for "Saving Hexdump(packet) To List In Scapy"