Description
The hardest Android challenge. Multiple layers of protection in droids4.apk.
Setup
Download the APK file.
wget <url>/droids4.apkSolution
Walk me through it- Step 1Static analysis: decompile and map the appStart with jadx decompilation. Understand the app structure: where is the password validation? Does it involve native code, obfuscated strings, reflection, or runtime class loading?bash
jadx droids4.apk -d droids4_java/bashunzip droids4.apk -d droids4_raw/bashls droids4_raw/Learn more
Advanced Android protections may include: ProGuard/R8 obfuscation (class/method name mangling), string encryption (strings decrypted at runtime), reflection (dynamic method calls), DexGuard (commercial obfuscator), and APK split/multi-dex.
Start by finding the entry point (MainActivity), then trace all function calls from the button click handler inward to find the validation logic.
- Step 2Analyze native librariesUnzip the APK and examine any .so files in the lib/ directory. Load them in Ghidra and look for the JNI entry points. The flag validation may be entirely in native code.bash
ls droids4_raw/lib/bashfile droids4_raw/lib/x86/*.sobashstrings droids4_raw/lib/x86/*.so | grep -i picoLearn more
Even in obfuscated native code, string literals are often stored in plain text in the .rodata section. The
stringscommand extracts printable sequences of 4+ characters from any file, which can quickly reveal hardcoded flags or keys. - Step 3Dynamic analysis with FridaIf static analysis is insufficient, use Frida to hook key methods at runtime. Hook the final comparison or any method that receives the flag string. Use frida-trace to automatically trace all method calls.bash
frida-trace -U -f com.example.droids4 -j '*!check*'bashfrida-trace -U -f com.example.droids4 -j '*!*' -J '*!equals*'Learn more
frida-trace automatically generates hook scripts for matched methods and prints their arguments. The
-jflag matches Java methods by class and method name pattern. This is useful when you need to discover which method to hook without reading all the source first.For APK patching: use apktool to decompile, modify the smali to bypass the check or log the expected value, recompile with
apktool b, sign with a debug certificate, and install the patched APK.
Flag
picoCTF{...}
Combine static analysis (jadx + Ghidra) with dynamic analysis (Frida hooks) to extract the flag through multiple protection layers.