Environment Setup
This guide will walk you through setting up a complete iOS reverse engineering environment, from installing Ghidra to configuring the custom scripts from this repository.Before proceeding, ensure you’ve reviewed the prerequisites and have the necessary background knowledge and software installed.
Installing Ghidra
Ghidra is your primary tool for static analysis of iOS binaries.Install Java
Ghidra requires Java 11 or later.Verify Java installation:If Java is not installed, download from Adoptium.net or use your package manager:
- macOS
- Linux
- Windows
Download Ghidra
Download the latest stable release from the official website:Download Ghidra →Extract the archive to your preferred location:
Installing Swift Demangler
The Swift Name Demangler script requires Swift to be installed on your system.- macOS
- Linux
- Windows
Swift comes pre-installed with XcodeIf you have Xcode installed, you already have Swift:If not installed, install Xcode Command Line Tools:
Getting the Repository Scripts
Clone or download the iOS Reverse Engineering repository to access the Ghidra scripts.Clone the Repository
SwiftNameDemangler.py- Demangles Swift symbolsSwizzlingDetector.py- Detects method swizzlingObfuscatedAppExamples/- Example IPA files
Locate Ghidra Scripts Directory
Create or locate your Ghidra scripts directory:Default locations:
- macOS/Linux:
~/ghidra_scripts/ - Windows:
%USERPROFILE%\ghidra_scripts\
Getting Example IPA Files
The repository includes example iOS applications demonstrating various obfuscation techniques.NoTampering.ipa
Baseline application without obfuscation. Use this to understand normal iOS binary structure.
ObjectiveSwizzling.ipa
Demonstrates Objective-C method swizzling. Perfect for testing the SwizzlingDetector script.
ControlFlowFlattening.ipa
Shows control flow obfuscation. Useful for understanding advanced obfuscation techniques.
ObfuscatedAppExamples/ directory of the repository.
Extracting and Loading IPA Files
IPA files are essentially ZIP archives containing the iOS application bundle.Locate the Mach-O Binary
Navigate to the app bundle and find the executable:The main executable typically has the same name as the app (without extension).
Import into Ghidra
In Ghidra:
- Create a new project: File → New Project
- Select Non-Shared Project and choose a location
- Import the binary: File → Import File
- Navigate to and select the Mach-O executable
- Ghidra will auto-detect the format as Mach-O
- Click OK to import with default settings
Using the Ghidra Scripts
Now that your environment is set up, learn how to use the custom scripts.Swift Name Demangler
This script automatically renames mangled Swift symbols to human-readable names.Open Script Manager
In Ghidra’s CodeBrowser: Window → Script ManagerOr press Ctrl+Shift+E (Windows/Linux) or Cmd+Shift+E (macOS)
Find SwiftNameDemangler.py
Use the filter box to search for “Swift” or browse the script list.The script should appear with:
- Category: Swift
- Author: LaurieWired
Swizzling Detector
This script detects method swizzling by finding references to runtime manipulation functions.Analyze Results
If swizzling is detected:Navigate to these addresses in Ghidra to examine the swizzling implementation.If no swizzling found:
Investigate Swizzling Locations
For each reference address:
- Click Navigation → Go To… (or press G)
- Enter the address
- Examine the surrounding code to understand what methods are being swizzled
- Original method being stored
- New implementation being set
- Reason for the swizzling (logging, modification, etc.)
Workflow Example
Putting it all together with a complete analysis workflow:Demangle Swift Symbols
Run SwiftNameDemangler.py to make the binary more readable.Wait for completion, then browse the function list to see demangled names.
Detect Runtime Manipulation
Run SwizzlingDetector.py to find any swizzling.Take note of all reference addresses.
Manual Analysis
Navigate to interesting functions:
- Entry point (
mainor iOS lifecycle methods) - Swizzling implementations
- Suspicious or obfuscated functions
Troubleshooting
Swift Demangler Not Working
Swift Demangler Not Working
Symptoms: Script fails or doesn’t demangle namesSolutions:
- Verify Swift is installed:
swift-demangle --version(orxcrun swift-demangle --versionon macOS) - Check the script is using the correct command for your OS
- On Linux, ensure Swift is in your PATH
- Try running the demangler manually to test:
Scripts Not Appearing in Ghidra
Scripts Not Appearing in Ghidra
Symptoms: Scripts don’t show in Script ManagerSolutions:
- Verify scripts are in the correct directory
- Click the Refresh button in Script Manager
- Check Window → Script Manager → Script Directories for correct path
- Ensure scripts have
.pyextension
Analysis Takes Too Long
Analysis Takes Too Long
Symptoms: Ghidra analysis or scripts run for hoursSolutions:
- For initial analysis, disable some analyzers if binary is large
- SwiftNameDemangler can take 10-30 minutes for large apps (this is normal)
- Increase Ghidra’s memory allocation in
ghidraRunorsupport/launch.properties - Close other applications to free up system resources
Can't Find Mach-O Binary in IPA
Can't Find Mach-O Binary in IPA
Symptoms: IPA extracts but can’t find executableSolutions:
- Check
Payload/*.app/Info.plistforCFBundleExecutablevalue - Look for files without extensions in the
.appdirectory - Use
filecommand to identify Mach-O files: - The executable is typically the largest file in the app bundle
Next Steps
Explore Example IPAs
Try analyzing all three example applications to practice with different obfuscation techniques
Customize Scripts
Modify the provided scripts to suit your specific analysis needs or create new ones
Check the Wiki
Read detailed guides on iOS reverse engineering techniques and concepts
Join the Community
Follow @lauriewired and contribute to the project on GitHub