Use Child Gating to instrument forked processes
mainChild gating is an experimental feature that allows ZygiskFrida to intercept fork/vfork calls to instrument child processes. This is useful when an application runs security checks in a separate process.
Modes of Operation:
freeze: The child process is prevented from returning from the fork. It stays alive but executes no code.kill: The child process is killed immediately upon forking.inject: Theinjected_librariesare loaded into the child process, and then it resumes normal execution.
Important Caveats for inject mode:
- Library Duplication: You cannot load the same gadget file into the child process that is already in the parent (even via symbolic link). You must use a physical copy of the gadget.
- Port Conflicts: The child gadget will conflict with the parent gadget's port. You must provide a separate configuration file for the child gadget (e.g.,
/data/local/tmp/re.zyg.fri/libgadget-child.config.so) with a different port. - Cleanup: Using child gating may prevent apps from shutting down normally. If an app becomes unresponsive, manually kill it using:
adb shell 'su -c kill -9 $(pidof <package_name>)'
# Step 1: Create a physical copy of the gadget for the child
adb shell 'su -c cp /data/local/tmp/re.zyg.fri/libgadget.so /data/local/tmp/re.zyg.fri/libgadget-child.so'
# Step 2: Configure the child gadget with a unique port in /data/local/tmp/re.zyg.fri/libgadget-child.config.so
# (See 'Configure child gadget port' for JSON structure)
# Step 3: Connect to the child gadget
adb forward tcp:27043 tcp:27043
frida -H 127.0.0.1:27043 -n Gadget