Colin Ross
2008-06-27 18:13:44 UTC
Hi,
I wonder if you can help me. I am trying to use Scapy to pass ICMP
packets with an incrementing IP Option.
To do this I am:
a=IP()
b=ICMP()
What I want to do from here is to pass on to a.options the value in hex,
starting with "\x00\x00\x00\x00"
My problem is that if I set a.option="\x00\x00\x00\x00", this works fine.
However, If I attempt to make each octet a variable and create this option,
When I send the packet, it comes out as "\\x00\\x00\\x00\\x00", and does not
get translated correctly.
Here is a simplified version of my script, with all looping taken out.
################################
a=IP()
b=ICMP()
a.dst='10.211.55.2'
#Set int variables to increment
O1 = 0
O2 = 0
O3 = 0
O4 = 0
#Convert int to hex
o1 = '%x'%(O1)
o2 = '%x'%(O2)
o3 = '%x'%(O3)
o4 = '%x'%(O4)
#Add in leading 0 if hex string is single digit (i.e. Less than 0x10)
if O1 < 16:
o1 = '''0%x'''%(O1)
else:
o1 = '''%x'''%(O1)
if O2 < 16:
o2 = '''0%x'''%(O2)
else:
o2 = '''%x'''%(O2)
if O3 < 16:
o3 = '''0%x'''%(O3)
else:
o3 = '''%x'''%(O3)
if O4 < 16:
o4 = '''0%x'''%(O4)
else:
o4 = '''%x'''%(O4)
#Set IP options
a.options=r'\x%s\x%s\x%s\x%s'%(o1,o2,o3,o4)
ls(a)
send(a/b)
###########################
The output of the IPoptionsField of the ls(a) command at this point is:
options : IPoptionsField = '\\x00\\x00\\x00\\x00' ('')
In my actual IP Packet on the wire, my hex output is the ASCII equivalent to
the string (beginning with 5c 78 30 30, which is the hex ASCII of \x00),
when my goal at this point is to have it 00 00 00 00
How can I get around this and achieve my goal of incrementing a hex value in
the IP Options field?
Cheers
Colin
------ End of Forwarded Message
---------------------------------------------------------------------
To unsubscribe, send a mail to scapy.ml-***@secdev.org
I wonder if you can help me. I am trying to use Scapy to pass ICMP
packets with an incrementing IP Option.
To do this I am:
a=IP()
b=ICMP()
What I want to do from here is to pass on to a.options the value in hex,
starting with "\x00\x00\x00\x00"
My problem is that if I set a.option="\x00\x00\x00\x00", this works fine.
However, If I attempt to make each octet a variable and create this option,
When I send the packet, it comes out as "\\x00\\x00\\x00\\x00", and does not
get translated correctly.
Here is a simplified version of my script, with all looping taken out.
################################
a=IP()
b=ICMP()
a.dst='10.211.55.2'
#Set int variables to increment
O1 = 0
O2 = 0
O3 = 0
O4 = 0
#Convert int to hex
o1 = '%x'%(O1)
o2 = '%x'%(O2)
o3 = '%x'%(O3)
o4 = '%x'%(O4)
#Add in leading 0 if hex string is single digit (i.e. Less than 0x10)
if O1 < 16:
o1 = '''0%x'''%(O1)
else:
o1 = '''%x'''%(O1)
if O2 < 16:
o2 = '''0%x'''%(O2)
else:
o2 = '''%x'''%(O2)
if O3 < 16:
o3 = '''0%x'''%(O3)
else:
o3 = '''%x'''%(O3)
if O4 < 16:
o4 = '''0%x'''%(O4)
else:
o4 = '''%x'''%(O4)
#Set IP options
a.options=r'\x%s\x%s\x%s\x%s'%(o1,o2,o3,o4)
ls(a)
send(a/b)
###########################
The output of the IPoptionsField of the ls(a) command at this point is:
options : IPoptionsField = '\\x00\\x00\\x00\\x00' ('')
In my actual IP Packet on the wire, my hex output is the ASCII equivalent to
the string (beginning with 5c 78 30 30, which is the hex ASCII of \x00),
when my goal at this point is to have it 00 00 00 00
How can I get around this and achieve my goal of incrementing a hex value in
the IP Options field?
Cheers
Colin
------ End of Forwarded Message
---------------------------------------------------------------------
To unsubscribe, send a mail to scapy.ml-***@secdev.org