-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetect.py
47 lines (33 loc) · 1013 Bytes
/
detect.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
import sys
import scan
import time
import schedule
from DBhandler import getAddress, saveflaggedAddress, getFlaggedAddress, createTable
from scapy.all import sniff, ARP, IP, Ether, TCP
# get the ip range from the arguments passes by the GUI
target_ip_range = sys.argv[1]
dbList = []
flaggedList = []
createTable()
# scan for potential treats and flag if found
def scanAndFlag():
db = getAddress()
for data in db:
dbList.append(data[2])
for data in getFlaggedAddress():
flaggedList.append(data[2])
scannedIp = scan.scan_network(target_ip_range)
found = False
message = ''
for ip in scannedIp:
if ip['mac'] not in dbList and ip['mac'] not in flaggedList:
found = True
saveflaggedAddress(ip['ip'], ip['mac'])
else:
message = "No new intruder detected"
if found == False:
print(message)
schedule.every(5).seconds.do(scanAndFlag)
while True:
schedule.run_pending()
time.sleep(1)