attach
Attach to a running game or application process for memory scanning, value modification, function hooking, and code injection during reverse engineering.
Instructions
Attach to a running process.
Args:
target: Process name (string) or PID (integer)
Returns:
Session information.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target | Yes |
Implementation Reference
- The primary handler function for the 'attach' MCP tool. It attaches a Frida session to a target process by PID or name, manages session state, handles errors like process not found or permission denied, and returns session details.@mcp.tool() def attach(target: Union[str, int]) -> Dict[str, Any]: """ Attach to a running process. Args: target: Process name (string) or PID (integer) Returns: Session information. """ global _session if not FRIDA_AVAILABLE: return {"error": "Frida not installed. Run: pip install frida frida-tools"} if _session.is_attached(): detach() try: device = get_device() if isinstance(target, str): _session.session = device.attach(target) _session.process_name = target _session.pid = getattr(_session.session, 'pid', None) else: _session.session = device.attach(target) _session.pid = target for proc in device.enumerate_processes(): if proc.pid == target: _session.process_name = proc.name break _session.spawned = False return { "success": True, "pid": _session.pid, "process_name": _session.process_name, "message": f"Attached to {_session.process_name or target}" } except frida.ProcessNotFoundError: return {"error": f"Process not found: {target}"} except frida.PermissionDeniedError: return {"error": "Permission denied. Try running as administrator."} except Exception as e: return {"error": f"Failed to attach: {str(e)}"}