One person running several shells can change emails, IPs, keys and proxy
configs, but tends to type the same things everywhere: their own
server's IP, a personal domain, an email, a bot or API token. The
fingerprint scan now reads each home's bash/zsh/fish (and python/mysql)
history and reports those values as history_token fingerprints. Like
proxy secrets, they are salted and hashed, and Detail only says what
kind of value it is.
Noise is filtered out first: private/CGNAT addresses, the host's own
networks, our hosts, public resolvers, well-known domains (code hosts,
registries, big services, common Reality cover sites, our own), names
containing the account's own username, pure-hex checksums, paths, and
TLDs that double as field names (so "{{.HostConfig.RestartPolicy.Name}}"
isn't a domain). On the live host's 29 shells this finds no shared
values, as expected.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|---|---|---|
| .forgejo | ||
| cmd | ||
| dev/local-incus | ||
| docs | ||
| host | ||
| images | ||
| internal | ||
| pkg/shells | ||
| .gitignore | ||
| go.mod | ||
| go.sum | ||
| README.md | ||
shells-config
Public free-shell program for IRCNow / sh.ircforever.org.
Each user picks a name and gets <name>.sh.ircforever.org, an Incus container
on the shells VPS (89.167.23.102, Hetzner Helsinki), and a dedicated IPv6
/128 from 2a01:4f9:c014:663f::/64 routed directly into their container.
Architecture
main VPS (control plane) ──HMAC POST──▶ shellsd on shells VPS
│
▼
incus exec / useradd /
Traefik fragment write /
DNS provider call
pkg/shells/— library.Backendinterface + Incus implementation. IPv6 allocator, JSON state, Traefik file fragments, Cloudflare DNS client.cmd/shellsd/— webhook receiver daemon. systemd unit; listens on127.0.0.1:8090, fronted by Traefik onapi.sh.ircforever.org.cmd/shellctl/— break-glass CLI for the shells host.internal/webhook/— HMAC verify + HTTP handlers.host/— config that lives on the shells VPS:bootstrap.sh— idempotent host bootstrap (incus + UFW + sysctl + sshd)incus-init.yaml— preseed forincus admin initsshd-shells.conf—Match Group shellsblock for sshdshells-enter+shells-enter-root— login-shell wrapper into the user's container (viasudo+ the sudoers rule below)sudoers-shells—%shells ALL=(root) NOPASSWD: …shells-enter-rootshellsd.service— systemd unittelegraf.conf— baked into the base image; exposes in-guest metrics on :9273observability/— host-sidevmagent(scrapes each container's telegraf and remote-writes to the central VictoriaMetrics) +shells-targets.{py,service,timer}that regenerate the scrape list fromincus list
images/build-shells-base.sh— bake the Ubuntu 24.04 base image (incl. Telegraf)
Webhook API
All requests POST JSON to https://api.sh.ircforever.org/v1/… signed with
X-Signature: sha256=<hex(hmac_sha256(secret, body))> + X-Timestamp
(5-minute skew window).
| Endpoint | Body | Effect |
|---|---|---|
POST /v1/provision |
{username, pubkey} |
create container, host account, Traefik fragment, DNS records |
POST /v1/deprovision |
{username} |
reverse |
POST /v1/evidence |
{username, snapshot} |
read-only staff report before a ban: SSH logins (host jump + in-shell), portal activity, processes, sockets, cron/autostart, shell histories, recent files, executables with sha256, keys, podman, sites; snapshot also snapshots the container and home volume (evidence-<UTC time>) |
POST /v1/shell-details |
{username} |
managebot's "Shell details" panel, read-only: Incus state, created/started times, uptime, limits (CPU, memory, processes, disk) and current use; private IPv4 on incusbr0 (a warning when there is none: the Traefik sites are down), routed IPv6 and MACs; every Traefik route (<user>.yml, webhost-<user>-<label>.yml) with its backend and a TCP connect check from the host (stale when it isn't the shell's IPv4); TCP/UDP listeners (ss) with processes, public when reachable over IPv6; the process list (base marks the image's services and Podman plumbing); each account's Podman containers; every crontab. Incus 8 s, in-shell script 15 s (incus exec -n, so stdin is never read), 25 s overall; a part that fails is listed in errors and the rest still comes back, so a stopped shell still shows its config and routes. 404 for no such shell |
POST /v1/abuse |
– | latest abuse scan: per-shell findings (disguised or known-bad processes, cron restarters, outbound IRC reconnect storms / SSH fan-out / port scans / direct SMTP, YARA file signatures, IDS alerts) and proxy clients for managebot to show as flags |
POST /v1/abuse-scan |
– | runs an abuse scan now (starts shells-abuse-scan.service, waiting for one already running) and returns its report, as /v1/abuse does |
POST /v1/ids-events |
{user?, type? (alert|ssh|tls|all), sid?, q?, since?, until?, before?, limit?} |
IDS event browser for managebot: Suricata's eve.json and its rotations (eve.json.1, eve.json.N.gz) read newest-first, each record tied to the shell on either end (direction out when the shell opened the connection), with alert rule, SSH client/server versions or TLS server name, version and JA3/JA4; q matches signature, SSH software, TLS name or an address; limit 200 (max 1000); page with before = the previous next. Also a summary (counts by type, top rules, top shells; the whole range when since is given). At most 200 MB and 10 s per request (truncated when cut short) |
POST /v1/block |
{username} |
stop the container (login refused, data kept) |
POST /v1/unblock |
{username} |
start a blocked container |
GET /v1/list |
– | list provisioned shells |
GET /healthz |
– | 200 if incus reachable |
GET /metrics |
– | Prometheus exposition |
Abuse scan
shells-abuse-scan.timer runs shellsd abuse-scan every 15 minutes
(pkg/shells/abuse*.go). It only reads and flags; staff decide in managebot.
- Processes and crontabs in each running shell: known miners, proxies,
tunnels and attack tools by name; processes disguised as system ones
(
crond,[kworker/…]); binaries running from/tmpor a hidden home directory, or deleted while running; a core pegged for the whole window; cron entries that restart something from a hidden or temp directory. - Outbound connections: the scan installs
table inet shellwatch(count only, never drops) which counts new flows per shell → destination:port, and reads-and-resets it each run. Flags reconnect storms to one IRC server (nick-grabbers), many IRC servers, SSH to many hosts, port scans, wide fan-out, direct SMTP attempts and stratum pool ports. - Files: YARA (
apt install yara) withpkg/shells/abuse.yarover the home volumes and the shells'/tmp+/var/tmp, hourly, only files changed since the last pass (weekly, or when the rules change, everything). - IDS alerts: Suricata on the host (
host/suricata/, alerts only, never blocks) watches the shells' traffic: IPv4 onincusbr0before NAT, IPv6 oneth0for the shells' /64, with the Emerging Threats Open rules (updated daily bysuricata-update.timer). Each scan reads the alerts added to/var/log/suricata/eve.jsonsince the last one and keeps them per shell and rule for a day (kindids_alert). Only connections the shell opened count, and rules about ordinary traffic (SURICATA,ET INFO,ET POLICY,ET HUNTING, …) are left out. Suricata also logs SSH client versions and TLS server names to eve.json; managebot's/idspage browses all of it throughPOST /v1/ids-events. Addresses map to the shells that have them now, so an old record for a since-reused IPv4 can name the wrong shell.suricata-nic-offload.serviceturns TSO/GSO/GRO (and eth0's hardware GRO) off on both capture interfaces at boot: with them on, Suricata gets merged oversized packets it can't inspect and logs ~20k "truncated packet" alerts a day. Old alerts are archived under/var/log/suricata/archive/, which shellsd doesn't read. Suricata only reopens eve.json on a restart (SIGHUP andreopen-log-filesdidn't), so restart it after moving the file. - Proxy clients: Traefik's access log (the
traefikcontainer's Docker json log, found withdocker inspect traefik;SHELLSD_TRAEFIK_LOGoverrides it,offturns it off) is read on from where the last scan stopped. Requests to a user's site (<user>@file, or<user>-h-<label>@filefor an extra address) that became a long-lived websocket (status 0 or 101, or a 499 held for at least 5s; quick 499s are scanners) are counted per user, router and client address, with first/last seen and paths, and kept for 90 days after the client was last seen, also for users removed since. The host's and the shells' own addresses are left out. They go in the report asproxy_clients, not findings: managebot matches a client across accounts (one person running VLESS proxies on several shells uses them from the same address) and flags the overlap.
State and the report live in /var/lib/shells/abuse/ (SHELLSD_ABUSE_DIR).
Metrics
Each container runs Telegraf (baked into shells-base) exposing in-guest metrics
(cpu/mem/disk/net/netstat/system/…) on :9273 — no credentials live inside the
container (users control their own shell), so it only exposes metrics; nothing
pushes with a secret from inside. Telegraf is un-killable by the user because
shells are unprivileged (no sudo). A host-side vmagent (host/observability/)
scrapes every container over the incus bridge and remote-writes to the central
VictoriaMetrics on the main VPS; shells-targets.timer keeps the scrape list in
sync with incus list. Grafana renders the per-shell Proxmox LXC Container
Data community dashboard (ID 23742), retargeted to these metrics.
container telegraf :9273 ──scrape──▶ vmagent (host) ──remote_write──▶ VictoriaMetrics (VPS) ──▶ Grafana
Per-user surface
| Path | What lands there |
|---|---|
ssh <user>@89.167.23.102 (IPv4) |
host sshd → shells-enter → incus exec shells-<user> |
ssh <user>@<user>.sh.ircforever.org (IPv6) |
direct to container's own sshd (when DNS AAAA is set) |
https://<user>.sh.ircforever.org |
Traefik (host) → container's :80 |
Bootstrap a fresh shells host
# On the host, as root:
git clone … /usr/local/share/shells-config
cd /usr/local/share/shells-config
sudo host/bootstrap.sh
sudo images/build-shells-base.sh
# Install the daemon binary + secret:
sudo install -m 755 shellsd /usr/local/bin/shellsd
SECRET=$(openssl rand -hex 32)
sudo sed -i "s|^SHELLSD_HMAC_SECRET=.*|SHELLSD_HMAC_SECRET=$SECRET|" /etc/shellsd/env
sudo systemctl enable --now shellsd
Plan
See the parent plan file at
/Users/james/.claude/plans/polymorphic-gliding-rossum.md.
Auto-deploy (shellsd + portal)
CI (.forgejo/workflows/ci.yml) tests every push; on main it publishes
shellsd to the Forgejo generic package registry
(/api/packages/ircforever/generic/shellsd/{<commit>,latest}). The portal repo
(shells-dashboard) publishes shells-dashboard the same way.
On the shells box, shells-autodeploy.timer checks every 5 minutes and installs
a newer build: sha256-verified, previous binary kept as <bin>.bak.autodeploy,
service restarted and health-checked (shellsd /healthz; the portal must serve
/ and still answer /api/shell with 401). A failed check rolls back and that
version is skipped. shellsd isn't restarted while it has child processes (a
rebuild/upgrade or an open web console); it retries on the next run.
One-time install (root):
install -m 755 host/shells-autodeploy.sh /usr/local/sbin/shells-autodeploy
install -m 644 host/shells-autodeploy.service host/shells-autodeploy.timer /etc/systemd/system/
systemctl daemon-reload && systemctl enable --now shells-autodeploy.timer
journalctl -u shells-autodeploy -f # watch it
CI needs a REGISTRY_TOKEN secret (a Forgejo token with package write) on both
repos or the org. Tested by host/test/autodeploy_test.sh.