forked from ghostop14/sparrow-wifi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
falconwifidialogs.py
executable file
·2656 lines (2077 loc) · 109 KB
/
falconwifidialogs.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/python3
#
###################################################################
#
# Application: Sparrow-WiFi
# Module: falconwifidialogs.py
# Author: ghostop14
# Copyright 2017 ghostop14, All Rights Reserved
#
##################################################################
#
from PyQt5.QtWidgets import QDialog, QLabel, QTextEdit, QComboBox, QTableWidget,QTableWidgetItem, QPushButton, QHeaderView
from PyQt5.QtWidgets import QDesktopWidget, QApplication, QMessageBox, QMenu, QAction, QFileDialog, QAbstractItemView
from PyQt5.QtGui import QColor,QPalette, QFont, QIcon
from PyQt5 import QtCore
from PyQt5.QtCore import QTimer
from PyQt5.QtCore import Qt
import datetime
# from time import sleep
import json
import requests
try:
from manuf import manuf
hasOUILookup = True
except:
hasOUILookup = False
import os
import sys
from threading import Lock
if '..' not in sys.path:
sys.path.insert(0, '..')
from wirelessengine import WirelessEngine, WirelessNetwork, WirelessClient
from sparrowtablewidgets import DateTableWidgetItem, IntTableWidgetItem
from falconwifi import FalconWirelessEngine, WEPCrack, WPAPSKCrack, FalconDeauth
from telemetry import TelemetryDialog
from sparrowgps import SparrowGPS
# ------------------ oui db function -----------------------
def getOUIDB():
ouidb = None
if hasOUILookup:
if os.path.isfile('manuf'):
# We have the file but let's not update it every time we run the app.
# every 90 days should be plenty
last_modified_date = datetime.datetime.fromtimestamp(os.path.getmtime('manuf'))
now = datetime.datetime.now()
age = now - last_modified_date
if age.days > 90:
updateflag = True
else:
updateflag = False
else:
# We don't have the file, let's get it
updateflag = True
try:
ouidb = manuf.MacParser(update=updateflag)
except:
ouidb = None
else:
ouidb = None
return ouidb
# ------------------ Global functions for agent HTTP requests ------------------------------
# ----------- Basic GET/POST Methods --------------------------------------------
def makeGetRequest(url, waitTimeout=4):
try:
# Not using a timeout can cause the request to hang indefinitely
response = requests.get(url, timeout=waitTimeout)
except:
return -1, ""
if response.status_code != 200:
return response.status_code, ""
htmlResponse=response.text
return response.status_code, htmlResponse
def makePostRequest(url, jsonstr, waitTimeout=4):
# use something like jsonstr = json.dumps(somestring) to get the right format
try:
response = requests.post(url, data=jsonstr, timeout=waitTimeout)
except:
return -1, ""
htmlResponse=response.text
return response.status_code, htmlResponse
# ----------- Crack Methods --------------------------------------------
def execRemoteCrack(remoteIP, remotePort, type, curInterface, channel, ssid, apMacAddr, hasClient=False):
url = "http://" + remoteIP + ":" + str(remotePort) + "/falcon/startcrack"
jsondict = {}
jsondict['cracktype'] = type # This will be wep or wpapsk
jsondict['interface'] = curInterface
jsondict['channel'] = channel
jsondict['ssid'] = ssid
jsondict['apmacaddr'] = apMacAddr
jsondict['hasclient'] = hasClient
jsonstr = json.dumps(jsondict)
statusCode, responsestr = makePostRequest(url, jsonstr)
errmsg = ""
if statusCode == 200:
try:
responsedict = json.loads(responsestr)
errcode = responsedict['errcode']
errmsg = responsedict['errmsg']
return errcode, errmsg
except:
return -1, "Unknown error parsing json response"
elif statusCode == 400:
# 400 is a bad request and contains a JSON response
try:
responsedict = json.loads(responsestr)
try:
errmsg = responsedict['errmsg']
except:
# response json didn't have the expected field
if len(responsestr) == 0:
errmsg = "Error parsing agent response. Is it still running?"
else:
errmsg = "Error parsing agent response:" + responsestr
except:
# Parsing json threw exception
if len(responsestr) == 0:
errmsg = "Error parsing agent response. Is it still running?"
else:
errmsg = "Error parsing agent response:" + responsestr
else:
# This should never happen
if len(responsestr) == 0:
errmsg = "Error updating remote agent. Is it still running?"
else:
errmsg = "Error updating remote agent:" + responsestr
return -1, errmsg
def stopRemoteCrack(agentIP, agentPort, interface):
url = "http://" + agentIP + ":" + str(agentPort) + "/falcon/stopcrack/" + interface
statusCode, responsestr = makeGetRequest(url)
if statusCode == 200:
try:
responsedict = json.loads(responsestr)
retVal = responsedict['errcode']
errmsg = responsedict['errmsg']
return retVal, errmsg
except:
return -1, "Error parsing response"
else:
return -2, "Error in agent's response"
def getRemoteWEPCrackStatus(agentIP, agentPort, interface):
url = "http://" + agentIP + ":" + str(agentPort) + "/falcon/crackstatuswep/" + interface
statusCode, responsestr = makeGetRequest(url)
if statusCode == 200:
try:
responsedict = json.loads(responsestr)
retVal = responsedict['errcode']
errmsg = responsedict['errmsg']
if retVal == 0:
isRunning = responsedict['isrunning']
ivcount = responsedict['ivcount']
crackedPasswords = responsedict['crackedpasswords']
else:
isRunning = False
ivcount = 0
crackedPasswords = []
return retVal, errmsg, isRunning, ivcount, crackedPasswords
except:
return -1, "Error parsing response", 0, False, None
else:
return -2, "Error in agent's response", 0, False, None
def getRemoteWPAPSKCrackStatus(agentIP, agentPort, interface):
url = "http://" + agentIP + ":" + str(agentPort) + "/falcon/crackstatuswpapsk/" + interface
statusCode, responsestr = makeGetRequest(url)
if statusCode == 200:
try:
responsedict = json.loads(responsestr)
retVal = responsedict['errcode']
errmsg = responsedict['errmsg']
if retVal == 0:
isRunning = responsedict['isrunning']
hasHandshake = responsedict['hashandshake']
captureFilename = responsedict['capturefile']
else:
isRunning = False
hasHandshake = False
captureFilename = ""
return retVal, errmsg, isRunning, hasHandshake, captureFilename
except:
return -1, "Error parsing response", False, False, ""
else:
return -2, "Error in agent's response", False, False, ""
# ----------- Deauth Methods --------------------------------------------
def execRemoteDeauth(remoteIP, remotePort, newDeauth, continuous):
url = "http://" + remoteIP + ":" + str(remotePort) + "/falcon/deauth"
jsondict = newDeauth.toJsondict()
jsondict['continuous'] = continuous
jsonstr = json.dumps(jsondict)
statusCode, responsestr = makePostRequest(url, jsonstr)
errmsg = ""
if statusCode == 200:
try:
responsedict = json.loads(responsestr)
errcode = responsedict['errcode']
errmsg = responsedict['errmsg']
return errcode, errmsg
except:
return -1, "Unknown error parsing json response"
elif statusCode == 400:
# 400 is a JSON response
try:
responsedict = json.loads(responsestr)
try:
errmsg = responsedict['errmsg']
except:
# response json didn't have the expected field
if len(responsestr) == 0:
errmsg = "Error parsing agent response. Is it still running?"
else:
errmsg = "Error parsing agent response:" + responsestr
except:
# Parsing json threw exception
if len(responsestr) == 0:
errmsg = "Error parsing agent response. Is it still running?"
else:
errmsg = "Error parsing agent response:" + responsestr
else:
# This should never happen
if len(responsestr) == 0:
errmsg = "Error updating remote agent. Is it still running?"
else:
errmsg = "Error updating remote agent:" + responsestr
return -1, errmsg
def stopRemoteDeauth(remoteIP, remotePort, newDeauth):
url = "http://" + remoteIP + ":" + str(remotePort) + "/falcon/stopdeauth"
# NOTE: There isn't a risk of killing incorrect processes here since the processid isn't trusted from the
# GUI. The correct deauth object is looked up by a key and the processid stored for that key is used,
# so sending an incorrect processid won't have any effect.
jsondict = newDeauth.toJsondict()
jsonstr = json.dumps(jsondict)
statusCode, responsestr = makePostRequest(url, jsonstr)
errmsg = ""
if statusCode == 200:
return 0, ""
elif statusCode == 400:
# 400 is a JSON response
try:
responsedict = json.loads(responsestr)
try:
errmsg = responsedict['errmsg']
except:
# response json didn't have the expected field
if len(responsestr) == 0:
errmsg = "Error parsing agent response. Is it still running?"
else:
errmsg = "Error parsing agent response:" + responsestr
except:
# Parsing json threw exception
if len(responsestr) == 0:
errmsg = "Error parsing agent response. Is it still running?"
else:
errmsg = "Error parsing agent response:" + responsestr
else:
# This should never happen
if len(responsestr) == 0:
errmsg = "Error updating remote agent. Is it still running?"
else:
errmsg = "Error updating remote agent:" + responsestr
return -1, errmsg
def requestRemoteInterfaces(agentIP, agentPort):
url = "http://" + agentIP + ":" + str(agentPort) + "/wireless/interfaces"
statusCode, responsestr = makeGetRequest(url)
if statusCode == 200:
try:
interfaces = json.loads(responsestr)
retList = interfaces['interfaces']
return statusCode, retList
except:
return statusCode, None
else:
return statusCode, None
def requestRemoteMonitoringInterfaces(agentIP, agentPort):
url = "http://" + agentIP + ":" + str(agentPort) + "/wireless/moninterfaces"
statusCode, responsestr = makeGetRequest(url)
if statusCode == 200:
try:
interfaces = json.loads(responsestr)
retList = interfaces['interfaces']
return statusCode, retList
except:
return statusCode, None
else:
return statusCode, None
def stopAllRemoteDeauths(agentIP, agentPort, interface):
url = "http://" + agentIP + ":" + str(agentPort) + "/falcon/stopalldeauths/" + interface
statusCode, responsestr = makeGetRequest(url)
if statusCode == 200:
try:
responsedict = json.loads(responsestr)
retVal = responsedict['errcode']
errMsg = responsedict['errmsg']
return retVal, errMsg
except:
return statusCode, responsestr
else:
return statusCode,responsestr
def startRemoteMonitoringInterface(agentIP, agentPort, interface):
url = "http://" + agentIP + ":" + str(agentPort) + "/falcon/startmonmode/" + interface
statusCode, responsestr = makeGetRequest(url)
if statusCode == 200:
try:
responsedict = json.loads(responsestr)
retVal = responsedict['errcode']
errMsg = responsedict['errmsg']
return retVal, errMsg
except:
return statusCode, responsestr
else:
return statusCode,responsestr
def stopRemoteMonitoringInterface(agentIP, agentPort, interface):
url = "http://" + agentIP + ":" + str(agentPort) + "/falcon/stopmonmode/" + interface
statusCode, responsestr = makeGetRequest(url)
if statusCode == 200:
try:
responsedict = json.loads(responsestr)
retVal = responsedict['errcode']
errMsg = responsedict['errmsg']
return retVal, errMsg
except:
return statusCode, responsestr
else:
return statusCode,responsestr
def remoteScanRunning(agentIP, agentPort, interface):
url = "http://" + agentIP + ":" + str(agentPort) + "/falcon/scanrunning/" + interface
statusCode, responsestr = makeGetRequest(url)
if statusCode == 200:
try:
responsedict = json.loads(responsestr)
retVal = responsedict['errcode']
errMsg = responsedict['errmsg']
return retVal, errMsg
except:
return statusCode, responsestr
else:
return statusCode,responsestr
def startRemoteScan(agentIP, agentPort, interface):
url = "http://" + agentIP + ":" + str(agentPort) + "/falcon/startscan/" + interface
statusCode, responsestr = makeGetRequest(url)
if statusCode == 200:
try:
responsedict = json.loads(responsestr)
retVal = responsedict['errcode']
errMsg = responsedict['errmsg']
return retVal, errMsg
except:
return statusCode, responsestr
else:
return statusCode,responsestr
def stopRemoteScan(agentIP, agentPort, interface):
url = "http://" + agentIP + ":" + str(agentPort) + "/falcon/stopscan/" + interface
statusCode, responsestr = makeGetRequest(url)
if statusCode == 200:
try:
responsedict = json.loads(responsestr)
retVal = responsedict['errcode']
errMsg = responsedict['errmsg']
return retVal, errMsg
except:
return statusCode, responsestr
else:
return statusCode,responsestr
def requestAdvancedRemoteNetworks(remoteIP, remotePort):
url = "http://" + remoteIP + ":" + str(remotePort) + "/falcon/getscanresults"
statusCode, responsestr = makeGetRequest(url)
if statusCode == 200:
try:
networkjson = json.loads(responsestr)
wirelessNetworks = {}
wirelessClients = {}
if 'networks' in networkjson:
for curNetDict in networkjson['networks']:
newNet = WirelessNetwork.createFromJsonDict(curNetDict)
wirelessNetworks[newNet.getKey()] = newNet
if 'clients' in networkjson:
for curClientDict in networkjson['clients']:
newClient = WirelessClient.createFromJsonDict(curClientDict)
wirelessClients[newClient.getKey()] = newClient
return networkjson['errCode'], networkjson['errString'], wirelessNetworks, wirelessClients
except:
return -2, "Error parsing remote agent response", None, None
else:
return -1, "Error connecting to remote agent", None, None
# ------------------ AdvancedScanDialog functions ------------------------------
class AdvancedScanDialog(QDialog):
resized = QtCore.pyqtSignal()
visibility = QtCore.pyqtSignal(bool)
def __init__(self, useRemoteAgent=False, remoteAgentIP="", remoteAgentPort=8020, mainWin=None, parent = None):
super(AdvancedScanDialog, self).__init__(parent)
self.setWindowIcon(QIcon('../wifi_icon.png'))
self.visibility.connect(self.onVisibilityChanged)
self.mainWin = mainWin
self.clientTelemetryWindows = {}
self.networkTelemetryWindows = {}
self.updateLock = Lock()
self.scanProc = None
self.ouiLookupEngine = getOUIDB()
self.usingBlackoutColors = False
self.usingRemoteAgent = useRemoteAgent
self.remoteAgentIP = remoteAgentIP
self.remoteAgentPort = remoteAgentPort
self.updateWindowTitle()
self.startedMonMode = False
self.airodumpxmlfile = '/dev/shm/falconairodump-01.kismet.netxml'
self.airodumpcsvfile = '/dev/shm/falconairodump-01.csv'
self.setMinimumWidth(800)
self.setMinimumHeight(600)
self.center()
self.createControls()
if os.geteuid() != 0:
self.runningAsRoot = False
self.statBar.setText('You need to have root privileges to run local scans. Please exit and rerun it as root')
print("You need to have root privileges to run this script.\nPlease try again, this time using 'sudo'. Exiting.")
QMessageBox.question(self, 'Warning',"You need to have root privileges to run local scans.", QMessageBox.Ok)
self.runningAsRoot = False
if (not os.path.isfile('/usr/sbin/airodump-ng')) and (not os.path.isfile('/usr/local/sbin/airodump-ng')):
QMessageBox.question(self, 'Error',"Unable to locate the airodump-ng tool. Please check your system or install the 'aircrack-ng' toolset.", QMessageBox.Ok)
return
if (not os.path.isfile('/usr/bin/aircrack-ng')) and (not os.path.isfile('/usr/local/bin/aircrack-ng')):
QMessageBox.question(self, 'Error',"Unable to locate the aircrack-ng tool. Please check your system or install the 'aircrack-ng' toolset.", QMessageBox.Ok)
return
if (os.path.isfile('/usr/local/bin/wpapcap2john') == False) and (os.path.isfile('/usr/bin/wpapcap2john') == False):
QMessageBox.question(self, 'Warning',"wpapcap2john is better at finding WPA hashes on captures than aircrack, but it does not appear to be in /usr/local/bin or /usr/bin. If you have john on this system, please copy or create a symlink to wpapcap2john in /usr/local/bin for best results.", QMessageBox.Ok)
# Timer to incrementally read tmp file
self.updateTimer = QTimer()
self.updateTimer.timeout.connect(self.onUpdateTimer)
self.updateTimer.setSingleShot(True)
self.updateTimerTimeout = 4000
self.initCrackEngines()
self.checkScanAlreadyRunning()
def setLocal(self):
# self.clearTables()
self.resetTableColors()
# Going local, we don't have to worry so much about it, but going remote, we'd need to stop any running scans.
self.wepCrackRunning = False
self.wpaCrackRunning = False
if self.scanRunning():
self.stopScan(True)
self.usingRemoteAgent = False
self.fillComboBoxes()
self.updateWindowTitle()
self.checkScanAlreadyRunning()
def setRemoteAgent(self, agentIP, agentPort):
self.wepCrackRunning = False
if self.wepCrack.running():
self.wepCrack.stopCrack()
self.wpaCrackRunning = False
if self.wpaPSKCrack.running():
self.wpaPSKCrack.stopCrack()
if self.scanRunning():
self.stopScan(True)
self.stopAllDeauths()
self.usingRemoteAgent = True
self.remoteAgentIP = agentIP
self.remoteAgentPort = agentPort
self.fillComboBoxes()
# self.clearTables()
self.resetTableColors()
self.updateWindowTitle()
self.checkScanAlreadyRunning()
def updateWindowTitle(self):
title = 'Falcon Attack Tools'
if self.usingRemoteAgent:
title += " - " + self.remoteAgentIP + ":" + str(self.remoteAgentPort)
self.setWindowTitle(title)
def clearTables(self):
self.updateLock.acquire()
self.networkTable.setRowCount(0)
self.clientTable.setRowCount(0)
self.updateLock.release()
def onVisibilityChanged(self, visible):
try:
if not visible:
# Transitioned to hidden, if we have a scan running, stop it.
if self.scanRunning():
self.stopScan()
except:
pass
def hideEvent(self, event):
self.visibility.emit(False)
def initCrackEngines(self):
# WPA PSK key monitoring
self.wpaTimer = QTimer()
self.wpaTimer.timeout.connect(self.onWPATimer)
self.wpaTimer.setSingleShot(True)
self.wpaTimerTimeout = 5000
self.wpaTimer.setInterval(self.wpaTimerTimeout)
self.wpaPSKCrack = WPAPSKCrack()
self.wpaCrackRunning = False
self.wpaSSID = ""
# WEP key monitoring
self.wepTimer = QTimer()
self.wepTimer.timeout.connect(self.onWEPTimer)
self.wepTimer.setSingleShot(True)
self.wepTimerTimeout = 5000
self.wepTimer.setInterval(self.wpaTimerTimeout)
self.wepCrack = WEPCrack()
self.wepCrackRunning = False
self.wepUsingClient = False
self.wepSSID = ""
def fillComboBoxes(self):
# clear any current entries on a refresh
self.loadingComboBoxes = True
self.comboInterfaces.clear()
self.comboMonInterfaces.clear()
# Get regular interfaces
if self.usingRemoteAgent:
statusCode, interfaces = requestRemoteInterfaces(self.remoteAgentIP, self.remoteAgentPort)
if statusCode != 200:
interfaces = []
QMessageBox.question(self, 'Error',"An error occurred getting remote interfaces from the agent.", QMessageBox.Ok)
else:
interfaces=WirelessEngine.getInterfaces()
if (interfaces is not None) and (len(interfaces) > 0):
for curInterface in interfaces:
self.comboInterfaces.addItem(curInterface)
else:
self.statBar.setText('No wireless interfaces found.')
self.btnMonMode.setEnabled(False)
# get monitoring interfaces
if self.usingRemoteAgent:
statusCode, interfaces = requestRemoteMonitoringInterfaces(self.remoteAgentIP, self.remoteAgentPort)
if statusCode != 200:
interfaces = []
QMessageBox.question(self, 'Error',"An error occurred getting remote monitoring interfaces from the agent.", QMessageBox.Ok)
else:
interfaces = WirelessEngine.getMonitoringModeInterfaces()
if (interfaces is not None) and (len(interfaces) > 0):
for curInterface in interfaces:
self.comboMonInterfaces.addItem(curInterface)
else:
self.statBar.setText('No Monitoring Mode wireless interfaces found.')
self.loadingComboBoxes = False
def createComboBoxes(self):
# Wireless Interfaces
self.lblInterface = QLabel("Local Wireless Interface", self)
self.lblInterface.setGeometry(10, 10, 220, 30)
self.comboInterfaces = QComboBox(self)
self.comboInterfaces.setGeometry(180, 10, 100, 28)
# Create Mon Mode Button
self.btnMonMode = QPushButton("Create Monitoring Interface", self)
# self.btnMonMode.setStyleSheet("background-color: rgba(0,128,192,255);")
self.btnMonMode.setGeometry(300, 10, 200, 30)
self.btnMonMode.clicked.connect(self.onCreateMonClicked)
# Monitoring Mode Wireless Interfaces
self.lblMonInterface = QLabel("Local Monitoring Interface", self)
self.lblMonInterface.setGeometry(10, 50, 220, 30)
self.comboMonInterfaces = QComboBox(self)
self.comboMonInterfaces.setGeometry(180, 50, 100, 28)
# Want to recheck if a scan is already running
self.loadingComboBoxes = False
self.comboMonInterfaces.currentIndexChanged.connect(self.onMonInterfaceChanged)
# Stop Mon Mode Button
self.btnStopMonMode = QPushButton("Stop Monitoring Interface", self)
# self.btnMonMode.setStyleSheet("background-color: rgba(0,128,192,255);")
self.btnStopMonMode.setGeometry(300, 50, 200, 30)
self.btnStopMonMode.clicked.connect(self.onStopMonClicked)
self.fillComboBoxes()
def setBlackoutColors(self):
self.usingBlackoutColors = True
self.networkTable.setStyleSheet("QTableView {background-color: black;gridline-color: white;color: white} QTableCornerButton::section{background-color: white;}")
headerStyle = "QHeaderView::section{background-color: white;border: 1px solid black;color: black;} QHeaderView::down-arrow,QHeaderView::up-arrow {background: none;}"
self.networkTable.horizontalHeader().setStyleSheet(headerStyle)
self.networkTable.verticalHeader().setStyleSheet(headerStyle)
self.clientTable.setStyleSheet("QTableView {background-color: black;gridline-color: white;color: white} QTableCornerButton::section{background-color: white;}")
self.clientTable.horizontalHeader().setStyleSheet(headerStyle)
self.clientTable.verticalHeader().setStyleSheet(headerStyle)
def createControls(self):
self.statBar = QLabel(self)
self.statBar.setStyleSheet("QLabel{background:rgba(192,192,192,255);color:black;border: 1px solid blue; border-radius: 1px;}")
self.statBar.setText('Ready')
self.createComboBoxes()
# Scan Button
self.btnScan = QPushButton("&Scan", self)
self.btnScan.setCheckable(True)
self.btnScan.setShortcut('Ctrl+S')
self.btnScan.setStyleSheet("background-color: rgba(0,128,192,255);")
self.btnScan.clicked[bool].connect(self.onScanClicked)
self.btnScan.setGeometry(300, 90, 100, 30)
self.btnScan.setChecked(False)
# Update Main Button
# This isn't necessary anymore. It happens automatically now.
#if (self.mainWin):
# self.btnUpdate = QPushButton("Update Hidden SSIDs", self)
# self.btnUpdate.setStyleSheet("background-color: rgba(0,128,192,255);")
# self.btnUpdate.clicked.connect(self.onUpdateHiddenSSIDs)
#else:
# self.btnUpdate = None
# Network Table
self.lblNet = QLabel("Networks", self)
self.lblNet.setGeometry(10, 103, 220, 30)
self.networkTable = QTableWidget(self)
self.networkTable.setColumnCount(12)
# self.networkTable.setGeometry(10, 100, self.mainWidth-60, self.mainHeight/2-105)
self.networkTable.setShowGrid(True)
self.networkTable.setHorizontalHeaderLabels(['macAddr', 'vendor','SSID', 'Security', 'Privacy', 'Channel', 'Frequency', 'Signal Strength', 'Bandwidth', 'Last Seen', 'First Seen', 'GPS'])
self.networkTable.resizeColumnsToContents()
self.networkTable.setRowCount(0)
self.networkTable.horizontalHeader().setSectionResizeMode(2, QHeaderView.Stretch)
self.networkTable.horizontalHeader().sectionClicked.connect(self.onNetTableHeadingClicked)
self.networkTable.setSelectionMode( QAbstractItemView.SingleSelection )
self.networkTableSortOrder = Qt.DescendingOrder
self.networkTableSortIndex = -1
self.clientTableSortOrder = Qt.DescendingOrder
self.clientTableSortIndex = -1
# Network Table right-click menu
self.networkRightClickMenu = QMenu(self)
newAct = QAction('Copy', self)
newAct.setStatusTip('Copy data to clipboard')
newAct.triggered.connect(self.onCopyNet)
self.networkRightClickMenu.addAction(newAct)
self.networkRightClickMenu.addSeparator()
newAct = QAction('Telemetry', self)
newAct.setStatusTip('View network telemetry data')
newAct.triggered.connect(self.onShowNetworkTelemetry)
self.networkRightClickMenu.addAction(newAct)
self.networkRightClickMenu.addSeparator()
self.deauthSingleNet = QAction('Deauth Broadcast - Single', self)
self.deauthSingleNet.setStatusTip('Kick a client off its associated AP')
self.deauthSingleNet.triggered.connect(self.onDeauthSingleNet)
self.networkRightClickMenu.addAction(self.deauthSingleNet)
self.deauthContinuousNet = QAction('Deauth Broadcast - Continuous', self)
self.deauthContinuousNet.setStatusTip('Kick a client off its associated AP')
self.deauthContinuousNet.triggered.connect(self.onDeauthContinuousNet)
self.networkRightClickMenu.addAction(self.deauthContinuousNet)
self.deauthStopNet = QAction('Stop deauth', self)
self.deauthStopNet.setStatusTip('Kick a client off its associated AP')
self.deauthStopNet.triggered.connect(self.onDeauthStopNet)
self.networkRightClickMenu.addAction(self.deauthStopNet)
self.netCaptureWEP = QAction('Capture WEP Keys', self)
self.netCaptureWEP.setStatusTip('Capture WEP Keys')
self.netCaptureWEP.triggered.connect(self.onNetCaptureWEPKeys)
self.networkRightClickMenu.addAction(self.netCaptureWEP)
self.netStopWEP = QAction('Stop WEP Capture', self)
self.netStopWEP.setStatusTip('Stop WEP Capture')
self.netStopWEP.triggered.connect(self.onNetStopWEP)
self.networkRightClickMenu.addAction(self.netStopWEP)
self.netCaptureWPA = QAction('Capture WPA Keys', self)
self.netCaptureWPA.setStatusTip('Capture WPA Keys')
self.netCaptureWPA.triggered.connect(self.onNetCaptureWPAKeys)
self.networkRightClickMenu.addAction(self.netCaptureWPA)
self.netStopWPA = QAction('Stop WPA Capture', self)
self.netStopWPA.setStatusTip('Stop WPA key capture')
self.netStopWPA.triggered.connect(self.onNetStopWPA)
self.networkRightClickMenu.addAction(self.netStopWPA)
#newAct = QAction('Clone', self)
#newAct.setStatusTip('Clone an access point')
#newAct.triggered.connect(self.onCloneAP)
#self.networkRightClickMenu.addAction(newAct)
# Attach it to the table
self.networkTable.setContextMenuPolicy(Qt.CustomContextMenu)
self.networkTable.customContextMenuRequested.connect(self.showNetworkContextMenu)
# Export Button
self.btnExport = QPushButton("&Export Clients", self)
self.btnExport.setStyleSheet("background-color: rgba(0,128,192,255);")
self.btnExport.clicked.connect(self.onExportClicked)
# Client statiion Table
self.lblClients = QLabel("Client Stations", self)
self.clientTable = QTableWidget(self)
self.clientTable.setColumnCount(10)
self.clientTable.setShowGrid(True)
self.clientTable.setHorizontalHeaderLabels(['Station Mac', 'Vendor','Associated AP','Assoc SSID','Channel','Signal Strength','Last Seen', 'First Seen', 'GPS','Probed SSIDs'])
self.clientTable.resizeColumnsToContents()
self.clientTable.setRowCount(0)
self.clientTable.horizontalHeader().setSectionResizeMode(9, QHeaderView.Stretch)
self.clientTable.horizontalHeader().sectionClicked.connect(self.onClientTableHeadingClicked)
self.clientTable.setSelectionMode( QAbstractItemView.SingleSelection )
# Client Table right-click menu
self.clientRightClickMenu = QMenu(self)
newAct = QAction('Copy', self)
newAct.setStatusTip('Copy data to clipboard')
newAct.triggered.connect(self.onCopyClient)
self.clientRightClickMenu.addAction(newAct)
self.clientRightClickMenu.addSeparator()
newAct = QAction('Telemetry', self)
newAct.setStatusTip('View network telemetry data')
newAct.triggered.connect(self.onShowClientTelemetry)
self.clientRightClickMenu.addAction(newAct)
self.clientRightClickMenu.addSeparator()
self.deauthSingle = QAction('Deauth Client - Single', self)
self.deauthSingle.setStatusTip('Kick a client off its associated AP')
self.deauthSingle.triggered.connect(self.onDeauthClientSingle)
self.clientRightClickMenu.addAction(self.deauthSingle)
self.deauthContinuous = QAction('Deauth Client - Continuous', self)
self.deauthContinuous.setStatusTip('Kick a client off its associated AP')
self.deauthContinuous.triggered.connect(self.onDeauthClientContinuous)
self.clientRightClickMenu.addAction(self.deauthContinuous)
self.deauthStop = QAction('Stop deauth', self)
self.deauthStop.setStatusTip('Kick a client off its associated AP')
self.deauthStop.triggered.connect(self.onDeauthStop)
self.clientRightClickMenu.addAction(self.deauthStop)
self.clientCaptureWEP = QAction('Capture WEP Keys', self)
self.clientCaptureWEP.setStatusTip('Capture WEP Keys')
self.clientCaptureWEP.triggered.connect(self.onClientCaptureWEPKeys)
self.clientRightClickMenu.addAction(self.clientCaptureWEP)
self.clientStopWEP = QAction('Stop WEP Capture', self)
self.clientStopWEP.setStatusTip('Stop WEP Capture')
self.clientStopWEP.triggered.connect(self.onClientStopWEP)
self.clientRightClickMenu.addAction(self.clientStopWEP)
# Attach it to the table
self.clientTable.setContextMenuPolicy(Qt.CustomContextMenu)
self.clientTable.customContextMenuRequested.connect(self.showClientContextMenu)
self.setBlackoutColors()
def resizeEvent(self, event):
# self.resized.emit()
# self.statusBar().showMessage('Window resized.')
# return super(mainWin, self).resizeEvent(event)
size = self.geometry()
self.statBar.setGeometry(0, size.height()-30, size.width(), 30)
self.networkTable.setGeometry(10, 132, size.width()-20, size.height()//2-105)
self.lblClients.move(10, size.height()//2+45)
self.clientTable.setGeometry(10, size.height()//2+70, size.width()-20, size.height()//2-110)
# self.console.setGeometry(10, 150, size.width()-20, size.height()-150)
# self.btnScan.setGeometry(size.width()-110,30, 100, 30)
#if (self.mainWin):
# self.btnUpdate.setGeometry(size.width()-160, 90, 150, 30)
self.btnExport.setGeometry(size.width()-130, size.height()//2+33, 120, 30)
def center(self):
# Get our geometry
qr = self.frameGeometry()
# Find the desktop center point
cp = QDesktopWidget().availableGeometry().center()
# Move our center point to the desktop center point
qr.moveCenter(cp)
# Move the top-left point of the application window to the top-left point of the qr rectangle,
# basically centering the window
self.move(qr.topLeft())
def closeEvent(self, event):
try:
# Stop active AP/Client scans if active
if self.scanRunning():
curInterface = str(self.comboMonInterfaces.currentText())
if self.usingRemoteAgent:
stopRemoteScan(self.remoteAgentIP, self.remoteAgentPort, curInterface)
else:
FalconWirelessEngine.airodumpStop(curInterface)
# stop any deauth processes
self.stopAllDeauths()
# stop any WEP cracking processes
if self.wepCrackRunning:
if self.usingRemoteAgent:
curInterface = self.getMonitoringInterface()
if len(curInterface) > 0:
stopRemoteCrack(self.remoteAgentIP, self.remoteAgentPort, curInterface)
else:
self.wepCrack.stopCrack()
self.wepCrackRunning = False
# stop any WPA PSK cracking processes
if self.wpaCrackRunning:
if self.usingRemoteAgent:
curInterface = self.getMonitoringInterface()
if len(curInterface) > 0:
stopRemoteCrack(self.remoteAgentIP, self.remoteAgentPort, curInterface)
else:
self.wpaPSKCrack.stopCrack()
self.wpaCrackRunning = False
# Close any open telemetry windows
keysToRemove = []
for curKey in self.networkTelemetryWindows.keys():
curWindow = self.networkTelemetryWindows[curKey]
try:
curWindow.close()
self.networkTelemetryWindows[curKey] = None
keysToRemove.append(curKey)
except:
pass
# Have to separate the iteration and the removal or you'll get a "list changed during iteration" exception
for curKey in keysToRemove:
del self.networkTelemetryWindows[curKey]
keysToRemove.clear()
for curKey in self.clientTelemetryWindows.keys():
curWindow = self.clientTelemetryWindows[curKey]
try:
curWindow.close()
self.clientTelemetryWindows[curKey] = None
keysToRemove.append(curKey)
except:
pass
for curKey in keysToRemove:
del self.clientTelemetryWindows[curKey]
# signal that we closed
if self.mainWin:
self.mainWin.advScanClosed.emit()
# accept the event
event.accept()
except OSError as e:
print("Caught error:" + e.strerror)
except:
print("Caught error.")
def onCopyNet(self):
self.updateLock.acquire()
curRow = self.networkTable.currentRow()
curCol = self.networkTable.currentColumn()
if curRow == -1 or curCol == -1:
self.updateLock.release()
return