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+EngineHere is what http://SAP:50000/irj/portal looks like

Use nmap to check for open ports and known services (sap routers, webdnypro, web services, web servers, etc.)
Crawl the URLs if there is a web server running.
Fuzz the directories (you can use Burp Intruder) if it has web servers on certain ports. Here are some good wordlists provided by the SecLists Project for finding default SAP ICM Paths and other interesting directories or files:
https://github.com/danielmiessler/SecLists/blob/master/Discovery/Web_Content/URLs/urls_SAP.txt https://github.com/danielmiessler/SecLists/blob/master/Discovery/Web_Content/CMS/SAP.fuzz.txt https://github.com/danielmiessler/SecLists/blob/master/Discovery/Web_Content/sap.txt
Use the SAP SERVICE DISCOVERY auxiliary Metasploit module for enumerating SAP instances/services/components:
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
Crawl the URLs (see discovery phase).
Fuzz the URLs like in the discovery phase. Here is what http://SAP:50000/index.html looks like:

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 :)

Try
/irj/go/km/navigation/for possible directory listing or authentication bypasshttp://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:

Before running the
startcommand on the bizploit script at the Discovery phase, you can also add the following for performing vulnerability assessment:
Other Useful Tools for Testing
PowerSAP - Powershell tool to assess sap security
Burp Suite - a must have for directory fuzzing and web security assessments
pysap - Python library to craft SAP network protocol packets
https://github.com/gelim/nmap-erpscan - Help nmap to detect SAP/ERP
References
https://github.com/davehardy20/SAP-Stuff - a script to semi-automate Bizploit
Last updated