YOU ARE DOWNLOADING DOCUMENT

Please tick the box to continue:

Transcript
Page 1: A Stuxnet for Mainframes

A STUXNET FOR MAINFRAMES

Page 2: A Stuxnet for Mainframes

Cheryl Biswas

• Security researcher/analyst Threat Intel

• APTs, Mainframes, ICS SCADA, Shadow IT, StarTrek

• BSidesLV, Circle City, BSidesT0, SecTor, Hackfest, TiaraCon

• https://whitehatcheryl.wordpress.com

• Twitter: @3ncr1pt3d

DISCLAIMER: The views represented here are solely her own and not those of her employers, past or present.

11/4/2016@3ncr1pt3d A Stuxnet For Mainframes

Page 3: A Stuxnet for Mainframes

HEAD IN THE SAND DEFENCE

Page 4: A Stuxnet for Mainframes

YOU SAY SCADA

WE SAY … MAINFRAMES

Page 5: A Stuxnet for Mainframes

MOM!! THE INTERNET IS BROKEN

Page 6: A Stuxnet for Mainframes

INTRO

In the beginning

There were mainframes

And it was good.

Page 7: A Stuxnet for Mainframes

Then came Scada. And it was good too. https://www.google.ca/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=0ahUKEwj85ODe-5HNAhVO3mMKHc8FAPoQjRwIBw&url=

http%3A%2F%2Ffossils-archeology.wikia.com%2Fwiki%2FAnkylosaurus&psig=AFQjCNGq6-7u8ZwwlVa8TYJrf2UIluqCyg&ust=1465253196880476

Page 8: A Stuxnet for Mainframes

CONGRATULATIONS! IT’S A ... PLC

Page 9: A Stuxnet for Mainframes

BUT THEN CAME ...

Page 10: A Stuxnet for Mainframes

WHAT IS SCADA

Page 11: A Stuxnet for Mainframes

I CAN’T LIVE ... IF LIVING IS WITHOUT YOU

Page 12: A Stuxnet for Mainframes
Page 13: A Stuxnet for Mainframes

DOES NOT PLAY WELL

WITH OTHERS

Page 14: A Stuxnet for Mainframes

WHAT ARE MAINFRAMES?

Page 15: A Stuxnet for Mainframes

MAINFRAMES … RIGHT?

Page 16: A Stuxnet for Mainframes

THESE ARE NOT THE MAINFRAMES YOU’RE LOOKING FOR

Page 17: A Stuxnet for Mainframes

THIS AIN’T YOUR GRANDMA’S MAINFRAME

Page 18: A Stuxnet for Mainframes

MAINFRAMES - BUILT TO LAST• High Availability

• Longevity

• Virtualization

• The ability to offload to separate engines

• Backward compatibility with older software

• Massive Throughput

https://en.wikipedia.org/wiki/Mainframe_computer

Page 19: A Stuxnet for Mainframes

@3ncr1pt3d A Stuxnet For Mainframes 11/4/2016

Page 20: A Stuxnet for Mainframes
Page 21: A Stuxnet for Mainframes

SCADA MAINFRAME❏ Culture❏ Security Approach❏ Perceptions❏ Built to Last❏ Closed off❏ Does not play well

with others

❏ Culture❏ Security Approach❏ Perceptions❏ Built to Last❏ Closed off❏ Does not play well

with others

Page 22: A Stuxnet for Mainframes
Page 23: A Stuxnet for Mainframes
Page 24: A Stuxnet for Mainframes

Innovation

DisruptionWould you like some security

with that?

Page 25: A Stuxnet for Mainframes

SECURITY BASICS WE KEEP GETTING WRONG❏ Passwords

❏ Encryption

❏ Access

❏ Patchinghttp://blog.senr.io/blog/unique-snowflakes-or-ubiquitous-tech-the-truth-behind-the-industrial-internet-of-things-iiot

Page 26: A Stuxnet for Mainframes

ICS / SCADA - WHAT HAVE WE LEARNED?

Page 27: A Stuxnet for Mainframes

"NONE OF OUR SCADA OR ICS

EQUIPMENT IS ACCESSIBLE FROM THE INTERNET."

O RLY?

Page 28: A Stuxnet for Mainframes

PROJECT SHINE

1,000,000 SCADA ICS

DEVICES FOUND ONLINE

Page 29: A Stuxnet for Mainframes
Page 30: A Stuxnet for Mainframes
Page 31: A Stuxnet for Mainframes
Page 32: A Stuxnet for Mainframes

SCADA ATTACK VECTORS

Page 33: A Stuxnet for Mainframes

SCADA ATTACKSMalicious Trojan

http://www.risidata.com/Database

Page 34: A Stuxnet for Mainframes

SCADA ATTACKSStolen equipment

http://www.risidata.com/Database

Page 35: A Stuxnet for Mainframes

SCADA ATTACKSSocial Engineering

http://www.risidata.com/Database

Page 36: A Stuxnet for Mainframes

SCADA - JUMPING AIR GAPS• Designed for underwater communication

• Near ultrasonic frequency

• Remote key logging for multiple hops

http://www.jocm.us/index.php?m=content&c=index&a=show&catid=124&id=600

Page 37: A Stuxnet for Mainframes
Page 38: A Stuxnet for Mainframes

MAINFRAMES & SCADA - THE LINKS• Similar in Culture

• Lack of security

• Perceived as secure

• “Air Gapped”

• “See no evil” – cuz you don’t see it if you aren’t

looking

Page 39: A Stuxnet for Mainframes
Page 40: A Stuxnet for Mainframes

BUT IT’S AIR GAPPED“Mainframe modernization or exposing the classic

system of record data to new services means that the data is no longer isolated on the mainframe – the

world is now “unknown, unknown.” We have lost sight and control of where the data is going the minute we try to harness mainframe data for other purposes than

batch or transaction applications.”zOS Expert

http://www.symantec.com/connect/blogs/mind-gap-are-air-gapped-systems-safe-breaches

Page 41: A Stuxnet for Mainframes

MAINFRAME - LACK OF ATTACK DATABecause … What you don’t see won’t hurt you

Page 42: A Stuxnet for Mainframes

CULTURE

http://mainframed767.tumblr.com/post/79167015212/please-dont-post-on-mainframe-forums?is_related_post=1

Page 43: A Stuxnet for Mainframes
Page 44: A Stuxnet for Mainframes

MAINFRAME EXPLOIT RESEARCH

Page 45: A Stuxnet for Mainframes

MAINFRAME - EXPLOIT RESEARCHBigendiansmalls

https://www.bigendiansmalls.com/category/security/exploit-development/

Page 46: A Stuxnet for Mainframes

MAINFRAME - NMAP

Can now detect Mainframe portsMainframe banners are not staticMore accessible to others for hacking

http://mainframed767.tumblr.com/post/132669411918/mainframes-and-nmap-together-at-lasthttp://mainframed767.tumblr.com/post/47105571997/nmap-script-to-grab-mainframe-screens

Page 47: A Stuxnet for Mainframes

MAINFRAMES - BIND SHELLCODEMainframe assemblerEBCDIC to ASCII converterConnect with NetCat

https://www.bigendiansmalls.com/mainframe-bind-shell-source-code/

ASCII TO EBCDIC

ASCII TOEBCDIC EBCDIC TO ASCII

Page 48: A Stuxnet for Mainframes

LETS GET TECHNICAL

Page 49: A Stuxnet for Mainframes

MAINFRAMES - STACK BUT DIFFERENT▪Mainframe prologue creates Dynamic Storage Area

▪Points to next free byte on the stack used

▪Does not subtract from ESP to allocate space

▪Register used as a stack pointer

▪Not forced to do so.

https://www.bigendiansmalls.com/smashing-the-zos-le-daisy-chain-for-fun-and-cease-and-desist-letters-guest-post-2/

Page 50: A Stuxnet for Mainframes

ALLOCATION OF MEMORY - FUNCTION PROLOGUE

0x80123430x8012344Function Called0x8012345 - SFP

IP

EBP

MAIN()ESP

EBP

SFPESP +

Page 51: A Stuxnet for Mainframes

ALLOCATION MEMORY - FUNCTION PROLOGUE

0x80123450x8012344Function Called

IP Allocated Memory

EBP

-28ESPMAIN() FUNCTION()

SFPESP +

Page 52: A Stuxnet for Mainframes

ALLOCATION MEMORY - FUNCTION EPILOGUIE

IP

EBP

MAIN()ESP

EBP

SFPESP +

SFP

Page 53: A Stuxnet for Mainframes

ALLOCATION MEMORY - DSA PROLOGUE

0x80123450x8012344Function “Called”

IPDynamic Storage Area

MAIN()

Pointer to original DS

DSA NOT STACK

Save Area

Page 54: A Stuxnet for Mainframes

Not gonna happen

HOW TO EXPLOIT - STRING EXPLOITATION != WINAlways aware of length

StringStringStringStringString

Length

StringStringStringStri

Length

https://www.bigendiansmalls.com/smashing-the-zos-le-daisy-chain-for-fun-and-cease-and-desist-letters-guest-post-2/

AAAAAAAAAA

Page 55: A Stuxnet for Mainframes

MAINFRAMES - UNIQUE TO EXPLOITS0C1 Exception

http://mainframed767.tumblr.com/post/136886215917/guest-post-jan-cannaerts-smashing-the-zos-le

AAAAAAAAAAAAAAAAAAAAA

Memory containing Data

OPCODESOPCODE does not exist

No size checking

AAAAAAAA

Overflow causes execution to branch to another memory location

Page 56: A Stuxnet for Mainframes

MAINFRAMES - UNIQUE TO EXPLOITS0C1 Exception

http://mainframed767.tumblr.com/post/136886215917/guest-post-jan-cannaerts-smashing-the-zos-le

DSA Level 0 DSA 1

Returns to DS 0

DSA Level 0 DSA 2DSA

Level 1

Register 14 = RP

Page 57: A Stuxnet for Mainframes

MAINFRAMES - UNIQUE TO EXPLOITGlobally addressed arraysS0C1 Exception

http://mainframed767.tumblr.com/post/136886215917/guest-post-jan-cannaerts-smashing-the-zos-le

DSA Level 0 DSA 2DSA Level 1

Register 14 = RP

DSA 2DSA 1 DSA 3

Procedure returns to Level 1

Actually executes code in DSA2

Page 58: A Stuxnet for Mainframes

MAINFRAMES - INSECURITY OF MEMORYMemory not more secure than Windows or Unix.No “DEP”No strict ASLR

http://mainframed767.tumblr.com/post/136886215917/guest-post-jan-cannaerts-smashing-the-zos-le

Page 59: A Stuxnet for Mainframes

ACCESSIBLE TO YOU!

Page 60: A Stuxnet for Mainframes

FTP EXPLOIT

EXPLOIT/MAINFRAME/FTP/FTP_JCL_CREDS

Page 61: A Stuxnet for Mainframes

MAINFRAME - FIRST METASPLOIT MODULEPoorly configured FTP server.FTP -> Shell

https://www.bigendiansmalls.com/a-logical-first-step/

Page 62: A Stuxnet for Mainframes

FTP METASPLOIT MODULE

ARCH_CMD Executes a command, or uses a command to give a shell

Platform: Mainframe Uses the Mainframe payloads of metasploit

Target Automatic Only works with IBM FTP CS V.R.

Requires Credentials Credentials allow a file to be uploaded

Debugging enabled Can enable Verbose and FTPdebug

https://www.bigendiansmalls.com/a-logical-first-step/https://www.rapid7.com/db/modules/exploit/mainframe/ftp/ftp_jcl_creds

Page 63: A Stuxnet for Mainframes

FTP METASPLOIT MODULEChecks BannerIf banner correct, logs in and uploads fileFile is uploaded as JOB & executes

https://www.bigendiansmalls.com/a-logical-first-step/@3ncr1pt3d A Stuxnet For Mainframes 11/4/2016

Page 64: A Stuxnet for Mainframes

GENERIC JCL TEST FOR MAINFRAME EXPLOITSThis can be used as a template for other JCL based payloads

https://www.rapid7.com/db/modules/payload/cmd/mainframe/generic_jclhttps://www.bigendiansmalls.com/a-logical-first-step/

Page 65: A Stuxnet for Mainframes

Z/OS (MVS) COMMAND SHELL, REVERSE TCPCreates a reverse shell.This implementation does not include ebcdic character

translation, so a client with translation capabilities is required. MSF handles this automatically.

https://www.rapid7.com/db/modules/exploit/mainframe/ftp/ftp_jcl_credshttps://www.bigendiansmalls.com/mainframe-bind-shell-source-code/

Page 66: A Stuxnet for Mainframes

GENERIC COMMAND SHELLConnect back to attacker and spawn a command shell

Page 67: A Stuxnet for Mainframes

HOW THE MIGHTY FALL

Page 68: A Stuxnet for Mainframes

BIGENDIAN POC

11/4/2016@3ncr1pt3d A Stuxnet For Mainframes

Page 69: A Stuxnet for Mainframes

STUXNET - SCADA

Page 70: A Stuxnet for Mainframes
Page 71: A Stuxnet for Mainframes
Page 72: A Stuxnet for Mainframes

SCADA - STUXNET• Air Gap bypass

• APT

• C2

• Self erasing

• Specific to system it wants

• Nation State

Page 73: A Stuxnet for Mainframes

SCADA -THE THREAT IS REAL• Dec 2015 Powergrid attack in

Ukraine

• March 2016 Ransomware hits US power company in Michigan

• June 2016 Irongate Targetted ICS malware in testing stage

Page 74: A Stuxnet for Mainframes

CRYSTAL BALL GAZING

Page 75: A Stuxnet for Mainframes

We’re here to say history doesn’t need to repeat itself. Especially not when we know how dire the outcome could be. Scada gives us the lessons we need to learn from and apply to mainframe security. The question now is - will we do it?

Page 76: A Stuxnet for Mainframes
Page 77: A Stuxnet for Mainframes

CONCLUSI

ON

Page 78: A Stuxnet for Mainframes

CONCLUSION

Page 79: A Stuxnet for Mainframes

THE KEYS TO THE KINGDOM▪ Obtain Domain admin level creds

▪ Gain a copy of NTDS.dit for Kerberos golden tickets to move freely

▪ Identify the back up and recovery systems, including DRP

▪ Identify the critical data and services. Mission critical

▪ Identify messaging servers

▪ Find and compromise application distribution platforms

Page 80: A Stuxnet for Mainframes

CONCLUSI

ON

Page 81: A Stuxnet for Mainframes
Page 82: A Stuxnet for Mainframes

HOW TO GET YOUR FEET WET

Researchers to Research

• https://www.bigendiansmalls.com/

• http://mainframed767.tumblr.com/

• Mainframe Assembly

• locallyhttp://www.cbttape.org/ftp/asmbook/alnv200.pdf

Page 83: A Stuxnet for Mainframes

HOW TO GET YOUR FEET WET• Virtualization software to play

• http://www.bsp-gmbh.com/turnkey/

• http://mvs380.sourceforge.net/

• https://www.tripwire.com/state-of-security/security-data-protection/cyber-secur

ity/mainframe-insecuritites-or-hack-the-gibson-no-really/


Related Documents