from root to special - def con con 22/def con 22 presentations... · – python/jcl/ftp ... from...

56
From ROOT to SPECIAL Hacking IBM Mainframes Soldier of Fortran @mainframed767

Upload: trinhtruc

Post on 17-Mar-2018

222 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

From ROOT to SPECIAL

Hacking IBM Mainframes

Soldier of Fortran @mainframed767

Page 2: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

DISCLAIMER!

All research was done under personal time. I am not here in the name of, or on behalf of, my employer.

Therefore, any views expressed in this talk are my own and not those of my employer.

This talk discusses work performed in my spare time generally screwing around with mainframes and thinking 'what if this still works...'

@mainframed767

Page 3: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

?Question?

PLAIN TXT 53%

SSL 47%

INTERNET MAINFRAMES

Page 4: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

?SSL?

Self Signed 33%

No Error 49�

SSL TN3270 MAINFRAMES Bad

CA 17%

Page 5: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

Who are you?

•  Security Guy

•  Tired of 90’s thinking

•  Eye opening experience

@mainframed767

Page 6: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

PCI Security Expert

Mainframe Security Guru

ISO 27002 & PCI

Certifier

“What’s NETSTAT?”

- Our Horrible Consultant

Page 7: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

Spoken

Page 8: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

z/OS? WTF

•  Most popular “mainframe” OS

•  Version 2.1 out now!

Legacy my ass!

@mainframed767

Page 9: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

z/OS Demo

•  Let’s take a look at this thing

•  It’ll all make sense

@mainframed767

Page 10: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

zOS or PoS?

•  Hard to tell, identifying sucks

•  Scanner have “challenges”

nmap -sV -p 992 167.xxx.4.2 -Pn

@mainframed767

Page 11: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

Nmap 6.40

PORT: 992/tcp STATE: open

SERVICE: ssl

VERSION:

IBM OS/390

@mainframed767

Page 12: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

Nmap 6.46

PORT: 992/tcp STATE: open

SERVICE: ssl

VERSION:

Microsoft

IIS SSL

@mainframed767

Page 13: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,
Page 14: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

CENSORED(

CENSORED(

CENSORED(

CENSORED(

CENSORED(

CENSORED(

Page 15: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

Other Methods

•  Web Servers: IBM HTTP Server V5R3M0

Page 16: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

FTP Banner

@mainframed767

CENSORED(

Page 17: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

Lets Break in

•  Steal Credentials

•  Web Server

•  3270 Panels – Usin’ BIRP

@mainframed767

Page 18: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

Ettercap Demo

@mainframed767

Page 19: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

Missed it

@mainframed767

Page 20: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

CGI-Bin in tyool 2014

•  REXX / SH still used

•  Injection simple, if you know TSO commands

@mainframed767

Page 21: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

@mainframed767

Page 22: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,
Page 23: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,
Page 24: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

CENSORED( CENSORED(

@mainframed767

Page 25: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

B.I.R.P.

•  Big Iron Recon & Pwnage

– By @singe – HITB 2014

•  3270 is awesome

@mainframed767

Page 26: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

Standard 3270

@mainframed767

Page 27: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

BIRP 3270

@mainframed767

Page 28: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

Only FTP?

•  No Problem! •  FTP lets you run JCL (JCL = Script)

•  Command: SITE FILE=JES

Page 29: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

Access Granted

•  Now we have access

•  FTP Account •  Asking someone

Now what?

@mainframed767

Page 30: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,
Page 31: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

Escalate!

•  Let’s escalate our privilege

•  Connect with telnet/ssh/3270

@mainframed767

Page 32: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

Getroot.rx

•  rexx script •  Leverages CVE-2012-5951:

Unspecified vulnerability in IBM Tivoli NetView 1.4, 5.1 through 5.4, and 6.1 on z/OS allows local users to gain privileges by leveraging access to the normal Unix System Services (USS) security level.

Page 33: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

Tsk tsk

•  IBM not really being honest here

• Works on any setuid REXX script!

@mainframed767

Page 34: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

@mainframed767

Page 35: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

DEMO

@mainframed767

Page 36: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

DEMO

Page 37: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

THANKS

•  Swedish Black Hat community

•  Oliver Lavery – GDS Security

•  Logica Breach Investigation Files

Page 38: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,
Page 39: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

Keep ACCESS

•  Get a copy of the RACF database

•  John the Ripper

racf2john racf.db

john racf_hashes

@mainframed767

Page 40: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

Steal

•  Use IRRDBU00 to convert RACF to flat file

•  Search for SPECIAL accounts

•  Login with a SPECIAL account

@mainframed767

Page 41: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

IRRDBU00

CENSORED(

@mainframed767

Page 42: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

Welcome to OWN zone

•  SPECIAL gives access to make any change to users

•  Add Users •  Make others SPECIAL, OPERATIONS

@mainframed767

Page 43: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

Give�r UID 0

@mainframed767

Page 44: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

Give�r SPECIAL

@mainframed767

Page 45: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

INETD

@mainframed767

Page 46: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

INETD

•  Works just like Linux

Kill inetd:

- ps –ef|grep inetd - Kill <id>

@mainframed767

Page 47: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

Connect with NETEBCDICAT

•  EBCDIC!

@mainframed767

•  Use NetEBCDICat

Page 48: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

BPX. Wha?

•  BPX.SUPERUSER – Allows people to su to root without password

Page 49: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

BPX.SUPERUSER

•  As SPECIAL user type (change userid):

PERMIT BPX.SUPERUSER CLASS(FACILITY) ID(USERID) ACCESS(READ)

And

SETROPTS GENERIC(FACILITY) REFRESH

Page 50: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

Tools

•  CATSO –  TSO Bind/Reverse shell

•  TSHOCKER – Python/JCL/FTP wrapper for CATSO

•  MainTP – Python/JCL/FTP getroot.rx wrapper

@mainframed767

Page 51: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,
Page 52: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

TShocker

@mainframed767

Page 53: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

Maintp

•  Uses GETROOT.rx + JCL and FTP and NetEBCDICat to get a remote root shell

@mainframed767

Page 54: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,
Page 55: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

Thanks

•  Logica Breach Investigation Team

•  Dominic White (@singe)

•  The community

Page 56: From ROOT to SPECIAL - DEF CON CON 22/DEF CON 22 presentations... · – Python/JCL/FTP ... From root to SPECIAL - Hacking IBM ... Technology, Phreaking, Lockpicking, Hackers, Infosec,

Contact

Twitter�

@mainframed767

Email�

[email protected]

Websites:

Mainframed767.tumblr.com

Soldieroffortran.org