Overview
Static analysis involves examining an iOS application without executing it. This technique allows you to understand app structure, identify vulnerabilities, and analyze code logic before runtime.Static analysis is non-invasive and leaves no traces on the device, making it ideal for initial reconnaissance.
Disassembly and Decompilation
Using Hopper Disassembler
Hopper is a powerful tool for disassembling iOS binaries and generating pseudo-code.Load in Hopper
Open the binary in Hopper and wait for analysis to complete. This may take several minutes for large applications.
Ghidra for iOS Analysis
Ghidra is a free alternative with powerful analysis capabilities.Setting up Ghidra for iOS
Setting up Ghidra for iOS
- Install Ghidra and the iOS loader plugin
- Create a new project and import the Mach-O binary
- Run auto-analysis (Analysis > Auto Analyze)
- Use the Decompiler window (Window > Decompiler)
Enable the “Objective-C” analyzer for better class and method recognition.
Reading Assembly Code
ARM64 Assembly Basics
Modern iOS devices use ARM64 architecture. Understanding key instructions is essential.Data Movement
mov- Move data between registersldr- Load from memorystr- Store to memoryadrp- Load page address
Branching
b- Unconditional branchbl- Branch with link (call)ret- Return from functioncbz/cbnz- Conditional branches
Arithmetic
add/sub- Addition/Subtractionmul- Multiplicationcmp- Compare valuesand/orr- Logical operations
Objective-C Runtime
_objc_msgSend- Method calls_objc_retain/_objc_release- Memory management_objc_getClass- Class lookup
Practical Example: Finding Authentication Logic
- Scenario
- Approach
- Assembly Analysis
You need to understand how an app validates premium subscriptions.
Identifying Security Vulnerabilities
Common Vulnerability Patterns
Hardcoded Credentials
Hardcoded Credentials
Search for suspicious string patterns:Look for:
- API keys in plaintext
- Default passwords
- Encryption keys
- Authentication tokens
Insecure Data Storage
Insecure Data Storage
Check for usage of insecure storage mechanisms:
NSUserDefaultsfor sensitive data- Unencrypted
plistfiles - World-readable files in Documents directory
Weak Cryptography
Weak Cryptography
Identify weak or custom crypto implementations:Red flags:
- Custom encryption algorithms
- ECB mode encryption
- Hardcoded IV values
- MD5/SHA1 for password hashing
Jailbreak Detection
Jailbreak Detection
Identifying jailbreak detection helps you bypass it:Common detection methods:
- File existence checks (
/Applications/Cydia.app) - Fork() system call
- Symbolic link verification
- Sandbox integrity checks
String Analysis
Extracting Strings
Strings often reveal critical information about app functionality.Finding String References
Find cross-references
In Hopper or Ghidra:
- Navigate to the Strings section
- Find your target string
- View cross-references (X-refs) to see where it’s used
URL and Endpoint Discovery
- API Endpoints
- URL Schemes
- Info.plist Analysis
- API base URLs
- Analytics endpoints
- Debug/staging servers
- Third-party integrations
Practical Workflow
Initial Reconnaissance
- Extract IPA and identify target binary
- Run
file,otool, andstringsfor basic info - Extract Info.plist and analyze configurations
Load in Disassembler
- Import binary into Hopper or Ghidra
- Wait for auto-analysis to complete
- Export class dumps for reference
String Analysis
- Search for relevant keywords
- Map string references to functionality
- Document API endpoints and secrets
Code Analysis
- Navigate to target methods
- Generate pseudo-code
- Document control flow and logic
- Identify vulnerabilities
Static analysis complete when you have:
- Understanding of app architecture
- List of interesting methods and classes
- Identified potential vulnerabilities
- API endpoints and authentication mechanisms
- Targets for dynamic analysis
Advanced Techniques
Class-dump Analysis
Generate Objective-C headers from the binary:Class dumps provide a clean view of all classes, methods, and properties without assembly.
Control Flow Analysis
Use Ghidra’s function graph view to:- Visualize execution paths
- Identify error handling
- Find unused/dead code
- Understand complex conditionals
Binary Diffing
Compare different versions to find changes:Resources
Hopper
Commercial disassembler for macOS
Ghidra
NSA’s free reverse engineering tool
class-dump
Generate Objective-C headers
ARM64 Reference
Official ARM architecture documentation