Files
metasploit-gs/modules/auxiliary/admin/mssql/mssql_sql.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
1.3 KiB
Ruby
Raw Normal View History

2009-01-12 05:18:05 +00:00
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
2009-01-12 05:18:05 +00:00
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Auxiliary
2009-01-12 05:18:05 +00:00
include Msf::Exploit::Remote::MSSQL
include Msf::OptionalSession::MSSQL
2013-08-30 16:28:54 -05:00
2009-01-12 05:18:05 +00:00
def initialize(info = {})
super(update_info(info,
'Name' => 'Microsoft SQL Server Generic Query',
2009-01-12 05:18:05 +00:00
'Description' => %q{
This module will allow for simple SQL statements to be executed against a
2017-08-24 21:38:44 -04:00
MSSQL/MSDE instance given the appropriate credentials.
2009-01-12 05:18:05 +00:00
},
2014-07-11 12:45:23 -05:00
'Author' => [ 'tebo <tebo[at]attackresearch.com>' ],
2009-01-12 05:18:05 +00:00
'License' => MSF_LICENSE,
'References' =>
[
2011-07-24 19:36:37 +00:00
[ 'URL', 'http://www.attackresearch.com' ],
2009-01-12 05:18:05 +00:00
[ 'URL', 'http://msdn.microsoft.com/en-us/library/cc448435(PROT.10).aspx'],
]
))
2013-08-30 16:28:54 -05:00
register_options(
[
OptString.new('SQL', [ false, 'The SQL query to execute', 'select @@version']),
])
2009-01-12 05:18:05 +00:00
end
2013-08-30 16:28:54 -05:00
def auxiliary_commands
{ "select" => "Run a select query (a LIMIT clause is probably a really good idea)" }
end
2013-08-30 16:28:54 -05:00
def cmd_select(*args)
datastore["SQL"] = "select #{args.join(" ")}"
run
end
2013-08-30 16:28:54 -05:00
2009-01-12 05:18:05 +00:00
def run
2024-02-12 15:47:49 -06:00
if session
set_session(session.client)
else
return unless mssql_login_datastore
end
2024-02-12 15:47:49 -06:00
mssql_query(datastore['SQL'], true)
2009-01-12 05:18:05 +00:00
end
end