[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-108198":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":8,"htmlUrl":8,"language":9,"languages":8,"totalLinesOfCode":8,"stars":10,"forks":11,"watchers":12,"openIssues":13,"contributorsCount":13,"subscribersCount":13,"size":13,"stars1d":13,"stars7d":13,"stars30d":14,"stars90d":13,"forks30d":13,"starsTrendScore":13,"compositeScore":15,"rankGlobal":8,"rankLanguage":8,"license":8,"archived":16,"fork":16,"defaultBranch":17,"hasWiki":18,"hasPages":16,"topics":19,"createdAt":8,"pushedAt":20,"updatedAt":21,"readmeContent":22,"aiSummary":23,"trendingCount":13,"starSnapshotCount":13,"syncStatus":12,"lastSyncTime":24,"discoverSource":25},108198,"IDA-Ghidra-bridge","oscarsantanaarias\u002FIDA-Ghidra-bridge","oscarsantanaarias",null,"Python",75,12,2,0,14,38.74,false,"main",true,[],"2026-10-12 13:53:09","2026-11-08 15:17:19","# IDA-Ghidra-bridge\n\nLightweight TCP JSON bridge servers for **IDA Pro** and **Ghidra** that expose reverse-engineering workflows over a simple socket protocol.\n\nAllows 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.\n\n---\n\n## Architecture & Lifecycle\n\n### 1. Dynamic Port Binding & Multi-Instance Support\nWhen working on large reversing projects with multiple binaries open at the same time (e.g. game client, launcher, DLL proxies, and stubs simultaneously):\n- The servers do **not** crash if a port is already taken.\n- The server starts scanning at **`BASE_PORT = 5073`** and automatically probes sequential ports (`5073`, `5074`, `5075`, `5076`...) until it finds an available one.\n- Each IDA or Ghidra window binds to its own port independently without conflicts.\n\n### 2. Hot-Reloading & Clean Re-Execution\nIn IDA Pro, the Python interpreter remains alive across multiple script executions:\n- `ID_Server.py` registers the running server handle into `builtins._ida_bridge_prev`.\n- 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.\n- You never get `Address already in use` or orphaned threads from re-running the script.\n\n### 3. Graceful Shutdown\n- **Via Socket**: Send `QUIT`, `STOP`, `EXIT`, or `SHUTDOWN` through the connection. The server confirms with `{\"ok\": true, \"shutdown\": true}` and closes immediately.\n- **In IDA Pro**: Call `ida_bridge_stop()` directly from the IDA Python CLI, or simply close IDA (daemon threads exit automatically).\n- **In Ghidra**: Click the red Cancel button in Ghidra's Script Manager (`is_cancelled()` is checked every 1s via socket timeout), or send `QUIT`.\n\n---\n\n## Installation & Setup\n\n### IDA Pro\n1. Open your target database (`.idb` \u002F `.i64`) in IDA Pro.\n2. In the IDA Python CLI (or via `File -> Script file...` \u002F `Alt+F7`), execute:\n   ```python\n   import ID_Server\n   ```\n3. The server starts listening on `127.0.0.1:5073` (or the next available port).\n4. To stop the server manually:\n   ```python\n   ida_bridge_stop()\n   ```\n\n### Ghidra\n1. Open your target program in Ghidra CodeBrowser.\n2. In the **Script Manager** (`Window -> Script Manager`), add the folder containing `Ghidra_Server.py` or run it directly in the Python interpreter.\n3. The server binds to `127.0.0.1:5073` (or next free port).\n\n---\n\n## Complete Command Reference (All 39 Commands)\n\nCommands are plain newline-delimited strings sent over TCP (`127.0.0.1:\u003CPORT>`). The server replies with a JSON object (or tab-delimited text for legacy commands).\n\n### 1. Navigation & Inspection\n\n| Command | Syntax | Description |\n|---|---|---|\n| `PING` | `PING` | Health check. Returns `\"pong\"`. |\n| `CURRENT` | `CURRENT` | Returns the current cursor address, function name, size, assembly instructions, and decompiled code. |\n| `NAME` | `NAME \u003Cea>` | Returns the symbol\u002Ffunction name defined at `\u003Cea>`. |\n| `FUNC` | `FUNC \u003Caddr>` | Returns full function metadata, entry point, size, signature, assembly, and Hex-Rays\u002FGhidra decompilation. |\n| `DECOMP` | `DECOMP \u003Caddr>` | Alias for `FUNC`. Decompiles the target function. |\n| `DISASM` | `DISASM \u003Cea> [n]` | Returns disassembly lines for `[n]` instructions starting from `\u003Cea>` (default: 40). |\n| `FIND` | `FIND \u003Csubstr>` | Case-insensitive search across all symbols and function names matching `\u003Csubstr>` (up to 300 matches). |\n| `EXPORT` | `EXPORT [filename]` | Exports all non-dummy symbols, mangled and demangled names to a text file (default: `ida_names.txt`). |\n| `HELP` | `HELP` | Returns a JSON list of all available commands supported by the server. |\n| `QUIT` | `QUIT` | Gracefully closes the client connection and stops the bridge server socket. |\n\n### 2. Cross-References & Call Graph\n\n| Command | Syntax | Description |\n|---|---|---|\n| `XREF` | `XREF \u003Caddr>` | Lists all incoming cross-references (code calls, data reads\u002Fwrites) targeting `\u003Caddr>`. |\n| `XFROM` | `XFROM \u003Caddr>` | Lists all outgoing cross-references originating from `\u003Caddr>`. |\n| `CALLERS` | `CALLERS \u003Caddr>` | Filters incoming references to return **only call sites** (including resolved indirect calls). |\n| `READERS` | `READERS \u003Caddr>` | Filters incoming references to return only instructions that **read** from `\u003Caddr>`. |\n| `WRITERS` | `WRITERS \u003Caddr>` | Filters incoming references to return only instructions that **write** to `\u003Caddr>`. |\n| `DECOMP_XREF` | `DECOMP_XREF \u003Caddr>` | Batch-decompiles every calling function of `\u003Caddr>` in a single request. |\n| `IMPORTXREF` | `IMPORTXREF \u003Cname>` | Locates all call sites throughout the entire binary for an imported Windows\u002FC API (e.g. `IMPORTXREF WSASendTo`). |\n| `TRACE` | `TRACE \u003Caddr>` | Traces the execution flow and basic blocks surrounding `\u003Caddr>`. |\n\n### 3. Pointers, Memory & Structures\n\n| Command | Syntax | Description |\n|---|---|---|\n| `READPTR` | `READPTR \u003Caddr> [count]` | Reads memory as pointer chains (32-bit or 64-bit) and classifies each target (`func`, `string`, `vtable`). |\n| `FINDPTR` | `FINDPTR \u003Caddr>` | Scans global data and tables to find any pointer referencing `\u003Caddr>` (finds vtables, dispatch tables). |\n| `STRUCT` | `STRUCT \u003Caddr> [n]` | Heuristically dumps contiguous memory interpreting fields as ints, floats, pointers, and strings. |\n| `DEFSTRUCT` | `DEFSTRUCT \u003Cname> [size]` | Creates a new named structure in the database type library. |\n| `SETFIELD` | `SETFIELD \u003Cstruct> \u003Coff> \u003Ctype> [name]` | Defines or modifies a structure field at `\u003Coff>` with `\u003Ctype>` and optional field name. |\n| `MKPTRS` | `MKPTRS \u003Caddr> [count]` | Converts raw database bytes into typed pointers in bulk. |\n| `NEARSTR` | `NEARSTR \u003Caddr>` | Finds string references located nearby in code or data sections within range. |\n\n### 4. Virtual Tables & RTTI\n\n| Command | Syntax | Description |\n|---|---|---|\n| `VTABLE` | `VTABLE \u003Cfuncaddr>` | Identifies which virtual tables contain `\u003Cfuncaddr>`, including neighboring method slots. |\n| `VTDUMP` | `VTDUMP \u003Caddr> [count]` | Dumps an entire virtual table: resolves each slot to its method name, offset, and index. |\n| `RTTI` | `RTTI \u003Caddr\\|Name>` | Traverses MSVC C++ RTTI structures (`TypeDescriptor` -> `CompleteObjectLocator` -> `vftable`) to resolve class hierarchies and base classes. |\n\n### 5. String & Byte Scanning\n\n| Command | Syntax | Description |\n|---|---|---|\n| `STR` | `STR \u003Cascii>` | Searches for ASCII strings across all loaded segments. |\n| `WSTR` | `WSTR \u003Cutf16>` | Searches for UTF-16 wide strings across all loaded segments. |\n| `BYTES` | `BYTES \u003Chex>` | Searches for raw opcode or data byte sequences (e.g. `BYTES 55 8B EC 83 EC`). |\n\n### 6. Database Modification & Typing\n\n| Command | Syntax | Description |\n|---|---|---|\n| `RENAME_FUNC` | `RENAME_FUNC \u003Caddr> \u003Cname>` | Renames the function at `\u003Caddr>` to `\u003Cname>`. |\n| `RENAME_SYMBOL` | `RENAME_SYMBOL \u003Caddr> \u003Cname>` | Renames a global data symbol or variable. |\n| `RENAME_LABEL` | `RENAME_LABEL \u003Caddr> \u003Cname>` | Renames a code label or jump target. |\n| `RENAME_LOCAL` | `RENAME_LOCAL \u003Cfunc> \u003Cold> \u003Cnew>` | Renames a local variable inside the decompiler view. |\n| `RETYPE` | `RETYPE \u003Cfunc> \u003Cvar> \u003Ctype>` | Modifies the data type of a variable or parameter inside the decompiler (e.g. `RETYPE 00401000 a1 Player*`). |\n| `SETCONV` | `SETCONV \u003Cfunc> \u003Cconvention>` | Sets calling convention (`__cdecl`, `__stdcall`, `__fastcall`, `__thiscall`). |\n| `MAKEFUNC` | `MAKEFUNC \u003Caddr>` | Forces creation of a function boundary at `\u003Caddr>`. |\n| `PATCH` | `PATCH \u003Caddr> \u003Chex>` | Directly overwrites bytes in the database (e.g. `PATCH 00401234 90 90`). |\n| `PCODE` | `PCODE \u003Caddr>` | Dumps Hex-Rays Microcode or Ghidra P-Code intermediate representation for deep compiler analysis. |\n\n---\n\n## Python Client Example\n\n```python\nimport socket\nimport json\n\nclass BridgeClient:\n    def __init__(self, host=\"127.0.0.1\", port=5073):\n        self.host = host\n        self.port = port\n\n    def send(self, cmd: str) -> dict:\n        s = socket.socket()\n        s.connect((self.host, self.port))\n        s.sendall((cmd + \"\\n\").encode(\"utf-8\"))\n        \n        chunks = []\n        while True:\n            chunk = s.recv(16384)\n            if not chunk:\n                break\n            chunks.append(chunk)\n            if b\"\\n\" in chunk:\n                break\n        s.close()\n        \n        raw = b\"\".join(chunks).decode(\"utf-8\", errors=\"ignore\").strip()\n        try:\n            return json.loads(raw)\n        except json.JSONDecodeError:\n            return {\"raw\": raw}\n\n# Example usage:\nclient = BridgeClient(port=5074)\n\n# Decompile target function\nres = client.send(\"FUNC 007B11C0\")\nif res.get(\"ok\"):\n    print(\"Function Name:\", res.get(\"function_name\"))\n    print(res[\"code\"][:300])\n\n# Trace incoming callers\ncallers = client.send(\"CALLERS 007B11C0\")\nprint(\"Total callers:\", callers.get(\"count\"))\n```\n\n---\n\n## License\n\nMIT\n\n","IDA-Ghidra-bridge 是一个轻量级的 TCP\u002FJSON 协议桥接工具，用于在 IDA Pro 和 Ghidra 逆向工程平台之间建立可编程接口。它通过动态端口绑定（默认起始端口 5073）、热重载支持和优雅关闭机制，使外部脚本或自动化流水线能无 GUI 干预地查询反编译结果、交叉引用、符号表、虚函数表、RTTI、结构体定义及内存补丁等信息。适用于需批量分析多个二进制文件（如游戏客户端、DLL 集合）、构建 CI\u002FCD 逆向流水线或集成自定义分析工具的安全研究与固件逆向场景。","2026-11-24 04:33:50","CREATED_QUERY"]