SlideShare a Scribd company logo
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Beyond The ‘Cript: Practical
iOS Reverse Engineering
Michael Allen (@_dark_knight_)
Security Consultant
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Why This Talk?
• Apps more hardened against
common attacks
• Bridge the gap
• Deeper understanding of what
happens under the hood
• Foundation for additional
research
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Outline/Agenda
• Building A General Toolkit
• iOS Application Assessment 101
– Usual results
– “New” approach
• The Reverse Engineer’s Toolkit
• Reverse Engineering iOS Applications
• Mach-O Binary Format
• Mach Tasks
• ARM(32/64)
• Objective-C
• Swift
• Identifying and bypassing Simple Jailbreak Detection Routines
• Conclusion
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Outline/Agenda
• Building A General Toolkit
• iOS Application Assessment 101
• The Reverse Engineer’s Toolkit
• Reverse Engineering iOS Applications
• Identifying and bypassing Simple Jailbreak
Detection Routines
• Conclusion
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Building A General Toolkit
• Jailbroken Device
• File System
• Network
• Instrumentation
• Automating Common Tasks
• Essentials
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Jailbroken Device
• Removing software restrictions
imposed by iOS, through the use of
software exploits
• Recommend dedicated device for
testing
• Latest jailbreak
– Pangu (iOS 9.2 – 9.3.3 64-bit
devices only)
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Jailbroken Device (contd.)
• Tethered
• Does not persist across reboots
• Requires computer to start device
• Untethered
• Persists on device across reboots
• Semi-tethered
• Requires computer to start into jailbroken state
• Rebooting or starting device without assistance possible. But boots into
non-jailbroken state
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Jailbroken Device (ProTip)
• Change default root password from alpine
• Access device over usb using usbmuxd
– sudo python tcprelay.py -t 22:22
• Generate ssh keys
– ssh-keygen -t rsa -f ~/.ssh/ironman -N "”
• Copy public key to device
– ssh-copy-id -i ~/.ssh/ironman.pub root@localhost
• Create an alias on (~/.ssh/config)
IOActive, Inc. Copyright ©2016. All Rights Reserved.
File System: Moving Files
• iFunbox
• iExplorer
• Sftp
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Network: BurpSuite Pro Intercepting Proxy
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Network: SSL Kill Switch 2
• “Disables SSL certificate validation - including certificate pinning -
within iOS Apps.”
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Instrumentation: Cycript
• Injects into target process
• Interactive console
• Objective-C and Javascript syntax
• Supported Architectures(iOS, Mac OS X)
• NowSecure fork where runtime powered by Frida* (Cycript on
steroids)
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Instrumentation: Cycript (contd.)
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Instrumentation: Frida
• Injects Google’s V8 engine into target process
• Javascript executed with full access to memory
• Function hooking
• Access to native methods
• Inject into starting process
• Multiple architectures (Windows, Mac, Linux, iOS and Android)
IOActive, Inc. Copyright ©2016. All Rights Reserved.
• Method tracing
Instrumentation: Frida (contd.)
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Automating Common Tasks
• Idb Tool - http://www.idbtool.com/
• Snoop-IT - http://repo.nesolabs.de/
• iRet - https://www.veracode.com/blog/2014/03/introducing-the-ios-reverse-engineering-
toolkit
• IntroSpy - https://github.com/iSECPartners/Introspy-iOS
• AppMon - https://dpnishant.github.io/appmon/
• Needle - https://github.com/mwrlabs/needle
• Varying levels of support
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Automating Common Tasks: Idb Tool
• Idb Tool
• “idb is a tool to simplify some common tasks for iOS app
security assessments and research.”
• Provides general app info
• URL Handler
• Keychain dumping
• Pasteboard
• Logging
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Automating Common Tasks: Idb Tool (contd.)
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Essentials: Command Line Utilities
• Command Line
– BigBoss Recommended Tools (Cydia)
– Erica Utilities (Cydia)
– Jonathan Levin compiled a number of commonly used binaries
for iOS
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Essentials: iOSBinpack (Jonathan Levin)
• Listing of available tools
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Outline/Agenda
• Building A General Toolkit
• iOS Application Assessment 101
• The Reverse Engineer’s Toolkit
• Reverse Engineering iOS Applications
• Identifying and bypassing Simple Jailbreak
Detection Routines
• Conclusion
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Common Attack Vectors: Sniffing On A
Remote Virtual Interface
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Common Attack Vectors: Sniffing On A
Remote Virtual Interface (contd.)
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Common Attack Vectors: Insecure Storage
• Property list files (.plist)
• SQLite databases
• Keychain
• Snapshots
• Cache
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Insecure Storage: Property Lists (.plist)
• Stores serialized objects
• Key value pairs
• Maybe compacted to bplist (binary plist)
– cat filename.plist | plutil -convert xml1 - -o -
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Insecure Storage: Client-Side Data Stores
• Often see SQLite being used for client-side storage
• Lightweight client-side database
• Query using SQL
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Insecure Storage: Fun Fact About SQLite
Data Stores
• Delete doesn’t do what you think
• Deleted data added to free list
• Free records not overwritten until more space required
• End result is data may not be overwritten for a while
• May be recovered with SQLite-parser
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Insecure Storage: Dumping The Keychain
• SQLite database stored in /var/Keychains
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Insecure Storage: Snapshots
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Insecure Storage: Inspecting The Cache
• Caches directory similar function to that of a web browser’s
cache
• Aimed at improving performance
• May store web cache content
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Insecure Storage: Dumping Binary Cookies
• Created by URL loading system or webview
• Stored on local file system in binary format.
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Common Attack Vectors: Inter-process
Communication
• Application registers custom URL scheme
• Invoked when scheme called
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Common Attack Vectors: Inter-process
Communication
• Suggest using lsdtrip to identify URL’s
• Use publicurls | privateurls option
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Inter-process Communication (Side Note)
• Malicious app could register your URL scheme
• [[UIApplication sharedApplication] openURL:myURL];
• Universal Links introduced in iOS 9
• Kills the openURL problem
• Developer specifies what URL’s will be processed by
app (association file)
• Communication over HTTPS
• No more enumerating apps via can canOpenURL
method
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Common Attack Vectors: Injection Attacks
• UIWebViews
• File-Handling Routine
• XML
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Summary: Usual Results
• Issues relating to Local Storage
– Keep in mind most of these attacks requires the device to be unlocked
• Unsecured API’s (via Burpsuite Pro)
• Some hard-coded secrets maybe (typically run strings against binary)
• The truth however is that most of these bugs closed
– Binary protections are now standard
– Data Protection API’s (keychain etc)
– Universal links introduced with iOS 9 address IPC loophole
– …...
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Additionally What Happens When?
• The common tools fail?
• Your Google Fu returns nothing?
• There are custom security protections in place
• You want to extend an existing tool?
• You want start investigating deeply hidden logic bugs
– Crypto functions etc
• Move beyond 3rd party applications
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Towards A “New” Approach
• At this point we need to take a different approach one that
involves Reverse Engineering and leverages knowledge of :
• iOS internals
• ARM(32/64) Assembly
• Deep dive into Objective-C/Swift
• …....
• Let’s improve our toolkit
• And expand our knowledge base
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Outline/Agenda
• Building A General Toolkit
• iOS Application Assessment 101
• The Reverse Engineer’s Toolkit
• Reverse Engineering iOS Applications
• Identifying and bypassing Simple Jailbreak
Detection Routines
• Conclusion
IOActive, Inc. Copyright ©2016. All Rights Reserved.
The Reverse Engineer’s Toolkit
• IDA Pro
• Hopper
• LLDB
• Jtool
• Procexp
• GNU Project Debugger (gdb)
• Apple CC Tools
IOActive, Inc. Copyright ©2016. All Rights Reserved.
The Reverse Engineer’s Toolkit: IDA Pro
IOActive, Inc. Copyright ©2016. All Rights Reserved.
The Reverse Engineer’s Toolkit: Hopper
IOActive, Inc. Copyright ©2016. All Rights Reserved.
The Reverse Engineer’s Toolkit: lldb
• Debugging an application binary with lldb
• iOS Device
1. debugserver -x backboard ip:port </path/to/executable>
• MAC Host
1. lldb
2. process connect connect://<remote_host>:<port>
3. image list –o –f (ASLR)
IOActive, Inc. Copyright ©2016. All Rights Reserved.
The Reverse Engineer’s Toolkit: lldb (contd.)
IOActive, Inc. Copyright ©2016. All Rights Reserved.
• Breakpoint = offset1 + offset2
• Or just use the symbols 
The Reverse Engineer’s Toolkit: lldb ASLR
(contd.)
1
2
IOActive, Inc. Copyright ©2016. All Rights Reserved.
The Reverse Engineer’s Toolkit: jtool
• otool type functionality with way more options
• MACH-O analysis (atos, dyldinfo, nm, strings etc)
• Multi-platform (OS X, iOS, Linux)
• ARM64 disassembler
IOActive, Inc. Copyright ©2016. All Rights Reserved.
The Reverse Engineer’s Toolkit: jtool (contd.)
IOActive, Inc. Copyright ©2016. All Rights Reserved.
The Reverse Engineer’s Toolkit: jtool (bonus)
IOActive, Inc. Copyright ©2016. All Rights Reserved.
The Reverse Engineer’s Toolkit: procexp
• Getting task related info
• Display threads, mach ports, dump core (memory image) etc..
IOActive, Inc. Copyright ©2016. All Rights Reserved.
The Reverse Engineer’s Toolkit: gdb
• Use source from http://cydia.radare.org
• No support for arm64 architectures
IOActive, Inc. Copyright ©2016. All Rights Reserved.
The Reverse Engineer’s Toolkit: filemon
• Tracing file system activity with FSEvents
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Apple’s CC Tools
• otool
• MACH-O Binary Swiss army knife
• nm
• Displays symbol table
• lipo
• Architectures embedded in binary
• Codesign
• Binary signing
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Outline/Agenda
• Building A General Toolkit
• iOS Application Assessment 101
• The Reverse Engineer’s Toolkit
• Reverse Engineering iOS Applications
• Identifying and bypassing Simple Jailbreak
Detection Routines
• Conclusion
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Reverse Engineering iOS Applications
(Under The Hood)
• Mach-O Binary Format
• Mach Tasks
• ARM(32/64)
• Objective-C
• Swift
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Mach-O Binary Format
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Application Binary
Version Location
< iOS 8 /var/mobile/Application/<app bundle id>
iOS 8 +
 /var/mobile/Containers/Bundle/Application/<app
bundle id>
 App binary, nibs, Code Signature
 /var/mobile/Containers/Data/Application/<app
bundle id>
 Documents, Library, tmp folder
iOS 9.3.x  /var/containers/Bundle/Application/<app bundle id>
 App binary
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Mach-O Binary
• Header – Identifies file type,
architecture etc
• Load Commands – Details layout
and linkage specifications
• Data – Code
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Mach-O: Header
<mach-o/loader.h>
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Mach-O: Flags
• PIE: Commonly checked flag during an assessment.
• ASLR for executable types
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Mach-O: Load Commands (Kernel)
• LC_SEGMENT[_64] main load command
– Memory regions with same r/w/x protection
<mach-o/loader.h>
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Mach-O: SEGMENTS
• __PAGEZERO(NULL pointer trap, all access permissions revoked )
• _TEXT(program code)
• _DATA (readable/writeable program data)
• _LINKEDIT (symbol and other tables used by linker)
• _RESTRICT (see dyld.cpp, will not load DYLD_INSERT_LIBRARIES)
• Optional sections
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Mach-O: Common Segments and Sections
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Mach-O: Viewing Segments and Sections
IOActive, Inc. Copyright ©2016. All Rights Reserved.
MachOView (GUI)
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Mach-O: Load Commands (dyld)
• Kernel hands off to DYLD(dynamic linker)
• Uses dynamic linker specified in LC_LOAD_DYLINKER
• Loads each LC_LOAD_DYLIB
• Resolves symbols
• Interposing (method switching)
• add __interpose section to __DATA SEGMENT
• Force library loading with DYLD_INSERT_LIBRARIES
• code with __attribute(constructor) auto runs
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Mach Tasks
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Mach Tasks
• At this point binary mapped into memory
• Process on other systems
• Port (IPC Endpoint)
• Own the port, own the task
• Mach Trap task_for_pid()
• Requires jailbreak tfp0 patch for kernel(PID0)
• processor_set_tasks()
• Any task port in system
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Mach Tasks – Interacting with the task
• Get the task port
• Read/write memory with mach_vm* api’s
• Inject your own shellcode
• Left to your imagination
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Mach Tasks – Owning The Port
* mach_vm_region returns information about a memory region in a given
address space.
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Mach Tasks – Dumping Memory
• Write your own code and call appropriate mach_vm* api’s
• Use procexp <pid> regions
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Mach Tasks – Dumping Memory
• Read using lldb (memory read –outfile <outfile> –count <size> <address>)
IOActive, Inc. Copyright ©2016. All Rights Reserved.
ARM Assembly
IOActive, Inc. Copyright ©2016. All Rights Reserved.
ARM32 - Registers
Register Purpose
R0 – R12 General purpose registers
R13 Stack pointer
R14 Link register. Holds return address during a
function call.
R15 Program counter (PC)
CPSR Information on current execution state
(Endianness bit, Thumb bit, Mode bit)
IOActive, Inc. Copyright ©2016. All Rights Reserved.
ARM32 – Function Calling Convention
• Functions are invoked via a B, BX, BL, BLX
Register Purpose
r0-r3  First four function parameters.
 Other arguments passed on stack
r0 Stores return value
IOActive, Inc. Copyright ©2016. All Rights Reserved.
ARM32 – Basic Loading Instructions
Register Purpose
LDR Loads a word.
Ex. LDR R3, [R0]
Loads the word value at R0 into R3
STR Stores a word.
Ex. STR R3, [R4]
Takes the value in R3 and stores at memory
address R4
• Arm is a load/store architecture
• Data must be loaded into registers before they can be used
IOActive, Inc. Copyright ©2016. All Rights Reserved.
ARM64 - Registers
Register Purpose
x0-x28 General purpose registers (64 bit)
w0-w30 General purpose registers (32 bit)
x29 Frame pointer
x30 Link register (return address)
SP Stack pointer
PC Program counter
IOActive, Inc. Copyright ©2016. All Rights Reserved.
ARM64 – Function Calling Convention
Register Purpose
x0-x7 Arguments/return values
x9-x15 Local variables
x19-x29 Callee-saved registers
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Objective-C
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Objective-C
• objc_msgSend
• Equivalent of calling functions in C
• id objc_msgSend(id self, SEL op,…)
• receiver(id self)
• selector(SEL op)
• Receiver is a pointer to class message is intended for
• Selector is the method to handle message
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Objective-C (contd.)
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Objective-C (contd.)
x0 – receiver
x1 – selector
x2 – argument
objc_msgSend – func call
-v –d objc retrieves info on
classes, methods etc
*ARM64
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Objective-C: Method Swizzling Under The
Hood
• objc_method struct holds information about method of a class
[/usr/include/objc/runtime.h]
• Hooking Frameworks [/Library/Frameworks/CydiaSubstrate.framework]
Member Description
method_name Method name
method_types Accepted parameters
method_imp Pointer to implementation
Swizzling just changes implementation using
underlying C functions:
• class_replaceMethod
• method_exchangeImplementations
• method_setImplementation
CydiaSubstrate:
• MSHookMessageEx
• MSHookFunction
IOActive, Inc. Copyright ©2016. All Rights Reserved.
CydiaSubstrate Method Swizzling
IOActive, Inc. Copyright ©2016. All Rights Reserved.
SWIFT
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Swift
• Introduced with iOS 8
• Still uses traditional message passing for Swift classes that inherit from
Objective-C classes
• Swift classes may use
• Direct function calls
• Vtables
• C++ like mangled function names
• Method Swizzling if subclass of NSObject
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Swift: Mangled Function Names
Swift Objective-C
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Swift: Mangled Function Names
• __TFC9jailbreak14ViewController12btnFileCheckfS0_FPSs9AnyObject_T_
– __T Swift Symbol
– F indicates function
– C indicates it is a function belonging to a class
– 9jailbreak module name prefixed with length
– 14ViewController class name prefixed with length
– 12btnFileCheck function name prefixed with length
– S0_FPSs no clue ?? 
– f function attribute
– 9AnyObject function parameter
– T_ return type
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Swift: demangle Tool
• See also hopper-swift-demangle plugin
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Outline/Agenda
• Building A General Toolkit
• iOS Application Assessment 101
• The Reverse Engineer’s Toolkit
• Reverse Engineering iOS Applications
• Identifying and bypassing Simple Jailbreak
Detection Routines
• Conclusion
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Disclaimer
• We will discuss binary patching next
• Yeah but I could do this with ?
• Yes there are several other options:
• xCon
• tsProtector
• Officer
• Tools discussed earlier(remember CydiaSubstrate
hooking with MSHookFunction)
• What happens when you can’t?
• Get comfortable reading/modifying ARM assembly
• Start with simple examples
IOActive, Inc. Copyright ©2016. All Rights Reserved.
But First A Note On Patching 101
• Replace instruction with NOP
• No Operation
• Change conditional instructions to unconditional ones
• BNE, BEQ, BLT….changes to just B etc
• Update the register that determines branch taken
• reg write <register> <value>
• p $<reg> = <value>
• Remove SEGMENT
• __RESTRICT
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Identifying and bypassing Simple Jailbreak
Detection Routines Case Study
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Case Study: Viewing File System Activity
• Using filemon -l
• Creates hard links to temporary files
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Case Study: Viewing Logs
• Using idevicesyslog [libimobiledevice]
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Case Study: Obtaining The Binary
• Dump the binary (facilitated by DYLD and DYLD_INSERT_LIBRARIES
environment variable)
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Case Study: Obtaining Symbols
• Dump the symbols along with dylib’s to which they belong
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Case Study: Extracting strings
• Any interesting strings?
• Dump cstring section (same as running strings)
• Knowledge of SEGMENTS and sections important
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Case Study: Extracting DYLIB’S
• procexp <pid> regions
Dump the library with lldb
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Case Study: Extracting DYLIB’S
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Case Study: Obtaining Classes
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Case Study: Bypassing RootFS Check
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Case Study: Bypassing RootFS Check
statfs func call
Patch here
statfs argument
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Case Study: Bypassing RootFS Check
Patch here
• Patch register w8
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Case Study: Bypassing RootFS Check
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Case Study: Bypassing Debugger Checks
Changes when
debugger attached
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Case Study: Bypassing Debugger Checks
(ppid)
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Case Study: Bypassing Debugger Checks
(ppid)
ppid func callPatch here
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Case Study: Bypassing Debugger Checks
(ppid)
• parent process id of calling process
Patch here
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Case Study: Bypassing Debugger Checks
(p_traced)
sysctl func call
Patch here
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Case Study: Bypassing Debugger Checks
(p_traced)
Patch here
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Case Study: Bypassing Fork Check
Call to fork
Return value in X0
Patch CMN W19, #1
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Case Study: Bypassing Fork Check
Patch here
IOActive, Inc. Copyright ©2016. All Rights Reserved.
Conclusion
• Common bugs being closed
• A “new” approach and break from the norm is required for in depth assessments
• Assembly knowledge a MUST for Reversing Engineering
– Low level assembly allows you to bypass many security protections, discover hidden gems and
then some
• Knowledge of iOS architecture will not only improve your assessments but also provide a
launching pad for other research
• Disassemblers are your friends (IDA, Hopper, Jtool …..)
• Add the reverse engineering skillset to your arsenal !!!
IOActive, Inc. Copyright ©2016. All Rights Reserved.
References
• Books:
• Mac OS X and iOS Internals To the Apple’s Core (Jonathan Levin)
• The Mobile Application Hacker’s Handbook (Dominic Chell, Tyrone Erasmus et al. )
• Hacking and Securing iOS Applications (Jonathan Zdziarski)
• iOS Application Security: The Definitive Guide for Hackers and Developers (David Thiel)
• Blogs and Tools:
• processor_set_tasks() - http://newosxbook.com/articles/PST2.html
• procexp – http://newosxbook.com/tools/procexp.html
• iOSBinaries - http://newosxbook.com/tools/iOSBinaries.html
• jtool - http://newosxbook.com/tools/jtool.html
• filemon - http://newosxbook.com/tools/filemon.html
• AmIBeingDebugged - https://developer.apple.com/library/mac/qa/qa1361/_index.html
• Frida - http://www.frida.re/
• Cycript - http://www.cycript.org/
• iFunBox - http://www.i-funbox.com/
• SSL Kill Switch – https://github.com/iSECPartners/ios-ssl-kill-switch
• BurpSuite - https://portswigger.net/burp/
• IDA - https://www.hex-rays.com/products/ida/
• Hopper - https://www.hopperapp.com/
• Idb - http://www.idbtool.com/
• PT_DENY_ATTACH - https://www.theiphonewiki.com/wiki/Bugging_Debuggers
• ARM - http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.den0024a/ch05s01s03.html
• SQLite-parser - https://github.com/mdegrazia/SQLite-Deleted-Records-Parser
• SQLite Deletion - http://www.zdziarski.com/blog/?p=6143
• lsdtrip - http://newosxbook.com/src.jl?tree=listings&file=ls.m#dumpURL

More Related Content

What's hot

iOS Application Exploitation
iOS Application ExploitationiOS Application Exploitation
iOS Application Exploitation
Positive Hack Days
 
Infosecurity.be 2019: What are relevant open source security tools you should...
Infosecurity.be 2019: What are relevant open source security tools you should...Infosecurity.be 2019: What are relevant open source security tools you should...
Infosecurity.be 2019: What are relevant open source security tools you should...
B.A.
 
The Internet of Insecure Things: 10 Most Wanted List
The Internet of Insecure Things: 10 Most Wanted ListThe Internet of Insecure Things: 10 Most Wanted List
The Internet of Insecure Things: 10 Most Wanted List
Security Weekly
 
The ABCs of Source-Assisted Web Application Penetration Testing With OWASP ZA...
The ABCs of Source-Assisted Web Application Penetration Testing With OWASP ZA...The ABCs of Source-Assisted Web Application Penetration Testing With OWASP ZA...
The ABCs of Source-Assisted Web Application Penetration Testing With OWASP ZA...
Denim Group
 
Breaking Secure Mobile Applications - Hack In The Box 2014 KL
Breaking Secure Mobile Applications - Hack In The Box 2014 KLBreaking Secure Mobile Applications - Hack In The Box 2014 KL
Breaking Secure Mobile Applications - Hack In The Box 2014 KL
iphonepentest
 
SANS @Night Talk: SQL Injection Exploited
SANS @Night Talk: SQL Injection ExploitedSANS @Night Talk: SQL Injection Exploited
SANS @Night Talk: SQL Injection Exploited
Micah Hoffman
 
Incident response before:after breach
Incident response before:after breachIncident response before:after breach
Incident response before:after breach
Sumedt Jitpukdebodin
 
Syntribos API Security Test Automation
Syntribos API Security Test AutomationSyntribos API Security Test Automation
Syntribos API Security Test Automation
Matthew Valdes
 
Is My App Secure ?
 Is My App Secure ? Is My App Secure ?
Is My App Secure ?
Herman Duarte
 
[Wroclaw #7] Why So Serial?
[Wroclaw #7] Why So Serial?[Wroclaw #7] Why So Serial?
[Wroclaw #7] Why So Serial?
OWASP
 
WordPress Security and Best Practices
WordPress Security and Best PracticesWordPress Security and Best Practices
WordPress Security and Best Practices
Robert Vidal
 
Owasp joy of proactive security
Owasp joy of proactive securityOwasp joy of proactive security
Owasp joy of proactive security
Scott Behrens
 
Tw noche geek quito webappsec
Tw noche geek quito   webappsecTw noche geek quito   webappsec
Tw noche geek quito webappsecThoughtworks
 
20+ Ways to Bypass Your macOS Privacy Mechanisms
20+ Ways to Bypass Your macOS Privacy Mechanisms20+ Ways to Bypass Your macOS Privacy Mechanisms
20+ Ways to Bypass Your macOS Privacy Mechanisms
SecuRing
 
Secure Node Code (workshop, O'Reilly Security)
Secure Node Code (workshop, O'Reilly Security)Secure Node Code (workshop, O'Reilly Security)
Secure Node Code (workshop, O'Reilly Security)
Guy Podjarny
 
Give Me Three Things: Anti-Virus Bypass Made Easy
Give Me Three Things: Anti-Virus Bypass Made EasyGive Me Three Things: Anti-Virus Bypass Made Easy
Give Me Three Things: Anti-Virus Bypass Made Easy
Security Weekly
 
AppSec Tel Aviv - OWASP Top 10 For JavaScript Developers
AppSec Tel Aviv - OWASP Top 10 For JavaScript Developers AppSec Tel Aviv - OWASP Top 10 For JavaScript Developers
AppSec Tel Aviv - OWASP Top 10 For JavaScript Developers
Lewis Ardern
 
The API Primer (OWASP AppSec Europe, May 2015)
The API Primer (OWASP AppSec Europe, May 2015)The API Primer (OWASP AppSec Europe, May 2015)
The API Primer (OWASP AppSec Europe, May 2015)
Greg Patton
 
My tryst with sourcecode review
My tryst with sourcecode reviewMy tryst with sourcecode review
My tryst with sourcecode review
Anant Shrivastava
 
OWASP Portland - OWASP Top 10 For JavaScript Developers
OWASP Portland - OWASP Top 10 For JavaScript DevelopersOWASP Portland - OWASP Top 10 For JavaScript Developers
OWASP Portland - OWASP Top 10 For JavaScript Developers
Lewis Ardern
 

What's hot (20)

iOS Application Exploitation
iOS Application ExploitationiOS Application Exploitation
iOS Application Exploitation
 
Infosecurity.be 2019: What are relevant open source security tools you should...
Infosecurity.be 2019: What are relevant open source security tools you should...Infosecurity.be 2019: What are relevant open source security tools you should...
Infosecurity.be 2019: What are relevant open source security tools you should...
 
The Internet of Insecure Things: 10 Most Wanted List
The Internet of Insecure Things: 10 Most Wanted ListThe Internet of Insecure Things: 10 Most Wanted List
The Internet of Insecure Things: 10 Most Wanted List
 
The ABCs of Source-Assisted Web Application Penetration Testing With OWASP ZA...
The ABCs of Source-Assisted Web Application Penetration Testing With OWASP ZA...The ABCs of Source-Assisted Web Application Penetration Testing With OWASP ZA...
The ABCs of Source-Assisted Web Application Penetration Testing With OWASP ZA...
 
Breaking Secure Mobile Applications - Hack In The Box 2014 KL
Breaking Secure Mobile Applications - Hack In The Box 2014 KLBreaking Secure Mobile Applications - Hack In The Box 2014 KL
Breaking Secure Mobile Applications - Hack In The Box 2014 KL
 
SANS @Night Talk: SQL Injection Exploited
SANS @Night Talk: SQL Injection ExploitedSANS @Night Talk: SQL Injection Exploited
SANS @Night Talk: SQL Injection Exploited
 
Incident response before:after breach
Incident response before:after breachIncident response before:after breach
Incident response before:after breach
 
Syntribos API Security Test Automation
Syntribos API Security Test AutomationSyntribos API Security Test Automation
Syntribos API Security Test Automation
 
Is My App Secure ?
 Is My App Secure ? Is My App Secure ?
Is My App Secure ?
 
[Wroclaw #7] Why So Serial?
[Wroclaw #7] Why So Serial?[Wroclaw #7] Why So Serial?
[Wroclaw #7] Why So Serial?
 
WordPress Security and Best Practices
WordPress Security and Best PracticesWordPress Security and Best Practices
WordPress Security and Best Practices
 
Owasp joy of proactive security
Owasp joy of proactive securityOwasp joy of proactive security
Owasp joy of proactive security
 
Tw noche geek quito webappsec
Tw noche geek quito   webappsecTw noche geek quito   webappsec
Tw noche geek quito webappsec
 
20+ Ways to Bypass Your macOS Privacy Mechanisms
20+ Ways to Bypass Your macOS Privacy Mechanisms20+ Ways to Bypass Your macOS Privacy Mechanisms
20+ Ways to Bypass Your macOS Privacy Mechanisms
 
Secure Node Code (workshop, O'Reilly Security)
Secure Node Code (workshop, O'Reilly Security)Secure Node Code (workshop, O'Reilly Security)
Secure Node Code (workshop, O'Reilly Security)
 
Give Me Three Things: Anti-Virus Bypass Made Easy
Give Me Three Things: Anti-Virus Bypass Made EasyGive Me Three Things: Anti-Virus Bypass Made Easy
Give Me Three Things: Anti-Virus Bypass Made Easy
 
AppSec Tel Aviv - OWASP Top 10 For JavaScript Developers
AppSec Tel Aviv - OWASP Top 10 For JavaScript Developers AppSec Tel Aviv - OWASP Top 10 For JavaScript Developers
AppSec Tel Aviv - OWASP Top 10 For JavaScript Developers
 
The API Primer (OWASP AppSec Europe, May 2015)
The API Primer (OWASP AppSec Europe, May 2015)The API Primer (OWASP AppSec Europe, May 2015)
The API Primer (OWASP AppSec Europe, May 2015)
 
My tryst with sourcecode review
My tryst with sourcecode reviewMy tryst with sourcecode review
My tryst with sourcecode review
 
OWASP Portland - OWASP Top 10 For JavaScript Developers
OWASP Portland - OWASP Top 10 For JavaScript DevelopersOWASP Portland - OWASP Top 10 For JavaScript Developers
OWASP Portland - OWASP Top 10 For JavaScript Developers
 

Similar to Beyond the 'cript practical i os reverse engineering lascon

Outsmarting SmartPhones
Outsmarting SmartPhonesOutsmarting SmartPhones
Outsmarting SmartPhones
saurabhharit
 
Android Penetration testing - Day 2
 Android Penetration testing - Day 2 Android Penetration testing - Day 2
Android Penetration testing - Day 2
Mohammed Adam
 
2a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 12a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 1
Sam Bowne
 
Ruxmon April 2014 - Introduction to iOS Penetration Testing
Ruxmon April 2014 - Introduction to iOS Penetration TestingRuxmon April 2014 - Introduction to iOS Penetration Testing
Ruxmon April 2014 - Introduction to iOS Penetration Testingeightbit
 
OWASP Melbourne - Introduction to iOS Application Penetration Testing
OWASP Melbourne - Introduction to iOS Application Penetration TestingOWASP Melbourne - Introduction to iOS Application Penetration Testing
OWASP Melbourne - Introduction to iOS Application Penetration Testingeightbit
 
CNIT 128 2. Analyzing iOS Applications (Part 1)
CNIT 128 2. Analyzing iOS Applications (Part 1)CNIT 128 2. Analyzing iOS Applications (Part 1)
CNIT 128 2. Analyzing iOS Applications (Part 1)
Sam Bowne
 
Hacking and Securing iOS Apps : Part 1
Hacking and Securing iOS Apps : Part 1Hacking and Securing iOS Apps : Part 1
Hacking and Securing iOS Apps : Part 1
Subhransu Behera
 
Owasp advanced mobile-application-code-review-techniques-v0.2
Owasp advanced mobile-application-code-review-techniques-v0.2Owasp advanced mobile-application-code-review-techniques-v0.2
Owasp advanced mobile-application-code-review-techniques-v0.2drewz lin
 
OSX/Pirrit: The blue balls of OS X adware
OSX/Pirrit: The blue balls of OS X adwareOSX/Pirrit: The blue balls of OS X adware
OSX/Pirrit: The blue balls of OS X adware
Amit Serper
 
Fernando Arnaboldi - Exposing Hidden Exploitable Behaviors Using Extended Dif...
Fernando Arnaboldi - Exposing Hidden Exploitable Behaviors Using Extended Dif...Fernando Arnaboldi - Exposing Hidden Exploitable Behaviors Using Extended Dif...
Fernando Arnaboldi - Exposing Hidden Exploitable Behaviors Using Extended Dif...
Codemotion
 
Hybrid app development with ionic
Hybrid app development with ionicHybrid app development with ionic
Hybrid app development with ionic
Wan Muzaffar Wan Hashim
 
Laying the Foundation for Ionic Platform Insights on Spark
Laying the Foundation for Ionic Platform Insights on SparkLaying the Foundation for Ionic Platform Insights on Spark
Laying the Foundation for Ionic Platform Insights on Spark
Ionic Security
 
Beginners guide on how to start exploring IoT 2nd session
Beginners  guide on how to start exploring IoT 2nd sessionBeginners  guide on how to start exploring IoT 2nd session
Beginners guide on how to start exploring IoT 2nd session
veerababu penugonda(Mr-IoT)
 
Web-App Remote Code Execution Via Scripting Engines
Web-App Remote Code Execution Via Scripting EnginesWeb-App Remote Code Execution Via Scripting Engines
Web-App Remote Code Execution Via Scripting Engines
c0c0n - International Cyber Security and Policing Conference
 
Intro to Ionic for Building Hybrid Mobile Applications
Intro to Ionic for Building Hybrid Mobile ApplicationsIntro to Ionic for Building Hybrid Mobile Applications
Intro to Ionic for Building Hybrid Mobile Applications
Sasha dos Santos
 
Monitoring Attack Surface to Secure DevOps Pipelines
Monitoring Attack Surface to Secure DevOps PipelinesMonitoring Attack Surface to Secure DevOps Pipelines
Monitoring Attack Surface to Secure DevOps Pipelines
Denim Group
 
EMC World 2016 12 Factor Apps FTW
EMC World 2016 12 Factor Apps FTWEMC World 2016 12 Factor Apps FTW
EMC World 2016 12 Factor Apps FTW
Tommy Trogden
 
P2 Introduction
P2 IntroductionP2 Introduction
P2 Introduction
irbull
 
Xamarin v.Now
Xamarin v.NowXamarin v.Now
Xamarin v.Now
Craig Dunn
 
Continuous integration by Rémy Virin
Continuous integration by Rémy VirinContinuous integration by Rémy Virin
Continuous integration by Rémy VirinCocoaHeads France
 

Similar to Beyond the 'cript practical i os reverse engineering lascon (20)

Outsmarting SmartPhones
Outsmarting SmartPhonesOutsmarting SmartPhones
Outsmarting SmartPhones
 
Android Penetration testing - Day 2
 Android Penetration testing - Day 2 Android Penetration testing - Day 2
Android Penetration testing - Day 2
 
2a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 12a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 1
 
Ruxmon April 2014 - Introduction to iOS Penetration Testing
Ruxmon April 2014 - Introduction to iOS Penetration TestingRuxmon April 2014 - Introduction to iOS Penetration Testing
Ruxmon April 2014 - Introduction to iOS Penetration Testing
 
OWASP Melbourne - Introduction to iOS Application Penetration Testing
OWASP Melbourne - Introduction to iOS Application Penetration TestingOWASP Melbourne - Introduction to iOS Application Penetration Testing
OWASP Melbourne - Introduction to iOS Application Penetration Testing
 
CNIT 128 2. Analyzing iOS Applications (Part 1)
CNIT 128 2. Analyzing iOS Applications (Part 1)CNIT 128 2. Analyzing iOS Applications (Part 1)
CNIT 128 2. Analyzing iOS Applications (Part 1)
 
Hacking and Securing iOS Apps : Part 1
Hacking and Securing iOS Apps : Part 1Hacking and Securing iOS Apps : Part 1
Hacking and Securing iOS Apps : Part 1
 
Owasp advanced mobile-application-code-review-techniques-v0.2
Owasp advanced mobile-application-code-review-techniques-v0.2Owasp advanced mobile-application-code-review-techniques-v0.2
Owasp advanced mobile-application-code-review-techniques-v0.2
 
OSX/Pirrit: The blue balls of OS X adware
OSX/Pirrit: The blue balls of OS X adwareOSX/Pirrit: The blue balls of OS X adware
OSX/Pirrit: The blue balls of OS X adware
 
Fernando Arnaboldi - Exposing Hidden Exploitable Behaviors Using Extended Dif...
Fernando Arnaboldi - Exposing Hidden Exploitable Behaviors Using Extended Dif...Fernando Arnaboldi - Exposing Hidden Exploitable Behaviors Using Extended Dif...
Fernando Arnaboldi - Exposing Hidden Exploitable Behaviors Using Extended Dif...
 
Hybrid app development with ionic
Hybrid app development with ionicHybrid app development with ionic
Hybrid app development with ionic
 
Laying the Foundation for Ionic Platform Insights on Spark
Laying the Foundation for Ionic Platform Insights on SparkLaying the Foundation for Ionic Platform Insights on Spark
Laying the Foundation for Ionic Platform Insights on Spark
 
Beginners guide on how to start exploring IoT 2nd session
Beginners  guide on how to start exploring IoT 2nd sessionBeginners  guide on how to start exploring IoT 2nd session
Beginners guide on how to start exploring IoT 2nd session
 
Web-App Remote Code Execution Via Scripting Engines
Web-App Remote Code Execution Via Scripting EnginesWeb-App Remote Code Execution Via Scripting Engines
Web-App Remote Code Execution Via Scripting Engines
 
Intro to Ionic for Building Hybrid Mobile Applications
Intro to Ionic for Building Hybrid Mobile ApplicationsIntro to Ionic for Building Hybrid Mobile Applications
Intro to Ionic for Building Hybrid Mobile Applications
 
Monitoring Attack Surface to Secure DevOps Pipelines
Monitoring Attack Surface to Secure DevOps PipelinesMonitoring Attack Surface to Secure DevOps Pipelines
Monitoring Attack Surface to Secure DevOps Pipelines
 
EMC World 2016 12 Factor Apps FTW
EMC World 2016 12 Factor Apps FTWEMC World 2016 12 Factor Apps FTW
EMC World 2016 12 Factor Apps FTW
 
P2 Introduction
P2 IntroductionP2 Introduction
P2 Introduction
 
Xamarin v.Now
Xamarin v.NowXamarin v.Now
Xamarin v.Now
 
Continuous integration by Rémy Virin
Continuous integration by Rémy VirinContinuous integration by Rémy Virin
Continuous integration by Rémy Virin
 

Recently uploaded

From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 

Recently uploaded (20)

From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 

Beyond the 'cript practical i os reverse engineering lascon

  • 1. IOActive, Inc. Copyright ©2016. All Rights Reserved. Beyond The ‘Cript: Practical iOS Reverse Engineering Michael Allen (@_dark_knight_) Security Consultant
  • 2. IOActive, Inc. Copyright ©2016. All Rights Reserved. Why This Talk? • Apps more hardened against common attacks • Bridge the gap • Deeper understanding of what happens under the hood • Foundation for additional research
  • 3. IOActive, Inc. Copyright ©2016. All Rights Reserved. Outline/Agenda • Building A General Toolkit • iOS Application Assessment 101 – Usual results – “New” approach • The Reverse Engineer’s Toolkit • Reverse Engineering iOS Applications • Mach-O Binary Format • Mach Tasks • ARM(32/64) • Objective-C • Swift • Identifying and bypassing Simple Jailbreak Detection Routines • Conclusion
  • 4. IOActive, Inc. Copyright ©2016. All Rights Reserved. Outline/Agenda • Building A General Toolkit • iOS Application Assessment 101 • The Reverse Engineer’s Toolkit • Reverse Engineering iOS Applications • Identifying and bypassing Simple Jailbreak Detection Routines • Conclusion
  • 5. IOActive, Inc. Copyright ©2016. All Rights Reserved. Building A General Toolkit • Jailbroken Device • File System • Network • Instrumentation • Automating Common Tasks • Essentials
  • 6. IOActive, Inc. Copyright ©2016. All Rights Reserved. Jailbroken Device • Removing software restrictions imposed by iOS, through the use of software exploits • Recommend dedicated device for testing • Latest jailbreak – Pangu (iOS 9.2 – 9.3.3 64-bit devices only)
  • 7. IOActive, Inc. Copyright ©2016. All Rights Reserved. Jailbroken Device (contd.) • Tethered • Does not persist across reboots • Requires computer to start device • Untethered • Persists on device across reboots • Semi-tethered • Requires computer to start into jailbroken state • Rebooting or starting device without assistance possible. But boots into non-jailbroken state
  • 8. IOActive, Inc. Copyright ©2016. All Rights Reserved. Jailbroken Device (ProTip) • Change default root password from alpine • Access device over usb using usbmuxd – sudo python tcprelay.py -t 22:22 • Generate ssh keys – ssh-keygen -t rsa -f ~/.ssh/ironman -N "” • Copy public key to device – ssh-copy-id -i ~/.ssh/ironman.pub root@localhost • Create an alias on (~/.ssh/config)
  • 9. IOActive, Inc. Copyright ©2016. All Rights Reserved. File System: Moving Files • iFunbox • iExplorer • Sftp
  • 10. IOActive, Inc. Copyright ©2016. All Rights Reserved. Network: BurpSuite Pro Intercepting Proxy
  • 11. IOActive, Inc. Copyright ©2016. All Rights Reserved. Network: SSL Kill Switch 2 • “Disables SSL certificate validation - including certificate pinning - within iOS Apps.”
  • 12. IOActive, Inc. Copyright ©2016. All Rights Reserved. Instrumentation: Cycript • Injects into target process • Interactive console • Objective-C and Javascript syntax • Supported Architectures(iOS, Mac OS X) • NowSecure fork where runtime powered by Frida* (Cycript on steroids)
  • 13. IOActive, Inc. Copyright ©2016. All Rights Reserved. Instrumentation: Cycript (contd.)
  • 14. IOActive, Inc. Copyright ©2016. All Rights Reserved. Instrumentation: Frida • Injects Google’s V8 engine into target process • Javascript executed with full access to memory • Function hooking • Access to native methods • Inject into starting process • Multiple architectures (Windows, Mac, Linux, iOS and Android)
  • 15. IOActive, Inc. Copyright ©2016. All Rights Reserved. • Method tracing Instrumentation: Frida (contd.)
  • 16. IOActive, Inc. Copyright ©2016. All Rights Reserved. Automating Common Tasks • Idb Tool - http://www.idbtool.com/ • Snoop-IT - http://repo.nesolabs.de/ • iRet - https://www.veracode.com/blog/2014/03/introducing-the-ios-reverse-engineering- toolkit • IntroSpy - https://github.com/iSECPartners/Introspy-iOS • AppMon - https://dpnishant.github.io/appmon/ • Needle - https://github.com/mwrlabs/needle • Varying levels of support
  • 17. IOActive, Inc. Copyright ©2016. All Rights Reserved. Automating Common Tasks: Idb Tool • Idb Tool • “idb is a tool to simplify some common tasks for iOS app security assessments and research.” • Provides general app info • URL Handler • Keychain dumping • Pasteboard • Logging
  • 18. IOActive, Inc. Copyright ©2016. All Rights Reserved. Automating Common Tasks: Idb Tool (contd.)
  • 19. IOActive, Inc. Copyright ©2016. All Rights Reserved. Essentials: Command Line Utilities • Command Line – BigBoss Recommended Tools (Cydia) – Erica Utilities (Cydia) – Jonathan Levin compiled a number of commonly used binaries for iOS
  • 20. IOActive, Inc. Copyright ©2016. All Rights Reserved. Essentials: iOSBinpack (Jonathan Levin) • Listing of available tools
  • 21. IOActive, Inc. Copyright ©2016. All Rights Reserved. Outline/Agenda • Building A General Toolkit • iOS Application Assessment 101 • The Reverse Engineer’s Toolkit • Reverse Engineering iOS Applications • Identifying and bypassing Simple Jailbreak Detection Routines • Conclusion
  • 22. IOActive, Inc. Copyright ©2016. All Rights Reserved. Common Attack Vectors: Sniffing On A Remote Virtual Interface
  • 23. IOActive, Inc. Copyright ©2016. All Rights Reserved. Common Attack Vectors: Sniffing On A Remote Virtual Interface (contd.)
  • 24. IOActive, Inc. Copyright ©2016. All Rights Reserved. Common Attack Vectors: Insecure Storage • Property list files (.plist) • SQLite databases • Keychain • Snapshots • Cache
  • 25. IOActive, Inc. Copyright ©2016. All Rights Reserved. Insecure Storage: Property Lists (.plist) • Stores serialized objects • Key value pairs • Maybe compacted to bplist (binary plist) – cat filename.plist | plutil -convert xml1 - -o -
  • 26. IOActive, Inc. Copyright ©2016. All Rights Reserved. Insecure Storage: Client-Side Data Stores • Often see SQLite being used for client-side storage • Lightweight client-side database • Query using SQL
  • 27. IOActive, Inc. Copyright ©2016. All Rights Reserved. Insecure Storage: Fun Fact About SQLite Data Stores • Delete doesn’t do what you think • Deleted data added to free list • Free records not overwritten until more space required • End result is data may not be overwritten for a while • May be recovered with SQLite-parser
  • 28. IOActive, Inc. Copyright ©2016. All Rights Reserved. Insecure Storage: Dumping The Keychain • SQLite database stored in /var/Keychains
  • 29. IOActive, Inc. Copyright ©2016. All Rights Reserved. Insecure Storage: Snapshots
  • 30. IOActive, Inc. Copyright ©2016. All Rights Reserved. Insecure Storage: Inspecting The Cache • Caches directory similar function to that of a web browser’s cache • Aimed at improving performance • May store web cache content
  • 31. IOActive, Inc. Copyright ©2016. All Rights Reserved. Insecure Storage: Dumping Binary Cookies • Created by URL loading system or webview • Stored on local file system in binary format.
  • 32. IOActive, Inc. Copyright ©2016. All Rights Reserved. Common Attack Vectors: Inter-process Communication • Application registers custom URL scheme • Invoked when scheme called
  • 33. IOActive, Inc. Copyright ©2016. All Rights Reserved. Common Attack Vectors: Inter-process Communication • Suggest using lsdtrip to identify URL’s • Use publicurls | privateurls option
  • 34. IOActive, Inc. Copyright ©2016. All Rights Reserved. Inter-process Communication (Side Note) • Malicious app could register your URL scheme • [[UIApplication sharedApplication] openURL:myURL]; • Universal Links introduced in iOS 9 • Kills the openURL problem • Developer specifies what URL’s will be processed by app (association file) • Communication over HTTPS • No more enumerating apps via can canOpenURL method
  • 35. IOActive, Inc. Copyright ©2016. All Rights Reserved. Common Attack Vectors: Injection Attacks • UIWebViews • File-Handling Routine • XML
  • 36. IOActive, Inc. Copyright ©2016. All Rights Reserved. Summary: Usual Results • Issues relating to Local Storage – Keep in mind most of these attacks requires the device to be unlocked • Unsecured API’s (via Burpsuite Pro) • Some hard-coded secrets maybe (typically run strings against binary) • The truth however is that most of these bugs closed – Binary protections are now standard – Data Protection API’s (keychain etc) – Universal links introduced with iOS 9 address IPC loophole – …...
  • 37. IOActive, Inc. Copyright ©2016. All Rights Reserved. Additionally What Happens When? • The common tools fail? • Your Google Fu returns nothing? • There are custom security protections in place • You want to extend an existing tool? • You want start investigating deeply hidden logic bugs – Crypto functions etc • Move beyond 3rd party applications
  • 38. IOActive, Inc. Copyright ©2016. All Rights Reserved. Towards A “New” Approach • At this point we need to take a different approach one that involves Reverse Engineering and leverages knowledge of : • iOS internals • ARM(32/64) Assembly • Deep dive into Objective-C/Swift • ….... • Let’s improve our toolkit • And expand our knowledge base
  • 39. IOActive, Inc. Copyright ©2016. All Rights Reserved. Outline/Agenda • Building A General Toolkit • iOS Application Assessment 101 • The Reverse Engineer’s Toolkit • Reverse Engineering iOS Applications • Identifying and bypassing Simple Jailbreak Detection Routines • Conclusion
  • 40. IOActive, Inc. Copyright ©2016. All Rights Reserved. The Reverse Engineer’s Toolkit • IDA Pro • Hopper • LLDB • Jtool • Procexp • GNU Project Debugger (gdb) • Apple CC Tools
  • 41. IOActive, Inc. Copyright ©2016. All Rights Reserved. The Reverse Engineer’s Toolkit: IDA Pro
  • 42. IOActive, Inc. Copyright ©2016. All Rights Reserved. The Reverse Engineer’s Toolkit: Hopper
  • 43. IOActive, Inc. Copyright ©2016. All Rights Reserved. The Reverse Engineer’s Toolkit: lldb • Debugging an application binary with lldb • iOS Device 1. debugserver -x backboard ip:port </path/to/executable> • MAC Host 1. lldb 2. process connect connect://<remote_host>:<port> 3. image list –o –f (ASLR)
  • 44. IOActive, Inc. Copyright ©2016. All Rights Reserved. The Reverse Engineer’s Toolkit: lldb (contd.)
  • 45. IOActive, Inc. Copyright ©2016. All Rights Reserved. • Breakpoint = offset1 + offset2 • Or just use the symbols  The Reverse Engineer’s Toolkit: lldb ASLR (contd.) 1 2
  • 46. IOActive, Inc. Copyright ©2016. All Rights Reserved. The Reverse Engineer’s Toolkit: jtool • otool type functionality with way more options • MACH-O analysis (atos, dyldinfo, nm, strings etc) • Multi-platform (OS X, iOS, Linux) • ARM64 disassembler
  • 47. IOActive, Inc. Copyright ©2016. All Rights Reserved. The Reverse Engineer’s Toolkit: jtool (contd.)
  • 48. IOActive, Inc. Copyright ©2016. All Rights Reserved. The Reverse Engineer’s Toolkit: jtool (bonus)
  • 49. IOActive, Inc. Copyright ©2016. All Rights Reserved. The Reverse Engineer’s Toolkit: procexp • Getting task related info • Display threads, mach ports, dump core (memory image) etc..
  • 50. IOActive, Inc. Copyright ©2016. All Rights Reserved. The Reverse Engineer’s Toolkit: gdb • Use source from http://cydia.radare.org • No support for arm64 architectures
  • 51. IOActive, Inc. Copyright ©2016. All Rights Reserved. The Reverse Engineer’s Toolkit: filemon • Tracing file system activity with FSEvents
  • 52. IOActive, Inc. Copyright ©2016. All Rights Reserved. Apple’s CC Tools • otool • MACH-O Binary Swiss army knife • nm • Displays symbol table • lipo • Architectures embedded in binary • Codesign • Binary signing
  • 53. IOActive, Inc. Copyright ©2016. All Rights Reserved. Outline/Agenda • Building A General Toolkit • iOS Application Assessment 101 • The Reverse Engineer’s Toolkit • Reverse Engineering iOS Applications • Identifying and bypassing Simple Jailbreak Detection Routines • Conclusion
  • 54. IOActive, Inc. Copyright ©2016. All Rights Reserved. Reverse Engineering iOS Applications (Under The Hood) • Mach-O Binary Format • Mach Tasks • ARM(32/64) • Objective-C • Swift
  • 55. IOActive, Inc. Copyright ©2016. All Rights Reserved. Mach-O Binary Format
  • 56. IOActive, Inc. Copyright ©2016. All Rights Reserved. Application Binary Version Location < iOS 8 /var/mobile/Application/<app bundle id> iOS 8 +  /var/mobile/Containers/Bundle/Application/<app bundle id>  App binary, nibs, Code Signature  /var/mobile/Containers/Data/Application/<app bundle id>  Documents, Library, tmp folder iOS 9.3.x  /var/containers/Bundle/Application/<app bundle id>  App binary
  • 57. IOActive, Inc. Copyright ©2016. All Rights Reserved. Mach-O Binary • Header – Identifies file type, architecture etc • Load Commands – Details layout and linkage specifications • Data – Code
  • 58. IOActive, Inc. Copyright ©2016. All Rights Reserved. Mach-O: Header <mach-o/loader.h>
  • 59. IOActive, Inc. Copyright ©2016. All Rights Reserved. Mach-O: Flags • PIE: Commonly checked flag during an assessment. • ASLR for executable types
  • 60. IOActive, Inc. Copyright ©2016. All Rights Reserved. Mach-O: Load Commands (Kernel) • LC_SEGMENT[_64] main load command – Memory regions with same r/w/x protection <mach-o/loader.h>
  • 61. IOActive, Inc. Copyright ©2016. All Rights Reserved. Mach-O: SEGMENTS • __PAGEZERO(NULL pointer trap, all access permissions revoked ) • _TEXT(program code) • _DATA (readable/writeable program data) • _LINKEDIT (symbol and other tables used by linker) • _RESTRICT (see dyld.cpp, will not load DYLD_INSERT_LIBRARIES) • Optional sections
  • 62. IOActive, Inc. Copyright ©2016. All Rights Reserved. Mach-O: Common Segments and Sections
  • 63. IOActive, Inc. Copyright ©2016. All Rights Reserved. Mach-O: Viewing Segments and Sections
  • 64. IOActive, Inc. Copyright ©2016. All Rights Reserved. MachOView (GUI)
  • 65. IOActive, Inc. Copyright ©2016. All Rights Reserved. Mach-O: Load Commands (dyld) • Kernel hands off to DYLD(dynamic linker) • Uses dynamic linker specified in LC_LOAD_DYLINKER • Loads each LC_LOAD_DYLIB • Resolves symbols • Interposing (method switching) • add __interpose section to __DATA SEGMENT • Force library loading with DYLD_INSERT_LIBRARIES • code with __attribute(constructor) auto runs
  • 66. IOActive, Inc. Copyright ©2016. All Rights Reserved. Mach Tasks
  • 67. IOActive, Inc. Copyright ©2016. All Rights Reserved. Mach Tasks • At this point binary mapped into memory • Process on other systems • Port (IPC Endpoint) • Own the port, own the task • Mach Trap task_for_pid() • Requires jailbreak tfp0 patch for kernel(PID0) • processor_set_tasks() • Any task port in system
  • 68. IOActive, Inc. Copyright ©2016. All Rights Reserved. Mach Tasks – Interacting with the task • Get the task port • Read/write memory with mach_vm* api’s • Inject your own shellcode • Left to your imagination
  • 69. IOActive, Inc. Copyright ©2016. All Rights Reserved. Mach Tasks – Owning The Port * mach_vm_region returns information about a memory region in a given address space.
  • 70. IOActive, Inc. Copyright ©2016. All Rights Reserved. Mach Tasks – Dumping Memory • Write your own code and call appropriate mach_vm* api’s • Use procexp <pid> regions
  • 71. IOActive, Inc. Copyright ©2016. All Rights Reserved. Mach Tasks – Dumping Memory • Read using lldb (memory read –outfile <outfile> –count <size> <address>)
  • 72. IOActive, Inc. Copyright ©2016. All Rights Reserved. ARM Assembly
  • 73. IOActive, Inc. Copyright ©2016. All Rights Reserved. ARM32 - Registers Register Purpose R0 – R12 General purpose registers R13 Stack pointer R14 Link register. Holds return address during a function call. R15 Program counter (PC) CPSR Information on current execution state (Endianness bit, Thumb bit, Mode bit)
  • 74. IOActive, Inc. Copyright ©2016. All Rights Reserved. ARM32 – Function Calling Convention • Functions are invoked via a B, BX, BL, BLX Register Purpose r0-r3  First four function parameters.  Other arguments passed on stack r0 Stores return value
  • 75. IOActive, Inc. Copyright ©2016. All Rights Reserved. ARM32 – Basic Loading Instructions Register Purpose LDR Loads a word. Ex. LDR R3, [R0] Loads the word value at R0 into R3 STR Stores a word. Ex. STR R3, [R4] Takes the value in R3 and stores at memory address R4 • Arm is a load/store architecture • Data must be loaded into registers before they can be used
  • 76. IOActive, Inc. Copyright ©2016. All Rights Reserved. ARM64 - Registers Register Purpose x0-x28 General purpose registers (64 bit) w0-w30 General purpose registers (32 bit) x29 Frame pointer x30 Link register (return address) SP Stack pointer PC Program counter
  • 77. IOActive, Inc. Copyright ©2016. All Rights Reserved. ARM64 – Function Calling Convention Register Purpose x0-x7 Arguments/return values x9-x15 Local variables x19-x29 Callee-saved registers
  • 78. IOActive, Inc. Copyright ©2016. All Rights Reserved. Objective-C
  • 79. IOActive, Inc. Copyright ©2016. All Rights Reserved. Objective-C • objc_msgSend • Equivalent of calling functions in C • id objc_msgSend(id self, SEL op,…) • receiver(id self) • selector(SEL op) • Receiver is a pointer to class message is intended for • Selector is the method to handle message
  • 80. IOActive, Inc. Copyright ©2016. All Rights Reserved. Objective-C (contd.)
  • 81. IOActive, Inc. Copyright ©2016. All Rights Reserved. Objective-C (contd.) x0 – receiver x1 – selector x2 – argument objc_msgSend – func call -v –d objc retrieves info on classes, methods etc *ARM64
  • 82. IOActive, Inc. Copyright ©2016. All Rights Reserved. Objective-C: Method Swizzling Under The Hood • objc_method struct holds information about method of a class [/usr/include/objc/runtime.h] • Hooking Frameworks [/Library/Frameworks/CydiaSubstrate.framework] Member Description method_name Method name method_types Accepted parameters method_imp Pointer to implementation Swizzling just changes implementation using underlying C functions: • class_replaceMethod • method_exchangeImplementations • method_setImplementation CydiaSubstrate: • MSHookMessageEx • MSHookFunction
  • 83. IOActive, Inc. Copyright ©2016. All Rights Reserved. CydiaSubstrate Method Swizzling
  • 84. IOActive, Inc. Copyright ©2016. All Rights Reserved. SWIFT
  • 85. IOActive, Inc. Copyright ©2016. All Rights Reserved. Swift • Introduced with iOS 8 • Still uses traditional message passing for Swift classes that inherit from Objective-C classes • Swift classes may use • Direct function calls • Vtables • C++ like mangled function names • Method Swizzling if subclass of NSObject
  • 86. IOActive, Inc. Copyright ©2016. All Rights Reserved. Swift: Mangled Function Names Swift Objective-C
  • 87. IOActive, Inc. Copyright ©2016. All Rights Reserved. Swift: Mangled Function Names • __TFC9jailbreak14ViewController12btnFileCheckfS0_FPSs9AnyObject_T_ – __T Swift Symbol – F indicates function – C indicates it is a function belonging to a class – 9jailbreak module name prefixed with length – 14ViewController class name prefixed with length – 12btnFileCheck function name prefixed with length – S0_FPSs no clue ??  – f function attribute – 9AnyObject function parameter – T_ return type
  • 88. IOActive, Inc. Copyright ©2016. All Rights Reserved. Swift: demangle Tool • See also hopper-swift-demangle plugin
  • 89. IOActive, Inc. Copyright ©2016. All Rights Reserved. Outline/Agenda • Building A General Toolkit • iOS Application Assessment 101 • The Reverse Engineer’s Toolkit • Reverse Engineering iOS Applications • Identifying and bypassing Simple Jailbreak Detection Routines • Conclusion
  • 90. IOActive, Inc. Copyright ©2016. All Rights Reserved. Disclaimer • We will discuss binary patching next • Yeah but I could do this with ? • Yes there are several other options: • xCon • tsProtector • Officer • Tools discussed earlier(remember CydiaSubstrate hooking with MSHookFunction) • What happens when you can’t? • Get comfortable reading/modifying ARM assembly • Start with simple examples
  • 91. IOActive, Inc. Copyright ©2016. All Rights Reserved. But First A Note On Patching 101 • Replace instruction with NOP • No Operation • Change conditional instructions to unconditional ones • BNE, BEQ, BLT….changes to just B etc • Update the register that determines branch taken • reg write <register> <value> • p $<reg> = <value> • Remove SEGMENT • __RESTRICT
  • 92. IOActive, Inc. Copyright ©2016. All Rights Reserved. Identifying and bypassing Simple Jailbreak Detection Routines Case Study
  • 93. IOActive, Inc. Copyright ©2016. All Rights Reserved. Case Study: Viewing File System Activity • Using filemon -l • Creates hard links to temporary files
  • 94. IOActive, Inc. Copyright ©2016. All Rights Reserved. Case Study: Viewing Logs • Using idevicesyslog [libimobiledevice]
  • 95. IOActive, Inc. Copyright ©2016. All Rights Reserved. Case Study: Obtaining The Binary • Dump the binary (facilitated by DYLD and DYLD_INSERT_LIBRARIES environment variable)
  • 96. IOActive, Inc. Copyright ©2016. All Rights Reserved. Case Study: Obtaining Symbols • Dump the symbols along with dylib’s to which they belong
  • 97. IOActive, Inc. Copyright ©2016. All Rights Reserved. Case Study: Extracting strings • Any interesting strings? • Dump cstring section (same as running strings) • Knowledge of SEGMENTS and sections important
  • 98. IOActive, Inc. Copyright ©2016. All Rights Reserved. Case Study: Extracting DYLIB’S • procexp <pid> regions Dump the library with lldb
  • 99. IOActive, Inc. Copyright ©2016. All Rights Reserved. Case Study: Extracting DYLIB’S
  • 100. IOActive, Inc. Copyright ©2016. All Rights Reserved. Case Study: Obtaining Classes
  • 101. IOActive, Inc. Copyright ©2016. All Rights Reserved. Case Study: Bypassing RootFS Check
  • 102. IOActive, Inc. Copyright ©2016. All Rights Reserved. Case Study: Bypassing RootFS Check statfs func call Patch here statfs argument
  • 103. IOActive, Inc. Copyright ©2016. All Rights Reserved. Case Study: Bypassing RootFS Check Patch here • Patch register w8
  • 104. IOActive, Inc. Copyright ©2016. All Rights Reserved. Case Study: Bypassing RootFS Check
  • 105. IOActive, Inc. Copyright ©2016. All Rights Reserved. Case Study: Bypassing Debugger Checks Changes when debugger attached
  • 106. IOActive, Inc. Copyright ©2016. All Rights Reserved. Case Study: Bypassing Debugger Checks (ppid)
  • 107. IOActive, Inc. Copyright ©2016. All Rights Reserved. Case Study: Bypassing Debugger Checks (ppid) ppid func callPatch here
  • 108. IOActive, Inc. Copyright ©2016. All Rights Reserved. Case Study: Bypassing Debugger Checks (ppid) • parent process id of calling process Patch here
  • 109. IOActive, Inc. Copyright ©2016. All Rights Reserved. Case Study: Bypassing Debugger Checks (p_traced) sysctl func call Patch here
  • 110. IOActive, Inc. Copyright ©2016. All Rights Reserved. Case Study: Bypassing Debugger Checks (p_traced) Patch here
  • 111. IOActive, Inc. Copyright ©2016. All Rights Reserved. Case Study: Bypassing Fork Check Call to fork Return value in X0 Patch CMN W19, #1
  • 112. IOActive, Inc. Copyright ©2016. All Rights Reserved. Case Study: Bypassing Fork Check Patch here
  • 113. IOActive, Inc. Copyright ©2016. All Rights Reserved. Conclusion • Common bugs being closed • A “new” approach and break from the norm is required for in depth assessments • Assembly knowledge a MUST for Reversing Engineering – Low level assembly allows you to bypass many security protections, discover hidden gems and then some • Knowledge of iOS architecture will not only improve your assessments but also provide a launching pad for other research • Disassemblers are your friends (IDA, Hopper, Jtool …..) • Add the reverse engineering skillset to your arsenal !!!
  • 114. IOActive, Inc. Copyright ©2016. All Rights Reserved. References • Books: • Mac OS X and iOS Internals To the Apple’s Core (Jonathan Levin) • The Mobile Application Hacker’s Handbook (Dominic Chell, Tyrone Erasmus et al. ) • Hacking and Securing iOS Applications (Jonathan Zdziarski) • iOS Application Security: The Definitive Guide for Hackers and Developers (David Thiel) • Blogs and Tools: • processor_set_tasks() - http://newosxbook.com/articles/PST2.html • procexp – http://newosxbook.com/tools/procexp.html • iOSBinaries - http://newosxbook.com/tools/iOSBinaries.html • jtool - http://newosxbook.com/tools/jtool.html • filemon - http://newosxbook.com/tools/filemon.html • AmIBeingDebugged - https://developer.apple.com/library/mac/qa/qa1361/_index.html • Frida - http://www.frida.re/ • Cycript - http://www.cycript.org/ • iFunBox - http://www.i-funbox.com/ • SSL Kill Switch – https://github.com/iSECPartners/ios-ssl-kill-switch • BurpSuite - https://portswigger.net/burp/ • IDA - https://www.hex-rays.com/products/ida/ • Hopper - https://www.hopperapp.com/ • Idb - http://www.idbtool.com/ • PT_DENY_ATTACH - https://www.theiphonewiki.com/wiki/Bugging_Debuggers • ARM - http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.den0024a/ch05s01s03.html • SQLite-parser - https://github.com/mdegrazia/SQLite-Deleted-Records-Parser • SQLite Deletion - http://www.zdziarski.com/blog/?p=6143 • lsdtrip - http://newosxbook.com/src.jl?tree=listings&file=ls.m#dumpURL

Editor's Notes

  1. Bridge gap: between the mundane methodologies and vulnerabilities and a new approach that finds additional bugs that require assembly knowledge to discover. 
  2. See also iExplorer
  3. Exercise caution May not be compatible with tweaks and you may end up losing jb Copy binary you need
  4. UDID from itunes
  5. Often stores Application preferences in /Library/Preferences using NSDefaults class
  6. Application uses UIWebView to render content.
  7. Application registers custom URL scheme Application invoked when scheme is called Recall bug in Skype that allowed calls via protocol handler without users consent
  8. Application registers custom URL scheme Application invoked when scheme is called Recall bug in Skype that allowed calls via protocol handler without users consent
  9. Remote iOS Debugger plugin Allows users to debug iOS target applications directly from IDA
  10. debugserver not configured on device by default attach device to Xcode enable debugging thin binary for your device slap on entitlements See paper at end for details on configuration
  11. All processes share the same copy of dyld_shared_cache - It’s only loaded once
  12. XNU BSD – files, processes etc MACH microkernel – task, memory, IPC primitives IOKIT – Kernel Extensions ELF – Extensible and Library Format
  13. https://opensource.apple.com/tarballs/xnu/
  14. Kernel - Allocate virtual memory - Create main thread - Code Signing - Encryption LC_SEGMENT instructs the kernel how to set up the memory space of the newly run process. “segments” are directly loaded from the Mach-O binary into memory. Kernel loader bsd/kern/mach_loader.c
  15. Memory regions with same r/w/x protection _RESTRICT with _restrict section __PAGEZERO - 32 bit systems corresponds to single page of memory (4KB) - 64 bit systems entire 32-bit address space or first 4GB - All access permissions revoked
  16. LC_UNIXTHREAD/LC_MAIN defines entry point LC_ENCRYPTION_INFO LC_CODE_SIGNATURE
  17. LC_UNIXTHREAD/LC_MAIN defines entry point LC_ENCRYPTION_INFO LC_CODE_SIGNATURE
  18. Interposing inject/replace functions See DYLD_INSERT_LIBRARIES used by dumpdecrytped
  19. XNU Kernel is at heart of OSX/iOS Heart of XNU is MACH microkernel processor_set_tasks – Controls processor group (usually cores on single CPU) XNU abstraction to scale to multiprocessors/multicores architectures. Trap is an exception by executing special instruction
  20. CPSR – Current Program Status Register ARM – instructions are 32 bits wide THUMB – 16/32 bits wide PC – Like EIP/RIP Stack Pointer - ESP
  21. Load store architecture
  22. Plugin for Hopper that automates this https://github.com/keith/hopper-swift-demangle
  23. TBNZ test the bit to determine if i
  24. A process ID value of 1 indicates that there is no parent process associated with the calling process.
  25. A process ID value of 1 indicates that there is no parent process associated with the calling process.
  26. sysctl - Get or set kernel state CTL_KERN - top-level name for kernel-specific information KERN_PROC - Indicates that sysctl will return a struct with process entries. KERN_PROC_PID - specifies that the target process will be selected based on a process ID (PID). - Finally, the last item is the PID of that process.