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.

68 lines
1.7 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',
'Description' => %q{
2009-01-12 05:18:05 +00:00
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.
},
'Author' => [ 'tebo <tebo[at]attackresearch.com>' ],
'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'],
],
'Notes' => {
'Stability' => [CRASH_SAFE],
'SideEffects' => [IOC_IN_LOGS],
'Reliability' => []
}
)
)
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
2024-03-05 13:27:00 -06:00
set_mssql_session(session.client)
2024-02-12 15:47:49 -06:00
else
2024-03-27 09:54:38 -05:00
unless mssql_login_datastore
print_error('Error with mssql_login call')
info = mssql_client.initial_connection_info
2024-03-27 09:54:38 -05:00
if info[:errors] && !info[:errors].empty?
info[:errors].each do |err|
print_error(err)
end
end
return
end
end
2024-02-12 15:47:49 -06:00
mssql_query(datastore['SQL'], true)
2009-01-12 05:18:05 +00:00
end
end