Lightweight TCP JSON bridge servers for IDA Pro and Ghidra that expose reverse-engineering workflows over a simple socket protocol.
Allows external tools, CLI scripts, Python utilities, and automated pipelines to query decompilation, xrefs, symbols, virtual tables, RTTI, structures, and patch memory without manual GUI interaction.
When working on large reversing projects with multiple binaries open at the same time (e.g. game client, launcher, DLL proxies, and stubs simultaneously):
- The servers do not crash if a port is already taken.
- The server starts scanning at
BASE_PORT = 5073and automatically probes sequential ports (5073,5074,5075,5076...) until it finds an available one. - Each IDA or Ghidra window binds to its own port independently without conflicts.
In IDA Pro, the Python interpreter remains alive across multiple script executions:
ID_Server.pyregisters the running server handle intobuiltins._ida_bridge_prev.- If you re-run or reload the script in the same IDA instance, it automatically invokes
stop()on the previous instance and joins its thread (join(3.0)), cleanly releasing the port before starting the new server. - You never get
Address already in useor orphaned threads from re-running the script.
- Via Socket: Send
QUIT,STOP,EXIT, orSHUTDOWNthrough the connection. The server confirms with{"ok": true, "shutdown": true}and closes immediately. - In IDA Pro: Call
ida_bridge_stop()directly from the IDA Python CLI, or simply close IDA (daemon threads exit automatically). - In Ghidra: Click the red Cancel button in Ghidra's Script Manager (
is_cancelled()is checked every 1s via socket timeout), or sendQUIT.
- Open your target database (
.idb/.i64) in IDA Pro. - In the IDA Python CLI (or via
File -> Script file.../Alt+F7), execute:import ID_Server
- The server starts listening on
127.0.0.1:5073(or the next available port). - To stop the server manually:
ida_bridge_stop()
- Open your target program in Ghidra CodeBrowser.
- In the Script Manager (
Window -> Script Manager), add the folder containingGhidra_Server.pyor run it directly in the Python interpreter. - The server binds to
127.0.0.1:5073(or next free port).
Commands are plain newline-delimited strings sent over TCP (127.0.0.1:<PORT>). The server replies with a JSON object (or tab-delimited text for legacy commands).
| Command | Syntax | Description |
|---|---|---|
PING |
PING |
Health check. Returns "pong". |
CURRENT |
CURRENT |
Returns the current cursor address, function name, size, assembly instructions, and decompiled code. |
NAME |
NAME <ea> |
Returns the symbol/function name defined at <ea>. |
FUNC |
FUNC <addr> |
Returns full function metadata, entry point, size, signature, assembly, and Hex-Rays/Ghidra decompilation. |
DECOMP |
DECOMP <addr> |
Alias for FUNC. Decompiles the target function. |
DISASM |
DISASM <ea> [n] |
Returns disassembly lines for [n] instructions starting from <ea> (default: 40). |
FIND |
FIND <substr> |
Case-insensitive search across all symbols and function names matching <substr> (up to 300 matches). |
EXPORT |
EXPORT [filename] |
Exports all non-dummy symbols, mangled and demangled names to a text file (default: ida_names.txt). |
HELP |
HELP |
Returns a JSON list of all available commands supported by the server. |
QUIT |
QUIT |
Gracefully closes the client connection and stops the bridge server socket. |
| Command | Syntax | Description |
|---|---|---|
XREF |
XREF <addr> |
Lists all incoming cross-references (code calls, data reads/writes) targeting <addr>. |
XFROM |
XFROM <addr> |
Lists all outgoing cross-references originating from <addr>. |
CALLERS |
CALLERS <addr> |
Filters incoming references to return only call sites (including resolved indirect calls). |
READERS |
READERS <addr> |
Filters incoming references to return only instructions that read from <addr>. |
WRITERS |
WRITERS <addr> |
Filters incoming references to return only instructions that write to <addr>. |
DECOMP_XREF |
DECOMP_XREF <addr> |
Batch-decompiles every calling function of <addr> in a single request. |
IMPORTXREF |
IMPORTXREF <name> |
Locates all call sites throughout the entire binary for an imported Windows/C API (e.g. IMPORTXREF WSASendTo). |
TRACE |
TRACE <addr> |
Traces the execution flow and basic blocks surrounding <addr>. |
| Command | Syntax | Description |
|---|---|---|
READPTR |
READPTR <addr> [count] |
Reads memory as pointer chains (32-bit or 64-bit) and classifies each target (func, string, vtable). |
FINDPTR |
FINDPTR <addr> |
Scans global data and tables to find any pointer referencing <addr> (finds vtables, dispatch tables). |
STRUCT |
STRUCT <addr> [n] |
Heuristically dumps contiguous memory interpreting fields as ints, floats, pointers, and strings. |
DEFSTRUCT |
DEFSTRUCT <name> [size] |
Creates a new named structure in the database type library. |
SETFIELD |
SETFIELD <struct> <off> <type> [name] |
Defines or modifies a structure field at <off> with <type> and optional field name. |
MKPTRS |
MKPTRS <addr> [count] |
Converts raw database bytes into typed pointers in bulk. |
NEARSTR |
NEARSTR <addr> |
Finds string references located nearby in code or data sections within range. |
| Command | Syntax | Description |
|---|---|---|
VTABLE |
VTABLE <funcaddr> |
Identifies which virtual tables contain <funcaddr>, including neighboring method slots. |
VTDUMP |
VTDUMP <addr> [count] |
Dumps an entire virtual table: resolves each slot to its method name, offset, and index. |
RTTI |
RTTI <addr|Name> |
Traverses MSVC C++ RTTI structures (TypeDescriptor -> CompleteObjectLocator -> vftable) to resolve class hierarchies and base classes. |
| Command | Syntax | Description |
|---|---|---|
STR |
STR <ascii> |
Searches for ASCII strings across all loaded segments. |
WSTR |
WSTR <utf16> |
Searches for UTF-16 wide strings across all loaded segments. |
BYTES |
BYTES <hex> |
Searches for raw opcode or data byte sequences (e.g. BYTES 55 8B EC 83 EC). |
| Command | Syntax | Description |
|---|---|---|
RENAME_FUNC |
RENAME_FUNC <addr> <name> |
Renames the function at <addr> to <name>. |
RENAME_SYMBOL |
RENAME_SYMBOL <addr> <name> |
Renames a global data symbol or variable. |
RENAME_LABEL |
RENAME_LABEL <addr> <name> |
Renames a code label or jump target. |
RENAME_LOCAL |
RENAME_LOCAL <func> <old> <new> |
Renames a local variable inside the decompiler view. |
RETYPE |
RETYPE <func> <var> <type> |
Modifies the data type of a variable or parameter inside the decompiler (e.g. RETYPE 00401000 a1 Player*). |
SETCONV |
SETCONV <func> <convention> |
Sets calling convention (__cdecl, __stdcall, __fastcall, __thiscall). |
MAKEFUNC |
MAKEFUNC <addr> |
Forces creation of a function boundary at <addr>. |
PATCH |
PATCH <addr> <hex> |
Directly overwrites bytes in the database (e.g. PATCH 00401234 90 90). |
PCODE |
PCODE <addr> |
Dumps Hex-Rays Microcode or Ghidra P-Code intermediate representation for deep compiler analysis. |
import socket
import json
class BridgeClient:
def __init__(self, host="127.0.0.1", port=5073):
self.host = host
self.port = port
def send(self, cmd: str) -> dict:
s = socket.socket()
s.connect((self.host, self.port))
s.sendall((cmd + "\n").encode("utf-8"))
chunks = []
while True:
chunk = s.recv(16384)
if not chunk:
break
chunks.append(chunk)
if b"\n" in chunk:
break
s.close()
raw = b"".join(chunks).decode("utf-8", errors="ignore").strip()
try:
return json.loads(raw)
except json.JSONDecodeError:
return {"raw": raw}
# Example usage:
client = BridgeClient(port=5074)
# Decompile target function
res = client.send("FUNC 007B11C0")
if res.get("ok"):
print("Function Name:", res.get("function_name"))
print(res["code"][:300])
# Trace incoming callers
callers = client.send("CALLERS 007B11C0")
print("Total callers:", callers.get("count"))MIT