-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmakemon_v1.2-18
223 lines (150 loc) · 5.29 KB
/
makemon_v1.2-18
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
#!/bin/bash
trap '{ clear; exit 2; }' SIGINT SIGTERM SIGQUIT
while [ "$UID" != "0" ]; do
echo "You must be root!"
exit 1
done
check_iface() {
if [ ! "$(cat /etc/environment | grep -o 'IFACE[^ ]*')" ]; then
echo -e "Your global interface variable is not set.\nIt should only need to be set once.\n"
read -p "Press <enter> to continue"
echo -e "
#~~~~~~~~~~~~~~~~#
$(iw dev | grep -o 'Interface [^ ]*' | sed -e 's/Interface //g' | sort -n)
#~~~~~~~~~~~~~~~~#\n"
read -p "Enter a wireless interface to use, [press enter to set later]: " i_face
if [ "$i_face" ]; then
echo -e "\nIFACE=$i_face" >> /etc/environment && wait
echo -e "Your interface has been set. You won't have to set it again so long
as it remains in /etc/environment. To reload /etc/environment,
for system-wide use, log out and then log back in or reboot.\n"
read -p "press <enter> to continue"
fi
fi
}; check_iface
main_interface() {
# For live ISO compatibility IFACE set with iw output.
if [ ! "$IFACE" ]; then
IFACE="$(iw dev | grep -m1 -o 'Interface w[^ ]*' | sed -e 's/Interface //g')"
fi
clear
echo -e "
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
1.) Make 1 monitor interface
2.) Make multiple interfaces
3.) List created interfaces
4.) Delete monitor interfaces
5.) Help menu
6.) Exit
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# \n"
}
rand_mac() {
gen() { local NUM="$(tr -dc '0-9a-f' </dev/urandom | head -c 2)"; echo -n "$NUM:"; }
for c in {1..6}; do
if [ "$c" -lt "6" ]; then
gen
else
gen | tr -d ':'
fi
done
}
remove_mon() {
count="$(iw dev | grep -o "mon[1-9]" | wc -l)"
if [ "$count" == "0" ]; then echo -e "\nNo interfaces to remove!"; return; fi
for a in $(seq 1 $count)
do
iw mon${a} del
clear && echo -e "mon${a} removed..."
done
echo -e "\nAll monitor interfaces removed!"
}
# Variable assigned a random mac.
nmac="$(rand_mac)"
make_mon() {
if [ "$(iw dev | grep -o "mon[1-9]" | wc -l)" -gt "0" ]; then remove_mon; fi
if [ "$(iw $IFACE interface add mon1 type monitor addr ${1} 2>&1 | grep -Eo 'command failed')" ]; then
unset nmac; nmac="$(rand_mac)"
make_mon "$nmac" && wait
else
echo -e "\nmon1 is up!"
fi
}
multi_mon() {
if [ "$(iw dev | grep -o "mon[1-9]" | wc -l)" -gt "0" ]; then remove_mon; fi
VNICS="${1}"
if [ ! "${1}" ]; then read -p "How many VNICs do you want?: " VNICS; echo; fi
for ((n=1; n <= VNICS; n++))
do
maker() {
if [ "$(iw $IFACE interface add mon${n} type monitor addr $(rand_mac) 2>&1 | grep -Eo 'command failed')" ]; then
unset nmac; local nmac="$(rand_mac)"
maker && wait
else
clear; echo -e "mon${n} is up..."
return;
fi; }; maker; done
echo -e "\nAll interfaces are up!"
}
list_mon() {
local count="$(iw dev | grep -o "mon[0-9]" | wc -l)"
if [ "$count" == "0" ]
then
echo -e "\nNo interfaces to list!"
else
echo -e "\n [Interfaces Available]"
echo -e "#~~~~~~~~~~~~~~~~~~~~~~#\n"
if [ "$count" -gt "10" ]; then
for ((b=1; b <= count; b++))
do
echo -e " $(iw dev | grep -m1 -Eo "(mon(${b}){1})") $(iw mon${b} info | grep -Eo "([^ ]*[0-9|a-f]:[a-f|0-9]{2})")"
done | column; echo
else
for ((b=1; b <= count; b++))
do
echo -e " $(iw dev | grep -m1 -Eo "(mon(${b}){1})") $(iw mon${b} info | grep -Eo "([^ ]*[0-9|a-f]:[a-f|0-9]{2})")"
done && echo; fi
fi
}
help_menu() {
clear; echo -e "Makemon is a slim tool for creating a single or many virtual
monitor-mode wireless interfaces for various wireless tasks.
You can use command-line options or you can use the simple
command-line user interface to select what options you want
to use.
[USER INTERFACE USAGE]
Run <makemon> as a command and follow the prompts.
[COMMAND-LINE USAGE]
makemon [-omlrh] [2..99+]
[OPTIONS]
-o Create a single virtual monitor interface.
-m Create multiple virtual monitor mode interfaces.
-l Show created virtual monitor mode interfaces.
-r Delete all virtual monitor interfaces.
-h Show this menu.
"
}
if [ ! "${1}" ]; then
while true; do
clear && main_interface
read -p "Enter an option: " CHOICE
case $CHOICE in
1) make_mon "$(rand_mac)" && read -p 'press <enter> to continue ' ;;
2) multi_mon && read -p 'press <enter> to continue ';;
3) list_mon && read -p 'press <enter> to continue ' ;;
4) remove_mon && read -p 'press <enter> to continue ' ;;
5) help_menu && read -p 'press <enter> to continue ';;
6) exit 0 ;;
*) echo -e "\n[ERROR]: Not an accepted option!"; read -p 'press <enter> to continue ' ;;
esac
done
else
CHOICE="${1}"
case $CHOICE in
-o) make_mon "$(rand_mac)" ;;
-m) multi_mon "${2}" ;;
-l) list_mon ;;
-r) remove_mon ;;
-h) help_menu ;;
*) echo -e "[ERROR]: ${1} is not an accepted option!"; exit 1 ;;
esac
fi