使用 scapy 指定数据包长度 [英] Specifying packet length with scapy

查看:422
本文介绍了使用 scapy 指定数据包长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 scapy 发送特定的数据包大小(100 字节),但似乎无法得到它.

I'm trying to send a specific packet size (100 bytes) with scapy but cant seem to get it.

我用这个开始.

sr(IP(dst="192.168.1.1")/TCP(dport=443))

查看文档/帮助我不知道是否可以使用 PacketLenField 来指定数据包的长度.我可以用 NMAP &NSE 但想在 NMAP 之外进行.

Looking at the docs / help I cant tell if I can use PacketLenField to specify the length of the packet. I can do it with NMAP & NSE but would like to do it outside of NMAP.

对此有什么想法吗?

谢谢!

推荐答案

您可以在制作数据包时添加所需数量的字节作为字符串,例如:

You can just add on the required number of bytes as a String when crafting the packet e.g.:

payload = 'ZZZZZZZZZZZZZZZZZZZZZ'
pkt = Ether() / IP() / TCP() / payload

会起作用.您只需要根据需要调整有效载荷的长度.

will work. You just need to adjust the length of the payload as you require.

这篇关于使用 scapy 指定数据包长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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