Pentesting SAP

Introduction about SAP

SAP stands for Systems Applications and Products in Data Processing. SAP, by definition, is also the name of the ERP (Enterprise Resource Planning) software as well as the name of the company. SAP system consists of a number of fully integrated modules, which covers virtually every aspect of business management.

Each SAP instance (or SID) is composed of three layers: database, application and presentation), each landscape usually consists of four instances: dev, test, QA and production. Each of the layers can be exploited to some extent, but most effect can be gained by attacking the database.

Each SAP instance is divided into clients. Each one has a user SAP*, the application’s equivalent of “root”. Upon initial creation, this user SAP* gets a default password: “060719992” (more default password below). You’d be surprised if you knew how often these passwords aren’t changed in test or dev environments!

Try to get access to the shell of any server using username <SID>adm. Bruteforcing can help, whoever there can be Account Lockout mechanism.

Discovery

Next section is mostly from https://github.com/shipcod3/mySapAdventures from user shipcod3!

  • Check the Application Scope or Program Brief for testing. Take note of the hostnames or system instances for connecting to SAP GUI.

  • Use OSINT (open source intelligence), Shodan and Google Dorks to check for files, subdomains, and juicy information if the application is Internet-facing or public:

inurl:50000/irj/portal
inurl:IciEventService/IciEventConf
inurl:/wsnavigator/jsps/test.jsp
inurl:/irj/go/km/docs/
https://www.shodan.io/search?query=sap+portal
https://www.shodan.io/search?query=SAP+Netweaver
https://www.shodan.io/search?query=SAP+J2EE+Engine
alt text

Testing the Thick Client / SAP GUI

Here is the command to connect to SAP GUI sapgui <sap server hostname> <system number>

  • Check for default credentials (In Bugcrowd’s Vulnerability Rating Taxonomy, this is considered as P1 -> Server Security Misconfiguration | Using Default Credentials | Production Server):

  • Run Wireshark then authenticate to the client (SAP GUI) using the credentials you got because some clients transmit credentials without SSL. There are two known plugins for Wireshark that can dissect the main headers used by the SAP DIAG protocol too: SecureAuth Labs SAP dissection plug-in and SAP DIAG plugin by Positive Research Center.

  • Check for privilege escalations like using some SAP Transaction Codes (tcodes) for low-privilege users: SU01 - To create and maintain the users SU01D - To Display Users SU10 - For mass maintenance SU02 - For Manual creation of profiles SM19 - Security audit - configuration SE84 - Information System for SAP R/3 Authorizations

  • Check if you can execute system commands / run scripts in the client.

  • Check if you can do XSS on BAPI Explorer

Testing the web interface

alt text
  • Look for common web vulnerabilities (Refer to OWASP Top 10) because there are XSS, RCE, XXE, etc. vulnerabilities in some places.

  • Check out Jason Haddix’s “The Bug Hunters Methodology” for testing web vulnerabilities.

  • Auth Bypass via verb Tampering? Maybe :)

  • Open http://SAP:50000/webdynpro/resources/sap.com/XXX/JWFTestAddAssignees# then hit the “Choose” Button and then in the opened window press “Search”. You should be able to see a list of SAP users (Vulnerability Reference: ERPSCAN-16-010 )

  • Are the credentials submitted over HTTP? If it is then it is considered as P3 based on Bugcrowd’s Vulnerability Rating Taxonomy: Broken Authentication and Session Management | Weak Login Function Over HTTP. Hint: Check out http://SAP:50000/startPage too or the logon portals :)

alt text
  • Try /irj/go/km/navigation/ for possible directory listing or authentication bypass

  • http://SAP/sap/public/info contains some juicy information:

Attack!

  • Check if it runs on old servers or technologies like Windows 2000.

  • Plan the possible exploits / attacks, there are a lot of Metasploit modules for SAP discovery (auxiliary modules) and exploits:

  • Try to use some known exploits (check out Exploit-DB) or attacks like the old but goodie “SAP ConfigServlet Remote Code Execution” in the SAP Portal:

alt text
  • Before running the start command on the bizploit script at the Discovery phase, you can also add the following for performing vulnerability assessment:

Other Useful Tools for Testing

References

Last updated