如何在使用python构建TCP SYN数据包时设置tcp选项时间戳? [英] How to set the tcp option timestamp while building a tcp SYN packet using python?

查看:250
本文介绍了如何在使用python构建TCP SYN数据包时设置tcp选项时间戳?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在tcp选项中发送带有时间戳值的tcp SYN数据包。由于tcp opts应该以32位表示形式预打包,因此谁能通过示例向我介绍如何在32位数据包表示形式中设置值。

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.

请先感谢

推荐答案

使用 Scapy 。定义TCP层时,只需使用

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))])

其中TSval是您的时间戳值。如果要将结果数据包转换为其二进制表示形式,请在其上调用 str()

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

将来数据包中,您可以根据每个0 > RFC 1323

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

这篇关于如何在使用python构建TCP SYN数据包时设置tcp选项时间戳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆