Documentation
¶
Overview ¶
Package shell is the boundary between AIMS and the operator's interactive shell for the `bring` implant-context feature (see BRING.md). It knows the supported shell dialects and, crucially, how to quote a value so that a shell reproduces it verbatim without interpreting its contents.
Quote is the single trusted escaping boundary of the whole feature. In a C2 setting an agent's reported strings (name, working directory, hostname) are attacker-controlled; if any such value reached generated shell code unescaped, a malicious implant would gain code execution on the operator's box. Every agent-derived value interpolated into a bring payload must therefore pass through Quote.
Index ¶
Constants ¶
const ( KeyID = "id" KeyName = "name" KeyTool = "tool" KeyCWD = "cwd" KeyRoute = "route" KeyPending = "pending" )
Payload field keys. The Go emitter (cmd/bring.writePayload) and the shell parser in the init templates must agree on these exact strings; the templates receive them via initData so the two sides cannot drift apart.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
Init writes the shell integration — the bring()/leave() functions and their helpers — for the given shell to w. This is the trusted half of the `bring` feature: the emitted code contains no agent data (agent values arrive only later, as inert payload data parsed by bring()). Source it once from your shell rc, e.g. `source <(aims init zsh)`.
Only zsh is wired today (P1); bash and fish return a clear not-implemented error so the command fails loudly rather than emitting a broken snippet.
func Quote ¶
Quote renders s as a single shell token that the given shell expands back to exactly s, with no interpretation of its contents. It is the single trusted boundary between attacker-controlled agent data and generated shell code (see the package doc): every value interpolated into a bring payload MUST pass through Quote. The result is safe for arbitrary bytes — including newlines, $(...), backticks, semicolons and quotes.
func SanitizeDisplay ¶
SanitizeDisplay hardens an agent-derived value before it is carried into the shell. It removes: control characters — including the newline and the TAB that delimits payload fields; and the bytes a prompt might re-interpret — '$' and '`' (command substitution under zsh PROMPT_SUBST) and '%' (zsh prompt escapes). The result is also length-capped.
This is display hardening layered on top of the capture-as-data payload (which already prevents execution, since the shell parses rather than evals the payload): together they guarantee a hostile implant string is inert data — never code — and cannot corrupt the prompt. It is applied to every emitted value, including the id, so control bytes can never break the line format.
Types ¶
type Shell ¶
type Shell int
Shell identifies a supported shell dialect. Dialects differ in how they quote string literals, which is why quoting is dispatched on the Shell.
func Detect ¶
func Detect() Shell
Detect guesses the operator's shell from the $SHELL environment variable, defaulting to Bash when it is unset or unrecognized.