forked from v1s1t0r1sh3r3/airgeddon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
airgeddon.sh
8416 lines (7097 loc) · 215 KB
/
airgeddon.sh
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/env bash
#Title........: airgeddon.sh
#Description..: This is a multi-use bash script for Linux systems to audit wireless networks.
#Author.......: v1s1t0r
#Date.........: 20170305
#Version......: 6.1
#Usage........: bash airgeddon.sh
#Bash Version.: 4.2 or later
#Enabled with extra-verbose mode 2 / Enabled 1 / Disabled 0 - Debug mode for faster development skipping intro and initial checks - Default value 0
debug_mode=0
#Enabled 1 / Disabled 0 - Auto update feature (it has no effect on debug mode) - Default value 1
auto_update=1
#Enabled 1 / Disabled 0 - Auto change language feature - Default value 1
auto_change_language=1
#Language vars
#Change this line to select another default language. Select one from available values in array
language="ENGLISH"
declare -A lang_association=(
["en"]="ENGLISH"
["es"]="SPANISH"
["fr"]="FRENCH"
["ca"]="CATALAN"
["pt"]="PORTUGUESE"
["ru"]="RUSSIAN"
["gr"]="GREEK"
)
#Tools vars
essential_tools_names=(
"ifconfig"
"iwconfig"
"iw"
"awk"
"airmon-ng"
"airodump-ng"
"aircrack-ng"
"xterm"
)
optional_tools_names=(
"wpaclean"
"crunch"
"aireplay-ng"
"mdk3"
"hashcat"
"hostapd"
"dhcpd"
"iptables"
"ettercap"
"etterlog"
"sslstrip"
"lighttpd"
"dnsspoof"
"wash"
"reaver"
"bully"
"pixiewps"
"unbuffer"
"bettercap"
"beef"
)
update_tools=("curl")
declare -A possible_package_names=(
[${essential_tools_names[0]}]="net-tools" #ifconfig
[${essential_tools_names[1]}]="wireless-tools" #iwconfig
[${essential_tools_names[2]}]="iw" #iw
[${essential_tools_names[3]}]="awk" #awk
[${essential_tools_names[4]}]="aircrack-ng" #airmon-ng
[${essential_tools_names[5]}]="aircrack-ng" #airodump-ng
[${essential_tools_names[6]}]="aircrack-ng" #aircrack-ng
[${essential_tools_names[7]}]="xterm" #xterm
[${optional_tools_names[0]}]="aircrack-ng" #wpaclean
[${optional_tools_names[1]}]="crunch" #crunch
[${optional_tools_names[2]}]="aircrack-ng" #aireplay-ng
[${optional_tools_names[3]}]="mdk3" #mdk3
[${optional_tools_names[4]}]="hashcat" #hashcat
[${optional_tools_names[5]}]="hostapd" #hostapd
[${optional_tools_names[6]}]="isc-dhcp-server / dhcp-server / dhcp" #dhcpd
[${optional_tools_names[7]}]="iptables" #iptables
[${optional_tools_names[8]}]="ettercap / ettercap-text-only / ettercap-graphical" #ettercap
[${optional_tools_names[9]}]="ettercap / ettercap-text-only / ettercap-graphical" #etterlog
[${optional_tools_names[10]}]="sslstrip" #sslstrip
[${optional_tools_names[11]}]="lighttpd" #lighttpd
[${optional_tools_names[12]}]="dsniff" #dnsspoof
[${optional_tools_names[13]}]="reaver" #wash
[${optional_tools_names[14]}]="reaver" #reaver
[${optional_tools_names[15]}]="bully" #bully
[${optional_tools_names[16]}]="pixiewps" #pixiewps
[${optional_tools_names[17]}]="expect / expect-dev" #unbuffer
[${optional_tools_names[18]}]="bettercap" #bettercap
[${optional_tools_names[19]}]="beef-xss / beef-project" #beef
[${update_tools[0]}]="curl" #curl
)
#More than one alias can be defined separated by spaces at value
declare -A possible_alias_names=(
["beef"]="beef-xss beef-server"
)
#General vars
airgeddon_version="6.1"
language_strings_expected_version="6.1-1"
standardhandshake_filename="handshake-01.cap"
tmpdir="/tmp/"
osversionfile_dir="/etc/"
minimum_bash_version_required="4.2"
hashcat3_version="3.0"
resume_message=224
abort_question=12
pending_of_translation="[PoT]"
escaped_pending_of_translation="\[PoT\]"
standard_resolution="1024x768"
curl_404_error="404: Not Found"
language_strings_file="language_strings.sh"
#WPS vars
minimum_reaver_pixiewps_version="1.5.2"
minimum_bully_pixiewps_version="1.1"
minimum_bully_verbosity4_version="1.1"
known_pins_dbfile="known_pins.db"
pins_dbfile_checksum="pindb_checksum.txt"
wps_default_generic_pin="12345670"
wps_attack_script_file="ag.wpsattack.sh"
wps_out_file="ag.wpsout.txt"
timeout_secs_per_pin="30"
timeout_secs_per_pixiedust="30"
#Repository and contact vars
github_user="v1s1t0r1sh3r3"
github_repository="airgeddon"
branch="master"
script_filename="airgeddon.sh"
urlgithub="https://github.com/${github_user}/${github_repository}"
urlscript_directlink="https://raw.githubusercontent.com/${github_user}/${github_repository}/${branch}/${script_filename}"
urlscript_pins_dbfile="https://raw.githubusercontent.com/${github_user}/${github_repository}/${branch}/${known_pins_dbfile}"
urlscript_pins_dbfile_checksum="https://raw.githubusercontent.com/${github_user}/${github_repository}/${branch}/${pins_dbfile_checksum}"
urlscript_language_strings_file="https://raw.githubusercontent.com/${github_user}/${github_repository}/${branch}/${language_strings_file}"
host_to_check_internet="github.com"
mail="v1s1t0r.1s.h3r3@gmail.com"
author="v1s1t0r"
#Dhcpd, Hostapd and misc Evil Twin vars
ip_range="192.168.1.0"
alt_ip_range="172.16.250.0"
router_ip="192.168.1.1"
alt_router_ip="172.16.250.1"
broadcast_ip="192.168.1.255"
alt_broadcast_ip="172.16.250.255"
range_start="192.168.1.33"
range_stop="192.168.1.100"
alt_range_start="172.16.250.33"
alt_range_stop="172.16.250.100"
std_c_mask="255.255.255.0"
ip_mask="255.255.255.255"
dhcpd_file="ag.dhcpd.conf"
internet_dns1="8.8.8.8"
internet_dns2="8.8.4.4"
sslstrip_port="10000"
bettercap_proxy_port="8080"
bettercap_dns_port="5300"
minimum_bettercap_advanced_options="1.5.9"
sslstrip_file="ag.sslstrip.log"
ettercap_file="ag.ettercap.log"
bettercap_file="ag.bettercap.log"
beef_port="3000"
beef_control_panel_url="http://127.0.0.1:${beef_port}/ui/panel"
jshookfile="hook.js"
beef_file="ag.beef.conf"
beef_pass="airgeddon"
beef_db="beef.db"
beef_installation_url="https://github.com/beefproject/beef/wiki/Installation"
hostapd_file="ag.hostapd.conf"
control_file="ag.control.sh"
webserver_file="ag.lighttpd.conf"
webdir="www/"
indexfile="index.htm"
checkfile="check.htm"
cssfile="portal.css"
jsfile="portal.js"
attemptsfile="ag.et_attempts.txt"
currentpassfile="ag.et_currentpass.txt"
successfile="ag.et_success.txt"
processesfile="ag.et_processes.txt"
possible_dhcp_leases_files=(
"/var/lib/dhcp/dhcpd.leases"
"/var/state/dhcp/dhcpd.leases"
"/var/lib/dhcpd/dhcpd.leases"
)
possible_beef_known_locations=(
"/usr/share/beef/"
"/usr/share/beef-xss/"
"/opt/beef/"
"/opt/beef-project/"
#Custom BeEF location (set=0)
)
#Distros vars
known_compatible_distros=(
"Wifislax"
"Kali"
"Parrot"
"Backbox"
"BlackArch"
"Cyborg"
"Ubuntu"
"Debian"
"SuSE"
"CentOS"
"Gentoo"
"Fedora"
"Red Hat"
"Arch"
"OpenMandriva"
)
known_arm_compatible_distros=(
"Raspbian"
"Parrot arm"
"Kali arm"
)
#Hint vars
declare main_hints=(128 134 163)
declare dos_hints=(129 131 133)
declare handshake_hints=(127 130 132 136)
declare handshake_attack_hints=(142)
declare decrypt_hints=(171 178 179 208 244)
declare select_interface_hints=(246)
declare language_hints=(250)
declare evil_twin_hints=(254 258 264 269 309 328 400)
declare evil_twin_dos_hints=(267 268)
declare beef_hints=(408)
declare wps_hints=(342 343 344 356 369 390)
#Charset vars
crunch_lowercasecharset="abcdefghijklmnopqrstuvwxyz"
crunch_uppercasecharset="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
crunch_numbercharset="0123456789"
crunch_symbolcharset="!#$%/=?{}[]-*:;"
hashcat_charsets=("?l" "?u" "?d" "?s")
#Colors vars
green_color="\033[1;32m"
green_color_title="\033[0;32m"
red_color="\033[1;31m"
red_color_slim="\033[0;031m"
blue_color="\033[1;34m"
cyan_color="\033[1;36m"
brown_color="\033[0;33m"
yellow_color="\033[1;33m"
pink_color="\033[1;35m"
white_color="\e[1;97m"
normal_color="\e[1;0m"
#Check coherence between script and language_strings file
function check_language_strings() {
debug_print
if [ -f "${scriptfolder}${language_strings_file}" ]; then
language_file_found=1
language_file_mismatch=0
#shellcheck source=./language_strings.sh
source "${scriptfolder}${language_strings_file}"
set_language_strings_version
if [ "${language_strings_version}" != "${language_strings_expected_version}" ]; then
language_file_mismatch=1
fi
else
language_file_found=0
fi
if [[ "${language_file_found}" -eq 0 ]] || [[ "${language_file_mismatch}" -eq 1 ]]; then
language_strings_handling_messages
generate_dynamic_line "airgeddon" "title"
if [ "${language_file_found}" -eq 0 ]; then
echo_red "${language_strings_no_file[${language}]}"
if [ "${airgeddon_version}" = "6.1" ]; then
echo
echo_yellow "${language_strings_first_time[${language}]}"
fi
elif [ "${language_file_mismatch}" -eq 1 ]; then
echo_red "${language_strings_file_mismatch[${language}]}"
fi
echo
echo_blue "${language_strings_try_to_download[${language}]}"
read -p "${language_strings_key_to_continue[${language}]}" -r
check_internet_access "${host_to_check_internet}"
if [ "$?" = "0" ]; then
download_language_strings_file
if [ "$?" = "0" ]; then
echo
echo_yellow "${language_strings_successfully_downloaded[${language}]}"
read -p "${language_strings_key_to_continue[${language}]}" -r
clear
return 0
else
echo
echo_red "${language_strings_failed_downloading[${language}]}"
fi
else
echo
echo_red "${language_strings_failed_downloading[${language}]}"
fi
echo
echo_blue "${language_strings_exiting[${language}]}"
echo
hardcore_exit
fi
}
#Download the language strings file
function download_language_strings_file() {
debug_print
remote_language_strings_file=$(timeout -s SIGTERM 15 curl -L ${urlscript_language_strings_file} 2> /dev/null)
if [ "${remote_language_strings_file}" != "${curl_404_error}" ]; then
echo "${remote_language_strings_file}" > "${scriptfolder}${language_strings_file}"
chmod +x "${scriptfolder}${language_strings_file}" > /dev/null 2>&1
#shellcheck source=./language_strings.sh
source "${scriptfolder}${language_strings_file}"
return 0
else
return 1
fi
}
#Set messages for language_strings handling
function language_strings_handling_messages() {
declare -gA language_strings_no_file
language_strings_no_file["ENGLISH"]="Error. Language strings file not found"
language_strings_no_file["SPANISH"]="Error. No se ha encontrado el fichero de traducciones"
language_strings_no_file["FRENCH"]="Erreur. Fichier contenant les traductions absent"
language_strings_no_file["CATALAN"]="Error. No s'ha trobat el fitxer de traduccions"
language_strings_no_file["PORTUGUESE"]="Erro. O arquivo de tradução não foi encontrado"
language_strings_no_file["RUSSIAN"]="Ошибка. Не найден языковой файл"
language_strings_no_file["GREEK"]="Σφάλμα. Το αρχείο γλωσσών δεν βρέθηκε"
declare -gA language_strings_file_mismatch
language_strings_file_mismatch["ENGLISH"]="Error. The language strings file found mismatches expected version"
language_strings_file_mismatch["SPANISH"]="Error. El fichero de traducciones encontrado no es la versión esperada"
language_strings_file_mismatch["FRENCH"]="Erreur. Les traductions trouvées ne sont pas celles attendues"
language_strings_file_mismatch["CATALAN"]="Error. El fitxer de traduccions trobat no és la versió esperada"
language_strings_file_mismatch["PORTUGUESE"]="Erro. O a versão do arquivos de tradução encontrado é a incompatível"
language_strings_file_mismatch["RUSSIAN"]="Ошибка. Языковой файл не соответствует ожидаемой версии"
language_strings_file_mismatch["GREEK"]="Σφάλμα. Το αρχείο γλωσσών που έχει βρεθεί δεν αντιστοιχεί με την προαπαιτούμενη έκδοση"
declare -gA language_strings_try_to_download
language_strings_try_to_download["ENGLISH"]="airgeddon will try to download the language strings file..."
language_strings_try_to_download["SPANISH"]="airgeddon intentará descargar el fichero de traducciones..."
language_strings_try_to_download["FRENCH"]="airgeddon va essayer de télécharger les fichiers de traductions..."
language_strings_try_to_download["CATALAN"]="airgeddon intentarà descarregar el fitxer de traduccions..."
language_strings_try_to_download["PORTUGUESE"]="O airgeddon tentará baixar o arquivo de tradução..."
language_strings_try_to_download["RUSSIAN"]="airgeddon попытается загрузить языковой файл..."
language_strings_try_to_download["GREEK"]="Το airgeddon θα προσπαθήσει να κατεβάσει το αρχείο γλωσσών..."
declare -gA language_strings_successfully_downloaded
language_strings_successfully_downloaded["ENGLISH"]="Language strings file was successfully downloaded"
language_strings_successfully_downloaded["SPANISH"]="Se ha descargado con éxito el fichero de traducciones"
language_strings_successfully_downloaded["FRENCH"]="Les fichiers traduction ont été correctement téléchargés"
language_strings_successfully_downloaded["CATALAN"]="S'ha descarregat amb èxit el fitxer de traduccions"
language_strings_successfully_downloaded["PORTUGUESE"]="O arquivo de tradução foi baixado com sucesso"
language_strings_successfully_downloaded["RUSSIAN"]="Языковой файл был успешно загружен"
language_strings_successfully_downloaded["GREEK"]="Το αρχείο γλωσσών κατέβηκε με επιτυχία"
declare -gA language_strings_failed_downloading
language_strings_failed_downloading["ENGLISH"]="The language string file can't be downloaded. Check your internet connection or download it manually from ${normal_color}${urlgithub}"
language_strings_failed_downloading["SPANISH"]="No se ha podido descargar el fichero de traducciones. Comprueba tu conexión a internet o descárgalo manualmente de ${normal_color}${urlgithub}"
language_strings_failed_downloading["FRENCH"]="Impossible de télécharger le fichier traduction. Vérifiez votre connexion à internet ou téléchargez le fichier manuellement ${normal_color}${urlgithub}"
language_strings_failed_downloading["CATALAN"]="No s'ha pogut descarregar el fitxer de traduccions. Comprova la connexió a internet o descarrega'l manualment de ${normal_color}${urlgithub}"
language_strings_failed_downloading["PORTUGUESE"]="Não foi possível baixar o arquivos de tradução. Verifique a sua conexão com a internet ou baixe manualmente em ${normal_color}${urlgithub}"
language_strings_failed_downloading["RUSSIAN"]="Языковой файл не может быть загружен. Проверьте подключение к Интернету или загрузите его вручную с ${normal_color}${urlgithub}"
language_strings_failed_downloading["GREEK"]="Το αρχείο γλωσσών δεν μπορεί να κατέβει. Ελέγξτε τη σύνδεση σας με το διαδίκτυο ή κατεβάστε το χειροκίνητα ${normal_color}${urlgithub}"
declare -gA language_strings_first_time
language_strings_first_time["ENGLISH"]="If you are seeing this message after an automatic update, don't be scared! It's probably because airgeddon has different file structure since version 6.1. It will be automatically fixed"
language_strings_first_time["SPANISH"]="Si estás viendo este mensaje tras una actualización automática, ¡no te asustes! probablemente es porque a partir de la versión 6.1 la estructura de ficheros de airgeddon ha cambiado. Se reparará automáticamente"
language_strings_first_time["FRENCH"]="Si vous voyez ce message après une mise à jour automatique ne vous inquiétez pas! A partir de la version 6.1 la structure de fichier d'airgeddon a changé. L'ajustement se fera automatiquement"
language_strings_first_time["CATALAN"]="Si estàs veient aquest missatge després d'una actualització automàtica, no t'espantis! probablement és perquè a partir de la versió 6.1 l'estructura de fitxers de airgeddon ha canviat. Es repararà automàticament"
language_strings_first_time["PORTUGUESE"]="Se você está vendo esta mensagem depois de uma atualização automática, não tenha medo! A partir da versão 6.1 da estrutura de arquivos do airgeddon mudou. Isso será corrigido automaticamente"
language_strings_first_time["RUSSIAN"]="Если вы видите это сообщение после автоматического обновления, не переживайте! Вероятно, это объясняется тем, что, начиная с версии 6.1, airgeddon имеет другую структуру файлов. Проблема будет разрешена автоматически"
language_strings_first_time["GREEK"]="Εάν βλέπετε αυτό το μήνυμα μετά από κάποια αυτόματη ενημέρωση, μην τρομάξετε! Πιθανόν είναι λόγω της διαφορετικής δομής του airgeddon μετά από την έκδοση 6.1. Θα επιδιορθωθεί αυτόματα"
declare -gA language_strings_exiting
language_strings_exiting["ENGLISH"]="Exiting airgeddon script v${airgeddon_version} - See you soon! :)"
language_strings_exiting["SPANISH"]="Saliendo de airgeddon script v${airgeddon_version} - Nos vemos pronto! :)"
language_strings_exiting["FRENCH"]="Fermeture du script airgeddon v${airgeddon_version} - A bientôt! :)"
language_strings_exiting["CATALAN"]="Sortint de airgeddon script v${airgeddon_version} - Ens veiem aviat! :)"
language_strings_exiting["PORTUGUESE"]="Saindo do script airgeddon v${airgeddon_version} - Até breve! :)"
language_strings_exiting["RUSSIAN"]="Выход из скрипта airgeddon v${airgeddon_version} - До встречи! :)"
language_strings_exiting["GREEK"]="Κλείσιμο του airgeddon v${airgeddon_version} - Αντίο :)"
declare -gA language_strings_key_to_continue
language_strings_key_to_continue["ENGLISH"]="Press [Enter] key to continue..."
language_strings_key_to_continue["SPANISH"]="Pulsa la tecla [Enter] para continuar..."
language_strings_key_to_continue["FRENCH"]="Pressez [Enter] pour continuer..."
language_strings_key_to_continue["CATALAN"]="Prem la tecla [Enter] per continuar..."
language_strings_key_to_continue["PORTUGUESE"]="Pressione a tecla [Enter] para continuar..."
language_strings_key_to_continue["RUSSIAN"]="Нажмите клавишу [Enter] для продолжения..."
language_strings_key_to_continue["GREEK"]="Πατήστε το κουμπί [Enter] για να συνεχίσετε..."
}
#Print the current line of where this was called and the function's name. Applies to some (which are useful) functions
function debug_print() {
if [ ${debug_mode} -eq 2 ]; then
declare excluded_functions=(
"ask_yesno"
"check_pending_of_translation"
"contains_element"
"echo_blue"
"echo_brown"
"echo_cyan"
"echo_green"
"echo_green_title"
"echo_pink"
"echo_red"
"echo_red_slim"
"echo_white"
"echo_yellow"
"generate_dynamic_line"
"interrupt_checkpoint"
"language_strings"
"last_echo"
"print_hint"
"print_large_separator"
"print_simple_separator"
"read_yesno"
"remove_warnings"
"special_text_missed_optional_tool"
"store_array"
"under_construction_message"
)
if (IFS=$'\n'; echo "${excluded_functions[*]}") | grep -qFx "${FUNCNAME[1]}"; then
return 1
fi
#TODO "${@}" to print parameters
echo "Line:${BASH_LINENO[1]}" "${FUNCNAME[1]}"
return 0
fi
}
#Set the message to show again after an interrupt ([Ctrl+C] or [Ctrl+Z]) without exiting
function interrupt_checkpoint() {
debug_print
if [ -z "${last_buffered_type1}" ]; then
last_buffered_message1=${1}
last_buffered_message2=${1}
last_buffered_type1=${2}
last_buffered_type2=${2}
else
if [ "${1}" -ne ${resume_message} ]; then
last_buffered_message2=${last_buffered_message1}
last_buffered_message1=${1}
last_buffered_type2=${last_buffered_type1}
last_buffered_type1=${2}
fi
fi
}
#Add the text on a menu when you miss an optional tool
function special_text_missed_optional_tool() {
debug_print
declare -a required_tools=("${!3}")
allowed_menu_option=1
if [ ${debug_mode} -eq 0 ]; then
tools_needed="${optionaltool_needed[${1}]}"
for item in "${required_tools[@]}"; do
if [ "${optional_tools[${item}]}" -eq 0 ]; then
allowed_menu_option=0
tools_needed+="${item} "
fi
done
fi
if [ ${allowed_menu_option} -eq 1 ]; then
last_echo "${arr[${1},${2}]}" "${normal_color}"
else
[[ ${arr[${1},${2}]} =~ ^([0-9]+)\.(.*)$ ]] && forbidden_options+=("${BASH_REMATCH[1]}")
tools_needed=${tools_needed:: -1}
echo_red_slim "${arr[${1},${2}]} (${tools_needed})"
fi
}
#Generate the chars in front of and behind a text for titles and separators
function generate_dynamic_line() {
debug_print
local type=${2}
if [ "${type}" = "title" ]; then
ncharstitle=78
titlechar="*"
elif [ "${type}" = "separator" ]; then
ncharstitle=58
titlechar="-"
fi
titletext=${1}
titlelength=${#titletext}
finaltitle=""
for ((i=0; i < (ncharstitle/2 - titlelength+(titlelength/2)); i++)); do
finaltitle="${finaltitle}${titlechar}"
done
if [ "${type}" = "title" ]; then
finaltitle="${finaltitle} ${titletext} "
elif [ "${type}" = "separator" ]; then
finaltitle="${finaltitle} (${titletext}) "
fi
for ((i=0; i < (ncharstitle/2 - titlelength+(titlelength/2)); i++)); do
finaltitle="${finaltitle}${titlechar}"
done
if [ $((titlelength % 2)) -gt 0 ]; then
finaltitle+="${titlechar}"
fi
if [ "${type}" = "title" ]; then
echo_green_title "${finaltitle}"
elif [ "${type}" = "separator" ]; then
echo_blue "${finaltitle}"
fi
}
#Wrapper to check managed mode on an interface
function check_to_set_managed() {
debug_print
check_interface_mode
case "${ifacemode}" in
"Managed")
echo
language_strings "${language}" 0 "red"
language_strings "${language}" 115 "read"
return 1
;;
"(Non wifi card)")
echo
language_strings "${language}" 1 "red"
language_strings "${language}" 115 "read"
return 1
;;
esac
return 0
}
#Wrapper to check monitor mode on an interface
function check_to_set_monitor() {
debug_print
check_interface_mode
case "${ifacemode}" in
"Monitor")
echo
language_strings "${language}" 10 "red"
language_strings "${language}" 115 "read"
return 1
;;
"(Non wifi card)")
echo
language_strings "${language}" 13 "red"
language_strings "${language}" 115 "read"
return 1
;;
esac
return 0
}
#Check for monitor mode on an interface
function check_monitor_enabled() {
debug_print
mode=$(iwconfig "${interface}" 2> /dev/null | grep Mode: | awk '{print $4}' | cut -d ':' -f 2)
if [[ ${mode} != "Monitor" ]]; then
echo
language_strings "${language}" 14 "red"
language_strings "${language}" 115 "read"
return 1
fi
return 0
}
#Check if an interface is a wifi card or not
function check_interface_wifi() {
debug_print
execute_iwconfig_fix
return $?
}
#Execute the iwconfig fix to know if an interface is a wifi card or not
function execute_iwconfig_fix() {
debug_print
iwconfig_fix
iwcmd="iwconfig ${interface} ${iwcmdfix} > /dev/null 2> /dev/null"
eval "${iwcmd}"
return $?
}
#Create a list of interfaces associated to its macs
function renew_ifaces_and_macs_list() {
debug_print
readarray -t IFACES_AND_MACS < <(ip link | egrep "^[0-9]+" | cut -d ':' -f 2 | awk '{print $1}' | grep lo -v | grep "${interface}" -v)
declare -gA ifaces_and_macs
for iface_name in "${IFACES_AND_MACS[@]}"; do
mac_item=$(cat < "/sys/class/net/${iface_name}/address" 2> /dev/null)
if [ -n "${mac_item}" ]; then
ifaces_and_macs[${iface_name}]=${mac_item}
fi
done
declare -gA ifaces_and_macs_switched
for iface_name in "${!ifaces_and_macs[@]}"; do
ifaces_and_macs_switched[${ifaces_and_macs[${iface_name}]}]=${iface_name}
done
}
#Check the interface coherence between interface names and macs
function check_interface_coherence() {
debug_print
renew_ifaces_and_macs_list
interface_auto_change=0
interface_found=0
for iface_name in "${!ifaces_and_macs[@]}"; do
if [ "${interface}" = "${iface_name}" ]; then
interface_found=1
interface_mac=${ifaces_and_macs[${iface_name}]}
break
fi
done
if [ ${interface_found} -eq 0 ]; then
for iface_mac in "${ifaces_and_macs[@]}"; do
iface_mac_tmp=${iface_mac:0:15}
interface_mac_tmp=${interface_mac:0:15}
if [ "${iface_mac_tmp}" = "${interface_mac_tmp}" ]; then
interface=${ifaces_and_macs_switched[${iface_mac}]}
interface_auto_change=1
break
fi
done
fi
return ${interface_auto_change}
}
#Prepare the vars to be used on wps pin database attacks
function set_wps_mac_parameters() {
debug_print
six_wpsbssid_first_digits=${wps_bssid:0:8}
six_wpsbssid_first_digits_clean=${six_wpsbssid_first_digits//:}
six_wpsbssid_last_digits=${wps_bssid: -8}
six_wpsbssid_last_digits_clean=${six_wpsbssid_last_digits//:}
four_wpsbssid_last_digits=${wps_bssid: -5}
four_wpsbssid_last_digits_clean=${four_wpsbssid_last_digits//:}
}
#Calculate pin based on Zhao Chunsheng algorithm (computepin), step 1
function calculate_computepin_algorithm_step1() {
debug_print
hex_to_dec=$(printf '%d\n' 0x"${six_wpsbssid_last_digits_clean}") 2> /dev/null
computepin_pin=$((hex_to_dec % 10000000))
}
#Calculate pin based on Zhao Chunsheng algorithm (computepin), step 2
function calculate_computepin_algorithm_step2() {
debug_print
computepin_pin=$(printf '%08d\n' $((10#${computepin_pin} * 10 + checksum_digit)))
}
#Calculate pin based on Stefan Viehböck algorithm (easybox)
function calculate_easybox_algorithm() {
debug_print
hex_to_dec=($(printf "%04d" "0x${four_wpsbssid_last_digits_clean}" | sed 's/.*\(....\)/\1/;s/./& /g'))
[[ ${four_wpsbssid_last_digits_clean} =~ ${four_wpsbssid_last_digits_clean//?/(.)} ]] && hexi=($(printf '%s\n' "${BASH_REMATCH[*]:1}"))
c1=$(printf "%d + %d + %d + %d" "${hex_to_dec[0]}" "${hex_to_dec[1]}" "0x${hexi[2]}" "0x${hexi[3]}")
c2=$(printf "%d + %d + %d + %d" "0x${hexi[0]}" "0x${hexi[1]}" "${hex_to_dec[2]}" "${hex_to_dec[3]}")
K1=$((c1 % 16))
K2=$((c2 % 16))
X1=$((K1 ^ hex_to_dec[3]))
X2=$((K1 ^ hex_to_dec[2]))
X3=$((K1 ^ hex_to_dec[1]))
Y1=$((K2 ^ 0x${hexi[1]}))
Y2=$((K2 ^ 0x${hexi[2]}))
Z1=$((0x${hexi[2]} ^ hex_to_dec[3]))
Z2=$((0x${hexi[3]} ^ hex_to_dec[2]))
easybox_pin=$(printf '%08d\n' "$((0x$X1$X2$Y1$Y2$Z1$Z2$X3))" | rev | cut -c -7 | rev)
}
#Calculate the last digit on pin following the checksum rule
function pin_checksum_rule() {
debug_print
current_calculated_pin=$((10#${1} * 10))
accum=0
accum=$((accum + 3 * (current_calculated_pin/10000000 % 10)))
accum=$((accum + current_calculated_pin/1000000 % 10))
accum=$((accum + 3 * (current_calculated_pin/100000 % 10)))
accum=$((accum + current_calculated_pin/10000 % 10))
accum=$((accum + 3 * (current_calculated_pin/1000 % 10)))
accum=$((accum + current_calculated_pin/100 % 10))
accum=$((accum + 3 * (current_calculated_pin/10 % 10)))
control_digit=$((accum % 10))
checksum_digit=$((10 - control_digit))
checksum_digit=$((checksum_digit % 10))
}
#Manage the calls to check common wps pin algorithms
function check_and_set_common_algorithms() {
debug_print
echo
language_strings "${language}" 388 "blue"
declare -g calculated_pins=("${wps_default_generic_pin}")
calculate_computepin_algorithm_step1
pin_checksum_rule "${computepin_pin}"
calculate_computepin_algorithm_step2
calculated_pins+=("${computepin_pin}")
calculate_easybox_algorithm
pin_checksum_rule "${easybox_pin}"
easybox_pin=$(printf '%08d\n' $((current_calculated_pin + checksum_digit)))
calculated_pins+=("${easybox_pin}")
integrate_algorithms_pins
if [ "$?" = "0" ]; then
echo
language_strings "${language}" 389 "yellow"
fi
}
#Integrate calculated pins from algorithms into pins array
function integrate_algorithms_pins() {
debug_print
some_calculated_pin_included=0
for pin in "${calculated_pins[@]}"; do
this_pin_already_included=0
for item in "${pins_found[@]}"; do
if [ "${item}" = "${pin}" ]; then
this_pin_already_included=1
break
fi
done
if [ ${this_pin_already_included} -eq 0 ]; then
pins_found+=(${pin})
counter_pins_found=$((counter_pins_found + 1))
some_calculated_pin_included=1
fi
done
if [ "${some_calculated_pin_included}" -eq 1 ]; then
return 0
fi
return 1
}
#Search for target wps bssid mac in pin database and set the vars to be used
function search_in_pin_database() {
debug_print
bssid_found_in_db=0
counter_pins_found=0
declare -g pins_found=()
for item in "${!PINDB[@]}"; do
if [ "${item}" = "${six_wpsbssid_first_digits_clean}" ]; then
bssid_found_in_db=1
arrpins=(${PINDB[${item//[[:space:]]/ }]})
for item2 in "${arrpins[@]}"; do
counter_pins_found=$((counter_pins_found+1))
pins_found+=(${item2})
done
break
fi
done
}
#Prepare monitor mode avoiding the use of airmon-ng or airmon-zc generating two interfaces from one
function prepare_et_monitor() {
debug_print
disable_rfkill
phy_iface=$(basename "$(readlink "/sys/class/net/${interface}/phy80211")")
iface_phy_number=${phy_iface:3:1}
iface_monitor_et_deauth="mon${iface_phy_number}"
iw phy "${phy_iface}" interface add "${iface_monitor_et_deauth}" type monitor 2> /dev/null
ifconfig "${iface_monitor_et_deauth}" up > /dev/null 2>&1
iwconfig "${iface_monitor_et_deauth}" channel "${channel}" > /dev/null 2>&1
}
#Assure the mode of the interface before the Evil Twin process
function prepare_et_interface() {
debug_print
et_initial_state=${ifacemode}
if [ "${ifacemode}" != "Managed" ]; then
new_interface=$(${airmon} stop "${interface}" 2> /dev/null | grep station)
ifacemode="Managed"
[[ ${new_interface} =~ \]?([A-Za-z0-9]+)\)?$ ]] && new_interface="${BASH_REMATCH[1]}"
if [ "${interface}" != "${new_interface}" ]; then
check_interface_coherence
if [ "$?" = "0" ]; then
interface=${new_interface}
fi
echo
language_strings "${language}" 15 "yellow"
fi
fi
}
#Restore the state of the interfaces after Evil Twin process
function restore_et_interface() {
debug_print
echo
language_strings "${language}" 299 "blue"
disable_rfkill
iw dev "${iface_monitor_et_deauth}" del > /dev/null 2>&1
if [ "${et_initial_state}" = "Managed" ]; then
ifconfig "${interface}" down > /dev/null 2>&1
iwconfig "${interface}" mode managed > /dev/null 2>&1
ifconfig "${interface}" up > /dev/null 2>&1
ifacemode="Managed"
else
new_interface=$(${airmon} start "${interface}" 2> /dev/null | grep monitor)
ifacemode="Monitor"
[[ ${new_interface} =~ \]?([A-Za-z0-9]+)\)?$ ]] && new_interface="${BASH_REMATCH[1]}"
if [ "${interface}" != "${new_interface}" ]; then
interface=${new_interface}
fi
fi
}
#Unblock if possible the interface if blocked
function disable_rfkill() {
debug_print
if hash rfkill 2> /dev/null; then
rfkill unblock all > /dev/null 2>&1
fi
}
#Put the interface on managed mode and manage the possible name change
function managed_option() {
debug_print
check_to_set_managed
if [ "$?" != "0" ]; then
return
fi
disable_rfkill
language_strings "${language}" 17 "blue"
ifconfig "${interface}" up
new_interface=$(${airmon} stop "${interface}" 2> /dev/null | grep station)
ifacemode="Managed"
[[ ${new_interface} =~ \]?([A-Za-z0-9]+)\)?$ ]] && new_interface="${BASH_REMATCH[1]}"
if [ "${interface}" != "${new_interface}" ]; then
check_interface_coherence
if [ "$?" = "0" ]; then
interface=${new_interface}
fi
echo
language_strings "${language}" 15 "yellow"
fi
echo
language_strings "${language}" 16 "yellow"
language_strings "${language}" 115 "read"
}
#Put the interface on monitor mode and manage the possible name change
function monitor_option() {
debug_print
check_to_set_monitor
if [ "$?" != "0" ]; then
return
fi
disable_rfkill
language_strings "${language}" 18 "blue"
ifconfig "${interface}" up
iwconfig "${interface}" rate 1M > /dev/null 2>&1
if [ "$?" != "0" ]; then
echo
language_strings "${language}" 20 "red"
language_strings "${language}" 115 "read"
return
fi
if [ "${check_kill_needed}" -eq 1 ]; then
language_strings "${language}" 19 "blue"
${airmon} check kill > /dev/null 2>&1
nm_processes_killed=1
fi
new_interface=$(${airmon} start "${interface}" 2> /dev/null | grep monitor)
ifacemode="Monitor"
[[ ${new_interface} =~ \]?([A-Za-z0-9]+)\)?$ ]] && new_interface="${BASH_REMATCH[1]}"
if [ "${interface}" != "${new_interface}" ]; then
check_interface_coherence
if [ "$?" = "0" ]; then
interface=${new_interface}
fi
echo
language_strings "${language}" 21 "yellow"
fi
echo
language_strings "${language}" 22 "yellow"
language_strings "${language}" 115 "read"
}
#Check the interface mode
function check_interface_mode() {
debug_print
execute_iwconfig_fix