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

Fixed a number of incorrect receives and replaced them with receive_bytes.

Added some logic to make sure all data is read off the socket.
This commit is contained in:
patrik
2010-08-24 20:25:46 +00:00
parent 1e80229708
commit d4e0b179c1
2 changed files with 45 additions and 17 deletions

View File

@@ -28,17 +28,23 @@ portrule = shortport.port_or_service(3306, "mysql")
action = function( host, port )
local socket = nmap.new_socket()
local catch = function() socket:close() end
local try = nmap.new_try(catch)
local result, response = {}, nil
local result = {}
local users = {"", "root"}
-- set a reasonable timeout value
socket:set_timeout(5000)
for _, v in ipairs( users ) do
try( socket:connect(host, port) )
response = try( mysql.receiveGreeting( socket ) )
local status, response = socket:connect(host, port)
if( not(status) ) then return " \n ERROR: Failed to connect to mysql server" end
status, response = mysql.receiveGreeting( socket )
if ( not(status) ) then
stdnse.print_debug(3, SCRIPT_NAME)
socket:close()
return response
end
status, response = mysql.loginRequest( socket, { authversion = "post41", charset = response.charset }, v, nil, response.salt )
if response.errorcode == 0 then
table.insert(result, string.format("%s account has empty password", ( v=="" and "anonymous" or v ) ) )