如何使RECVMSG在Linux系统中失败

发布于 2025-02-13 07:46:38 字数 857 浏览 0 评论 0 原文

有什么办法如何制作 recvmsg 收听UDP以返回值小于0的值?

我无法在系统上运行代码,只能发送UDP数据包。

编辑:

我尝试了@ben voigt的报价,将 icmp端口数据包发送到此端口,这可能会触发 econnreset econnrefused 因此,我尝试了此代码

from scapy.all import *
send(IP(dst=dst_ip)/UDP(sport=src_port,dport=dst_port))
[here is PCAP file][1] , when I run that code the `recvmsg` has been called(not return -1 of-course) 

,因此不,我尝试将 icmp端口无法实现的发送到该端口,并希望 recvmsg 将失败

from scapy.all import *
send(IP(dst=dst_ip)/ICMP(type=3,code=3)/IP(dst=dst_ip)/UDP(sport=src_port,dport=dst_port))

src =“ https://i.sstatic.net/p2oyx.png” alt =“在此处输入 “>这是PCAP文件,但是 recvmsg 甚至没有调用

Is there any way how to makes to recvmsg that listen to UDP to return value that smaller than 0?

I can't run code on the system, only send UDP packet.

Edit:

I have tried the @Ben Voigt offer , sending to this port ICMP Port Unreachable packet to this port and that may trigger ECONNRESET or ECONNREFUSED
So I tried this code

from scapy.all import *
send(IP(dst=dst_ip)/UDP(sport=src_port,dport=dst_port))
[here is PCAP file][1] , when I run that code the `recvmsg` has been called(not return -1 of-course) 

So no I tried to send ICMP Port Unreachable to that port and hope that recvmsg will fail

from scapy.all import *
send(IP(dst=dst_ip)/ICMP(type=3,code=3)/IP(dst=dst_ip)/UDP(sport=src_port,dport=dst_port))

enter image description here

here is PCAP file but the recvmsg not even called

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

画中仙 2025-02-20 07:46:39

如果要 recvMSG 返回 -1 用于测试。参见有关更多详细信息。

If you want recvmsg return -1 for testing, implement your own recvmsg in a shared library and inject it in your program with LD_PRELOAD. See The LD_PRELOAD trick for more details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文