All creds to @samanL33T for starting the list here.
List of Mainframe Hacking/Pentesting Resources. This list is a collection of resources available online to learn Mainframe Penetration Testing & Security.
Special thanks to @samanL33T, @hacksomeheavymetal, @mainframed767, @bigendiansmalls, @ayoul3__ and many other researchers for all their work in this field.
Contributions are welcome !
- IBM zSeries
- Books
- Tutorials
- Concepts and Terms
- Typical TCP Ports
- Web based Thin Clients Terminal Emulators
- Emulate zOS
- zOS booting, logging and working environments
- Top Ten Security Vulnerabilities in z/OS Security
- Scripts & Tools
- Default Accounts and Transactions
- Pentesting
- Presentations & Talks
- ACF2 Specific references
- Security Technical Implementation Guides (STIGs)
- Miscellaneous
- IBM iSeries
↑ IBM zSeries
↑ Books
- Amazon - Mainframe Basics for Security Professionals_ Getting Started with RACF - Ori Pomerantz, Barbara Vander Weele, Mark E. Nelson, Tim Hahn (2008, IBM Press)
- Amazon - IBM Redbooks - Introduction to the New Mainframe: z/OS Basics
- PDF - PoCorGTFO#12 - Page 32 - A JCL Adventure with Network Job Entry
↑ Tutorials
- bigiron - Wiki/Collection of materials related to IBM z/OS security
- TSO Tutorial
- Z/OS Introduction- An IBM Redbooks video course
- Multiple Mainframe Security guides from Chicago Classic Computing
- Using UNIX System Services to escalate your privileges on z/OS
- The crash course to z/OS pentesting by @hacksomeheavymetal
↑ Acronyms and Concepts
The complete list of z/OS acronyms
- Username limited to 7 char length
- Legacy password policy but YMMV
- 8 char length restrictions
- No special chars
- Master Console
- A "system" level console
- If you get access then its game over
- Everything on a Mainframe is a JOB managed by JES2 (Job Entry Sub-system)
- Jobs are submitted to JES
- JES will queue the job and work on jobs in the order and priority they are assigned
- JES then takes the output and places it where it belongs
- Network JOB Entry (NJE) - Can be used to send a JOB or multiple JOBs to a remote Mainframe for processing
- Runs over TCP/IP
- "Speaks" NJE Protocol
- Port 175/TCP or 2252/TCP (TLS)
- NODE - Name of a remote Mainframe system running NJE
- RHOST - Remote calling system name
- OHOST - Current system name
- External Security Managers (ESMs) - ACL, RBAC, etc
- TOP-SECRET
- ACF-2
- RACF
- The "racf.db" file stores all password hashes, provides access control and more
- There are three main security attributes on RACF:
- Special : can alter RACF rules and access any resource
- Operations : access all files unless being forbidden from doing so
- Auditor : access audit trails and manage logging classes
- CLIST - The equivalent of scripting language like Python
- REXX files
- The equivalent of scripting language like Python/Ruby
- REXX Sockets have ASCII translation built in
- JCL files
- The equivalent of shell scripts (sort of)
- You can submit JOBs in JCL over FTP
- Has a "JOB card" or header and a "PMG" or program to exec
- TSO - z/OS cli (Linux bash equivalent)
- Login has a user enumeration flaw via on-screen error messages
- "Traditional" process accounting
- CLIST/REXX/JCL scripting
- OMVS / USS – Unix
- ISPF - Menu Screens (GUI)
- LPAR or Logical partition - Allocation of cpu, disk and mem resources (z/OS VMs equivalent) - Each LPAR can run different stuff e.g. IBM z/OS (mainframe) or with z/VM Linux (RedHat)
- SYSPLEX - Multiple LPARS (across hardware too)
- CICS / IMS
- Transaction Managers
- CICS is a middleware of sorts
- If we manage to "exit" the application running on CICS, we can instruct CICS to execute default admin programs (CECI, CEMT, etc.) => rarely secured
- Applications - Run COBOL, Fortran or Java
- TN3270/E - 3270 terminal emulation over Telnet
- Telnet-like protocol introduced in 1971
- Allowed "green screen" terminals to go over network TCP/IP rather than hardwire
- Transmits "screens" made up of fields
- Response submits modified screen & fields
- Synchronous & Stateful
- All apps presented in same way – i.e. TSO, CICS, IMS, REXX etc. all use it
- Emulator client can be modified to reveal HIDDEN/non-display fields and edit PROTECTED fields
- SNA - Systems Network Architecture
- VTAM
- Virtual Telecommunications Access Method Subsystem that implements SNA
- Multiplexer of sorts
- Often the first thing you connect to on a mainframe
- Lets you connect to different application – Can connect you to other LPARs & sysplex’s
- Uses APPLIDs or "macros"
- LU / PU - Logical/Physical Unit – Connections to VTAM (wired vs multiplexed) – TN3270 to mainframe usually gives you a LU
- DATASETS - The "file" z/OS concept
- PDS or PARTITIONED DATASETS - The "folder" z/OS concept
- OMVS
- TSO command that gives you a /bin/sh shell
- Its a Unix subsystem for network, FTP, webservices support
- You can "su" to root (and run other Unix commands) without a password, if the account is in 'BPX.SUPERUSER'
- ISPF - Interactive System Productivity Facility
- TSO command that gives you the Menu screens (GUI)
- What everyone uses to interact with TSO
- Includes file browser & editor
- APF - Programs that are setuid 0
- TPX - Similar to the gnu-screen
- App Creds
- User enumeration flaws are common
- Sometimes weaker password policies
- Other stuff
- Databases: DB2 & IMS
- Unix: FTP, HTTP, WebSphere
- MQ
- Etc
↑ Typical TCP Ports
- TN3270
- 23 - default, often VTAM
- 992 - default, SSL enabled
- 1023-x0xx - application environments (direct to CICS/IMS regions)
- 2323, x023, x992 - other ports to check
- FTP
- Provides access to both worlds (TSO & OMVS)
- Respects wildcards (.RACF.*)
- Awesome brute forcing point
- Other
- DB2 (5023) & MQ (1415)
- HP/BMC/Tivoli monitoring
- WebSphere
- Note: One host can have lots of IPs (Order of 10-20)
↑ Web based Thin Clients Terminal Emulators
↑ Emulate zOS
↑ zOS booting, logging and working environments
Logging in:
-
On the login screen enter credentials, e.g.:
login: ibmuser
pass: sys1 or <empty>
proc: ISPFPROC|OMVSPROC|IKJACCNT
-
On the welcome screen enter userid and see 2.1., e.g.:
logon ibmuser
-
In some cases you may need to confirm that you are in VTAM or CICS - run this:
ibmtest
-
VTAM returns the following alphanumeric sequence:
IBMECHO ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
Working environments: Depending on the chosen procedure you will end up in on of the working environments.
- ISPF: Courses-like environment with various panels. Allows to perform various tasks on its own, execute commands in TSO, run installed utilities in the z/OS etc.
- OMVS: Also known as Unix System Services is a POSIX compliant unix that runs within the z/OS itself. Similar to other unices. Execute "omvs" in TSO (may not work if you don't have a pseudo terminal allocated, e.g. via SSH. In such case remove and create symlink in / to dev).
- TSO: Time Sharing Option is like a login session on linux. Very basic. You can run various commands and applications including "omvs" and "ispf". By typing "ishell" you can run ISPF shell that allows you to run commands in the OMVS.
Basic navigation: In the ISPF-like programs:
- PF10/PF11 shifts screen view right/left to see all displayed info
- PF7/PF8 scrolls screen view up/down to see all displayed info
- PA1 attention key on the virtual keyboard that terminates the execution of the current command in TSO (e.g. when in the '***' prompt).
- use "File -> Save screen contents" in x3270 (or similar) to save output from the terminal to a local file
- you can abbreviate some of the commands, e.g. setropts -> setr, listcat -> listc etc.
↑ Top Ten Security Vulnerabilities in zOS Security
- Excessive Number of User ID’s w/No Password Interval
- Inappropriate Usage of z/OS UNIX Superuser Privilege, UID = 0
- Data Set Profiles with UACC Greater than READ
- RACF Database is not Adequately Protected
- Excessive Access to APF Libraries
- General Resource Profiles in WARN Mode
- Production Batch Jobs have Excessive Resource Access
- Data Set Profiles with UACC of READ
- Improper Use or Lack of UNIXPRIV Profiles
- Started Task IDs are not Defined as PROTECTED IDs
↑ Scripts and Tools
- TN3270 Clients - X3270
- Multipurpose Nmap Scripts
- tn3270-screen.nse
- tso-enum.nse
- tso-brute.nse
- vtam-enum.nse
- lu-enum.nse
- cics-enum.nse - needs valid account and applid
- cics-info.nse - needs valid account and applid
- cics-user-brute.nse - needs valid applid
- cics-user-enum.nse - needs valid applid
- nje-node-brute.nse
- nje-pass-brute.nse
- Network Job Entry (NJE) python library and example scripts
- iNJEctor.py: A script to send messages and commands to a target node using NJE
- jcl.py: Example python script to send JCL to a target system via NJE as another user
- TSO-Brute
- TPX Brute - The z/OS TPX logon panel brute forcer
- RACF Database Parser
- OMVSenum.sh
- lu_brute.py
- Mainframe Application pentesting (CICS etc.)
- CICSPwn - If your account has access to the CICS trans. "CECI" you can upload JCL and get a shell
- BIRP
- CICSshot - Take screenshots of CICS
- Hacked wc3270 emulator
- zOS Enumeration Scripts
- FTP - JCL commmand execution - Metasploit Modules by @bigendiansmalls
- Metasploit Payloads for z/OS
- NC110-OMVS Netcat for z/OS OMVS
- TShOcker - Mini command interpreter for TSO & UNIX accessible by NetCat
- MainTP
- zOS Privilege Escalation scripts by ayoul3__
- Note on TESTAUTH command for running a program in elevated state
- zOSFTPlib - python ftplib-like library specifically for Z/OS
↑ Default Accounts and Transactions
↑ Pentesting
This is a small pentest guide based on my limited experience testing Mainframes and also several Talks and Presentations available on the Internet, namely tasks and tools to run for each steps listed bellow and some advice.
Mainframes are just computers... costing ungodly prices with also ungodly high specs and availability capacity. That said, unless theres something very wrong, it will hold high loads.
As with every typical security assessment, there is always lots of reservations by the teams or person managing the systems. This is especially true with these systems, since they are very expensive, handling probably the most mission critical operations in the company. Remember to tell them that you are there to help them secure their systems and not to make their lives harder. Respect them and win them over, because they probably are the same age as your father or mother (or even older) ;)
Before starting, ask the Team or Person that manages the Mainframe, if there is a TEST or QA LPAR(s) or Sysplex(s) that mirror PROD. Its preferable to test those.
Initial Recon and Gaining Access
First off... without valid credentials not much can be done, so it is important to find valid creds and enumeration is very important in obtaining them.
Start with a full TCP port Portscan and enable Service discovery e.g.:
nmap -sTV --allports --version-all --version-intensity 9 -p- -v --open -Pn -n mainframe.com -oA mainframe.com
The mainframe can be running webservers (e.g. web based 3270 clients), so try all the usual web attacks and reverse engineer (java applets) shenanigans.
Next take a screenshot of all TN3270 enabled ports. That way you can get an ideia of what the Mainframe is exposing without having to manually use a TN3270 enabled terminal like X3270. You can for example rapidly spot where TSO is running.
nmap -sV --version-all --version-intensity 9 -v --open -Pn -n -p- --script tn3270-screen mainframe.com
Now try to enumerate VTAM to check if TSO is enabled. Again this is a completely unauthenticated scan. Do a scan per port and use diferent output folders, so you don't overwrite the output files.
Also notice the Nmap script argument vtam-enum.command
and vtam-enum.macros
. Sometimes you won't be dropped right in a TSO login screen after connecting to a TN3270 port. You will need to issue a command first to access VTAM. In the examples bellow I've included some typical examples, but YMMV depending on what you are testing (you might not even be in VTAM or they running CICS) - If you can't figure out the command, you can try to ask someone from the mainframe team (I warned you to win them over ;) ).
You can run this with or without a idlist=yourlist.txt
nmap -sV --version-all --version-intensity 9 -v --open -Pn -n -p 23 --script vtam-enum --script-args brute.threads=5,idlist=yourlist.txt,vtam-enum.path="\VTAM-OUT-23\" mainframe.com
nmap -sV --version-all --version-intensity 9 -v --open -Pn -n -p 23 --script vtam-enum --script-args brute.threads=5,idlist=yourlist.txt,vtam-enum.command="tso",vtam-enum.macros=true,vtam-enum.path="\VTAM-OUT-23\" mainframe.com
nmap -sV --version-all --version-intensity 9 -v --open -Pn -n -p 23 --script vtam-enum --script-args brute.threads=5,idlist=yourlist.txt,vtam-enum.command="logon tso",vtam-enum.macros=true,vtam-enum.path="\VTAM-OUT-23\" mainframe.com
nmap -sV --version-all --version-intensity 9 -v --open -Pn -n -p 23 --script vtam-enum --script-args brute.threads=5,idlist=yourlist.txt,vtam-enum.command="exit;logon applid(cicsfake)",vtam-enum.macros=true,vtam-enum.path="\VTAM-OUT-23\" mainframe.com
nmap -sV --version-all --version-intensity 9 -v --open -Pn -n -p 23 --script vtam-enum --script-args brute.threads=5,idlist=yourlist.txt,vtam-enum.command="ibmtest;logon applid(cicsfake)",vtam-enum.macros=true,vtam-enum.path="\VTAM-OUT-23\" mainframe.com
When you finish, check the output files.
Next step let's enumerate some TSO Users.
This is a very common issue in TSO because it explicity indicates on error messages, if the user exists or not. IBM has issued a fix for this (turn PASSWORDPREPROMPT ON)
nmap -sV --version-all --version-intensity 9 -v --open -Pn -n -p- --script tso-enum --script-args brute.threads=5,userdb=default_tso_accounts.txt,tso-enum.commands="logon applid(tso)" mainframe.com
nmap -sV --version-all --version-intensity 9 -v --open -Pn -n -p 23,992,1023,7023 --script tso-enum --script-args brute.threads=5,userdb=default_tso_accounts.txt mainframe.com
Remember that TN3270 web clients can also be used for this, especially if they mimic the same default behavior of TSO. That said you can use Burp Suite to also perform this.
If you can see the error messages being shown and/or found a valid user, well then you have probably your first reportable finding "Username Enumeration" :)
CICS Transaction Enumeration
Use the Default CICS Transactions for the Nmap script argument idlist
scan parameter.
Brute Force TSO Users Creds
Use the Default Accounts for the Nmap script argument userdb
and passdb
scan parameter.
Get creds:
- Test Default accounts
- Reuse - If you have creds from, for example, Windows try them - they could be synced with with Active Directory
- Steal - Phishing, Social Engineer, Check Config Files, Keepass, Confluence, Sharepoint, SMB Shares, Wikis, etc - search for terms associated with Mainframes (TSO, LPAR, CICS, etc)
- Sniff - MITM TN3270 on port TCP/23 is plain text... yes in 2021.
- Brute-Force - Be careful doing this because you can lock accounts, depending on the implemented password policy.
So you got some valid creds, but remember when trying to login, that some users might only have access to TSO or Unix, but not both.
Local Recon
[todo]
Privilege Escalation
[todo]
↑ Presentations and Talks
- Playlist - All the videos of Security Talks by Soldier of FORTRAN (@mainframed767)
- Playlist - All the videos of Tools by Soldier of FORTRAN (@mainframed767)
- Playlist - All the videos of Mainframe Hacking by Soldier of FORTRAN (@mainframed767)
2011
- Prezo - How to Break Into z/OS Systems Through USS, TCP/IP, and the Internet
- Video - DEFCON 14: IBM Networking Attacks-Or The Easiest Way To Own A Mainframe by Martyn Ruks
2012
2013
- Prezo - How to Break into z/OS Systems - Staurt Henderson
- Prezo - BSidesLV 2013 - Legacy 0-Day How hackers breached the Logica Mainframe - Soldier of FORTRAN (@mainframed767)
- Prezo - Mainframes: What the F$#K is That About? - Soldier of FORTRAN (@mainframed767)
- Prezo - BSidesAustin Mainframes: Everybody has one but nobody knows how to hack them - Soldier of FORTRAN (@mainframed767)
2014
- Video - Hacking Mainframes; Vulnerabilities in applications exposed over TN3270 by Dominic White (Sensepost)
- Prezo - Hacking Mainframes; Vulnerabilities in applications exposed over TN3270 by Dominic White (Sensepost)
2015
- Prezo - Top 10 Security Vulnerabilities in z/OS by John Hillman (Vanguard)
- Video - Defcon 22 From ROOT to SPECIAL - Soldier of FORTRAN (@mainframed767)
- Prezo - Defcon 22 From ROOT to SPECIAL - Soldier of FORTRAN (@mainframed767)
- Video - Learning Mainframe Hacking: Where the hell did all my free time go? by @bigendiansmalls
- Video - DEF CON 23 - Young and Rikansrud - Security Necromancy : Further Adventures in Mainframe Hacking (@mainframed767) & @bigendiansmalls
2016
- Video - Gaps in your Defense: Hacking the Mainframe by Soldier of FORTRAN (@mainframed767)
- Prezo - Gaps in your Defense: Hacking the Mainframe by Soldier of FORTRAN (@mainframed767)
- Prezo - The current state of Mainframe Hacking by Phil Young - Soldier of FORTRAN (@mainframed767)
- Prezo - Advanced Mainframe Hacking by Phil Young - Soldier of FORTRAN (@mainframed767)
2017
- Video - #HITB2017AMS D1T1 - Hacking Customer Information Control System (CICS) by Ayoub Elaassal (@ayoul3__)
- Video - Ransomware on the Mainframe: Checkmate by @bigendiansmalls
2018
- Prezo - Post exploit goodness on a Mainframe SPECIAL is the new root by (@ayoul3__)
- Video - Exploiting the Mainframe - Z/OS integrity 101 by Mark Wilson & Ray Overby
- Video - BSides Glasgow 2018 - Nigel Pentland - Cracking Mainframe Passwords
- Video - Mainframe [z/OS] Reverse Engineering & Exploit Development by @bigendiansmalls
2019
- Video - NorthSec 2019 – Philip Young – Mainframe Hacking in 2019
- Video - CackalackyCon1 - Dan Helton - A Gentle Introduction to Hacking Mainframes by Dan Helton
2020
- Prezo - Gibson 101 - Quick Introduction to Hacking Mainframes in 2020
- Video - Wild West Hackin' Fest 2020 (Virtual): Not Just Evil: Hacking Mainframes with Network Job Entry - Philip Young - Soldier of FORTRAN (@mainframed767)
2021
- Video - HOW TO HACK "THE MAINFRAME" ! (for real) - TRUESEC - Davide Girardi - STÖK
- Prezo - Crossover Episode: The Real-Life Story of the First Mainframe Container Breakout - Ian Coldwater and Chad Rikansrud (Bigendian Smalls)
2022
↑ ACF2 Specific references
↑ STIGs
- z/OS TSS STIG
- z/OS RACF STIG
- z/OS ACF2 STIG
- DoD Security Technical implementation Guides(STIGS) - Search for ACF2, Z/OS, RACF etc.
↑ Miscellaneous
- Mainframe Hacking - Choose Your own Adventure Game
- Evil Mainframe Hacking Training/Course
- CBT Tape - Collection of Freeware & Open Source distribution of IBM mainframe MVS & OS/360 Environments
- z/OS Internet Library by IBM - Collection of manuals,guides & books about z/OS
- z/OS - all things security
- IBM z/OS Management Facility web application arbitrary file read
- Mapping Mainframe Memory Made Easy
- Hacking CICS: 7 Ways to Defeat Mainframe Applications
↑ AS400 / IBM i Series server / IBM System i
↑ iSeries Books
- Amazon - Hacking iSeries by Shalom Carmel
- Amazon - Mastering IBM i: The Complete Resource for Today's IBM i System by Jim Buck & Jerry Fottral
- Amazon - Experts' Guide to OS/400 & i5/OS Security by Carol Woodbury & Patrick Botz
- PDF - The IBM AS400 A technical introduction
↑ Tutorials and Checklists
- AS/400 Security Assessment Mindmap
- iSeries Penetration Testing
- Security Audit of IBM AS/400 and System i : Part 1
- Security Audit of IBM AS/400 and System i : Part 2
- Security Assessment of the IBM i (AS 400) System : Part 1
- Seclists Mailing list thread on Pentesting AS/400
- Resources from Shalom Carmel's talk at BH Europe - 2006
↑ Tools
- hack400tool - security handling tools for IBM Power Systems (formerly known as AS/400)
- Hash generator for IBM System i hashes (DES, SHA-1)
- AS/400 SHA-1 hash format plugin for John the Ripper
↑ iSeries Presentations and Talks
- Hack the Legacy: IBM I aka AS400 Revealed by Bart Kulach
- AS/400 for pentesters by Shalom Carmel
- AS/400: Lifting the Veil of Obscurity