Drive x64dbg
from Python.
pybridge is an x64dbg plugin and a standard-library Python client: breakpoints, single-stepping, registers, memory, API hooks and traces — in the GUI or in headless.exe, with nothing to pip install.
from x64dbg_bridge import Debugger with Debugger.launch(r"C:\Tools\x64dbg\release") as dbg: # starts headless.exe dbg.init(r"C:\Windows\System32\whoami.exe") dbg.set_breakpoint("kernelbase.LoadLibraryExW", break_=False, log="LoadLibrary({utf16@arg.get(0)})") dbg.set_breakpoint("kernelbase.CreateFileW") if dbg.run(wait=True, timeout=10): print(dbg.read_string(dbg.eval("arg.get(0)"), wide=True)) print(dbg.regs())
What's inside
Works with official x64dbg, on x64 and x32 targets.
Plugin
pybridge.dp64 / .dp32: a local TCP server speaking one JSON request per line. Usable from any language.
Python client
x64dbg_bridge.Debugger: launch or attach, step, read and write memory, hook APIs — standard library only.
Headless templates
Twelve ready-made x64dbg scripts (API log, unpack dumps, pattern search, traces) run by one PowerShell launcher.
Dump emulation
emulate_dump.py runs a .dmp in Unicorn and serves it over the same protocol, so the client drives it like a live process.
Quick start
Windows, x64dbg, Python 3.10 or newer.
- Download
pybridge_1.0.0.zip. - Extract it into x64dbg's
releasefolder (it addsx64\plugins\pybridge.dp64,x32\plugins\pybridge.dp32andpybridge\). - Point Python at the client and launch:
import sys
sys.path.insert(0, r"C:\Tools\x64dbg\release\pybridge\python")
from x64dbg_bridge import Debugger
with Debugger.launch(r"C:\Tools\x64dbg\release", arch="x64") as dbg:
dbg.init(r"C:\Windows\System32\notepad.exe")
print(dbg.regs())
Already in x64dbg? Run pybridge.start in the command bar (port 27041), then Debugger() connects to it.
API at a glance
Addresses accept integers or x64dbg expressions: "kernelbase.CreateFileW", "rsp+8", "[rsp]".
| Category | Methods |
|---|---|
| Session | launch(), init(), attach(), stop(), close() |
| Execution | run(), pause(), step_into(), step_over(), step_out(), wait(), state() |
| Registers | regs(), reg(), set_reg() |
| Memory | read(), write(), read_ptr(), read_string(), is_valid(), disasm() |
| Breakpoints | set_breakpoint(), delete_breakpoint(), set_hardware_breakpoint() |
| API hooks | hook_api(), dump_memory() |
| Anti-anti-debug | hide_debugger(), scyllahide_profiles(), scyllahide_set_profile() |
| Traces | trace(), export_trace() (JSON / CSV / Tenet / Frinet, with Fathom) |
| Commands | cmd(), command(), eval(), result |
Headless templates
The launcher fills in the target, runs headless.exe with an isolated configuration and collects everything in out\<template>-<date>\.
.\headless\run-headless.ps1 -Template api-log -Target C:\Windows\System32\whoami.exe -X64dbgDir C:\Tools\x64dbg\release .\headless\run-headless.ps1 -Template unpack-dump -Target .\sample.exe -X64dbgDir C:\Tools\x64dbg\release -Arch x32
| Template | Purpose |
|---|---|
api-log, hook-apis-extended | log API calls with their arguments, without pausing |
hook-unpack, unpack-dump | follow runtime unpacking and dump the region flipped to executable |
dump-module, dump-at-delay | save the main module and a full minidump |
break-on-file | conditional breakpoint followed by automatic actions |
antidebug | hide the debugger and log anti-debug probes |
find-pattern | search a hex or ASCII pattern over the whole memory map |
trace-export, run-trace | record a trace and export it (needs Fathom's TraceExport) |
emulate-dump | serve a .dmp emulation on 127.0.0.1:27041 |
Security
The server only accepts local connections, but any local program that connects to it fully controls the debugger. Start it only when you need it, and use it on binaries you are allowed to study.