Labsco
fosdickio logo

Binary Ninja

โ˜… 397

from fosdickio

A Binary Ninja plugin, MCP server, and bridge that seamlessly integrates Binary Ninja with your favorite MCP client.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeAdvanced setup

Binary Ninja MCP

This repository contains a Binary Ninja plugin, MCP server, and bridge that enables seamless integration of Binary Ninja's capabilities with your favorite LLM client.

Binary Ninja MCP Logo

Features

  • Seamless, real-time integration between Binary Ninja and MCP clients
  • Enhanced reverse engineering workflow with AI assistance
  • Support for every MCP client (Cline, Claude desktop, Roo Code, etc.)
  • Open multiple binaries and switch the active target automatically

Examples

Solving a CTF Challenge

Check out this demo video on YouTube that uses the extension to solve a CTF challenge.

Components

This repository contains two separate components:

  1. A Binary Ninja plugin that provides an MCP server that exposes Binary Ninja's capabilities through HTTP endpoints. This can be used with any client that implements the MCP protocol.
  2. A separate MCP bridge component that connects your favorite MCP client to the Binary Ninja MCP server.

Supported Capabilities

The following table lists the available MCP functions for use:

FunctionDescription
decompile_functionDecompile a specific function by name and return HLIL-like code with addresses.
get_il(name_or_address, view, ssa)Get IL for a function in hlil, mlil, or llil (SSA supported for MLIL/LLIL).
define_typesAdd type definitions from a C string type definition.
delete_commentDelete the comment at a specific address.
delete_function_commentDelete the comment for a function.
declare_c_type(c_declaration)Create/update a local type from a single C declaration.
format_value(address, text, size)Convert a value and annotate it at an address in BN (adds a comment).
function_atRetrieve the name of the function the address belongs to.
fetch_disassemblyGet the assembly representation of a function by name or address.
get_entry_points()List entry point(s) of the loaded binary.
get_binary_statusGet the current status of the loaded binary.
get_commentGet the comment at a specific address.
get_function_commentGet the comment for a function.
get_user_defined_typeRetrieve definition of a user-defined type (struct, enumeration, typedef, union).
get_xrefs_to(address)Get all cross references (code and data) to an address.
get_data_decl(name_or_address, length)Return a C-like declaration and a hexdump for a data symbol or address.
hexdump_address(address, length)Text hexdump at address. length < 0 reads exact defined size if available.
hexdump_data(name_or_address, length)Hexdump by data symbol name or address. length < 0 reads exact defined size if available.
get_xrefs_to_enum(enum_name)Get usages related to an enum (matches member constants in code).
get_xrefs_to_field(struct_name, field_name)Get all cross references to a named struct field.
get_xrefs_to_struct(struct_name)Get xrefs/usages related to a struct (members, globals, code refs).
get_xrefs_to_type(type_name)Get xrefs/usages related to a struct/type (globals, refs, HLIL matches).
get_xrefs_to_union(union_name)Get xrefs/usages related to a union (members, globals, code refs).
get_stack_frame_vars(function_identifier)Get stack frame variable information for a function (names, offsets, sizes, types).
get_type_info(type_name)Resolve a type and return declaration, kind, and members.
get_callers(identifiers)List callers plus call sites for one or more function identifiers.
get_callees(identifiers)List callees plus call sites for one or more function identifiers.
make_function_at(address, platform)Create a function at an address. platform optional; use default to pick the BinaryView/platform default.
list_platforms()List all available platform names.
list_binaries()List managed/open binaries with ids and active flag.
select_binary(view)Select active binary by id or filename.
list_all_strings()List all strings (no pagination; aggregates all pages).
list_classesList all namespace/class names in the program.
list_data_itemsList defined data labels and their values.
list_exportsList exported functions/symbols.
list_importsList imported symbols in the program.
list_local_types(offset, count)List local Types in the current database (name/kind/decl).
list_methodsList all function names in the program.
list_namespacesList all non-global namespaces in the program.
list_segmentsList all memory segments in the program.
list_strings(offset, count)List all strings in the database (paginated).
list_strings_filter(offset, count, filter)List matching strings (paginated, filtered by substring).
rename_dataRename a data label at the specified address.
rename_functionRename a function by its current name to a new user-defined name.
rename_single_variableRename a single local variable inside a function.
rename_multi_variablesBatch rename multiple local variables in a function (mapping or pairs).
set_local_variable_type(function_address, variable_name, new_type)Set a local variable's type.
retype_variableRetype variable inside a given function.
search_functions_by_nameSearch for functions whose name contains the given substring.
search_types(query, offset, count)Search local Types by substring (name/decl).
set_commentSet a comment at a specific address.
set_function_commentSet a comment for a function.
set_function_prototype(name_or_address, prototype)Set a function's prototype by name or address.
patch_bytes(address, data, save_to_file)Patch raw bytes at an address (byte-level, not assembly). Can patch entire instructions by providing their bytecode. Address: hex (e.g., "0x401000") or decimal. Data: hex string (e.g., "90 90"). save_to_file (default True) saves to disk and re-signs on macOS.

These are the list of HTTP endpoints that can be called:

  • /allStrings: All strings in one response.
  • /formatValue?address=<addr>&text=<value>&size=<n>: Convert and set a comment at an address.
  • /getXrefsTo?address=<addr>: Xrefs to address (code+data).
  • /getDataDecl?name=<symbol>|address=<addr>&length=<n>: JSON with declaration-style string and a hexdump for a data symbol or address. Keys: address, name, size, type, decl, hexdump. length < 0 reads exact defined size if available.
  • /hexdump?address=<addr>&length=<n>: Text hexdump aligned at address; length < 0 reads exact defined size if available.
  • /hexdumpByName?name=<symbol>&length=<n>: Text hexdump by symbol name. Recognizes BN auto-labels like data_<hex>, byte_<hex>, word_<hex>, dword_<hex>, qword_<hex>, off_<hex>, unk_<hex>, and plain hex addresses.
  • /makeFunctionAt?address=<addr>&platform=<name|default>: Create a function at an address (idempotent if already exists). platform=default uses the BinaryView/platform default.
  • /platforms: List all available platform names.
  • /binaries or /views: List managed/open binaries with ids and active flag.
  • /selectBinary?view=<id|filename>: Select active binary for subsequent operations.
  • /data?offset=<n>&limit=<m>&length=<n>: Defined data items with previews. length controls bytes read per item (capped at defined size). Default behavior reads exact defined size when available; length=-1 forces exact-size.
  • /getXrefsToEnum?name=<enum>: Enum usages by matching member constants.
  • /getXrefsToField?struct=<name>&field=<name>: Xrefs to struct field.
  • /getXrefsToType?name=<type>: Xrefs/usages related to a struct/type name.
  • /getTypeInfo?name=<type>: Resolve a type and return declaration and details.
  • /getXrefsToUnion?name=<union>: Union xrefs/usages (members, globals, refs).
  • /getStackFrameVars?name=<function>|address=<addr>: Get stack frame variable information for a function.
  • /getCallers?identifiers=<name|addr>[,...]: Return caller summaries (functions, call sites, HLIL/IL snippets) for one or more identifiers. Accepts identifiers, identifier, names, or addresses query params.
  • /getCallees?identifiers=<name|addr>[,...]: Return callee summaries with the same schema as /getCallers, detailing every outgoing call target per request identifier.
  • /localTypes?offset=<n>&limit=<m>: List local types.
  • /strings?offset=<n>&limit=<m>: Paginated strings.
  • /strings/filter?offset=<n>&limit=<m>&filter=<substr>: Filtered strings.
  • /searchTypes?query=<substr>&offset=<n>&limit=<m>: Search local types by substring.
  • /patch or /patchBytes?address=<addr>&data=<hex>&save_to_file=<bool>: Patch raw bytes at an address (byte-level, not assembly). Can patch entire instructions by providing their bytecode. Address: hex (e.g., "0x401000") or decimal. Data: hex string (e.g., "90 90"). save_to_file (default True) saves to disk and re-signs on macOS.
  • /renameVariables: Batch rename locals in a function. Parameters:
    • Function: one of functionAddress, address, function, functionName, or name.
    • Provide renames via one of:
      • renames: JSON array of {old, new} objects
      • mapping: JSON object of old->new
      • pairs: compact string old1:new1,old2:new2 Returns per-item results plus totals. Order is respected; later pairs can refer to earlier new names.

Development

Code Quality

This project uses Ruff for linting and formatting. Configuration is in ruff.toml.

Running Ruff Manually

Check for issues:

ruff check .

Auto-fix issues:

ruff check --fix .

Check formatting issues:

ruff format --check .

Format code:

ruff format .

GitHub Actions

A GitHub Action workflow (.github/workflows/lint-format.yml) automatically runs Ruff on:

  • Every push to the main branch
  • Every pull request targeting the main branch

The workflow will fail if there are linting errors or formatting issues, ensuring code quality in CI.