Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending specific hex data using scapy

Tags:

python

hex

scapy

I want to send specific hex sequences e.g FF FF FF FF FF FF on wire using scapy without using the Raw option. Will finding the string equivalent of these hex sequences and using them as packet payload have the same effect since scapy will convert them to hex and send ?

like image 462
user2061944 Avatar asked Nov 11 '14 12:11

user2061944


1 Answers

In python 2.x you can create the binary data from a hex string using the binascii module. I've used this to correctly set the duid in DHCPv6 request, just passing it to the option of the packet type.

For example

>>> import binascii
>>> binascii.unhexlify('FFFFFFFFFFFF')
'\xff\xff\xff\xff\xff\xff'

Passing that string to the payload should be all you need. Of course you can just type the string with \x escapes as above, but it's easier to represent it as a nice hex string and call unhexlify when you need the correct binary data.

like image 142
wds Avatar answered Oct 12 '22 23:10

wds