Skip to content

Frida

18 commands

A dynamic instrumentation toolkit: inject JavaScript into running processes on Android, iOS, Windows, macOS and Linux to trace and modify behaviour.

  • instrumentation
  • hooking
  • mobile

Install Frida

pipx install frida-tools

Setup4

pip install frida-tools

Installs the Frida CLI tools. The frida-server on the device must match this version exactly.

Link
frida --version

Prints the client version, so you can download the matching frida-server.

Link
adb push frida-server /data/local/tmp/ && adb shell "chmod 755 /data/local/tmp/frida-server"

Copies frida-server to a rooted Android device and makes it executable.

Link
adb shell "su -c /data/local/tmp/frida-server &"

Starts frida-server as root in the background.

Link

Discovery3

frida-ls-devices

Lists devices Frida can see.

Link
frida-ps -U

Processes on the USB-connected device.

frida-ps -Uai

Installed apps with their identifiers and PIDs of running ones.

Link

Attaching and spawning6

frida -U -f <package>

Spawns the app with Frida attached and opens a JavaScript REPL. Spawning catches code that runs at startup.

Link
frida -U -n <name>

Attaches to an already running process by name.

Link
frida -U -p <pid>

Attaches by PID.

Link
frida -U -f <package> -l <script>

Loads a script into the process at startup.

Link
frida -U -f <package> --codeshare <handle>

Loads a community script from Frida CodeShare. Read it before running it.

Link
frida -H <ip>:<port> -n <name>

Connects to a remote frida-server over the network.

Link

Tracing3

frida-trace -U -f <package> -j "<class>!<method>"

Auto-generates hooks for Java methods matching a pattern and logs calls.

Link
frida-trace -U -n <name> -i "<function>"

Traces native functions such as open and openat.

Link
frida-trace -U -n <name> -m "-[<class> <selector>]"

Traces Objective-C methods on iOS.

Link

Snippets2

Java.perform(() => { const C = Java.use('<class>'); C.<method>.implementation = function () { return true; }; });

REPL or script snippet: replaces a Java method’s return value — here, defeating a root check.

Link
Interceptor.attach(Module.getExportByName(null, '<fn>'), { onEnter(args) { console.log(args[0].readUtf8String()); } });

Hooks a native function and logs its first argument.

Link