How to set the tcp option timestamp while building a tcp SYN packet using python?

旧时模样 提交于 2019-12-12 04:43:57

问题


I need to send a tcp SYN packet with timestamp value in tcp option. Since tcp opts should be prepacked in 32-bit representation, can anyone brief me how to set the value in 32 bit packet representaion with a example.

Thanks in advance


回答1:


You should be able to do that pretty easily with Scapy. When defining your TCP layer, just use

TCP(flags='S', options=[('Timestamp', (TSval, 0))])

where TSval is your timestamp value. If you want to convert the resultant packet to its binary representation, call str() on it.

In future packets, you can replace the 0 with the appropriate TS echo reply per RFC 1323.



来源:https://stackoverflow.com/questions/5082516/how-to-set-the-tcp-option-timestamp-while-building-a-tcp-syn-packet-using-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!