Static Analysis (SAST)
What is Static Analysis?
Section titled “What is Static Analysis?”Static Application Security Testing (SAST) in mobile hacking involves examining the application’s compiled code, resources, and configuration files without actively executing the app on a device or emulator.
The goal is to understand the app’s logic, identify hardcoded secrets, and spot insecure coding practices simply by reading the reversed source code.
Android Static Analysis
Section titled “Android Static Analysis”Android analysis is famously straightforward because Dalvik bytecode can be almost perfectly decompiled back into readable Java.
Key Tools
Section titled “Key Tools”- Apktool: Used to unpack the APK, decode the
AndroidManifest.xml(which is compiled into a binary format), and extract resources. It also disassembles the.dexfiles into Smali code (a human-readable representation of bytecode). - JADX (Jadx-GUI): The gold standard for decompiling
.dexinto equivalent Java code. You drag and drop an APK into Jadx, and it provides a highly readable Java source tree. - MobSF (Mobile Security Framework): An automated all-in-one SAST tool that scans the code for common vulnerabilities and hardcoded secrets.
What to Look For
Section titled “What to Look For”- Hardcoded Secrets: Developers frequently leave API keys, AWS credentials, or encryption keys hardcoded in string definitions (
res/values/strings.xml) or directly inside Java classes. - Insecure Data Storage: Looking for code that writes sensitive data to
SharedPreferenceswithout encryption, or saves files to the globally readable External Storage (/sdcard). - Exported Components: Reviewing the
AndroidManifest.xmlfor Activities, Services, or ContentProviders that haveandroid:exported="true"(or implicitly exported by having an intent-filter) but lack proper permission checks. This allows a malicious app on the same device to trigger internal app functionality.
iOS Static Analysis
Section titled “iOS Static Analysis”Static analysis on iOS is significantly harder than on Android. Apps downloaded from the App Store are encrypted using Apple’s FairPlay DRM, and they are compiled directly to ARM machine code (Mach-O binaries), not an intermediate bytecode.
The Decryption Hurdle
Section titled “The Decryption Hurdle”Before you can analyze an iOS app, you must decrypt it. This generally requires a jailbroken device. The app is launched (so the OS decrypts it into memory), and tools like frida-ios-dump or Clutch dump the decrypted memory back into an unencrypted IPA file.
Key Tools
Section titled “Key Tools”- Hopper Disassembler / IDA Pro / Ghidra: Since you are dealing with machine code, you need a disassembler/decompiler to generate pseudo-C code or Assembly.
- Radare2 / Cutter: Powerful open-source alternative for binary analysis.
- class-dump: A utility for extracting the Objective-C runtime headers from Mach-O files, giving you a roadmap of the app’s classes, methods, and properties.
What to Look For
Section titled “What to Look For”- Property Lists (plists): Checking
Info.plistfor misconfigured Custom URL Schemes, which can be exploited for malicious redirection or parameter injection. - Binary Protections: Using tools like
otoolto verify that the developer compiled the app with standard protections enabled (PIE, ARC, Stack Canaries). - Hardcoded Keys: Running
stringsagainst the decrypted binary to fish out obvious URLs, tokens, or encryption keys left behind by developers.