10
10
from tabulate import tabulate
11
11
12
12
class colors :
13
+ def __init__ (self ):
14
+ pass
15
+
13
16
GRN = '\033 [92m'
14
17
RD = '\033 [91m'
15
18
NRM = '\033 [0m'
@@ -18,10 +21,13 @@ class colors:
18
21
tables = ['accessPoints' , 'ProbeRequests' , 'ProbeResponses' ,'EAP' ]
19
22
try :
20
23
class queries ():
21
-
24
+
25
+ def __init__ (self ):
26
+ pass
27
+
22
28
def __int__ (self ):
23
29
super (queries , self ).__init__ ()
24
-
30
+
25
31
def blockPrint (self ):
26
32
sys .stdout = open (os .devnull , 'w' )
27
33
@@ -50,11 +56,11 @@ def clean_up(self):
50
56
try :
51
57
qr = dp .read_sql ('select * from ' + tb + '' , con )
52
58
if tb_value == 0 :
53
- table = qr .sort_values ('PWR' , ascending = False ).drop_duplicates (subset = ['ESSID' , 'BSSID' , 'VENDOR' , 'CHAN' , 'ENC' , 'CIPHER' , ' AUTH' ], keep = 'first' )
59
+ table = qr .sort_values ('PWR' , ascending = False ).drop_duplicates (subset = ['ESSID' , 'BSSID' , 'VENDOR' , 'CHAN' , 'ENC' , 'AUTH' ], keep = 'first' )
54
60
elif tb_value == 1 :
55
61
table = qr .sort_values ('PWR' , ascending = False ).drop_duplicates (subset = ['ESSID' , 'CLIENT' , 'VENDOR' ], keep = 'first' )
56
62
elif tb_value == 2 :
57
- table = qr .sort_values ('PWR' , ascending = False ).drop_duplicates (subset = ['ESSID' , 'BSSID' , 'VENDOR' , 'CHAN' , 'ENC' , 'CIPHER' , 'AUTH' , 'CLIENT' ], keep = 'first' )
63
+ table = qr .sort_values ('PWR' , ascending = False ).drop_duplicates (subset = ['ESSID' , 'BSSID' , 'VENDOR' , 'CHAN' , 'ENC' , 'CIPHER' , 'AUTH' , 'CLIENT' ], keep = 'first' )
58
64
elif tb_value == 3 :
59
65
table = qr .drop_duplicates (subset = ['SRC_MAC' , 'USERNAME' , 'BSSID' ], keep = 'first' )
60
66
clrdb = table
@@ -68,8 +74,8 @@ def clean_up(self):
68
74
clrdb .index = clrdb .index + 1
69
75
del clrdb ['index' ]
70
76
clrdb .to_sql ("" + tb + "" , con , if_exists = "replace" )
71
- except pandas .io .sql .DatabaseError :
72
- continue
77
+ except pandas .io .sql .DatabaseError :
78
+ continue
73
79
74
80
def Custom_Queries (self , option ):
75
81
try :
@@ -83,14 +89,14 @@ def Custom_Queries(self, option):
83
89
qr = dp .read_sql (CQ , con )
84
90
print (tabulate (qr .drop_duplicates (), showindex = False , headers = qr .columns , tablefmt = "psql" ))
85
91
except pandas .io .sql .DatabaseError :
86
- pass
92
+ pass
87
93
88
94
89
95
def show_table (self , option ):
90
96
try :
91
97
if option in ["AP" ]:
92
98
qr = dp .read_sql ('select * from accessPoints' , con )
93
- print (tabulate (qr .drop_duplicates (), showindex = False , headers = qr .columns , tablefmt = "psql" ))
99
+ print (tabulate (qr .drop_duplicates (), showindex = False , headers = qr .columns , tablefmt = "psql" ))
94
100
elif option in ["proberequests" ]:
95
101
qr = dp .read_sql ('select * from ProbeRequests' , con )
96
102
print (tabulate (qr .drop_duplicates (), showindex = False , headers = qr .columns , tablefmt = "psql" ))
@@ -99,7 +105,7 @@ def show_table(self, option):
99
105
print (tabulate (qr .drop_duplicates (), showindex = False , headers = qr .columns , tablefmt = "psql" ))
100
106
elif option in ["inscope_AP" ]:
101
107
qr = dp .read_sql ('select * from inscope_accessPoints' , con )
102
- print (tabulate (qr .drop_duplicates (), showindex = False , headers = qr .columns , tablefmt = "psql" ))
108
+ print (tabulate (qr .drop_duplicates (), showindex = False , headers = qr .columns , tablefmt = "psql" ))
103
109
elif option in ["inscope_proberequests" ]:
104
110
qr = dp .read_sql ('select * from inscope_proberequests' , con )
105
111
print (tabulate (qr .drop_duplicates (), showindex = False , headers = qr .columns , tablefmt = "psql" ))
@@ -115,7 +121,7 @@ def show_table(self, option):
115
121
elif option in ["LOOT" ]:
116
122
qr = dp .read_sql ('select * from LOOT' , con )
117
123
print (tabulate (qr .drop_duplicates (), showindex = False , headers = qr .columns , tablefmt = "psql" ))
118
- else :
124
+ else :
119
125
print colors .RD + "Error: Invalid query, please try again.\n " + colors .NRM
120
126
except pandas .io .sql .DatabaseError :
121
127
print colors .RD + "Error: Table does not exist or is empty, please try again.\n " + colors .NRM
@@ -151,7 +157,7 @@ def in_scope(self, option):
151
157
insqr .index = insqr .index + 1
152
158
del insqr ['index' ]
153
159
insqr .to_sql ("inscope_" + tb + "" , con , if_exists = "replace" )
154
- except pandas .io .sql .DatabaseError :
160
+ except pandas .io .sql .DatabaseError :
155
161
continue
156
162
except pandas .io .sql .DatabaseError :
157
163
continue
@@ -178,7 +184,7 @@ def in_scope(self, option):
178
184
insqr .index = insqr .index + 1
179
185
del insqr ['index' ]
180
186
insqr .to_sql ("inscope_" + tb + "" , con , if_exists = "replace" )
181
- except pandas .io .sql .DatabaseError :
187
+ except pandas .io .sql .DatabaseError :
182
188
continue
183
189
else :
184
190
print colors .RD + "SSID does not exist" + colors .NRM
@@ -190,12 +196,12 @@ def main(self, t2, where):
190
196
try :
191
197
qr = dp .read_sql ('' + t2 + ' ' + tb + where + '' , con )
192
198
result = result .append (qr )
193
- except pandas .io .sql .DatabaseError :
199
+ except pandas .io .sql .DatabaseError :
194
200
continue
195
-
201
+
196
202
result = result .drop_duplicates ()
197
- result = tabulate (result , showindex = False )
198
-
203
+ result = tabulate (result , showindex = False )
204
+
199
205
def show (self , option ):
200
206
where = ''
201
207
if option in ["SSIDS" ]:
@@ -232,12 +238,22 @@ def show_inscope_ssids(self):
232
238
result = qr .to_string (formatters = {'ESSID' :'{{:<{}s}}' .format (qr ['ESSID' ].str .len ().max ()).format }, header = False , index = False )
233
239
return str (result )
234
240
241
+ def show_inscope_MACs (self ):
242
+ qr = dp .read_sql ('select BSSID from inscope_accessPoints' , con )
243
+ result = qr .to_string (formatters = {'BSSID' :'{{:<{}s}}' .format (qr ['BSSID' ].str .len ().max ()).format }, header = False , index = False )
244
+ return str (result )
245
+
246
+ def show_MACs (self , SSID ):
247
+ qr = dp .read_sql ('select BSSID from inscope_accessPoints where ESSID = "' + SSID + '"' , con )
248
+ result = qr .to_string (formatters = {'BSSID' :'{{:<{}s}}' .format (qr ['BSSID' ].str .len ().max ()).format }, header = False , index = False )
249
+ return str (result )
250
+
235
251
def loot (self , loot ):
236
252
cl = dp .DataFrame (loot , index = [0 ])
237
253
cl = cl [['MAC' , 'Username' , 'Password' ]]
238
254
cl .reset_index (inplace = True )
239
255
del cl ['index' ]
240
- cl .to_sql ("LOOT" , con , index = False , if_exists = "append" )
256
+ cl .to_sql ("LOOT" , con , index = False , if_exists = "append" )
241
257
except NameError :
242
258
pass
243
259
print colors .RD + "Error: No workspace selected. Please Create or load a work" + colors .NRM
0 commit comments