2009-12-26 05:22:34 +00:00
|
|
|
##
|
2013-10-15 18:50:46 +00:00
|
|
|
# This module requires Metasploit: http//metasploit.com/download
|
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2009-12-26 05:22:34 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Exploit::Remote::MYSQL
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'MySQL SQL Generic Query',
|
|
|
|
'Description' => %q{
|
|
|
|
This module allows for simple SQL statements to be executed
|
|
|
|
against a MySQL instance given the appropriate credentials.
|
|
|
|
},
|
|
|
|
'Author' => [ 'Bernardo Damele A. G. <bernardo.damele[at]gmail.com>' ],
|
|
|
|
'License' => MSF_LICENSE
|
|
|
|
))
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('SQL', [ true, 'The SQL to execute.', 'select version()'])
|
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
def auxiliary_commands
|
|
|
|
{ "select" => "Run a select query (a LIMIT clause is probably a really good idea)" }
|
|
|
|
end
|
|
|
|
|
|
|
|
def cmd_select(*args)
|
|
|
|
datastore["SQL"] = "select #{args.join(" ")}"
|
|
|
|
run
|
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
|
|
|
return if not mysql_login_datastore
|
|
|
|
print_status("Sending statement: '#{datastore['SQL']}'...")
|
|
|
|
res = mysql_query(datastore['SQL']) || []
|
|
|
|
res.each do |row|
|
|
|
|
print_status(" | #{row.join(" | ")} |")
|
|
|
|
end
|
|
|
|
end
|
2009-12-26 05:22:34 +00:00
|
|
|
|
|
|
|
end
|