38
iOS Spelunking (Hacking in context) Mikhail Sosonkin

OWASP: iOS Spelunking

Embed Size (px)

Citation preview

Page 1: OWASP: iOS Spelunking

iOS Spelunking(Hacking in context)

Mikhail Sosonkin

Page 2: OWASP: iOS Spelunking

Security Researcher at SYNACK

Working on low level emulation with QEMU and iPhone automation.

Graduate of Polytechnic University/ISIS Lab 2005

a.k.a New York University Tandon School of Engineering

Masters in Software Engineering from Oxford University 2014

Exeter College

Page 4: OWASP: iOS Spelunking

What’s a vulnerability

Just crashes

Bugs Vulnerabilities

What we are used to

Logic errors

Page 5: OWASP: iOS Spelunking

Amazon Apple

“In short, the very four digits that Amazon considers unimportant enough to display in the clear on the web are precisely the same ones that Apple considers secure enough to perform identity verification.”

- http://www.wired.com/2012/08/apple-amazon-mat-honan-hacking/all/

Page 6: OWASP: iOS Spelunking

It is not enough to just be careful with your interfaces. You must also have mitigations and continuous analysis that includes “outsiders”.

Security considerations and reviews should be part of every step of development lifecycle.

Page 8: OWASP: iOS Spelunking

NetworkMan On The Side

http://www.wired.com/2015/04/researchers-uncover-method-detect-nsa-quantum-insert-hacks/

WebWhere did I leave that session key again?https://www.owasp.org/index.php/Top_10_2013-Table_of_Contents

Page 9: OWASP: iOS Spelunking

MiscommunicationsThe root of all bugs.

Don’t be too paranoid, it’s not healthybut always ask: “what do you do if someone compromises this component?”

Page 10: OWASP: iOS Spelunking

TargetingClassic:

Browser, Remote, PhishingJailbreakMe

A little more advanced:Via AWS - managed services (Exploiting external relationships)

USB - https://srlabs.de/badusb/ i.e. Stuxnethttp://syncstop.com/

Page 12: OWASP: iOS Spelunking

Supply chainOutsourced supplier has bad security practices

Malware via ad networks [Link]

Think GitHub code is safe?

Page 13: OWASP: iOS Spelunking

Someone is doing it through the browser

Page 14: OWASP: iOS Spelunking

Beg, borrow and steal

Finding vulnerabilities

Fuzzing (AFL, Many frameworks)

Code reading (SourceInsight, Understand)

Dynamic/Static analysis (Qira, Panda)

Page 15: OWASP: iOS Spelunking

ExploitControl EIP or X30

Doesn’t have to be 100%

Gain execution

Binary protections like ASLR and DEP

Page 16: OWASP: iOS Spelunking

InfectRun shell code

Might have some ROPing to do

And, stack pivoting

Find the egg

Bigger shellcode.

Download implant

Gain persistence i.e. launch daemon or dylib injection

Page 17: OWASP: iOS Spelunking

No Disclosure

Private Communities

Full disclosure

Responsible Disclosure

Coordinated Disclosure

Private Bug bounties: Google, Microsoft, Facebook, etc

Managed Bug Bounties

Trends in Vulnerability Disclosure

Page 18: OWASP: iOS Spelunking

Black Market Bug Bounties:

Zerodium, Vupen

Cosinc (link)

HackingTeam (Probably defunct)

MitnickSecurity

Lots of secretive companies (link)

A few not so secretive (link)

Page 19: OWASP: iOS Spelunking

InjectingDYLD interposing

Injecting using shellcode

Dylib injection

Mobile substrate

Lots of other methods:

http://www.slideshare.net/Synack/can-secw

Page 20: OWASP: iOS Spelunking

Not so different

OSX:

0x01000000 - mach ports

0x02000000 - Posix

0x03000003 - pthread_set_self

IOS

0x00000000 and below - mach ports

0x00000000 and above - Posix

0x80000000 - pthread_set_self

Page 21: OWASP: iOS Spelunking

Get initial info - OSX

Page 22: OWASP: iOS Spelunking

Get initial info - iOS

Page 23: OWASP: iOS Spelunking

Partial sourceXNU kernel

https://opensource.apple.com/tarballs/xnu/

Dyld source https://opensource.apple.com/tarballs/dyld/

Page 24: OWASP: iOS Spelunking

Demo time!- Identify input and buttons- Clicking buttons- Fill inputs- Rewire application

Recorded session

Page 25: OWASP: iOS Spelunking

Packages from CydiaCydia Substrate

Simulate Key Events

SimulateTouch

Cycript

iOS SSL Kill Switch [Link]

Page 27: OWASP: iOS Spelunking

Importingcy# @import com.tyilo.utils; 0

(/usr/lib/cycript0.9/com/tyilo/utils.cy)

cy# @import com.tyilo.ui_find; 0

(/usr/lib/cycript0.9/com/tyilo/ui_find.cy)

Page 28: OWASP: iOS Spelunking

Finding Items

Page 29: OWASP: iOS Spelunking

More specific

Page 30: OWASP: iOS Spelunking

Absolute location

Page 31: OWASP: iOS Spelunking

Finding inputs

Page 32: OWASP: iOS Spelunking

Finding buttons

Page 33: OWASP: iOS Spelunking

Call it a hunch

Page 34: OWASP: iOS Spelunking

Get the APIsClick the button:

stouch touch 2 297

Page 35: OWASP: iOS Spelunking

Get the APIsGet the creds using MITM:

$ mitmdump -s 'selectors.py -r -p -j selectors.json -a gs_test'

[2015-11-30 22:04:02,220] gs_test cwm.goldman.com/login/login_mobile.cgi|Found 'creds' in gsid=user&gspw=pass

[2015-11-30 22:04:02,221] gs_test cwm.goldman.com/login/login_mobile.cgi|Found 'creds' in user&gspw=pass

Page 36: OWASP: iOS Spelunking

Why?● Scriptable● API discovery● Fuzzing

○ Android screen unlock hack [link]

● Blackbox● No special build

Page 37: OWASP: iOS Spelunking

Getting started with iOS- Get iPhone 5s

- Swappa

- Apply Jailbreak- Install OpenSSH via Cydia- Use tcprelay to SSH over USB

- Start exploring- debugserver

- https://github.com/iosre/iOSAppReverseEngineering- https://nabla-c0d3.github.io/blog/2014/12/30/tcprelay-multiple-devices/