SAP Post-Exploitation - One script to 0wn 'em All

The topic here is this: Post-exploitation for SAP systens - not at application level, but at OS level..

Imagine a red-teamer gained acess to aadm user ID. Having SSH or RDP access. Whats next?
Well, theres a lot he/sehe can do. adm has the rights to go query DB directly. adm can access userkeystore. adm typically has the rights to read PSE files and keytabs. adm typically can access /sapmnt/trans of other SID within the landscape. adm can aslo access profiles, DEFAULT.PFL, etc, and insert a command line backdoor that will restart each time the application starts.

Watch this space. Am developing that script. :)

SECTION 1: The Possible Probe Points

- Get the SID via /etc/passwd or net users or service query or current user
- Identify possible PSE file location
- identfiy any possible cert dumps to get p12 format
- identify DB and kernel version
- identify connectivity and userstore - R3trans or sqlplus or hdbsql or sqlcmd etc..
- generic scan for interesting files
- OSS ids, etc..
- grab instacn eprofiels - DEFAULT J*/D* and*SCS
- identify agent for backup solution - possible Adminsitartor or root privilege at backup solution side..
- use hdblcm.. see the below footnotes

SECTION 2: Methods & Examples

Coming soon.

SECTION 3: The script

Coming soon.

SECTION 4: Backdooring Methods

1. Adding a persistent command via profilr
2. Manual create a new instamce, sapstart and sapstar generate default pass to add program cross client
3. Direct database SAP_ALL assignment

======= IGNORE BEYOND THIS LINE ========

[root@ayam /]# /hana/shared/HDB/hdblcm/hdblcm -help
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LC_CTYPE = "UTF-8",
        LANG = "en_GB.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_GB.UTF-8").
SAP HANA Lifecycle Management (hdblcm)
Copyright © 2000-2017 by SAP SE

Help:  hdblcm --help [--action=add_hosts|register_rename_system [--pass_through_help]
                      | --uninstall [--pass_through_help]]
              | --list_systems | --version

Usage: hdblcm [--action[=add_hosts|register_rename_system]] [--batch] [--configfile=]
              [--dump_configfile_template=] [--uninstall]

  --action[=add_hosts|register_rename_system]  Specifies the action to be performed [interactive, default value: 'exit']
  --batch                        -b            Runs the program in batch mode using default values for unspecified parameters
  --configfile=                      Reads parameters from the specified configuration file (parameters in command line
                                               take precedence)
  --dump_configfile_template=        Creates a configuration file with default values
  --help                         -h            Displays the help information
                                               For extended help, use with the parameter '--action' or '--uninstall'
  --list_systems                 -L            Shows installed SAP HANA systems
  --pass_through_help                          Adds special parameters of subprograms to the help information
  --uninstall                                  Uninstall system or components
  --version                      -v            Displays the version of hdblcm

The environment variable 'HDB_INSTALLER_TRACE_FILE=' enables the trace.
The environment variable 'HDBLCM_LOGDIR_COPY=' creates a copy of the log directory.
[root@ayam /]#

SAP HANA Database Installations:


J2E /sapmnt/J2E OTHERS

S4H /sapmnt/S4H OTHERS



WD1 /sapmnt/WD1 OTHERS

Already used instance numbers: 00 00 00 01 01 01 02 03 04 98
Next free instance number: 05

Also sample:

Waiting for stopped instance using: /usr/sap/HDB/SYS/exe/hdb/sapcontrol -prot NI_HTTP -nr 02 -function WaitforStopped 600 2

Starting instance using: /usr/sap/HDB/SYS/exe/hdb/sapcontrol -prot NI_HTTP -nr 02 -function StartWait 2700 2



Popular posts from this blog

Python: thread.error: can't start new thread

Windows 2003 W2k3 Getting Current MTU Size

SAP Fiori Launchpad Activation via Task List (STC01)