SAP Attack Methodology
Dmitry Gutsko
Security expert
Positive Technologies
PHDays III
Agenda
SAP: Typical three-tier architecture
SAP: Attack vectors
Where to begin?
― Scan ports
• 32xx
• 33xx
• 36xx
― Gather information about the system
• Find available clients
• Check for default passwords
• Identify a database server
― Tools:
• MaxPatrol (PenTest)
• sapyto
• console bruter by PT
Clients
SAP Application server
Client 000 Client 001 Client 066 Client 800
Clients
SAP Application server
Client 000 Client 001 Client 066 Client 800
Clients
SAP Application server
Client 000 Client 001 Client 066 Client 800
Default passwords
User account Default
password
Statistics
SAP* 06071992
PASS
0%
25%
DDIC 19920706 0%
TMSADM PASSWORD
$1Pawd2&
25%
12,5%
EARLYWATCH SUPPORT 0%
SAPCPIC ADMIN 25%
Default passwords
User account Default
password
Статистика использования
SAP* 06071992
PASS
0%
25%(сбер,Газ
DDIC 19920706 0%
TMSADM PASSWORD
$1Pawd2&
25%(Ом,сбер
12,5%(Газ
EARLYWATCH SUPPORT 0%
SAPCPIC ADMIN 25%(Газ, сбер
Additional information
(RFC_SYSTEM_INFO)
Direct access to Oracle
database
― Remote_OS_Authentication:
• User authentication by OS login
― SAPSR3 user password is stored in table
OPS$<SID>ADM.SAPUSER
― Password could be recovered
Direct access to Oracle
database
― Механизм Remote_OS_Authentication
• Аутентификация по имени пользователя в ОС
― Пароль пользователя SAPSR3 хранится в таблице
OPS$<SID>ADM.SAPUSER
― Пароль возможно расшифровать
Password Hijacking via
a Network
― Protocols: DIAG, RFC, HTTP
― Tools: Wireshark, SAP DIAG
plugin for Wireshark,
Cain&Abel, SapCap
DIAG protocol
RFC protocol
Hacking Passwords
― Algorithms: A, B, D, E, F, G, H, I (CODVN field)
― Tables: USR02, USH02, USRPWDHISTORY
― Tools: John the Ripper
― Profile parameters:
login/password_downwards_compatibility,
login/password_charset
Cryptographic algorithms
BCODE
field
PASSCODE
field
PWDSALTHEDHASH
field
A 8, upper, ASCII, username salt X
B MD5, 8, upper, ASCII, username salt X
D MD5, 8, upper, UTF-8, username
salt
X
E MD5, 8 , upper, UTF-8, username
salt
X
F SHA1, 40, UTF-8, username salt X
G X X
H SHA1,40, UTF-8, random salt X
I X X X
USR02 table
BNAME, BCODE, PASSCODE Fields
John the Ripper
Client Bypass
― Use transaction ST04
― Use transaction SM49/SM69
― Create your own ABAP program
Transaction ST04
Transaction ST04
Transaction ST04
Transaction SM49/SM69
Transaction SM49/SM69
ABAP program
― Source code:
― Report results:
Access to other SAPs
― Decrypt authentication data of RFC connection (0-day)
• RSECTAB, RFCDES tables
Access to other SAPs
Access to other SAPs
Access to other SAPs
Access to other SAPs
No data is shown by SE16
Access to other SAPs
Access to other SAPs
Access to other SAPs
Access to other SAPs
Hiding the Evidence of High Privileges
(profile SAP_ALL)
― Report RSUSR002 (transaction SUIM)
• Use Reference User
• Create a new profile ~ SAP_ALL,
Profile1 + Profile2 + Profile3 ~ SAP_ALL
• Create user ………… (0 day)
• Change ABAP code of report RSUSR002
• Update table UST04
Reference User
Reference User
Reference User
No user TEST1
Create a new profile
Create a new profile
Create a new profile
SAP_0 = SAP_ALL
Create a new profile
No user TEST4
User ………… (0 day)
― ABAP code of RSUSR002 report:
User ………… (0 day)
― ABAP code of RSUSR002 report:
User ………… (0 day)
― ABAP code of RSUSR002 report:
No user …………
Modification of RSUSR002 ABAP code
― Insert a new string:
DELETE userlist WHERE bname = ‘<USERNAME>’
Deletion of Profile Assignment from
UST04 table
Assignig profile SAP_ALL:
Deletion of Profile Assignment from
UST04 table
Assignig profile SAP_ALL:
Deletion of Profile Assignment from
UST04 table
Assignig profile SAP_ALL:
No user TEST0
Deletion of Profile Assignment from
UST04 table
Assignig profile SAP_ALL:
Thank you for your attention!
Dmitry Gutsko
dgutsko@ptsecurity.ru
24may 1600 valday dmitry gutsko 'sap attack methodology'

24may 1600 valday dmitry gutsko 'sap attack methodology'