Overview

MindMap

Ports Scanning

Common non-secure

Service NameDescriptionPort Number
ddmDDM server is used to access data via DRDA and for record level access.446
As-svrmapPort mapper returns the port number for the requested server.449
As-admin-httpHTTP server administration2001
As-mtgctrljManagement Central server is used to manage multiple AS/400s in a network.5544
As-mtgctrlManagement Central server is used to manage multiple AS/400s in a network5555
As-centralCentral server is used when a Client Access license is required and for downloading translation tables.8470
As-databaseDatabase server is used for accessing the AS/400 database.8471
As-dtaqData Queue server allows access to the AS/400 data queues, used for passing data between applications.8472
As-fileFile Server is used for accessing any part of the AS/400 file system8473
as-netprtPrinter Server is used to access printers known to the AS/400.8474
as-rmtcmdRemote command server is used to send commands from a PC to an AS/400 and for program calls8475
as-signonSign-on server is used for every Client Access connection to authenticate users and to change passwords.8476
as-usfUltimedia facilities are used for multimedia data.8480

Common secure (SSL)

Service nameDescriptionPort Number
ddm-sslDDM server is used to access data via DRDA and for record level access.447, 448
telnet-sslTelnet server.992
as-admin-httpsHTTP server administration.2010
as-mgtctrl-ssManagement Central server is used to manage multiple AS/400s in a network.5566
as-mgtctrl-csManagement Central server is used to manage multiple AS/400s in a network.5577
as-central-sCentral server is used when a Client Access license is required and for downloading translation tables.9470
as-database-sDatabase server is used for accessing the AS/400 database.9471
as-dtaq-sData Queue server allows access to the AS/400 data queues, used for passing data between applications.9472
as-file-sFile Server is used for accessing any part of the AS/400 file system.9473
as-netptr-sPrinter Server is used to access printers known to the AS/400.9474
as-rmtcmd-sRemote command server is used to send commands from a PC to an AS/400 and for program calls.9475
As-signon-sSign-on server is used for every Client Access connection to authenticate users and to change passwords.9476

Scanning

nc -v -z -w 1 as400.victim.com 1-100 | grep "open"

Configuration

Retrieve all configuration

# General infos
WRKSYSVAL SYSVAL(*ALL) OUTPUT(*PRINT)
 
# Security infos
WRKSYSVAL SYSVAL(*SEC) OUTPUT(*PRINT)
 
# Retrieve *PUBLIC Rights
PRTPUBAUT OBJTYPE(*USRPRF)
 
# Retrieve all rights on accounts
PRTPVTAUT OBJTYPE(*USRPRF)
 
# Audit one account
DSPUSRPRF USRPRF(LOGIN) OUTPUT(*OUTFILE) OUTFILE(COGICEO/TEST)
# Take the file : right click > export > file
 
# Trivial passwords ?
ANZDFTPWD
 
# Last passwords change 
PRTUSRPRF TYPE(*PWDINFO) SELECT(*SPCAUT) SPCAUT(*ALL)
 
# High privileges accounts - sort by privileges
PRTUSRPRF TYPE(*AUTINFO) SELECT(*SPCAUT) SPCAUT(*SECADM)
PRTUSRPRF TYPE(*AUTINFO) SELECT(*SPCAUT) SPCAUT(*ALLOBJ)
PRTUSRPRF TYPE(*AUTINFO) SELECT(*SPCAUT) SPCAUT(*JOBCTL)
 
# High privileges accounts - sort by classes
PRTUSRPRF TYPE(*AUTINFO) SELECT(*USRCLS) USRCLS(*SYSOPR)
PRTUSRPRF TYPE(*AUTINFO) SELECT(*USRCLS) USRCLS(*PGMR)
PRTUSRPRF TYPE(*AUTINFO) SELECT(*USRCLS) USRCLS(*SECADM)
PRTUSRPRF TYPE(*AUTINFO) SELECT(*USRCLS) USRCLS(*SECOFR)
 

Users Passwords

rexec -d -l LOGIN -p PASSWORD -b IP "ANZDFTPWD ACTION(*NONE)"

Retrieve libraries

rexec -l LOGIN -p PASSWORD -b IP "QSH CMD('ls /qsys.lib/')" | strings | grep -E '*.LIB$' | awk -F"." '{print $1}' > lib
 

How to get & crack AS/400 hashes?

Access to an AS/400 server with *ALLOBJ and *SECADM privileges

Depending on the current setting of the QPWDLVL system value, password hashes are stored in different formats on the AS/400:

  • QPWDLVL 0: IBM DES hashes (supported by JtR with our ‘as400-des’ format plugin) LM hashes (supported by default by JtR) SHA1 uppercase hashes (supported by JtR with our ‘as400-ssha1’ format plugin)
  • QPWDLVL 1: IBM DES hashes (supported by JtR with our ‘as400-des’ plugin) SHA1 uppercase hashes (supported by JtR with our ‘as400-ssha1’ plugin)
  • QPWDLVL 2: IBM DES hashes* (supported by JtR with our ‘as400-des’ plugin) LM hashes** (supported by default by JtR) SHA1 uppercase hashes*** (supported by JtR with our ‘as400-ssha1’ plugin) SHA1 mixed case hashes (supported by JtR with our ‘as400-ssha1’ plugin)
  • QPWDLVL 3: SHA1 uppercase hashes*** (supported by JtR with our ‘as400-ssha1’ plugin) SHA1 mixed case hashes (supported by JtR with our ‘as400-ssha1’ plugin)
  • Only if QPWDMAXLEN 10
    • Only if QPWDMAXLEN 14
    • Depending on password policy configuration

PREREQUISITES

LM hashes

  • Open IBMiScanner tool
  • Connect
  • From the list of available scans, select option 26: ‘SECURITY: Get John the Ripper hashes (LM hash)
  • In the output directory, a file named ‘lmhashes.txt’ will be created.
  • Copy the file to your John the Ripper ‘run’ directory
  • Run john the ripper: john —format=LM {filename}
  • Enjoy the passwords :)

DES hashes

  • Open IBMiScanner tool
  • Connect
  • From the list of available scans, select option 29: ‘SECURITY: Get John the Ripper hashes (DES)’
  • In the output directory, a file named ‘DES-hashes.txt’ will be created.
  • Copy the file to your John the Ripper ‘run’ directory
  • Run john the ripper: john —format=as400-des {filename}
  • Enjoy the passwords :)

SHA-1 hashes

(Please note that this method is generic for both mixed and upper case)

  • Open IBMiScanner tool
  • Connect
  • From the list of available scans, select option 27: ‘SECURITY: Get John the Ripper hashes (SHA-1 hash uppercase)’ for uppercase hashes.
  • For mixed case hashes, you can choose for option 28: ‘SECURITY: Get John the Ripper hashes SHA-1 hash mixed case)’ respectively.
  • In the output directory, a file named ‘SHA-uc-hashes.txt’ for uppercase hashes or ‘SHA-mc-hashes.txt’ for mixed case hashes will be created.
  • Copy the file to your John the Ripper ‘run’ directory
  • Run john the ripper: john —format=as400-ssha1 {filename}
  • Enjoy the passwords :)

Note: In case you used an older version of the IBMiscanner tool that outputs hashes in the format userid:hash, you can use the ibmiscanner2john.py script to convert the file into a format that can be processed by JtR

Pentest

Tools

git clone https://github.com/hackthelegacy/hack400tool
  • IBM System i Access V6R1_64
  • IBM System i Access V5R1 32b
  • Reflexion Client TN5250

Privilege Escalation