-
Notifications
You must be signed in to change notification settings - Fork 0
/
judgeIFrogue.py
88 lines (77 loc) · 2.56 KB
/
judgeIFrogue.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# -*- coding: cp936 -*-
#coding = utf-8
import dbOperations
results = dbOperations.selectAPFeatures()
list = []
for result in results:
list.append({"bssid":result["bssid"],
"ssid":result["ssid"],
"security":result["security"],
"signal":result["signals"],
"latitude":result["latitude"],
"longtitude":result["longtitude"],
"macAdress":result["macAdress"],
"timeString":result["timeString"]} )
def seeifexist(AP):
all = len(list)
flag = 0 #1 for totally same record
for i in range(0, all):
if(flag == 0):
if(list[i]['ssid']==AP['ssid'] and list[i]['bssid']==AP['bssid'] and list[i]['security']==AP['security']):
flag = 1
else:
break
if(flag == 1): return list[i-1]['trust']
else: return -10 #no record in
def judgessid(AP):
all = len(list)
ssid_trust = 1 #0 for trusted
for i in range(0, all):
if(list[i]['ssid']==AP['ssid']):
ssid_trust = 0
break
return ssid_trust
def judgebssid(AP):
all = len(list)
bssid_trust = 1 #0 for trusted
b = AP['bssid'].split(':')
for i in range(0, all):
a= list[i]['bssid'].split(':')
if(a[0] == b[0] and a[1] == b[1] and a[2] == b[2]):
bssid_trust = 0
break
return bssid_trust
def judgesignal(AP):
all = len(list)
signal_str = []
for i in range(0, all):
signal_str.append(list[i]['signal'])
new_signal_str = sorted(signal_str)
weakest = new_signal_str[all/4]
strongest = new_signal_str[all*3/4]
if(AP['signal']>=weakest and AP['signal']<=strongest):
signal_trust = 0 #0 for trusted
else:
signal_trust = 1
return signal_trust
def judgesecurity(AP):
security_trust = 1 #0 for trusted
a=''
if(AP['security']!=''):
a= AP['security'].split('-')[0].split('[')[1]
if(a=='WPA' or a=='WPA2' or a=='WEP'):
security_trust =0
else:
security_trust =1
return security_trust
def addAPSafety(ap):
all = len(ap)
for i in range(0,all):
#if(seeifexist(ap[i])!= -10):
if(False):
print ap[i]['ssid'],ap[i]['bssid'],"turst:",seeifexist(ap[i])
else:
if(judgessid(ap[i])+judgebssid(ap[i])+judgesignal(ap[i])+judgesecurity(ap[i])>=2):
dbOperations.insertSafety(ap[i]['bssid'],1)
else:
dbOperations.insertSafety(ap[i]['bssid'],0)