-
Notifications
You must be signed in to change notification settings - Fork 1
/
smbwrap.sh
304 lines (240 loc) · 6.74 KB
/
smbwrap.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
#!/bin/bash
function print_cmd {
echo -e "${BLUE}[*] Command: $1${NC}" | tee -a $savefile
}
function print_banner {
echo -e "${GREEN}
__ ________ _________ _ _______ ___ ______ __
/ / / ___| \/ || ___ \| | | | ___ \/ _ \ | ___ \ \ \
/ /_____\ \`--.| . . || |_/ /| | | | |_/ / /_\ \| |_/ /____\ \
< <______|\`--. \ |\/| || ___ \| |/\| | /| _ || __/______> >
\ \ /\__/ / | | || |_/ /\ /\ / |\ \| | | || | / /
\_\ \____/\_| |_/\____/ \/ \/\_| \_\_| |_/\_| /_/
${NC}"
echo -e "${GREEN} ((\o/))
.-----//^\\-----.
| /\`| |\`\ |
| | | |
| | | |
| | | |
'------===------'
${WHITE}wrapped with love by unkn0wnsyst3m
${TEAL}https://mfnttps.github.io/
${TEAL}https://github.com/unkn0wnsyst3m/
${NC}"
}
function help_menu {
echo -e "usage:
$0 -t <target> -p <port> [-n [nocolors]]
$0 -t <target> -p <port> [-U] <username> [-P] <password>
${RED}Mandatory: -t <target>${NC}"
print_banner
exit 1
}
if [ $# -eq 0 ]; then
help_menu
fi
username=""
password=""
target=""
port="445"
nocolors=false
unset OPTIND
unset OPTARG
OPTARG=""
while getopts ":U:P:p:t:nh" flag
do
case $flag in
U) username=$OPTARG
;;
P) password=$OPTARG
;;
p) port=$OPTARG
;;
t) target=$OPTARG
;;
n) nocolors=true
;;
h) help_menu
;;
?) help_menu
;;
esac
done
if [[ $target = "" ]]; then
help_menu
fi
if [[ $nocolors = true ]]
then
RED='\033[0m'
GREEN='\033[0m'
NC='\033[0m'
BLUE='\033[0m'
TEAL='\033[0m'
WHITE='\033[0m'
else
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
BLUE='\033[0;34m'
TEAL='\033[0;36m'
WHITE='\033[0;0m'
fi
savefile="$target.wrap"
print_banner
echo -e "${RED}
===================================
| Target Information |
===================================
Target ......... $target
Port ........... $port
Username ....... $username
Password ....... $password
Save File ...... $savefile
${NC}" | tee -a $savefile
sleep 2
##NMAP
echo -e "${RED}
=============================
| nmap |
=============================
${NC}" | tee -a $savefile
cmd="nmap $target -p $port -Pn -sV --script=smb-os-discovery,smb-vuln*"
print_cmd "$cmd"
cmd="$cmd | tee -a $savefile"
eval "$cmd"
##CRACKMAPEXEC
echo -e "${RED}
=============================
| crackmapexec |
=============================
${NC}" | tee -a $savefile
if [[ $username = "" && $password = "" ]]
then
cmd="crackmapexec smb --port $port $target --rid-brute -u '' -p ''"
print_cmd "$cmd"
cmd="$cmd | tee -a $savefile"
eval "$cmd"
cmd="crackmapexec smb --port $port $target --rid-brute -u Guest -p ''"
print_cmd "$cmd"
cmd="$cmd | tee -a $savefile"
eval "$cmd"
cmd="crackmapexec smb --port $port $target --rid-brute -u Anonymous -p ''"
print_cmd "$cmd"
cmd="$cmd | tee -a $savefile"
eval "$cmd"
fi
if [[ ! $username = "" ]] || [[ ! $password = "" ]]
then
cmd="crackmapexec smb --port $port $target --rid-brute -u $username -p '$password' --shares --spider '*'"
print_cmd "$cmd"
cmd="$cmd | tee -a $savefile"
#echo "$cmd"
eval "$cmd"
fi
##ENUM4LINUX.PY
echo -e "${RED}
=============================
| enum4linux-ng.py |
=============================
${NC}" | tee -a $savefile
if [[ $username = "" && $password = "" ]]
then
cmd="enum4linux-ng.py -vAR $target"
print_cmd "$cmd"
cmd="$cmd | tee -a $savefile"
eval "$cmd"
cmd="enum4linux-ng.py -vAR $target -u '' -p ''"
print_cmd "$cmd"
cmd="$cmd | tee -a $savefile"
eval "$cmd"
cmd="enum4linux-ng.py -vAR $target -u Guest -p ''"
print_cmd "$cmd"
cmd="$cmd | tee -a $savefile"
eval "$cmd"
cmd="enum4linux-ng.py -vAR $target -u Anonymous -p ''"
print_cmd "$cmd"
cmd="$cmd | tee -a $savefile"
eval "$cmd"
fi
if [[ ! $username = "" ]] || [[ ! $password = "" ]]
then
cmd="enum4linux-ng.py -vAR $target -u $username -p '$password'"
print_cmd "$cmd"
cmd="$cmd | tee -a $savefile"
#echo $cmd
eval "$cmd"
fi
##SMBMAP
echo -e "${RED}
=============================
| smbmap |
=============================
${NC}" | tee -a $savefile
if [[ $username = "" && $password = "" ]]
then
cmd="smbmap -H $target -u 'Anonymous' -p ''"
print_cmd "$cmd"
cmd="$cmd | tee -a $savefile"
eval "$cmd"
cmd="smbmap -H $target -u 'Guest' -p ''"
print_cmd "$cmd"
eval "$cmd"
cmd="smbmap -H $target -u '' -p ''"
print_cmd "$cmd"
cmd="$cmd | tee -a $savefile"
eval "$cmd"
fi
if [[ ! $username = "" ]] || [[ ! $password = "" ]]
then
cmd="smbmap -H $target -u $username -p '$password'"
print_cmd "$cmd"
cmd="$cmd | tee -a $savefile"
eval "$cmd"
fi
echo -e "${RED}
=============================
| smbclient |
=============================
${NC}" | tee -a $savefile
if [[ $username = "" && $password = "" ]]
then
cmd="smbclient -L $target --port=$port --option='client min protocol=NT1' -N"
print_cmd "$cmd"
eval "$cmd"
cmd="echo '' | smbclient -L $target --port=$port --option='client min protocol=NT1' -U ''"
print_cmd "$cmd"
cmd="$cmd | tee -a $savefile"
eval "$cmd"
cmd="echo '' | smbclient -L $target --port=$port --option='client min protocol=NT1' -U 'Anonymous'"
print_cmd "$cmd"
cmd="$cmd | tee -a $savefile"
eval "$cmd"
cmd="echo '' | smbclient -L $target --port=$port --option='client min protocol=NT1' -U 'Guest'"
print_cmd "$cmd"
cmd="$cmd | tee -a $savefile"
eval "$cmd"
cmd="smbclient -L $target --port=$port --option='client min protocol=LANMAN1' -N"
print_cmd "$cmd"
cmd="$cmd | tee -a $savefile"
eval "$cmd"
cmd="echo '' | smbclient -L $target --port=$port --option='client min protocol=LANMAN1' -U ''"
print_cmd "$cmd"
cmd="$cmd | tee -a $savefile"
eval "$cmd"
cmd="echo '' | smbclient -L $target --port=$port --option='client min protocol=LANMAN1' -U 'Anonymous'"
print_cmd "$cmd"
cmd="$cmd | tee -a $savefile"
eval "$cmd"
cmd="echo '' | smbclient -L $target --port=$port --option='client min protocol=LANMAN1' -U 'Guest'"
print_cmd "$cmd"
cmd="$cmd | tee -a $savefile"
eval "$cmd"
fi
if [[ ! $username = "" || ! $password = "" ]]
then
cmd="echo '$password' | smbclient -L $target --port=$port --option='client min protocol=LANMAN1' -U $username"
print_cmd "$cmd"
cmd="$cmd | tee -a $savefile"
eval "$cmd"
fi