I am trying to build a packet with a TCP option called user timeout. Does scapy support this? Adding options like MSS seems pretty straightforward. Here is the RFC for the option: https://www.rfc-editor.org/rfc/rfc5482#section-2
Any pointers?
I am trying to build a packet with a TCP option called user timeout. Does scapy support this? Adding options like MSS seems pretty straightforward. Here is the RFC for the option: https://www.rfc-editor.org/rfc/rfc5482#section-2
Any pointers?
The documentation doesn't seem to explain any way to set an arbitrary option by number.
Digging through the code, it looks like
TCPOptionsField.i2m
lets you do so just by passing anint
instead of astr
. So, try using28
the same places you'd useMSS
. It looks like you need to compose the rest of the option field as a string—the length, then the high-order byte of the UTO+granularity, then the low-order byte.Or just modify the code to handle it:
I think what you want is the TCPOptions tuple in scapy/layers/inet.py:
Then you can (hopefully) set the UTO the same way you'd set the MSS.
Either way, you're responsible for composing the 1-bit granularity and the 15-bit timeout before passing the result as an option value, but I think that's simpler than changing it to take a tuple of a bool and an int as the option value and composing it inside TCP.
Of course unless you've patched the kernel on both sides, and made sure the intervening network doesn't have any devices that bail on or strip out unknown TCP options, it's not going to be very interesting anyway.