Download
Docs menu+

Plugins

A borer plugin is what you know about a program, written down so borer can use it. borer's own analysis is general. A plugin adds the rules that hold for one program, one library or one engine.

There are two kinds of plugin:

  • A script is a short Rhai program. It reads what borer recovered (functions, strings, cross-references, bytes, decompiled code) and proposes names and comments.
  • A pack is a .borer text file. It holds what borer should know about a family of programs: names found by byte signature, naming conventions, class roles, which programs it is for, and scripts to run.

A pack can carry scripts, so a pack is how you ship a script.

When to use which

You want to Use
Answer one question about one binary, now A script, run once: borer script or the MCP script tool
Name functions by a rule (what they log, which table holds them) A script, then keep its names in a project or a pack
Carry names you found to the next build of the same program borer export-pack, which writes a pack's [names] lines
Run a rule every time a program of a family loads A pack with [scripts] run lines
Load a pack only for the programs it fits A pack with a [match] section, in a pack directory
Tell borer an engine's conventions (its singleton name, its stream classes, its base classes) A pack's [naming], [types] and [roles] sections

How a plugin runs

  1. borer loads the binary and runs its own analysis.
  2. The packs that load for the program apply their [names] and [lib] lines by byte signature.
  3. Each pack script runs. It sees the analysis with the pack names in place. It does not see the names another pack script proposes in the same run.
  4. A pack script's names go on functions borer left unnamed or named only by vtable slot. A name the binary itself gives (a symbol, a PDB) is kept.

A script you run yourself, from the command line or over MCP, runs after all of this and changes nothing until you apply what it proposes.

The sandbox

A script is safe to run even when a stranger wrote it. That is a design rule of the engine, not a convention:

  • No file, network, process or clock. A script has no function that opens a file, a socket or a process. import and eval are disabled, and sleep throws. A script reads only the loaded program.
  • No side effects. rename and comment only propose. The command line prints the proposals or saves them with --save; the MCP script tool is a dry run until dry_run=false.
  • Budgets. A run stops at 200,000,000 operations, 64 nested calls, 2,000 decompile and scenario calls, and 200 query, rows, layout and help("query") calls together. A call past its budget throws an error that names the budget.
  • Caps on what it keeps. A string holds at most 64 MiB (the strings inside one array or map count together), and an array, map or blob at most 2,097,152 items. A run keeps its first 500 printed lines, each cut at 4,096 characters, and at most 100,000 proposals of at most 1,024 characters each.
  • Deterministic. There is no clock and no randomness, and maps list their keys in sorted order. The same script on the same binary prints the same bytes.

This is what a script that reaches for the outside world gets back:

text
$ borer script notepad.exe open.rhai
Error: open.rhai: Function not found: open (&str | ImmutableString | String) (line 1, position 7)

$ borer script notepad.exe import.rhai
Error: import.rhai: Syntax error: 'import' is a reserved keyword (line 1, position 1)

$ borer script notepad.exe sleep.rhai
Error: sleep.rhai: Runtime error: sleep is not available: a script has no clock (line 1, position 1)

$ borer script notepad.exe loop.rhai
Error: loop.rhai: Too many operations (line 1, position 6)

The worst a script can do is spend its budget and propose bad names. Read what it proposes before you apply it.

A pack's scripts are different in one way: they run by themselves whenever the pack loads, with no dry run. They still only fill names borer did not have, and they still run in the sandbox. Read a pack before you put it in a pack directory, as you would read any rule you let name your functions.

From an agent

An agent runs scripts with the script tool. It takes code (the Rhai source) and dry_run (default true). Over MCP a script can also read every borer:// resource with query(uri) and rows(uri), so an agent can combine a dozen analyses in one call instead of a dozen round trips:

json
{
  "name": "script",
  "arguments": {
    "code": "for f in functions(\"crypt\") { print(`${hex(f.entry)} ${f.name}`); }",
    "dry_run": true
  }
}

The answer is what the script printed, then a table of the names and comments it proposed. With dry_run=false the proposals become session names, which save_project keeps and borer://exportpack/<name> turns into a pack.

The server loads the packs BORER_PACKS names and the packs in the pack directories whose [match] lines fit. borer://packs lists them and what their scripts did.

Where to go next

  • Your first script: from hello world to naming functions by what they log, in ten minutes.
  • Script API: every function a script can call.
  • Packs: the file format, section by section.
  • Recipes: scripts for real tasks, each one tested.
  • Sharing plugins: how to publish a pack.