ARPSpoofingDetection.py
976 Bytes
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
import os
import time
def ARPSpoofingDetection():
print("Check available hosts")
os.system("fping -g 192.168.0.0/24 1>/dev/null 2>/dev/null")
os.system("arp -a > arptable.txt")
ARPtable = open("arptable.txt", "r")
print("ARP Table below\n")
for line in ARPtable :
if line.find("incomplete") < 0 :
print(line)
ARPtable.seek(0)
Hosts = list()
for line in ARPtable :
# MAC Address
if line.find('.255') < 0 and line.find('incomplete') < 0 :
part = line.partition("at")
part = part[2]
part = part.rpartition("on")
MACAddress = part[0].rstrip().lstrip()
for i in Hosts :
if i == MACAddress :
print("**ARP Spoofing Detected**\n")
print(f"MAC Address : {MACAddress} \n")
Hosts.append(MACAddress)
while True :
ARPSpoofingDetection()
time.sleep(5)