# axiaojj/firmagent architecture

> Architecture diagram of the GitHub repository axiaojj/firmagent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/axiaojj/firmagent
- Repository: https://github.com/axiaojj/firmagent

## Overview

FirmAgent is a research toolkit for authorized firmware vulnerability discovery. The main workflow prepares sink and CFG-distance artifacts from a target binary, fuzzes the re-hosted service, and captures QEMU traces for request attribution; the resulting Source.json can feed optional LLM-assisted taint analysis. The graph preserves these distinct stages and the sink-filtering capability. Relationships are based on README workflow statements and shown source references; unsampled implementations are not inferred beyond those documented links.

Main entry points: [`FuzzingRecord/Fuzzer.py`](https://github.com/axiaojj/firmagent/blob/master/FuzzingRecord/Fuzzer.py) (API Fuzzer), [`Pre_Fuzzing/decompile.py`](https://github.com/axiaojj/firmagent/blob/master/Pre_Fuzzing/decompile.py) (IDA Decompilation), [`LLMATaint.py`](https://github.com/axiaojj/firmagent/blob/master/LLMATaint.py) (Taint Agent), [`FuzzingRecord/build_source_json.py`](https://github.com/axiaojj/firmagent/blob/master/FuzzingRecord/build_source_json.py) (Source Attribution)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prep["Binary Preparation"]
  node_ida["IDA Decompilation<br/>[decompile.py]"]
  node_sinkfunc["Sink Discovery<br/>[Get_SinkFunc.py]"]
  node_filter["Sink Filtering<br/>[FilterSink.py]"]
  node_filtergui["Sink Analysis<br/>[FilterSink_gui.py]"]
  node_distance["CFG Distance<br/>[Distance.py]"]
  node_api_extract["API Extraction"]
end

subgraph group_fuzz["Runtime Fuzzing"]
  node_fuzzer["API Fuzzer<br/>[Fuzzer.py]"]
  node_feedback["Coverage Feedback"]
end

subgraph group_trace["Trace Attribution"]
  node_qemu["Instrumented QEMU"]
  node_trace_log["QEMU Trace Log"]
  node_monitor["Trace Monitor<br/>[taint_monitor.py]"]
  node_stream["Request Stream"]
  node_sourcejson["Source Attribution"]
  node_sourcefile["Source.json"]
end

subgraph group_analysis["Taint Analysis"]
  node_taint_runner["Taint Agent<br/>[LLMATaint.py]"]
  node_taint["Taint Analysis<br/>[Taintanalysis.py]"]
  node_checker["Taint Checker<br/>[TaintChecker.py]"]
  node_llm["LLM API<br/>[LLMapi.py]"]
end

node_analyst(("Authorized Tester"))
node_binary["Firmware Binary"]
node_service["Re-hosted Service"]
node_llm_service["LLM Endpoint"]

node_analyst -->|"prepares binary"| node_ida
node_binary -->|"decompiles"| node_ida
node_ida -->|"provides evidence"| node_sinkfunc
node_sinkfunc -.->|"identifies sinks"| node_filter
node_filter -->|"delegates analysis"| node_filtergui
node_binary -->|"builds CFG scores"| node_distance
node_ida -.->|"supplies decompilation"| node_distance
node_ida -->|"extracts API details"| node_api_extract
node_analyst -->|"runs fuzzing"| node_fuzzer
node_api_extract -->|"provides API inputs"| node_fuzzer
node_distance -->|"guides feedback"| node_fuzzer
node_fuzzer -->|"routes feedback mode"| node_feedback
node_fuzzer -->|"sends requests"| node_service
node_service -->|"runs under"| node_qemu
node_qemu -->|"writes trace"| node_trace_log
node_fuzzer -->|"appends requests"| node_stream
node_trace_log -->|"reads trace"| node_monitor
node_stream -->|"tracks requests"| node_monitor
node_trace_log -->|"attributes trace"| node_sourcejson
node_stream -->|"matches requests"| node_sourcejson
node_monitor -->|"provides windows"| node_sourcejson
node_sourcejson -->|"writes attribution"| node_sourcefile
node_analyst -->|"starts analysis"| node_taint_runner
node_binary -->|"analyzes target"| node_taint_runner
node_sourcefile -->|"provides dynamic sources"| node_taint_runner
node_taint_runner -->|"runs analysis"| node_taint
node_taint_runner -->|"uses checks"| node_checker
node_taint -->|"requests analysis"| node_llm
node_llm -->|"sends prompts"| node_llm_service

click node_ida "https://github.com/axiaojj/firmagent/blob/master/Pre_Fuzzing/decompile.py"
click node_sinkfunc "https://github.com/axiaojj/firmagent/blob/master/Pre_Fuzzing/Get_SinkFunc.py"
click node_filter "https://github.com/axiaojj/firmagent/blob/master/Filter/FilterSink.py"
click node_filtergui "https://github.com/axiaojj/firmagent/blob/master/Filter/FilterSink_gui.py"
click node_distance "https://github.com/axiaojj/firmagent/blob/master/Pre_Fuzzing/Distance.py"
click node_api_extract "https://github.com/axiaojj/firmagent/blob/master/Pre_Fuzzing/llm_extract_api_params.py"
click node_fuzzer "https://github.com/axiaojj/firmagent/blob/master/FuzzingRecord/Fuzzer.py"
click node_feedback "https://github.com/axiaojj/firmagent/blob/master/FuzzingRecord/feedback_fuzzing.py"
click node_monitor "https://github.com/axiaojj/firmagent/blob/master/FuzzingRecord/taint_monitor.py"
click node_sourcejson "https://github.com/axiaojj/firmagent/blob/master/FuzzingRecord/build_source_json.py"
click node_taint_runner "https://github.com/axiaojj/firmagent/blob/master/LLMATaint.py"
click node_taint "https://github.com/axiaojj/firmagent/blob/master/Taintanalysis.py"
click node_checker "https://github.com/axiaojj/firmagent/blob/master/TaintChecker.py"
click node_llm "https://github.com/axiaojj/firmagent/blob/master/LLMapi.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ida,node_sinkfunc,node_filter,node_filtergui,node_distance,node_api_extract toneBlue
class node_fuzzer,node_feedback toneAmber
class node_qemu,node_trace_log,node_monitor,node_stream,node_sourcejson,node_sourcefile toneMint
class node_taint_runner,node_taint,node_checker,node_llm toneRose
class node_analyst,node_binary,node_service,node_llm_service toneIndigo
```

## Components

### Binary Preparation

- [IDA Decompilation](https://github.com/axiaojj/firmagent/blob/master/Pre_Fuzzing/decompile.py): `Pre_Fuzzing/decompile.py`
- [Sink Discovery](https://github.com/axiaojj/firmagent/blob/master/Pre_Fuzzing/Get_SinkFunc.py): `Pre_Fuzzing/Get_SinkFunc.py`
- [Sink Filtering](https://github.com/axiaojj/firmagent/blob/master/Filter/FilterSink.py): `Filter/FilterSink.py`
- [Sink Analysis](https://github.com/axiaojj/firmagent/blob/master/Filter/FilterSink_gui.py): `Filter/FilterSink_gui.py`
- [CFG Distance](https://github.com/axiaojj/firmagent/blob/master/Pre_Fuzzing/Distance.py): `Pre_Fuzzing/Distance.py`
- [API Extraction](https://github.com/axiaojj/firmagent/blob/master/Pre_Fuzzing/llm_extract_api_params.py): `Pre_Fuzzing/llm_extract_api_params.py`

### Runtime Fuzzing

- [API Fuzzer](https://github.com/axiaojj/firmagent/blob/master/FuzzingRecord/Fuzzer.py): `FuzzingRecord/Fuzzer.py`
- [Coverage Feedback](https://github.com/axiaojj/firmagent/blob/master/FuzzingRecord/feedback_fuzzing.py): `FuzzingRecord/feedback_fuzzing.py`

### Trace Attribution

- **Instrumented QEMU**
- **QEMU Trace Log**
- [Trace Monitor](https://github.com/axiaojj/firmagent/blob/master/FuzzingRecord/taint_monitor.py): `FuzzingRecord/taint_monitor.py`
- **Request Stream**
- [Source Attribution](https://github.com/axiaojj/firmagent/blob/master/FuzzingRecord/build_source_json.py): `FuzzingRecord/build_source_json.py`
- **Source.json**

### Taint Analysis

- [Taint Agent](https://github.com/axiaojj/firmagent/blob/master/LLMATaint.py): `LLMATaint.py`
- [Taint Analysis](https://github.com/axiaojj/firmagent/blob/master/Taintanalysis.py): `Taintanalysis.py`
- [Taint Checker](https://github.com/axiaojj/firmagent/blob/master/TaintChecker.py): `TaintChecker.py`
- [LLM API](https://github.com/axiaojj/firmagent/blob/master/LLMapi.py): `LLMapi.py`

### Other components

- **Authorized Tester**
- **Firmware Binary**
- **Re-hosted Service**
- **LLM Endpoint**

## Connections

- Authorized Tester → IDA Decompilation: prepares binary
- Firmware Binary → IDA Decompilation: decompiles
- IDA Decompilation → Sink Discovery: provides evidence
- Sink Discovery → Sink Filtering: identifies sinks
- Sink Filtering → Sink Analysis: delegates analysis (evidence: `Filter/FilterSink.py`)
- Firmware Binary → CFG Distance: builds CFG scores
- IDA Decompilation → CFG Distance: supplies decompilation
- IDA Decompilation → API Extraction: extracts API details
- Authorized Tester → API Fuzzer: runs fuzzing
- API Extraction → API Fuzzer: provides API inputs
- CFG Distance → API Fuzzer: guides feedback
- API Fuzzer → Coverage Feedback: routes feedback mode (evidence: `FuzzingRecord/Fuzzer.py`)
- API Fuzzer → Re-hosted Service: sends requests
- Re-hosted Service → Instrumented QEMU: runs under
- Instrumented QEMU → QEMU Trace Log: writes trace
- API Fuzzer → Request Stream: appends requests
- QEMU Trace Log → Trace Monitor: reads trace
- Request Stream → Trace Monitor: tracks requests
- QEMU Trace Log → Source Attribution: attributes trace
- Request Stream → Source Attribution: matches requests
- Trace Monitor → Source Attribution: provides windows
- Source Attribution → Source.json: writes attribution
- Authorized Tester → Taint Agent: starts analysis
- Firmware Binary → Taint Agent: analyzes target
- Source.json → Taint Agent: provides dynamic sources
- Taint Agent → Taint Analysis: runs analysis (evidence: `LLMATaint.py`)
- Taint Agent → Taint Checker: uses checks (evidence: `LLMATaint.py`)
- Taint Analysis → LLM API: requests analysis (evidence: `Taintanalysis.py`)
- LLM API → LLM Endpoint: sends prompts (evidence: `LLMapi.py`)
