You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Kali Linux中Scapy.all无ARP属性问题的解决方法求助

Fixing Scapy's Missing ARP Attribute & Malfunctioning ARP Request

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 pdst to 0.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/24 network (verify with ip 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 15:23:10