Frida CLI Tools

14.8.1 · active · verified Thu Apr 16

frida-tools provides a set of command-line interface (CLI) utilities for Frida, a dynamic instrumentation toolkit. It allows developers, reverse-engineers, and security researchers to inject JavaScript into native applications on various platforms (Windows, macOS, GNU/Linux, iOS, Android, QNX) to observe and reprogram running programs. The library is actively maintained, with the current version being 14.8.1, and typically follows the release cycle of its core dependency, 'frida'.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use the underlying 'frida' Python binding (which 'frida-tools' uses) to attach to a running process, inject a JavaScript agent, call an RPC method, and process messages. Replace 'cat' with an actual running process on your system or a connected device for a successful execution. For mobile devices, ensure 'frida-server' is running on the device and specify the correct device and process.

import frida

def on_message(message, data):
    print(f"[on_message] message: {message}, data: {data}")

try:
    # Attach to a running process, replace 'cat' with a valid process name or PID on your system
    # For remote devices, use frida.get_usb_device().attach('process_name') or frida.get_device_manager().get_device('id').attach('process_name')
    session = frida.attach('cat') # Example: a simple running process
    
    # Create a JavaScript script to inject
    script = session.create_script("""
        rpc.exports.enumerateModules = () => {
            return Process.enumerateModules();
        };
    """)
    
    # Set up message handler
    script.on('message', on_message)
    
    # Load the script into the target process
    script.load()
    
    # Call an exported RPC method from Python
    modules = script.exports_sync.enumerate_modules()
    print([m['name'] for m in modules])
    
    # Keep the script running (or detach when done)
    input('[*] Press Enter to detach from process\n')
    session.detach()
except frida.ProcessNotFoundError:
    print("Error: Process 'cat' not found. Please ensure 'cat' or another process is running.")
except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →