Linux Examples

Frida Linux Examples

Running Frida Inside Docker

Requirement: Frida uses ptrace and other syscalls that are blocked by Docker’s default seccomp profile. The container must be started with seccomp disabled.

Start Container Without Seccomp

1docker run --security-opt seccomp:unconfined -it <image-name> /bin/bash

What this does:

Why this is needed:

Verify Frida Works After Container Start

1# Inside the container — install frida-tools
2pip install frida-tools
3
4# List processes
5frida-ps
6
7# Trace a command
8frida-trace -f /bin/ls

Alternative: Custom Seccomp Profile

Instead of fully disabling seccomp, you can allow only the specific syscalls Frida needs:

1docker run --security-opt seccomp=/path/to/frida-seccomp.json -it <image-name> /bin/bash

Syscalls required by Frida (minimum set):

Capability Alternative (Less Permissive)

1docker run --cap-add SYS_PTRACE --security-opt seccomp:unconfined -it <image-name> /bin/bash

SYS_PTRACE alone may not be sufficient if the seccomp profile blocks required syscalls; combining both flags is the most reliable approach.


Frida Attach Modes on Linux

ModeCommandNotes
Attach by PIDfrida <pid>Process must be traceable
Attach by namefrida -n <process-name>First matching process
Spawn and attachfrida -f <binary> [args]Frida spawns then attaches
frida-tracefrida-trace -n <name> -i 'func*'Auto-generates JS stubs

Common Issues on Linux

SymptomCauseFix
ptrace: Operation not permittedseccomp blocking ptraceAdd --security-opt seccomp:unconfined
unable to attach in containerMissing SYS_PTRACE capAdd --cap-add SYS_PTRACE
Frida hangs on attachYAMA ptrace scopeecho 0 > /proc/sys/kernel/yama/ptrace_scope (host)
PTRACE_TRACEME deniedSELinux/AppArmor policyAdjust policy or use permissive mode for testing