Reputation: 103
I'm trying to create a tcp packet with self defined options field.
Generally we can do it by "options" argument when it is a standard option. "MSS" for example:
>>> hexdump(IP()/TCP(dport=5678,flags="S",options=[('MSS',16)]))
0000 45 00 00 2C 00 01 00 00 40 06 7C C9 7F 00 00 01 E..,....@.|.....
0010 7F 00 00 01 00 14 16 2E 00 00 00 00 00 00 00 00 ................
0020 60 02 20 00 69 86 00 00 02 04 00 10 `. .i.......
When things come to a non-standard option, say I need a option with type 0xf5. I tried:
>>> hexdump(IP()/TCP(dport=5678,flags="S",options=[(0xF5,16)]))
WARNING: option [245] is not string.
WARNING: option [245] is not string.
0000 45 00 00 28 00 01 00 00 40 06 7C CD 7F 00 00 01 E..(....@.|.....
0010 7F 00 00 01 00 14 16 2E 00 00 00 00 00 00 00 00 ................
0020 50 02 20 00 7B 9E 00 00 P. .{...
Obviously, it doesn't work. So is there a way to do that with scapy?
Upvotes: 2
Views: 1272
Reputation: 3134
TCPOptions is defined in scapy/layers/inet.py. You could add your own option to that.
Upvotes: 1