Rocket Software (@rocket on twitter, links below) has a great set of ported tools for System Z. One of them is Python 2.7.6 Python is in ever penetration tester’s toolkit, and one of my favorite uses for it is to get a “clean” shell once you have gotten connectivity to a system.
Mainframe is no different; using the old one liner
python -c "import pty;pty.spawn('/bin/sh')"
One can change an ugly shell (perhaps gained by Java app, or some other means: e.g. netcat, exploit, etc) into one with proper TTY / shell settings, as show in this simple gif:
The Gist below patches Rocket’s port of Python to make this work on System Z ( the pty.py – one line fix to match the naming conventions on mainframe).