CLI-first CAN security research toolkit
Project description
README.md
CANarchy
CANarchy is a stream-first CAN analysis and manipulation runtime designed for automation, security research, and agent-driven workflows.
The project is implemented in Python and uses uv for environment, dependency, and packaging workflows.
Every command emits a canonical event stream — structured, pipeable, and machine-readable. The CLI is the interface. JSONL is the wire format. J1939 is a first-class citizen, not an afterthought.
Today the repository delivers:
- a stable CLI surface for analysts, scripts, and coding agents
- J1939-first heavy vehicle workflows: PGN decoding, SPN extraction, TP session reassembly, DM1 fault parsing
- structured output (
--json,--jsonl,--table,--raw) on every command - live CAN transport via
python-canwith support for socketcan, virtual bus, and UDP multicast - UDS scan and trace, DBC decode/encode, capture/filter/replay, and an interactive shell
Why CANarchy?
Most CAN tools force the wrong tradeoff: interactive but hard to automate, scriptable but too raw, protocol-aware but inconsistent across interfaces. CANarchy is built around the opposite constraint: every output is a stream of typed events you can parse, pipe, or forward to an agent.
The event schema is the stable contract. The CLI wraps it. J1939 heavy vehicle analysis is the initial focus for protocol-aware workflows, with a security-research lens throughout.
Current State
Fully implemented and tested:
capture,send,filter,stats— transport workflows with livepython-canand deterministic scaffold backendsgenerate— cangen-style frame generation (fixed, random, incrementing modes)gateway— bridge frames between two interfaces (unidirectional and bidirectional)replay— deterministic replay planning from candump filesdecode,encode— DBC-backed signal decode and encodej1939 monitor,decode,pgn,spn,tp,dm1— J1939 operator workflows across live, file-backed, and decoded viewsuds scan,trace,services— UDS diagnostic workflows and service catalog, including initial transport-backed scan/trace heuristicsre counters— file-backed counter-candidate detection for reverse-engineering workflowsre entropy— file-backed entropy ranking across arbitration IDs and byte positionssession save,load,show— session managementexport— structured artifact exportshell— interactive REPL and--commandscripting modetui— terminal UI front end
Present in the CLI surface but not yet fully implemented:
re signals,re correlate— reverse-engineering helpers (planned)fuzz replay,fuzz mutate,fuzz id— active fuzzing (planned)
Default transport backend is python-can; set CANARCHY_TRANSPORT_BACKEND=scaffold for deterministic offline behavior.
Documentation
- Event Schema — canonical event envelope for all structured output
- Command spec
- CAN Tool Feature Matrix — high-level comparison to other OSS CAN tools
- Architecture
- Changelog
- Release Workflow
- J1939 Heavy Vehicle Demo
Installation
CANarchy currently targets Python 3.12 or newer and uses uv for environment and packaging workflows.
- Install Python 3.12 or newer.
- Install
uv. - Clone the repository.
- Sync the project environment and dependencies:
uv sync
- Run the CLI:
uv run canarchy --help
- Optionally install
canarchyon your PATH so you don't needuv runevery time:
uv tool install --editable .
canarchy --help
If you want to verify the local environment end to end, run:
uv run python -m unittest discover -s tests -v
Notes:
uv synccreates the local virtual environment and installs the package from the current checkout.- The checked-in
uv.lockfile should be used for reproducible dependency resolution. uv tool install --editable .putscanarchyon your PATH permanently; edits take effect without reinstalling.- Live transport support currently uses
python-can; persist backend settings in~/.canarchy/config.toml(see Getting Started).
Development
uv sync
uv tool install --editable .
canarchy --help
Versioning Policy
CANarchy uses Semantic Versioning.
Rules:
MAJORfor intentional breaking changes to the CLI contract, structured output contract, or other documented public behaviorMINORfor backward-compatible new commands, new output fields, or new capabilitiesPATCHfor backward-compatible fixes, documentation corrections, and implementation improvements that do not intentionally break the public contract
Prereleases:
- prereleases should use standard SemVer prerelease identifiers such as
0.2.0a1,0.2.0b1, or0.2.0rc1 - prereleases are appropriate when command behavior, output contracts, or packaging flows need release-candidate validation before a stable tag
Release tags:
- Git tags should match the package version exactly, prefixed with
v, for examplev0.1.0 canarchy --version, package metadata, and release tags should always agree
Current implementation:
src/canarchy/__init__.pyis the authoritative version source- package metadata is derived from that version during build
- CLI and MCP server version reporting reuse the same version value
Example Usage
# Capture and decode
canarchy capture can0 --candump
canarchy capture can0 --jsonl
canarchy decode trace.candump --dbc vehicle.dbc --jsonl
# J1939 heavy vehicle analysis
canarchy j1939 decode trace.candump --table
canarchy j1939 spn 110 --file trace.candump --table # Engine Coolant Temp
canarchy j1939 dm1 trace.candump --table # Active fault codes
# Pipe events into downstream tools
canarchy j1939 spn 110 --file trace.candump --jsonl \
| jq '[.payload.value, .payload.units, .payload.timestamp]'
# Active workflows
canarchy generate can0 --count 10 --gap 50 --id 7DF --jsonl
canarchy gateway can0 239.0.0.1 --count 100
canarchy replay trace.candump --rate 2.0 --json
Use --candump for a human-oriented live view. Use --jsonl when feeding output to scripts or agents — every line is a typed event from the canonical schema.
Live transport uses python-can by default. Set CANARCHY_PYTHON_CAN_INTERFACE to choose an interface type, or set CANARCHY_TRANSPORT_BACKEND=scaffold for deterministic offline behavior.
Current file support:
- file-backed workflows such as
filter,stats,decode,j1939 decode, andreplaynow read standard timestamped candump log files j1939 pgninspects recorded traffic with--file <capture.candump>- the supported log form today is
(timestamp) interface frame#data - additional supported candump forms include classic RTR
id#R, CAN FDid##<flags><data>, and error frames using a CAN error-flagged identifier such as20000080#0000000000000000 - supported capture-file suffixes today are
.candumpand.log - malformed candump log lines return structured transport errors instead of falling back to sample data
Structured Output
Successful commands return a stable JSON envelope:
{
"ok": true,
"command": "capture",
"data": {},
"warnings": [],
"errors": []
}
Failures return structured errors with actionable hints:
{
"ok": false,
"command": "decode",
"data": {},
"warnings": [],
"errors": [
{
"code": "DBC_LOAD_FAILED",
"message": "Failed to parse DBC file.",
"hint": "Validate the DBC syntax and line endings."
}
]
}
Philosophy
- CLI is the contract
- Protocol semantics over raw frames
- Structured outputs over formatted text
- Reproducible workflows over ad-hoc interaction
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file canarchy-0.3.0.tar.gz.
File metadata
- Download URL: canarchy-0.3.0.tar.gz
- Upload date:
- Size: 458.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce5d6a0ba450647870ce2e87fb4df16b73f0de2e3e8d76a731f5356678e3523b
|
|
| MD5 |
bbf10c43897a7f4153bcedb95e8a94b1
|
|
| BLAKE2b-256 |
439d25659d5dd55b0014a983ae7a5c1811de9ab1f8b2e5533b3afb9037a749f5
|
Provenance
The following attestation bundles were made for canarchy-0.3.0.tar.gz:
Publisher:
publish.yml on hexsecs/canarchy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
canarchy-0.3.0.tar.gz -
Subject digest:
ce5d6a0ba450647870ce2e87fb4df16b73f0de2e3e8d76a731f5356678e3523b - Sigstore transparency entry: 1343608978
- Sigstore integration time:
-
Permalink:
hexsecs/canarchy@1bd5fde39e04c74d78c4e751c453379609a4350a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/hexsecs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1bd5fde39e04c74d78c4e751c453379609a4350a -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file canarchy-0.3.0-py3-none-any.whl.
File metadata
- Download URL: canarchy-0.3.0-py3-none-any.whl
- Upload date:
- Size: 265.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83382d6566ff34b56a90ede79166a485f3622e2d3da09f642ff61797328e4f1d
|
|
| MD5 |
0163e9184721cb1b7489027b926d8042
|
|
| BLAKE2b-256 |
5117fde88406827c898ab7f33942186cec1440b6310121c76484f8e529975657
|
Provenance
The following attestation bundles were made for canarchy-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on hexsecs/canarchy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
canarchy-0.3.0-py3-none-any.whl -
Subject digest:
83382d6566ff34b56a90ede79166a485f3622e2d3da09f642ff61797328e4f1d - Sigstore transparency entry: 1343608984
- Sigstore integration time:
-
Permalink:
hexsecs/canarchy@1bd5fde39e04c74d78c4e751c453379609a4350a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/hexsecs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1bd5fde39e04c74d78c4e751c453379609a4350a -
Trigger Event:
workflow_dispatch
-
Statement type: