Penetration Testing SAP Systems: A Real-World Case Study I

In this case study, we detail a comprehensive penetration test of a client’s SAP ABAP deployment within our financial industry client. Our objective was to identify security weaknesses that could compromise the integrity and confidentiality of critical financial data and transactions managed by this core system.

SAP is a pivotal platform in the dynamic enterprise software industry, powering critical business processes across sectors with its seamless integration, robust development environment, and optimized performance. These processes include finance, logistics, and human resources. As one of the most widely used Enterprise Resource Planning (ERP) software applications, SAP, short for Systems, Applications, and Products in Data Processing, provides a comprehensive suite of solutions. ABAP, which stands for Advanced Business Application Programming, is the programming language utilized to create applications within the SAP ecosystem. Therefore, the most common components of this information system include finance, planning, costs, commercial, marketing, manufacturing, logistics, maintenance, quality control, and HR functions.

This section will focus on exploitation attacks to see how to approach pentesting towards an ERP (SAP-ABAP),

An SAP system that uses both ABAP and J2EE is known as a “dual stack instance.”

The main objective will be to obtain access to a SAP-ABAP system, which will be achieved through client software called SAP-GUI. In order to log in, specific parameters are required, which are listed below:

  • IP Address
  • System ID
  • Instance Number
  • Client Number
  • Credentials (Username and Password)

The following tools are required to perform pentesting on SAP ABAP systems, available for both Windows and Linux (Kali)

  • Nmap: For network discovery and security auditing.
  • Metasploit: For penetration testing.
  • Sapyto: A specific tool for SAP security testing.
  • SAP-GUI: SAP graphical user interface for connecting to the system.

NOTE: If the Kali distribution is used as the hacker system, all the tools mentioned will be preinstalled by default, except SAP-GUI and Sapyto.

Tools like Nmap, Metasploit, and Sapyto help identify the SAP server and its open ports. Common SAP ports include 32XX, 33XX, 36XX, 39XX, 3299, 50XX, and 81XX. Commands for these tools can help discover server details.

nmap –sV 10.49.96.206 –p 3200-3299,3300-3399,8000-8099,8100-8199,50000-59913,80,443

We can use the Metasploit framework to accomplish the same result using the sap_service_discovery auxiliary. The output of the previous command should resemble

msf auxiliary(sap_service_discovery) › run

Using the Sapyto framework enables us to achieve the same outcome but requires more advanced configuration. To get started, we must configure the Sapyto options and specify a target with its respective IP address and connector, as shown in the following images.

Executing the target and help commands on Sapyto

Running Sapyto’s addTarget and set host command

Execution of the discoverConnectors command associates a target with a Sapyto’s connector, and the back command triggers the connector discovery.
As can be seen in the different images, a large amount of helpful information has been obtained, within which the database used by the ERP has been identified, in this case, a database (MSSQL).

Once the objective has been identified, the next task is to obtain the SAP server’s System ID, which can be done with Metasploit or Sapyto.

Using the Metasploit framework, the System ID can be obtained with the following auxiliary sap_mgmt_con_version

To obtain the System ID with Sapyto, we must select the sapinfo plugin located at plugins/audit, as shown in the images below.

Once Sapyto is configured, the next step is to execute it with the start command.

Up to this point, we have obtained the IP address and the System ID, so the instance number is still needed. Most of the time, the instance number is the last two numbers of the RFC Destination, in this case, “00“

If, for some reason, the instance number was not obtained with the sapyto plugin called sapinfo, it could be checked by hand; the following instances are the most common:

  • 00
  • 01
  • 02
  • 03
  • 04
  • 05
  • 06

Using the Sapyto framework, it can be obtained with getClients plugin, which is located in the following path /plugin/Discover/getClients/

Once you have all the required parameters, configure SAP-GUI to create a new system entry. Use the gathered information to establish a connection to the SAP system.

Once you have done the above, a new window will open. Click on continue. A window will open again, and you will have to provide all the parameters previously obtained with the Metasploit and Sapyto tools and click on the continue button.

Credentials can be obtained through brute force attacks using tools like Sapyto and Metasploit or by using default credentials often overlooked by administrators. Common default credentials include user SAP* with password PASS.

User ID DescriptionClientPassword
SAP*superuser000,001, 06606071992
New ClientsPASS
DDICABAP SuperUser000,00119920706
EARLYWATCHUser for earlywatch service066SUPPORT
SAPCPICCommunication user000, 001ADMIN
TMSADMTransportation system administrator user000PASSWORD / $1Pawd2&

For this particular case, the following information will be used to enter the SAP system:

  • Client 610
  • SAP User*
  • Password PASS

Upon entering the correct credentials, we will gain access to the SAP system, allowing us to perform various post-exploration attacks. Once the information has been entered and if it is correct, the following window will appear.

If all the information is correct, access to the SAP system should be obtained. Once inside the system, various activities could be carried out, remembering that it is a Business Resource Management system. Therefore, the most common components of this Information System include finance, planning, costs, commercial, marketing, manufacturing, logistics, maintenance, quality control, and HR functions. Technologically speaking, the following could be done:

  • Obtain System Information
  • Listing SAP’s Users
  • Creating New Users With Administrative Roles (SAP_ALL)
  • Extracting User’s Hashes
  • Executing OS-level Commands
  • Get RFC Connections

This is achieved by clicking on the following path: Menu > Systems > Status.

As shown below, transaction nsu01 will be used to retrieve the users’ names.

The same transaction (/nsu01) will be used to create a user in the SAP system, as shown below.

Here we will use transaction nse16 and the database table /usr02 to obtain the user hashes, as shown in the images below.

As a recommendation, set the Output List Width parameter to 500 as well as the Maximum Number of Hits. Once finished, click on the clock-shaped icon shown in the image below.

A new window will open, showing the hashes of each user in the SAP systems that handle two types of hashes.

  • BCODE
  • PASSCODE

John the Ripper (or Hashcat) is used to crack hashes.

To execute commands at the Operating System level, the /nse38 ​​transaction will be used along with the report number RSBDCOSO. Then, click on the clock-shaped icon.

Once the above is done, a new window will open in which you can enter your preferred command.

NOTE: The level of privileges will depend on the user with whom the SAP system has been installed

Creating a new user and adding it to the Administrator Group.

Transaction /nsm59 is used to find the system’s RFC (Remote Function Call)connections with other SAP systems. This can be particularly useful if the SAP system has ABAP connections with other SAP systems. Double-clicking on one of these connections might give you automatic access to the other system.

SAP ABAP remains a relevant and critical platform for pentesting in 2024 due to its widespread use in enterprise environments for critical business operations. As SAP systems often handle sensitive data and core business processes, ensuring their security is paramount. At RBT Security, our main focus is to help companies identify vulnerabilities, enhance security measures, and protect against potential cyber threats. This case study was written to help identify and exploit common vulnerabilities in SAP systems.

Share the Post:

Table of Contents

Subscribe To Our Blog

Light