--- mysql-dump-hashes.nse 2015-11-05 15:41:05.000000000 -0500 +++ mysql-dump-hashes-fixed.nse 2018-08-19 14:47:49.877692000 -0400 @@ -84,12 +84,24 @@ local status, response = mysqlLogin(socket, username, password) if ( status ) then - local query = "SELECT DISTINCT CONCAT(user, ':', password) FROM mysql.user WHERE password <> ''" + local query = "SELECT DISTINCT CONCAT(user, ':', password) ".. + "FROM mysql.user WHERE password <> ''" local status, rows = mysql.sqlQuery( socket, query ) - socket:close() if ( status ) then result = mysql.formatResultset(rows, { noheaders = true }) + socket:close() break + else + -- From MySQL version 5.7 on the authentication_string column is used + local query = "SELECT DISTINCT CONCAT(user, ':', authentication_string) ".. + "FROM mysql.user ".. + "WHERE authentication_string <> '*THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE'" + local status, rows = mysql.sqlQuery( socket, query ) + socket:close() + if ( status ) then + result = mysql.formatResultset(rows, { noheaders = true }) + break + end end else socket:close()