Kali Linux中Scapy.all无ARP属性问题的解决方法求助
Hey there, let's work through your Scapy issue step by step. It looks like you've got two related problems: first, the initial error where scapy.all seemed to lack the ARP attribute, and now even though your code runs, the ARP request isn't correctly using the pdst parameter you set (that's why you're seeing ARP who has ?? says ?? and pdst: MultipleTypeField = '0.0.0.0' in the output). Let's fix this:
1. Validate Scapy Version & Import Correctly
First, make sure you're using the official, maintained version of Scapy—avoid the outdated scapy-python3 package, which is no longer supported. In Kali, update or install the right version with:
pip install --upgrade scapy
If importing scapy.all still doesn't expose the ARP class, try explicitly importing it from the correct layer:
from scapy.layers.l2 import ARP from scapy.all import ls, srp, Ether
Then adjust your code to use the directly imported ARP class instead.
2. Fix the ARP Request Parameter Issue
Your original code only creates an ARP request object, but Scapy needs it wrapped in an Ethernet broadcast frame to properly handle CIDR-formatted IP ranges like 192.168.43.1/24. Here's the revised, working code:
#!/usr/bin/env python import scapy.all as scapy def scan(ip): # Create ARP who-has request (op=1 is default, but explicit is clearer) arp_request = scapy.ARP(pdst=ip) # Create Ethernet broadcast frame to send the ARP request to all devices broadcast_frame = scapy.Ether(dst="ff:ff:ff:ff:ff:ff") # Combine the ARP request and broadcast frame arp_broadcast = broadcast_frame / arp_request # Send the request and capture responses (timeout=1 to avoid hanging) answered, unanswered = scapy.srp(arp_broadcast, timeout=1, verbose=False) # Print the properly populated ARP request details print("ARP Request Details:") print(arp_request.summary()) scapy.ls(arp_request) # Parse and display scan results print("\nScan Results:") client_list = [] for response in answered: client_data = {"ip": response[1].psrc, "mac": response[1].hwsrc} client_list.append(client_data) for client in client_list: print(f"IP: {client['ip']} | MAC: {client['mac']}") scan("192.168.43.1/24")
3. Why Your Original Code Had Weird Output
- You created an ARP object but didn't pair it with an Ethernet broadcast frame. Scapy can't resolve the CIDR range on its own without that layer, so it defaulted
pdstto0.0.0.0. - The
??in the summary happens because the ARP request wasn't attached to a frame that gives it network context—Scapy didn't know who to target.
4. Quick Checks to Ensure Everything Works
- Make sure your Kali machine is connected to the
192.168.43.0/24network (verify withip a). - You're already running the script as root, which is mandatory for Scapy to send raw network packets—good call there.
内容的提问来源于stack exchange,提问作者Lil Webhead

