Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ALL-1/filter.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
62 lines (57 sloc)
1.94 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import os | |
# Runs a bash script that scans the network's BSSID, PWR, ESSID and saves it to a csv file | |
os.system("chmod +x convert.sh") | |
os.system("chmod +x scanner.sh") | |
os.system("./scanner.sh") | |
os.system("./convert.sh") | |
# Opens the saved csv and parses the info and saved as lists | |
with open('isolated.csv') as file1: | |
reader = csv.reader(file1, delimiter=',') | |
temp = [] | |
full_list = [] | |
for row in reader: | |
temp.append(row) | |
for row in temp: | |
if row[1] == ',' or row[1] == 'Power' or row[1] == '' or row[1] == 'MAC' or row[2] == '': | |
continue | |
elif int(row[1]) <= -70 or int(row[1]) == -1: | |
continue | |
else: | |
full_list.append(row) | |
os.system("rm isolated.csv") | |
# Our trusted list is parsed and saved to a Python dictionary | |
with open('baseline.csv') as file2: | |
reader2 = csv.reader(file2) | |
base_dict = {} | |
for row in reader2: | |
try: | |
base_dict[row[2]] = {'BSSID': row[0], 'PWR': row[1]} | |
except: | |
continue | |
# Compares the scanned list to our trusted list and outputs safe if the area is secure, vice versa | |
safe = True | |
for list in full_list: | |
print(list) | |
if list[2] in base_dict.keys(): | |
# Check BSSID, if similar, move on | |
if list[0] == base_dict[list[2]]['BSSID']: | |
# Check pwr | |
lower = base_dict[list[2]]['PWR'] | |
true_lower = int(lower) + 5 | |
upper = base_dict[list[2]]['PWR'] | |
true_upper = int(upper) - 5 | |
if (int(list[1]) <= true_lower) and (int(list[1]) >= true_upper): | |
safe = True | |
else: | |
safe = False | |
else: | |
safe = False | |
else: | |
safe = False | |
if safe: | |
print("Safe, No Threat Found. Rescanning in 10 mins") | |
os.system ("notify --text 'The network should be secure' ") | |
else: | |
print("ERROR UNSAFE, Mobile notification sent") | |
os.system ("notify --text 'The network might not be secure' ") |