forked from Yo-kai-Sei-shin-kage/makemon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakemon
More file actions
216 lines (141 loc) · 4.58 KB
/
makemon
File metadata and controls
216 lines (141 loc) · 4.58 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
#!/bin/bash
while [ "$(whoami)" != "root" ]; do
echo "You must be root!"
exit 1
done
grn=$'\x1b[32m'
red=$'\x1b[31m'
pur=$'\x1b[35m'
ylw=$'\x1b[33m'
rst=$'\x1b[0m'
if [ ! "$(cat /etc/environment | grep -o 'IFACE[^ ]*')" ]; then
clear
echo -e "${grn}Your global interface variable is not set.${rst}"
echo -e "${grn}It should only need to be set once.${rst}\n"
read -p "${ylw}Press <${red}enter${ylw}> to continue${rst}"
clear
echo -e "
${ylw}#${grn}~~~~~~~~~~~~~~~~${ylw}#${rst}
${pur}$(iw dev | grep -o 'Interface [^ ]*' | sed -e 's/Interface //g' | sort -n)${rst}
${ylw}#${grn}~~~~~~~~~~~~~~~~${ylw}#${rst}\n"
read -p "${grn}Enter a wireless interface to use, [press enter to set later]:${rst} " i_face
if [ "$i_face" ]; then
echo -e "\nIFACE=$i_face" >> /etc/environment && wait
echo -e "${grn}Your interface has been set. You won't have to set it again so long
as it remains in ${ylw}/etc/environment${grn}. To reload ${ylw}/etc/environment${grn},
for system-wide use, log out and then log back in or reboot.${rst}\n"
read -p "${grn}press ${ylw}<${red}enter${ylw}>${grn} to continue${rst}"
clear
fi
fi
# 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 "
${grn}#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# ${rst}
${ylw} 1${red}.${grn}) ${rst}${pur}Make 1 monitor interface ${rst}
${ylw} 2${red}.${grn}) ${rst}${pur}Make multiple interfaces ${rst}
${ylw} 3${red}.${grn}) ${rst}${pur}Delete monitor interfaces ${rst}
${ylw} 4${red}.${grn}) ${rst}${red}Exit ${rst}
${grn}#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# ${rst}\n"
read -p "${grn}Enter an option:${rst} " CHOICE
if [ "$CHOICE" == "4" ]; then
clear && exit
fi
clear
remove_mon() {
m_count="$(echo -n $(iw dev | grep -o 'mon[0-9]' | wc -l))"
if [ "$m_count" -gt "0" ]; then
n_count=$(($m_count-1))
for n in $(seq 1 $m_count); do
iw dev mon$n del 2>&1>/dev/null; wait
done
fi
}
MASTER() {
#################
# Randomize Mac #
#################
RAND_MAC() {
gen() {
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
}
# Save Randomize mac to variable "nmac" #
nmac="$(RAND_MAC)"
##########################################
# Create a single new mon interface with #
# a randomized mac address #
##########################################
if [ "$CHOICE" == "1" ]; then
remove_mon
ifconfig $IFACE down; wait
iw dev $IFACE interface add mon1 type monitor; wait
add_mac() { macchanger mon1 -m $nmac 2>&1 | grep -o '\[ERROR\]'; wait; }
if [ "$(add_mac)" == "[ERROR]" ]; then
iw mon1 del && MASTER
else
ifconfig mon1 up; wait
echo -e "\x1b[32mmon1 is up\x1b[0m"
fi
#############################
# Delete all mon interfaces #
#############################
elif [ "$CHOICE" == "3" ]; then
# Check if any mons exist #
m_count="$(echo -n $(iw dev | grep -o 'mon[0-9]' | wc -l))"
if [ "$m_count" == "0" ]; then
echo -e "\x1b[91mNo mon interfaces to destroy!\x1b[0m"
exit 1
else
n_count=$(($m_count-1))
for n in $(seq 1 $m_count); do
iw dev mon$n del 2>&1>/dev/null; wait
done
ifconfig $IFACE up; wait
systemctl restart NetworkManager.service; wait
echo -e "\x1b[91mAll mons are gone\x1b[0m"
fi
######################################
# Create more than "1" mon interface #
######################################
elif [ "$CHOICE" == "2" ]; then
ifconfig $IFACE down; wait
remove_mon
echo -e "${grn}Set up to 10 new virtual NICs${rst}"
read -p "${grn}How many new VNICs do you want?:${rst} " VNICS
if [ "$VNICS" -gt "10" ]; then
echo -e "${red}Cannot set more than 10 VNICS!${rst}"
exit 1
elif [ "$VNICS" -lt "2" ]; then
echo -e "${red}If not more than 1 VNIC use option 1!${rst}"
exit 1
fi
clear
for i in $(seq 1 $VNICS); do
create_iface() {
nmacs="$(RAND_MAC)"
iw dev $IFACE interface add mon$i type monitor; wait
add_mac() { macchanger mon$i -m $nmacs 2>&1 | grep -o '\[ERROR\]'; wait; }
while [ "$(add_mac)" == "[ERROR]" ]; do
iw mon$i del && wait && create_iface
if [ "$(add_mac)" != "[ERROR]" ]; then
break
fi; done; }
create_iface && wait
ifconfig mon$i up && wait
echo -e "${grn}mon$i is up!${rst}"
done
fi
}
MASTER