我尝试创建用于测试嗅探的简便工具,这是我的代码:
def scan(ip):
arp_req = sc.ARP(pdst=ip)
bc = sc.Ether(dst="ff:ff:ff:ff:ff:ff")
arp_req_bc = bc/arp_req
answer = sc.srp(arp_req_bc, timeout=1, verbose=True)[0]
print("IP\t\t\tMAC Address\n-----------------------")
for element in answer:
print(element[1].psrc + "\t\t" + element[1].hwsrc)
scan("192.168.43.1/24")
输出为:
"Sniffing and sending packets is not available at layer 2: "
RuntimeError: Sniffing and sending packets is not available at layer 2: winpcap is not installed. You may use conf.L3socket orconf.L3socket6 to access layer 3
要在Windows中使用scapy模块,首先需要安装npcap或wincap。