1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-07 21:21:31 +00:00

o Improved the mysql library to handle multiple columns with the same name,

added a formatResultset function to format a query response to a table
  suitable for script output. [Patrik Karlsson]
This commit is contained in:
patrik
2012-05-19 12:23:41 +00:00
parent 660cb42825
commit 425ced35ab
7 changed files with 69 additions and 36 deletions

View File

@@ -78,13 +78,10 @@ action = function( host, port )
status, response = mysql.loginRequest( socket, { authversion = "post41", charset = response.charset }, username, password, response.salt )
if status and response.errorcode == 0 then
status, rows = mysql.sqlQuery( socket, "show databases" )
local status, rs = mysql.sqlQuery( socket, "show databases" )
if status then
for i=1, #rows do
-- cheap way of avoiding duplicates
dbs[rows[i]['Database']] = rows[i]['Database']
end
result = mysql.formatResultset(rs, { noheaders = true })
-- if we got here as root, we've got them all
-- if we're here as someone else, we cant be sure
if username == 'root' then
@@ -94,11 +91,5 @@ action = function( host, port )
end
socket:close()
end
for _, v in pairs( dbs ) do
table.insert(result, v)
end
return stdnse.format_output(true, result)
end