ARPSpoofingDetection.py 976 Bytes
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)