Skip to content

Commit 9853dae

Browse files
David MaloneyDavid Maloney
authored andcommitted
Land rapid7#7376, mysql_writable_dir module #2
some comits got missed here somehow
2 parents e13a966 + 2d361fa commit 9853dae

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

modules/auxiliary/scanner/mysql/mysql_writable_dirs.rb

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def initialize
1717
'Description' => %Q{
1818
Enumerate writeable directories using the MySQL SELECT INTO DUMPFILE feature, for more
1919
information see the URL in the references. ***Note: For every writable directory found,
20-
a file called test with the text test will be written to the directory.***
20+
a file with the specified FILE_NAME containing the text test will be written to the directory.***
2121
},
2222
'Author' => [ 'AverageSecurityGuy <stephen[at]averagesecurityguy.info>' ],
2323
'References' => [
@@ -29,7 +29,6 @@ def initialize
2929
register_options([
3030
OptPath.new('DIR_LIST', [ true, "List of directories to test", '' ]),
3131
OptString.new('FILE_NAME', [ true, "Name of file to write", Rex::Text.rand_text_alpha(8) ]),
32-
OptString.new('TABLE_NAME', [ true, "Name of table to use - Warning, if the table already exists its contents will be corrupted", Rex::Text.rand_text_alpha(8) ]),
3332
OptString.new('USERNAME', [ true, 'The username to authenticate as', "root" ])
3433
])
3534

@@ -43,30 +42,28 @@ def mysql_query_no_handle(sql)
4342
end
4443

4544
def run_host(ip)
46-
print_warning("For every writable directory found, a file called test with the text test will be written to the directory.")
47-
vprint_status("Login...")
45+
print_warning("For every writable directory found, a file called #{datastore['FILE_NAME']} with the text test will be written to the directory.")
46+
print_status("Login...")
4847

4948
unless mysql_login_datastore
5049
print_error('Unable to login to the server.')
5150
return
5251
end
5352

54-
File.open(datastore['DIR_LIST'], "r") do |f|
55-
f.each_line do |line|
56-
check_dir(line.chomp)
57-
end
53+
File.read(datastore['DIR_LIST']).each_line do |dir|
54+
check_dir(dir.chomp)
5855
end
5956

6057
end
6158

6259
def check_dir(dir)
6360
begin
64-
vprint_status("Checking #{dir}...")
61+
print_status("Checking #{dir}...")
6562
res = mysql_query_no_handle("SELECT _utf8'test' INTO DUMPFILE '#{dir}/" + datastore['FILE_NAME'] + "'")
6663
rescue ::RbMysql::ServerError => e
67-
vprint_warning("#{e.to_s}")
64+
print_warning(e.to_s)
6865
rescue Rex::ConnectionTimeout => e
69-
vprint_error("Timeout: #{e.message}")
66+
print_error("Timeout: #{e.message}")
7067
else
7168
print_good("#{dir} is writeable")
7269
report_note(

0 commit comments

Comments
 (0)