binary-reversing
Skill37 starsChanged 3 months agoMITView on GitHub
Load when reversing a compiled mobile binary (iOS Mach-O or Android ELF .so) with Ghidra or Binary Ninja, covering headless analysis, function classification by security relevance, crypto call tracing, JNI boundary review, and hardcoded secret extraction.
In this repository9 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- android-analysisSkill
- ios-analysisSkill
- mobile-huntingSkill
- mobile-reconSkill
- mobile-vuln-classesSkill
- report-writingSkill
- sdk-analysisSkill
- triage-validationSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 61
After Ghidra analysis, classify functions by security relevance:
- Very specific: line 128
What mode: Check options parameter for ECB (1) vs CBC/other
- Very specific: line 184
If analysis.binary_analyzer is set to "binja" in config:
- Very specific: line 247
Classify functions: Use function_classifier.py to identify security-relevant functions.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Binary Reversing: Ghidra & Binary Ninja Techniques
This skill defines binary analysis techniques for MobHunt hunter agents. It covers Ghidra headless analysis (primary) and Binary Ninja (optional) for both iOS Mach-O and Android ELF binaries.
Ghidra Headless Analysis
MobHunt uses Ghidra in headless mode via tools/binary_analysis/ghidra_analyze.sh. The script runs platform-specific Ghidra scripts that extract security-relevant data.
Running Analysis
# iOS binary analysis
bash tools/binary_analysis/ghidra_analyze.sh \
--binary workspace/<target>/ios/decrypted/<executable> \
--platform ios \
--output recon/<target>/
# Android native library analysis
bash tools/binary_analysis/ghidra_analyze.sh \
--binary workspace/<target>/android/extracted/apktool/lib/arm64-v8a/<lib>.so \
--platform android \
--output recon/<target>/Environment
GHIDRA_HOME: Installation directory (default:~/Library/ghidra/12.0.4)GHIDRA_HEADLESS: Path toanalyzeHeadless(auto-detected fromGHIDRA_HOME/support/)GHIDRA_TIMEOUT: Analysis timeout in seconds (default: 600)
What the Scripts Extract
iOS Script (ghidra_ios_script.java):
- Objective-C class and method lists
- Swift demangled symbols
- Crypto API calls (
CCCrypt,SecKey*,CC_MD5,CC_SHA*) - Keychain API usage (
SecItemAdd,SecItemCopyMatching) - URL scheme handlers
- String cross-references for sensitive patterns
- Function call graphs for security-critical paths
Android Script (ghidra_android_script.java):
- JNI exported functions (
Java_*naming convention) - Crypto function calls (OpenSSL, BoringSSL)
- String references (URLs, keys, paths)
- Dangerous function usage (
system,exec,dlopen) - Memory-unsafe function calls (
strcpy,sprintf,gets) - Symbol exports and imports
Function Classification
After Ghidra analysis, classify functions by security relevance:
python3 tools/binary_analysis/function_classifier.py \
--results recon/<target>/*_ghidra_results.json \
--output recon/<target>/Classification Categories
| Category | What It Catches | Priority |
crypto | Encryption, hashing, key generation, random | HIGH |
network | TLS, HTTP, socket, certificate operations | HIGH |
auth | Login, token, session, credential, OAuth | HIGH |
storage | File I/O, database, Keychain, SharedPrefs | MEDIUM |
ipc | URL handling, intent processing, IPC | MEDIUM |
jni | JNI boundary functions (Android) | MEDIUM |
dangerous | system(), exec(), dlopen(), unsafe memory | HIGH |
debug | Logging, assertion, debug flags | LOW |
Hunters should focus on crypto, network, auth, and dangerous categories first.
iOS Binary Reversing
Objective-C Runtime Analysis
Objective-C binaries contain rich metadata exploitable for analysis:
# List classes
otool -o <binary> | grep "name 0x" | head -50
# List methods per class (in Ghidra)
# Navigate to __objc_methnames sectionKey classes to investigate:
*ViewControllerwithwebViewproperties: WebView attack surface*APIClient,*NetworkManager: network configuration*KeychainManager,*SecureStorage: data protection*AuthManager,*LoginController: authentication flow*DeepLinkHandler,*URLRouter: IPC entry points
Swift Binary Analysis
Swift binaries are harder to reverse but contain type metadata:
# Swift demangling
swift demangle 's4MyApp10AuthTokenCV'
# → MyApp.AuthTokenCSwift-specific patterns in Ghidra:
- Swift metadata in
__swift5_*sections - Protocol witness tables reveal implemented protocols
- Generic specializations may contain type information
Crypto Function Tracing
In Ghidra, trace from crypto API calls to understand:
- What algorithm: Find
CCCryptcalls → checkalgorithmparameter:0= AES,1= DES,2= 3DES,10= RC4,11= RC2
- What mode: Check
optionsparameter for ECB (1) vs CBC/other - Key source: Trace the
keyparameter backward. Hardcoded? Derived? Random? - IV source: Trace the
ivparameter. Static? NULL? Random?
Finding criteria:
- DES/3DES/RC4/RC2 for any security purpose → FINDING
- ECB mode for multi-block encryption → FINDING
- Hardcoded key bytes → FINDING (extract the key value)
- NULL or static IV → FINDING if used with CBC
- MD5 for authentication/integrity → FINDING (not for checksums)Android Native Library Reversing
JNI Function Analysis
JNI exports follow a strict naming convention:
Java_<package>_<class>_<method>with dots replaced by underscores and special characters mangled.
Analysis steps:
- List JNI exports:
nm -gD <lib.so> | grep "Java_" - In Ghidra, navigate to each JNI function
- Check parameter handling:
GetStringUTFChars: is the result length-checked?GetByteArrayElements: is the array length validated?FindClass/GetMethodID: what Java methods does native code call?
Anti-Reverse Engineering Checks
Native libraries may contain anti-tampering:
ptrace(PTRACE_TRACEME): anti-debugging/proc/self/mapsreading: instrumentation framework detection- Signature verification via JNI callback to Java
- Checksum verification of DEX files
These are NOT security findings. They are defensive measures.
String Analysis in Native Code
# Extract strings from .so
strings -a <lib.so> | grep -E "(http|key|token|password|secret|api)"Native libraries often contain hardcoded secrets that developers assume are "hidden" by being in native code. They are not; strings and Ghidra find them.
Binary Ninja Analysis (Optional)
If analysis.binary_analyzer is set to "binja" in config:
python3 tools/binary_analysis/binja_analyze.py \
--binary <path> \
--platform ios|android \
--output <dir>BN provides similar capabilities to Ghidra with different strengths:
- Better Swift demangling and type recovery
- Faster analysis for large binaries
- HLIL (High Level IL) for more readable decompilation
- Python scripting API for custom analysis
The output format matches Ghidra's JSON schema for downstream compatibility.
Common Binary Findings
Hardcoded Secrets
| Signal | Severity | Validation (see the authorization boundary below) |
AWS access key (AKIA...) in binary strings | CRITICAL | Confirm the key is active with a single identity call such as aws sts get-caller-identity |
Google API key (AIza...) in binary | HIGH | Check what the key's restrictions permit |
| Firebase URL in binary | HIGH | Check <url>/.json for public read |
| Private key (PEM format) in binary | CRITICAL | Determine statically whether it is used for signing or TLS |
| OAuth client secret in binary | HIGH | Check whether the flow it belongs to accepts it |
| Generic API key near auth headers | MEDIUM | Check the endpoint it authenticates against |
Authorization boundary: extracting a secret from a binary you hold is static analysis; sending it anywhere is testing. Run any of the checks above only when the service is covered by the program's stated scope, and, when it is third-party hosted (AWS, Google, Firebase, and similar), only with the program's written permission. The account belongs to the program, and the provider never agreed to your test. Where that authorization is absent, keep the check static.
Rule: Every secret finding must say what the secret is and what access it grants. Where a permitted live check ran, report its result. Where none was permitted, report the provider's documented privileges for that key type and ask the program to confirm whether the key is active. A key confirmed expired or confirmed restricted to nothing sensitive is not a finding; an unconfirmed key is still a finding, at lower confidence.
Weak Cryptography
| Pattern | Issue | Severity |
CC_MD5 / MD5_Init for auth | Broken hash for security | HIGH |
| DES / 3DES cipher usage | Weak block cipher | MEDIUM |
| ECB mode encryption | Pattern-preserving | MEDIUM |
Hardcoded AES key in .rodata | Extractable key | HIGH |
| Static IV (all zeros or constant) | Predictable encryption | MEDIUM |
rand() / srand() for crypto | Predictable random | HIGH |
Missing Binary Protections
| Protection | How to Check | Finding? |
| PIE (Position Independent Executable) | otool -hv → PIE flag | Only on iOS < 14 / Android < 5 |
| Stack canaries | nm <binary> | grep __stack_chk | Only if missing on native code handling user input |
| ARC (iOS) | Presence of objc_release/objc_retain | No; ARC is about memory management, not security |
| RELRO (Android) | readelf -l <so> | grep GNU_RELRO | Informational only |
Modern platform rule: iOS 15+ and Android 10+ enforce most binary protections at the OS level. Missing protections are only findings on older platform versions or when the app explicitly disables them.
Analysis Workflow
- Start with strings: Extract and review strings before deep reversing. Most secrets are findable with
stringsalone. - Classify functions: Use
function_classifier.pyto identify security-relevant functions. - Trace crypto paths: For each crypto call, trace key source and data input.
- Check JNI boundaries (Android): Every JNI export is an attack surface if Java layer passes user-controlled data.
- Time-box: Spend no more than 15 minutes per binary on deep reversing. If nothing surfaces from strings + function classification, move on.
- Document offsets: For every finding, record the binary offset and function name so the validator and report writer can reference it.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

