Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Tool:Ghidra BSim

From ReverseEngineering.wiki
Tool
Vendor NSA (Ghidra project)
License Apache-2.0
Website https://github.com/NationalSecurityAgency/ghidra
On this wiki Facts · Code · Notes · Topics

BSim finds similar functions across many executables: it builds feature vectors from Ghidra's decompiler output and stores them in a database where nearest-neighbour queries return functions with similarity and confidence scores.

What it is

Unlike Tool:Ghidra Function ID, which hashes machine instructions exactly, BSim works on the decompiler's data-flow and control-flow graph, so it tolerates different compilers, optimisation levels and architectures. Each function becomes a sparse weighted feature vector (a signature); a database indexes the vectors with locality-sensitive hashing and answers 'which stored functions look like this one'.

Database kinds

  • H2 file databases: CreateH2BSimDatabaseScript.java, AddProgramToH2BSimDatabaseScript.java; good for one project.
  • PostgreSQL server (support/make-postgres.sh, config template choice) and Elasticsearch backends for large corpora.
  • Templates in BSim/data/: medium_32.xml (about 10 million functions, 32-bit; k=17, L=146), medium_64.xml, medium_nosize.xml, medium_cpool.xml (constant pool for Java/Dalvik) and large_32.xml, with lshweights_*.xml weight files. The settings word in the template (0x49 for medium 32) selects options.
  • Default similarity threshold in the search dialog is 0.7; confidence depends on how many features a function has, so tiny functions are unreliable.

Use

Ingest executables, set categories (SetExecutableCategoryScript.java), then query one function (QueryFunction.java) or a whole executable (CompareExecutablesScript.java) and filter results by name, executable or category. The main reverse-engineering use is transferring names from a known build (or a library with symbols) to an unknown one.

Other scripts: GenerateSignatures.java, DumpBSimSignaturesScript.java, CompareBSimSignaturesScript.java.

See Technique:Library function recognition.

Code & repositories

  • https://github.com/NationalSecurityAgency/ghidra @ 9a723ce99952771b8368329503aa589ae233e916 · license: Apache-2.0
    Ghidra source: Features/FunctionID (fidb schema, hasher, scripts, building_fid.txt) and Features/BSim (config templates, scripts).
    Tested on: source read, not run: source read, not run · checked 2026-10-18; last activity 2026-10-16; Note: the latest release ships binaries; the wiki links only the source, never the binaries