简体   繁体   English

Scapy/ARP 请求不适用于多个/范围 IP。 仅适用于单个 IP 请求

[英]Scapy/ARP request does not work for multiple/range IPs. Only for a single IP request

I am creating a simple function, which should collect MAC addresses of all devices in my network.我正在创建一个简单的 function,它应该收集我网络中所有设备的 MAC 地址。

import scapy.all as scapy

def network_scan(ip):
   arp_request = scapy.ARP(pdst=ip)
   print(arp_request.summary())

network_scan("10.0.2.1/24")

This ARP request returns "ARP who has?? says??"此 ARP 请求返回“ARP who has?? says??”

But when I try to request a MAC address of a single IP, it works good:但是当我尝试请求单个 IP 的 MAC 地址时,效果很好:

network_scan("10.0.2.1")

Single IP output: ARP who has 10.0.2.1 says myIP单 IP output: ARP 有 10.0.2.1 说myIP

The value you passed to the layer ARP is just fine.您传递给层 ARP 的值就可以了。 But your code is not sending/receiving any packets to the network.但是您的代码没有向网络发送/接收任何数据包。

you can see the complete solution here: https://www.thepythoncode.com/article/building-network-scanner-using-scapy你可以在这里看到完整的解决方案: https://www.thepythoncode.com/article/building-network-scanner-using-scapy

now, why it seems to work with your IP?现在,为什么它似乎适用于您的 IP? arp_request.summary() try to resolves the IP and saw it was yours. arp_request.summary() 尝试解析 IP 并看到它是你的。 but the scanning part still needs to send packets但扫描部分仍然需要发送数据包

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM