SlideShare a Scribd company logo
Dark Side of iOS

Kuba Brecka
@kubabrecka

Play Ragtime
Czech Republic
@kubabrecka
www.kubabrecka.com
How important is it for a
developer to know…
ž  OOP
ž  Functional programming
ž  Compiler theory, automata theory
ž  Algorithm complexity
ž  Databases
ž  Networking
ž  UI/UX
ž  Reverse engineering
But actually…
ž  …let’s take a look how deep the rabbit
hole goes
ž  I’ll try to answer some “forbidden”
questions
—  private API
—  app validation, review
—  binary structure, app encryption
—  some security consequences
The goal
ž  To show…
—  what Apple can do with your application
—  what can you (or others) find out from the app
binary
—  what can you do with a jailbroken device
—  where do “cracked” apps come from
—  what can a determined “black hat” do
ž  Not: to break the law
ž  Disclaimer: for educational purposes only
ž  Disclaimer 2: I’m no security expert, I’m just
some guy who likes digging into things
Sandbox
ž  Every application has its own sandbox
—  it can see its directory + a few of system
directories
—  for writing, it has only a few specific
directories
ž  There is no point in creating a file
manager
ž  App-to-app file transfers are ad-hoc
Jailbreak
ž  No signature verification
ž  Disabled sandbox
—  read and write anywhere in the filesystem (!)
ž  Turns off ASLR
ž  Re-allows blocked syscalls
—  fork, exec, …
ž  Debugging, attach to process
ž  Cydia
ž  tethered (easy), untethered (very hard)
—  jailbreakers are saving exploits for later
iOS 6.1 jailbreak – evasi0n
ž  http://theiphonewiki.com/wiki/Evasi0n
Private API
ž  Header files in Xcode are “stripped”
—  plenty of hidden classes and methods
—  the reason?
○  published APIs must be supported by Apple for a
long time
○  Apple wants to be able to change the internals
ž  Class-dump
—  http://stevenygard.com/projects/class-dump/
—  https://github.com/nst/iOS-Runtime-Headers
—  dumps all classes and methods from a binary
Method swizzling
ž  All selectors are called using a dynamic
dispatch
—  a method can be replaced by changing a record
in the method lookup tables
—  http://darkdust.net/writings/objective-c/method-
swizzling
- (BOOL)swizzled_synchronize {	
...	
[self swizzled_synchronize];	
...	
}	
	
+ (void)load {	
Method original = class_getInstanceMethod(self, @selector(synchronize));	
Method swizzled = class_getInstanceMethod(self, @selector(swizzled_synchronize));	
method_exchangeImplementations(original, swizzled);	
}
App validation
ž  What exactly is sent over to Apple?
—  Compiled binary for ARMv6 (?), ARMv7,
ARMv7s
—  Not: source code, binary for simulator
ž  What happens with the app during
validation?
—  checks of some “boring stuff”
○  icon, profile, plist, …
—  checks for private API usage
App review
ž  What happens to the app during review?
—  Officially: only App Store Review Guidelines
—  <my guess>
○  much less testing than you would think
○  they don’t have the source code
○  validation + automated tests
—  CPU load, battery consumption
○  manual tests
—  can the app be run? does it do something?
—  no extensive testing of all app features
○  individual teams have different results
○  hard-to-detect violation of rules are solved later
—  when the app is popular enough that someone cares
—  </my guess>
FairPlay and app encryption
ž  App Store apps are encrypted
—  just the binary, and only individual sections
# otool -arch all -Vl ...	
cmd LC_ENCRYPTION_INFO	
cmdsize 20	
cryptoff 4096	
cryptsize 724992	
cryptid 1	
ž  Imports are intact
ž  iOS kernel validates the signature and
deciphers the binary in memory
Encrypted binary
How to obtain a decrypted
binary?
ž  .ipa files floating around the Internet
—  AppTrackr, apps.su, apps-ipa.com etc.
—  iReSign
ž  How to create it?
—  Basically the only way is to extract the
deciphered memory image from a jailbroken
device
○  using gdb, pause the process, dump memory
A quick comparison – Android
ž  Java, Dalvik, Dalvik VM, .apk files
—  bytecode (.dex)
—  dex2jar tool will convert it into common .class files
—  then use your favorite Java decompiler (there’s lots
of them)
ž  Where to get an .apk?
—  google for “<appname> apk”
—  directly from a device
○  usually pretty straightforward, sometimes you need to
root the device first
ž  Protection: obfuscation
—  but the effect of it is questionable at best
The reality
ž  Obtaining an .ipa or .apk is easy
ž  Getting information out of a binary
—  Android
○  it’s Java, decompilation is a no-brainer
—  iOS
○  it’s ARM assembly
○  but you get plenty of metainformation for free, e.g.
class names and method names
ž  Modifying an app is a completely different
story
—  definitely doable with ordinary developer access
Hacker’s toolbox
ž  IDA 6.4
—  Great Obj-C support
—  Trial version for Mac OS
○  analyzes x86 + ARM
ž  iFunBox
—  Free
—  uses iTunes internal libraries
ž  Charles – Web Debugging Proxy Application
—  http://www.charlesproxy.com/, $50
—  Settings – Wi-Fi – (network) – HTTP Proxy – Manual
—  SSL (!)
Dark Side of iOS [SmartDevCon 2013]
What can you do about it?
ž  Short answer: nothing
ž  Long answer:
—  you can invent plenty of “security by
obscurity” mechanisms, but these are
always breakable, it’s just a matter of
attacker’s determination
—  get a realistic point of view, instead of a
paranoid one
○  okay: what’s the worse thing that can happen?
○  better: risk assessment
My message
ž  You want to know how something is
done?
—  Just take a look!
—  /Applications/Xcode.app/Contents/Developer/Platforms/
iPhoneSimulator.platform/Developer/SDKs/
iPhoneSimulator6.1.sdk/System/Library/Frameworks/
○  UIKit, QuartzCore, Foundation, CoreGraphics,
CoreFoundation, …
ž  Be reasonable about security and
question the implementation
—  e.g. iFunBox
Questions?
Thank you.
Kuba Brecka
@kubabrecka
www.kubabrecka.com
Dark Side of iOS

Kuba Brecka
@kubabrecka

Play Ragtime
Czech Republic

More Related Content

PDF
Обмен учетными данными между iOS 8 приложениями и вебом, Константин Чернухо, ...
PDF
CrikeyCon 2015 - iOS Runtime Hacking Crash Course
KEY
Jailbreaking iOS
PDF
iOS Application Security
PDF
Pentesting iOS Apps - Runtime Analysis and Manipulation
PDF
OWASP Melbourne - Introduction to iOS Application Penetration Testing
PPTX
iOS-Application-Security-iAmPr3m
PDF
Iphone Presentation for MuMe09
Обмен учетными данными между iOS 8 приложениями и вебом, Константин Чернухо, ...
CrikeyCon 2015 - iOS Runtime Hacking Crash Course
Jailbreaking iOS
iOS Application Security
Pentesting iOS Apps - Runtime Analysis and Manipulation
OWASP Melbourne - Introduction to iOS Application Penetration Testing
iOS-Application-Security-iAmPr3m
Iphone Presentation for MuMe09

What's hot (20)

PDF
iOS Application Penetation Test
PPT
iOS Application Penetration Testing for Beginners
PDF
Yow connected developing secure i os applications
PPTX
Pentesting iOS Applications
PPT
Mobile Security Assessment: 101
PDF
Hacking and Securing iOS Apps : Part 1
PDF
Pentesting iOS Apps
PDF
Ruxmon April 2014 - Introduction to iOS Penetration Testing
PPT
iOS Hacking: Advanced Pentest & Forensic Techniques
PDF
I Want More Ninja – iOS Security Testing
PPTX
Pentesting iPhone applications
PPTX
Hacking and securing ios applications
PDF
iOS Application Penetration Testing
PPTX
iOS jailbreaking
PDF
Online Retailer's Conference 2013 - Hacking Mobile Applications - Industry Ca...
PPTX
iOS Application Exploitation
PPTX
[Wroclaw #2] iOS Security - 101
PDF
Security Best Practices for Mobile Development
PDF
CNIT 128 2. Analyzing iOS Applications (Part 1)
PDF
CNIT 128: Android Implementation Issues (Part 2)
iOS Application Penetation Test
iOS Application Penetration Testing for Beginners
Yow connected developing secure i os applications
Pentesting iOS Applications
Mobile Security Assessment: 101
Hacking and Securing iOS Apps : Part 1
Pentesting iOS Apps
Ruxmon April 2014 - Introduction to iOS Penetration Testing
iOS Hacking: Advanced Pentest & Forensic Techniques
I Want More Ninja – iOS Security Testing
Pentesting iPhone applications
Hacking and securing ios applications
iOS Application Penetration Testing
iOS jailbreaking
Online Retailer's Conference 2013 - Hacking Mobile Applications - Industry Ca...
iOS Application Exploitation
[Wroclaw #2] iOS Security - 101
Security Best Practices for Mobile Development
CNIT 128 2. Analyzing iOS Applications (Part 1)
CNIT 128: Android Implementation Issues (Part 2)
Ad

Similar to Dark Side of iOS [SmartDevCon 2013] (20)

PDF
MobSecCon 2015 - Dynamic Analysis of Android Apps
PDF
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
ODP
Joxean Koret - Database Security Paradise [Rooted CON 2011]
PDF
Android_Malware_IOAsis_2014_Analysis.pdf
PDF
[Ultracode Munich #4] Short introduction to the new Android build system incl...
PDF
Jailbreak Detector Detector
PDF
Android Internals (This is not the droid you’re loking for...)
PDF
Writing Android Libraries
PPTX
How We Analyzed 1000 Dumps in One Day - Dina Goldshtein, Brightsource - DevOp...
PDF
Android security and penetration testing | DIVA | Yogesh Ojha
PPTX
Security Vulnerabilities in Mobile Applications (Kristaps Felzenbergs)
PPT
iOS Client Side Analysis
PDF
Need 4 Speed FI
PDF
Porting your favourite cmdline tool to Android
PPT
Introduction to Software Development
PPTX
Reversing & Malware Analysis Training Part 9 - Advanced Malware Analysis
PPT
The Anatomy of Java Vulnerabilities (Devoxx UK 2017)
PDF
Stuxnet redux. malware attribution & lessons learned
PDF
Webinar–Mobile Application Hardening Protecting Business Critical Apps
MobSecCon 2015 - Dynamic Analysis of Android Apps
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
Joxean Koret - Database Security Paradise [Rooted CON 2011]
Android_Malware_IOAsis_2014_Analysis.pdf
[Ultracode Munich #4] Short introduction to the new Android build system incl...
Jailbreak Detector Detector
Android Internals (This is not the droid you’re loking for...)
Writing Android Libraries
How We Analyzed 1000 Dumps in One Day - Dina Goldshtein, Brightsource - DevOp...
Android security and penetration testing | DIVA | Yogesh Ojha
Security Vulnerabilities in Mobile Applications (Kristaps Felzenbergs)
iOS Client Side Analysis
Need 4 Speed FI
Porting your favourite cmdline tool to Android
Introduction to Software Development
Reversing & Malware Analysis Training Part 9 - Advanced Malware Analysis
The Anatomy of Java Vulnerabilities (Devoxx UK 2017)
Stuxnet redux. malware attribution & lessons learned
Webinar–Mobile Application Hardening Protecting Business Critical Apps
Ad

Recently uploaded (20)

PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Mushroom cultivation and it's methods.pdf
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
project resource management chapter-09.pdf
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Getting Started with Data Integration: FME Form 101
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
August Patch Tuesday
PPTX
A Presentation on Artificial Intelligence
PDF
Encapsulation theory and applications.pdf
PDF
Heart disease approach using modified random forest and particle swarm optimi...
Assigned Numbers - 2025 - Bluetooth® Document
MIND Revenue Release Quarter 2 2025 Press Release
Unlocking AI with Model Context Protocol (MCP)
Mushroom cultivation and it's methods.pdf
A comparative analysis of optical character recognition models for extracting...
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
project resource management chapter-09.pdf
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Getting Started with Data Integration: FME Form 101
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
A comparative study of natural language inference in Swahili using monolingua...
Enhancing emotion recognition model for a student engagement use case through...
A novel scalable deep ensemble learning framework for big data classification...
August Patch Tuesday
A Presentation on Artificial Intelligence
Encapsulation theory and applications.pdf
Heart disease approach using modified random forest and particle swarm optimi...

Dark Side of iOS [SmartDevCon 2013]

  • 1. Dark Side of iOS Kuba Brecka @kubabrecka Play Ragtime Czech Republic
  • 3. How important is it for a developer to know… ž  OOP ž  Functional programming ž  Compiler theory, automata theory ž  Algorithm complexity ž  Databases ž  Networking ž  UI/UX ž  Reverse engineering
  • 4. But actually… ž  …let’s take a look how deep the rabbit hole goes ž  I’ll try to answer some “forbidden” questions —  private API —  app validation, review —  binary structure, app encryption —  some security consequences
  • 5. The goal ž  To show… —  what Apple can do with your application —  what can you (or others) find out from the app binary —  what can you do with a jailbroken device —  where do “cracked” apps come from —  what can a determined “black hat” do ž  Not: to break the law ž  Disclaimer: for educational purposes only ž  Disclaimer 2: I’m no security expert, I’m just some guy who likes digging into things
  • 6. Sandbox ž  Every application has its own sandbox —  it can see its directory + a few of system directories —  for writing, it has only a few specific directories ž  There is no point in creating a file manager ž  App-to-app file transfers are ad-hoc
  • 7. Jailbreak ž  No signature verification ž  Disabled sandbox —  read and write anywhere in the filesystem (!) ž  Turns off ASLR ž  Re-allows blocked syscalls —  fork, exec, … ž  Debugging, attach to process ž  Cydia ž  tethered (easy), untethered (very hard) —  jailbreakers are saving exploits for later
  • 8. iOS 6.1 jailbreak – evasi0n ž  http://theiphonewiki.com/wiki/Evasi0n
  • 9. Private API ž  Header files in Xcode are “stripped” —  plenty of hidden classes and methods —  the reason? ○  published APIs must be supported by Apple for a long time ○  Apple wants to be able to change the internals ž  Class-dump —  http://stevenygard.com/projects/class-dump/ —  https://github.com/nst/iOS-Runtime-Headers —  dumps all classes and methods from a binary
  • 10. Method swizzling ž  All selectors are called using a dynamic dispatch —  a method can be replaced by changing a record in the method lookup tables —  http://darkdust.net/writings/objective-c/method- swizzling - (BOOL)swizzled_synchronize { ... [self swizzled_synchronize]; ... } + (void)load { Method original = class_getInstanceMethod(self, @selector(synchronize)); Method swizzled = class_getInstanceMethod(self, @selector(swizzled_synchronize)); method_exchangeImplementations(original, swizzled); }
  • 11. App validation ž  What exactly is sent over to Apple? —  Compiled binary for ARMv6 (?), ARMv7, ARMv7s —  Not: source code, binary for simulator ž  What happens with the app during validation? —  checks of some “boring stuff” ○  icon, profile, plist, … —  checks for private API usage
  • 12. App review ž  What happens to the app during review? —  Officially: only App Store Review Guidelines —  <my guess> ○  much less testing than you would think ○  they don’t have the source code ○  validation + automated tests —  CPU load, battery consumption ○  manual tests —  can the app be run? does it do something? —  no extensive testing of all app features ○  individual teams have different results ○  hard-to-detect violation of rules are solved later —  when the app is popular enough that someone cares —  </my guess>
  • 13. FairPlay and app encryption ž  App Store apps are encrypted —  just the binary, and only individual sections # otool -arch all -Vl ... cmd LC_ENCRYPTION_INFO cmdsize 20 cryptoff 4096 cryptsize 724992 cryptid 1 ž  Imports are intact ž  iOS kernel validates the signature and deciphers the binary in memory
  • 15. How to obtain a decrypted binary? ž  .ipa files floating around the Internet —  AppTrackr, apps.su, apps-ipa.com etc. —  iReSign ž  How to create it? —  Basically the only way is to extract the deciphered memory image from a jailbroken device ○  using gdb, pause the process, dump memory
  • 16. A quick comparison – Android ž  Java, Dalvik, Dalvik VM, .apk files —  bytecode (.dex) —  dex2jar tool will convert it into common .class files —  then use your favorite Java decompiler (there’s lots of them) ž  Where to get an .apk? —  google for “<appname> apk” —  directly from a device ○  usually pretty straightforward, sometimes you need to root the device first ž  Protection: obfuscation —  but the effect of it is questionable at best
  • 17. The reality ž  Obtaining an .ipa or .apk is easy ž  Getting information out of a binary —  Android ○  it’s Java, decompilation is a no-brainer —  iOS ○  it’s ARM assembly ○  but you get plenty of metainformation for free, e.g. class names and method names ž  Modifying an app is a completely different story —  definitely doable with ordinary developer access
  • 18. Hacker’s toolbox ž  IDA 6.4 —  Great Obj-C support —  Trial version for Mac OS ○  analyzes x86 + ARM ž  iFunBox —  Free —  uses iTunes internal libraries ž  Charles – Web Debugging Proxy Application —  http://www.charlesproxy.com/, $50 —  Settings – Wi-Fi – (network) – HTTP Proxy – Manual —  SSL (!)
  • 20. What can you do about it? ž  Short answer: nothing ž  Long answer: —  you can invent plenty of “security by obscurity” mechanisms, but these are always breakable, it’s just a matter of attacker’s determination —  get a realistic point of view, instead of a paranoid one ○  okay: what’s the worse thing that can happen? ○  better: risk assessment
  • 21. My message ž  You want to know how something is done? —  Just take a look! —  /Applications/Xcode.app/Contents/Developer/Platforms/ iPhoneSimulator.platform/Developer/SDKs/ iPhoneSimulator6.1.sdk/System/Library/Frameworks/ ○  UIKit, QuartzCore, Foundation, CoreGraphics, CoreFoundation, … ž  Be reasonable about security and question the implementation —  e.g. iFunBox
  • 23. Dark Side of iOS Kuba Brecka @kubabrecka Play Ragtime Czech Republic