iOS Reverse Engineering Deep Dive
Mobile Reverse Engineering Tools & Techniques · Mobile Application Security track
11 min read
In this module
The FairPlay Wall
Every binary you pull from the App Store ships encrypted with Apple's FairPlay DRM. Most of the Mach-O's __TEXT segment, the executable code, is ciphertext on disk: the byte range that cryptoff and cryptsize describe below, which skips the headers and load commands. When iOS launches the app, the kernel decrypts that range into process memory. So Ghidra and Hopper see nothing useful in a fresh IPA. Decryption is step zero of any iOS reverse engineering session.
Checking for Encryption
The LC_ENCRYPTION_INFO_64 load command in the Mach-O header indicates whether the binary is encrypted:
# Check encryption status with otool$ otool -l Payload/MyApp.app/MyApp | grep -A4 LC_ENCRYPTION
cmd LC_ENCRYPTION_INFO_64 cmdsize 24 cryptoff 16384 cryptsize 2031616 cryptid 1cryptid = 1 means encrypted, 0 means decrypted. A successful dump flips it to 0.
Extracting Decrypted Binaries
Getting at the plaintext means running the app on a jailbroken device (or one with the process debugging entitlement) and snapshotting the decrypted region out of memory. The usual suspects:
- frida-ios-dump: Frida-based. Attaches to the running process, reads the decrypted
__TEXTsegment, and writes it back to disk withcryptidcleared. - bagbak: a newer Frida tool that handles frameworks and app extensions without you having to script it.
- flexdecrypt: runs on-device and uses the private
mremap_encryptedAPI to decrypt without injecting anything.
There's also a route that skips the jailbroken phone. Apple Silicon Macs run many App Store iPhone apps natively (unless the developer opted out of Mac availability), and the FairPlay-decrypted pages sit in a Mac process you can read. Tools such as appdecrypt did this with SIP left on up to macOS 11.3; on later macOS releases you'll need System Integrity Protection relaxed so you can attach to the process.
# Dump a decrypted IPA using frida-ios-dump$ python3 dump.py com.example.app
# The output is a decrypted IPA ready for static analysis# Verify decryption succeeded:$ otool -l Payload/MyApp.app/MyApp | grep cryptid cryptid 0App Store binaries are encrypted with FairPlay DRM. The __TEXT segment is decrypted by the kernel only at load time. Before any static analysis can begin, the binary must be dumped from a running process on a jailbroken device. Tools like frida-ios-dump and bagbak automate this by reading decrypted memory and producing a clean Mach-O binary.
class-dump and dsdump
Objective-C binaries are stuffed with runtime metadata — class names, method signatures, property declarations, protocol conformances. The runtime needs all of it for dynamic dispatch. Two tools dig that metadata back out as header files.
class-dump
Steve Nygard's class-dump is the original. It parses the Objective-C metadata sections of a Mach-O and prints clean headers:
$ class-dump Payload/MyApp.app/MyApp > headers.hYou get every Objective-C class declaration, instance variable, property, and method signature. It's a quicker route to understanding an app's architecture than any disassembler can match:
// Example class-dump output@interface BBAuthenticationManager : NSObject
@property (nonatomic, strong) NSString *accessToken;@property (nonatomic, strong) NSString *refreshToken;@property (nonatomic, assign) BOOL isAuthenticated;
- (void)loginWithUsername:(NSString *)username password:(NSString *)password completion:(void (^)(BOOL, NSError *))handler;- (void)refreshTokenIfNeeded;- (BOOL)validateCertificateChain:(NSArray *)chain;
@endA header dump like this points straight at authentication flows, certificate validation, and sensitive data storage. You haven't opened a disassembler yet.
dsdump
dsdump was the modern heir to class-dump. It handles Swift metadata too, and it's noticeably faster on large binaries. Its GitHub repository was archived in December 2025, though, so expect it to lag behind newer Swift metadata formats:
# Dump Objective-C headers$ dsdump --objc Payload/MyApp.app/MyApp
# Dump Swift type information$ dsdump --swift Payload/MyApp.app/MyAppObjective-C binaries embed class names, method signatures, and property declarations as runtime metadata required for dynamic dispatch. Tools like class-dump and dsdump extract this metadata into readable header files, revealing an app's entire class hierarchy and API surface without disassembly. This is the single most efficient first step in iOS reverse engineering.
Hopper Disassembler
Hopper is a macOS-native disassembler and decompiler purpose-built for Mach-O. Ghidra is free and capable on iOS binaries, and both Ghidra and IDA now ship their own Objective-C and Swift analysers, so the gap has narrowed. Hopper's appeal is that it's light, fast and Mac-native, with these Apple-specific conveniences out of the box:
- Native Objective-C support: Hopper resolves
objc_msgSendcalls to show the real selector being invoked, turning opaque function-pointer calls into readable method names. - Pseudo-code generation: a C-ish pseudo-code view. Less polished than Ghidra's decompiler, much faster, and plenty useful for quick passes.
- Inline string references: string constants attached to Objective-C selectors show up inline in the disassembly.
Navigating Objective-C in Hopper
Every Objective-C method call funnels through objc_msgSend, which takes the receiver and a selector. In raw disassembly, every call site looks identical:
; Raw ARM64 disassembly - hard to readadrp x8, #selector_ref_loginWithUsername_password_completion_@PAGEldr x1, [x8, #selector_ref_loginWithUsername_password_completion_@PAGEOFF]bl _objc_msgSendHopper resolves these references and presents a more readable view:
; Hopper's resolved view[BBAuthenticationManager loginWithUsername:x2 password:x3 completion:x4]That little bit of resolution turns ARM64 disassembly from a sea of opaque calls into something that reads almost like the original Objective-C.
Ghidra for iOS
Ghidra (the NSA's open-source reversing framework) handles Mach-O binaries well, and it covers ground Hopper doesn't.
Loading a Mach-O Binary
When you import a decrypted iOS binary into Ghidra:
- Pick the right language: AARCH64:LE:64:AppleSilicon (or AARCH64:LE:64:v8A for older targets).
- Tick the Objective-C boxes under auto-analysis.
- Let auto-analysis finish. Big binaries can take several minutes.
- Ghidra resolves the Objective-C metadata, names the classes, and annotates
objc_msgSendcalls inline.
Handling Objective-C Metadata
Ghidra parses __objc_classlist, __objc_methnames, and __objc_selrefs to rebuild the class hierarchy. After analysis, the Symbol Tree lists every Objective-C class and method by name, so navigation is mostly a matter of clicking around.
// Ghidra decompiler output for an ObjC methodvoid _BBAuthenticationManager_validateCertificateChain_( id self, SEL selector, NSArray *chain){ // Decompiled implementation visible here int count = objc_msgSend(chain, "count"); if (count < 2) { return 0; // Reject chains with fewer than 2 certificates } // ... continued validation logic}Which tool to reach for depends on what you're holding. Work down the tree from a freshly pulled binary:
Swift Reverse Engineering
Swift breaks most of the assumptions you'd carry over from Objective-C. Where Objective-C is built on dynamic dispatch and lavish runtime metadata, Swift prefers static dispatch and stricter typing. That alone changes the reversing experience top to bottom.
Name Mangling
Swift uses name mangling to bake type information into symbol names. A simple method ends up looking like:
_$s5MyApp12CryptoHelperC7decryptySS10Foundation4DataVFThat string encodes the module (MyApp), the class (CryptoHelper), the method (decrypt), parameter types, and return type. swift-demangle (bundled with Xcode) reverses it:
$ swift-demangle '_$s5MyApp12CryptoHelperC7decryptySS10Foundation4DataVF'MyApp.CryptoHelper.decrypt(Foundation.Data) -> Swift.StringGhidra ships a Swift demangler that resolves these symbols automatically during analysis.
Most of the scheme is plain length-prefixed identifiers (5MyApp is five characters of name), with single letters marking what kind of thing each name is and two-letter shorthands for standard library types. This toy walker knows only a handful of those, which is enough to read the three symbols below, all taken from a real swiftc build.
Witness Tables and Protocol Conformance
Swift's protocol-oriented design leans on witness tables — jump tables mapping protocol requirements to their concrete implementations. Whenever a type conforms to a protocol, the compiler emits a witness table full of function pointers to each protocol method.
In a reverse-engineering pass, witness tables show up as arrays of function pointers in the __swift5_proto section. You need to understand them to figure out which concrete implementation gets called when code is working through a protocol-typed value.
Practical Implications
Reversing Swift is just plain harder than Objective-C, and there are a few reasons stacked on top of each other:
- Skinnier runtime metadata: pure Swift classes that don't inherit from
NSObjectskip the rich Objective-C metadata class-dump loves. - Static dispatch: a lot of method calls get resolved at compile time and inlined. Nothing to hook at runtime.
- Value types: Swift structs travel by value and can spread across registers, which makes parameter reconstruction tedious.
- Generics: generic specialisation produces multiple compiled flavours of the same function, multiplying the surface you have to read.
Reversing Swift is meaningfully harder than reversing Objective-C. Mangled symbol names encode type information but go on forever. Static dispatch and inlining strip away hookable symbols. Value types fragment across registers. Protocol witness tables replace virtual method tables. Use swift-demangle for symbol resolution and budget extra time in the disassembler.
Entitlements and Provisioning Profiles
iOS apps declare their permissions and capabilities through entitlements — key-value pairs baked into the code signature. Reading them lays out what the app is allowed to do, and it tends to surface configurations that matter to a security review.
# Extract entitlements from a signed binary$ codesign -d --entitlements - Payload/MyApp.app
# Example output:# <key>com.apple.developer.associated-domains</key># <array># <string>applinks:example.com</string># </array># <key>keychain-access-groups</key># <array># <string>TEAMID.com.example.app.shared</string># </array># <key>com.apple.developer.networking.vpn.api</key># <array># <string>allow-vpn</string># </array>Entitlements worth pulling apart during a review:
- keychain-access-groups: which keychain items the app can read. Shared groups across apps mean shared data.
- com.apple.developer.associated-domains: Universal Link and App Clip domains. The app's web-to-app surface, in one list.
- aps-environment: push notification environment, dev or prod.
- com.apple.security.application-groups: shared containers between the app and its extensions.
The provisioning profile (embedded.mobileprovision) contains the team identifier, allowed entitlements, device UDIDs (for development profiles), and expiration date. It can be inspected with:
# Decode the provisioning profile$ security cms -D -i Payload/MyApp.app/embedded.mobileprovisionApple signs provisioning profiles and they can't be forged. They can, however, tell you the development team, the distribution channel (ad-hoc, enterprise, App Store), and any unusual entitlements worth a closer look.
iOS entitlements declare an app's capabilities: keychain access groups, associated domains, push notification environments, and shared containers. Extracting entitlements with codesign reveals the app's permission surface and inter-app communication channels. The provisioning profile adds context about the development team and distribution method. Together, they form a critical part of the static analysis phase.