A firmware map for your AI agent
Treasure Map draws the map; your agent finds the treasure.
Treasure Map runs a full static analysis of unpacked firmware, records facts about four kinds of dangerous call site and produces function-level patch diffs. Your agent queries them over MCP: the tool supplies the facts, the model makes the judgment.
Install
curl -LsSf https://github.com/JoeyZzZzZz/treasure-map/releases/latest/download/install.sh | sh
Installs the tmap command, then tmap init sets up the toolchain, registers the MCP server with your agents and installs the diff-review skill. Restart your agent when it finishes.
Works with any agent that speaks MCP. tmap init sets up Claude Code, Codex, Cursor, Claude Desktop and dsh for you.
Treasure Map, on your machineNo agent of its own, no model, no API key
./firmware.extracted tmap scanGhidra, one pass per binaryfw-v1, fw-v2tmap diffGhidra, BinExport, BinDiffAtlas~/.treasure-map/atlas.db
Fact layerread-only
What scan and diff found, each fact pinned to a binary, function and address.
Facts are what judgments rest on
Annotations never alter a fact
Annotation layerwritable
Your agent’s judgments, each recording the facts it rests on.
tmap mcpFacts: yes, no, or unknown with the reason
Judgments: annotate, annotate_diff
Your agentClaude Code, Codex, Cursor and others
Reads the pseudocode, traces the input, decides which candidate is a real bug, records why.
What it does
Map one firmware
Puts every dangerous call site on a map, with facts such as argument source, controllability and reachability. Anything it can’t determine is marked unknown, saying what’s missing. Your agent picks its views, reads the pseudocode and writes its judgments to the annotation layer.
How the map worksDiff two versions
Produces a function-level patch diff between two firmware versions, grouping changed functions by what happened around their dangerous call sites. Your agent reviews the few that really changed instead of combing through thousands, and whatever it leaves unread stays on the record.
How the diff worksShowcase
One run on public firmware, start to finish: every command and its output, what the agent found and the facts behind it, and what it did not reach.
The firmware map
Each dangerous call site is one candidate on the map, with a reading on six equal layers: argument source, controllability, writer, reachability, filtering on the way, and whether its function was fully analyzed. Each reading is yes, no or an explicit unknown that says what is missing and why.
Example: the candidate list your agent reads
Illustrative data, not from real firmware. Field names simplified.
- There is no score. The default view puts the highest-impact calls that nothing has proven safe first. Your agent can re-sort or filter by any layer.
- Re-sorting changes the order, never the set. A different order never hides a candidate. Only a filter you choose narrows the list.
- Only a proven-safe fact pushes a candidate down. An unknown never does, in any view: unknown is not safe.
- Yes
- No
- Unknown, with the reason
#1
system() Command execution
/usr/sbin/httpd FUN_0040a1f0 +0x000124
- Data comes from outsideYes
- recv() earlier in the same function
- An attacker controls itYes
- request bytes reach the argument
- Writer identifiedYes
- snprintf() builds the command string
- The call is reachedUnknown
- no direct caller found; it may be called through a dispatch table
- Filtered on the wayNo
- no check between the input and the call
- Function fully analyzedYes
- the function decompiled fully
Why it sits hereHighest-impact class, and nothing proves it safe.
evidence_refdemo-fw#7c4e2b19:0x0040a1f0@cmd@0x000124
Command-execution, memory-copy and format-string call sites come with in-function argument provenance. File-path call sites are covered for identification and ranking; their controllability comes from a text-level reading, and is marked as such.
The patch diff
tmap diff compares every binary whose content changed between the two versions, in parallel, running Ghidra, BinExport and BinDiff end to end, and produces a function-level patch diff. You never handle an intermediate file. From it, your agent answers three questions:
- Is this a security fix, and which weakness in the old version does it close?
- Is the fix complete?
- Does the same call remain elsewhere?
How one real diff narrowed down
-
FilesTreasure Map
110to4
One square per binary
Of 110 binaries, 106 were byte-identical on both sides and stayed out of the comparison. Only the 4 that changed went on to a function diff.
-
FunctionsTreasure Map
2262to23
One dot per function pair
The Challenge binary alone came back with 2262 function pairs marked changed. With addresses normalized, nearly all of them had only moved; 23 pairs were judged a real code change.
-
VerdictYour agent
23to3
The same 23, enlarged
Reading those 23, the agent’s report lands on three things, none of them a clean fix: a backdoor whose entry was deleted while its code stayed in, a buffer enlarged with no length check added, and validation added only in the browser.
Treasure Map computes the first two steps, with no model involved. Only the last step is your agent’s judgment.
- A function-level patch view.
- One entry per changed function pair, grouped by what happened around its dangerous call sites: a call that now goes somewhere else, a dangerous call site that is still there, a reading that could not be decided. A function with no counterpart stays undetermined, never “removed” or “added”.
- What a similarity score misses.
- BinDiff can report
similarity=1.0when a buffer length changed from0x40to0x3f. Treasure Map also compares address-normalized pseudocode and flags changed length constants at copy and format calls. - A review that knows what it skipped.
- The server picks the must-read changes, hands them out in work units and counts how many have been judged. An unread change is reported as unread, not as “nothing found”, and the review is not complete until every must-read item is judged.
- Scripts and configs too.
- Scripts and config files are compared by path, and each one can be judged. A binary that could not be diffed is listed as such, never counted as unchanged.
Example: the patch view, grouped
Illustrative, not from real firmware.
-
A call now goes somewhere else
Same call site; the new version calls a different function.
httpd · FUN_0040b9e0Old version:strcpy(local_48, pcVar1);New version:snprintf(local_48, 0x40, "%s", pcVar1); -
A dangerous call site is still there
The call itself stayed; only an argument changed.
httpd · FUN_0040b2a4Old version:strncpy(local_48, pcVar1,0x40);New version:strncpy(local_48, pcVar1, 0x3f); -
Could not be decided
The two functions don’t line up reliably, so they are not forced into a comparison.
upnpd · FUN_00409a10no comparison given
Blind spots
libcfg.socould not be diffed: listed here, not counted as unchanged
logd · FUN_00410c00no counterpart: undetermined, maybe inlined or moved
Why an agent needs a map
Agents read a single function well. Given a whole root filesystem (a hundred binaries, tens of thousands of functions), they tend to stop after the first few leads and report “nothing found” for code they never read. Some questions can’t be answered by looking at one binary:
-
Who writes the value?
A setting one program reads, such as an nvram key, is often written by another program. The map lists which programs write and read each nvram key, and whether it can be set from the web interface.
-
Who starts the program?
Web servers hand work to helper programs, and init scripts decide which daemons run. The map records which binaries and scripts launch each program, with symlinks such as
/bin/sh → busyboxresolved. -
What hasn’t been read?
Progress is counted against every candidate in the firmware, and each function or binary that could not be fully analyzed is named, so “nothing found” and “never read” stay apart.
-
What did the update change?
Given two firmware versions, the map finds every binary and file that changed, scripts, configs and web pages included, and the binaries that exist in only one version. A patch spread across several files is seen in full.
The agent does the reading and judging. Treasure Map tracks what has been read and judged, and the conclusions carry over to the next session.
Quick start
Developer preview. Commands, config, the atlas database and MCP tool fields may change incompatibly between versions.
-
Install
This installs
tmapand then runstmap init, which sets up the toolchain, registers the MCP server with the agents you choose, and installs the diff-review skill for agents that read skills. Restart your agent when it finishes.curl -LsSf https:// github.com/ JoeyZzZzZz/ treasure-map/ releases/ latest/ download/ install.sh | sh -
Map a firmware
The input is an already-extracted filesystem; unpack the image with any tool, or have your agent do it.
-wgives it a name.tmap scan ./firmware.extracted -w my-fw Then ask your agent
Audit firmware my-fw with Treasure Map. End with the leads worth following up, each with its evidence_ref and why. -
Diff two versions
Scan both releases, then compare them. A firmware pair splits into one diff per changed binary; the non-binary files are compared on their own.
tmap scan ./fw_v1.extracted -w fw-v1 tmap scan ./fw_v2.extracted -w fw-v2 tmap diff --before fw-v1 --after fw-v2Then ask your agent
Review the firmware diff fw-v1 → fw-v2 with Treasure Map: find the security fixes, judge whether each one is complete, and check whether the new code adds attack surface.
scan is the slow step: one Ghidra pass per binary, with progress shown. Re-run with the same -w to resume. Everything you scan and diff goes into one atlas (~/.treasure-map/atlas.db), and your agent chooses which firmware or diff to work on.
Install details
Full flags, manual registration and troubleshooting are in the README.
Platforms
- Linux x86_64, including WSL2Supported
- macOS on Apple SiliconSupported
- macOS on IntelSame toolchain, not acceptance-tested
- Linux arm64, native WindowsNot supported: no Ghidra decompiler or BinDiff build. On Windows, use WSL2
Setup
- Pinned sourcesEvery download comes from a pinned URL.
- Checked firstSize and sha256 are verified before anything is unpacked.
- Your go-ahead
tmap initshows its plan and changes nothing until you confirm.
To see the plan without changing anything: tmap init --dry-run.
Upkeep
tmap doctor- Check the toolchain, config and agent registrations. Changes nothing.
tmap update- Install the newest version, then run its
tmap init. tmap rescan- Re-scan runs left out of date by an upgrade;
--dry-runlists them. tmap uninstall- Remove what
tmap initinstalled. Your data stays.
Intended use
Treasure Map supports defensive security auditing and vulnerability research on firmware. It produces analysis leads; by design it does not generate proof-of-concept exploits, payloads, shellcode, or other directly weaponizable output. Only analyze firmware you lawfully possess: a device you own, or firmware made genuinely public by its vendor and obtained without bypassing any login, paywall or access control. Findings are candidates, not verdicts, and need independent human verification. The tool is provided as is, without warranty.