gpt4 book ai didi

c# - 如何使用套接字欺骗 IP 地址?

转载 作者:太空狗 更新时间:2023-10-29 17:48:24 26 4
gpt4 key购买 nike

我正在开发一个网站测试框架,我希望能够伪造用户 ip。我读到过,像 Loadrunner 这样的软件可以做到这一点,我也希望能够做到这一点。

可以找到如何正常使用socket的教程here ,但如果我想欺骗 ip,我将不得不以某种方式编辑 ip header 。这是在套接字级别完成的,还是在 .Net 中有其他更深的级别可以让我这样做?

最佳答案

你不能再这样了,因为在 Windows 的桌面版本中对原始套接字的访问受到限制:

On Windows 7, Windows Vista, Windows XP with Service Pack 2 (SP2), and Windows XP with Service Pack 3 (SP3), the ability to send traffic over raw sockets has been restricted in several ways:

  • TCP data cannot be sent over raw sockets.
  • UDP datagrams with an invalid source address cannot be sent over raw sockets. The IP source address for any outgoing UDP datagram must exist on a network interface or the datagram is dropped. This change was made to limit the ability of malicious code to create distributed denial-of-service attacks and limits the ability to send spoofed packets (TCP/IP packets with a forged source IP address).
  • A call to the bind function with a raw socket for the IPPROTO_TCP protocol is not allowed.
    Note The bind function with a raw socket is allowed for other protocols (IPPROTO_IP, IPPROTO_UDP, or IPPROTO_SCTP, for example).

(来自Dev Center - Desktop - TCP/IP Raw Sockets)

您可以相当轻松地创建原始套接字:

Socket s = new Socket(ip.AddressFamily, SocketType.Raw, ProtocolType.Ip); 

此时由您来构建适当的数据报(如果您手头没有关于如何执行此操作的文档,这将是一个单独的问题)

关于c# - 如何使用套接字欺骗 IP 地址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12963881/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com