Frida Cheat Sheet

Essential Frida CLI Commands

Start your pentesting session with these core commands to manage Frida and interact with apps:

  • List Processes: frida-ps -U Shows running processes on a USB-connected device (-R for remote).

  • Spawn App: frida -U -f <package_name> -l script.js Launches an app (e.g., com.example.app) and injects script.js.

  • Attach to Process:

    • By Name: frida -U -n <process_name> -l script.js

    • By PID: frida -U -p <PID> -l script.js Injects script into a running process.

  • Run Without Pausing: frida -U -f <package_name> -l script.js --no-pause Starts app without halting, ideal for automation.

  • Save Output: frida -U -f <package_name> -l script.js > log.txt Redirects console logs to a file.

  • Load Multiple Scripts: frida -U -f <package_name> -l script1.js -l script2.js Injects several scripts sequentially.

  • Interactive REPL: frida -U -f <package_name> Opens a live scripting console for debugging.

  • Trace Native Functions: frida-trace -U -i "<function_name>" <package_name> Auto-traces native functions (e.g., decrypt) and generates hook templates.

  • Hook System Process: frida -U -p 1 -l script.js Attaches to init (PID 1) for system-wide hooks (needs root).

  • Kill Process: frida-kill -U <PID> Terminates a process by PID for restarts.

  • Check Frida Server: adb shell "ps | grep frida" Verifies if frida-server is running on the device.

  • Start Frida Server: adb shell "/data/local/tmp/frida-server &" Runs frida-server in the background (adjust path if needed).

  • Explore with Objection: objection -g <package_name> explore Launches Objection for runtime app exploration.

  • Version Check: frida --version Confirms installed Frida version.

Pro Tip: Use frida --help for more options. Visit frida.re/docs for advanced guides.


Java Hooks

1. Hook a Java Method

Log or modify method behavior.

Use Case: Bypass authentication or log inputs. Tip: Return this.login(username, password) to keep original behavior.


2. Hook Method Overloads

Target specific parameter signatures.

Use Case: Alter inputs for overloaded methods. Tip: Find exact types in decompiled code (e.g., via JADX).


3. Enumerate Live Instances

Interact with runtime objects.

Use Case: Escalate privileges or dump session data. Tip: Verify field names in APK decompilation.


4. Hook Constructor

Control object initialization.

Use Case: Set high values for game items or user attributes. Tip: Useful for apps creating sensitive objects.


5. Override Parameters

Force specific method inputs.

Use Case: Test edge cases or manipulate state. Tip: Log inputs to understand default behavior.


Native & Memory Hooks

6. Hook Native Function

Intercept calls in .so libraries.

Use Case: Capture plaintext from native crypto functions. Tip: Run Module.enumerateExports("libnative.so") to list hookable functions.


Find byte patterns in memory.

Use Case: Locate hardcoded keys or tokens. Tip: Use Ghidra/IDA to identify patterns.


8. Memory Dump

Read raw memory at an address.

Use Case: Extract runtime secrets like keys. Tip: Combine with frida-trace to pinpoint addresses.


Security Bypasses

9. Bypass SSL Pinning

Disable pinning for traffic interception.

Use Case: Proxy HTTPS traffic with Burp Suite. Tip: If ineffective, try hooking OkHttpClient$Builder.


10. Bypass Root Detection

Spoof root checks.

Use Case: Run apps on rooted devices. Tip: Also hook custom classes like RootChecker.isRooted.


11. Bypass Emulator Detection

Trick apps into running on emulators.

Use Case: Test apps that block emulators. Tip: Check for custom detection logic in decompiled code.


Data & Network Monitoring

12. Hook Encryption/Decryption

Capture crypto inputs and outputs.

Use Case: Extract plaintext from encrypted data. Tip: Look for classes named Cipher, Crypto, or Utils.


13. Monitor Network Traffic

Log HTTP/HTTPS connections.

Use Case: Discover API endpoints or third-party services. Tip: Use with SSL bypass for full traffic visibility.


14. Hook Shared Preferences

Monitor key-value storage.

Use Case: Capture auth tokens or settings. Tip: Hook Editor.putString to log writes.


Game & Logic Manipulation

15. Modify Game Logic

Alter mechanics (e.g., dice rolls).

Use Case: Force high scores or test logic flaws. Tip: Adapt for any array-based method.


16. Set High Score

Manipulate leaderboard data.

Use Case: Test server-side validation or UI limits. Tip: Check if scores are client- or server-enforced.


Advanced Techniques

17. Trace Method Calls

Log call stacks for debugging.

Use Case: Map app flow or find hidden methods. Tip: Combine with specific hooks for context.


18. Hook Dynamic Class Loading

Monitor runtime-loaded classes.

Use Case: Detect obfuscated or anti-tamper code. Tip: Useful for complex apps.


19. Enumerate Exports

List native library functions.

Use Case: Find hookable native functions. Tip: Run before crafting native hooks.


20. UI Toast Injection

Display custom messages.

Use Case: Confirm hook execution or test UI. Tip: Always use scheduleOnMainThread for UI tasks.


Example: Pentest a Login

  1. Find Class: Decompile to locate com.example.app.Auth.

  2. Hook Login:

  3. Log APIs: Use network hook for endpoints.

  4. Check Storage: Hook SharedPreferences for tokens.

  5. Bypass Protections: Apply SSL/root bypass if needed.

Last updated

Was this helpful?