问题
I have a simple script:
import scapy.all as scapy
def scan(ip):
arg = scapy.ARP(pdst=ip)
print(arg.summary())
scan("192.168.11.0/24")
But when I run this script the output I get is:
ARP who has ?? says ??
Normally the summary would give me 2 IP address's where the 2 question marks are but for some reason that is not the case. Also I have made a network scanner and It was working fine yesterday and returned to me all ip and mac address on the network but today I can't seem to pass in a range(ex:"192.168.11.0/24")when I do the only output I get is:
IP MAC Address
----------------------------------------------------
192.168.11.1 08:02:8e:a1:6a:d0
Even though there are more devices in the network. Is there something wrong with scapy? If so how should I delete and reinstall it because I have already done pip uninstall scapy and pip install scapy and nothing works still.
回答1:
You're not actually doing anything with your script. Your function includes arg = scapy.ARP(pdst=ip)
, which creates an ARP packet. To send it, use sr or sr1. There are also ARP example one-liners that cover ARP pings. Applied here,
from scapy.all import *
def arp_scan(ips):
resp = arping(ips)
print(resp)
arp_scan("192.168.11.0/24")
We will get output that looks similar to
Begin emission:
*Finished sending 256 packets.
Received 1 packets, got 1 answers, remaining 255 packets
9c:5c:12:ca:7b:6f 192.168.11.1
来源:https://stackoverflow.com/questions/58259896/scapy-arp-function-not-giving-proper-output-when-running-it