Kali Python3环境安装scapy模块pip3 install scapy
本地网卡网段arp_scan脚本#!/usr/bin/python3
import logging
import subprocess
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from scapy.all import *
if len(sys.argv) != 2:
print("使用方法 - ./arp_ping.py [interface]")
print("示例 - ./arp_ping.py eth0")
print("用于扫描网卡所在的C类地址段")
sys.exit()
interface = str(sys.argv[1])
ip = str(subprocess.check_output("ifconfig "+ interface + " | grep 'broadcast' | cut -d ' ' -f 10 | cut -d '.' -f 1-3", shell=True).strip(), encoding='utf-8')
prefix = str(ip + '.')、
"""过滤出网段信息,输出信息如:x.x.x."""
for addr in range(0,254):
answer = sr1(ARP(pdst = prefix+str(addr)),timeout =