Skip to content

Containers and shells ​

The hub's Containers screen lists every container of every service on the vulnbox, live, and lets a player look inside one — its log, docker inspect, a shell — without SSH access to the vulnbox. It goes through the agent's connection to the hub; nothing listens on the vulnbox for it.

This acts on the live service

The overview and the logs only look. A shell runs commands in the service's container as they would run over SSH, and a restart interrupts the service: both during the game, with the checker watching. The hub says so wherever it offers them, every shell and restart is audit-logged, and every shell is recorded.

What the overview shows ​

Per service, vulnboxd's latest deploy (live, building, waiting, failed, rolled back, and the commit running) and the ports its proxy forwards. Per container:

  • state and health as Docker reports them, the last health check's output, the restart count, an OOM kill, the exit code, when it started and its uptime;
  • image as configured, the image id and its repo digests;
  • networks and IP addresses, published and exposed ports, and mounts (bind mounts, volumes, tmpfs);
  • resource use from the container's cgroup: CPU (with a percentage since the last look), memory (current, limit, peak, OOM kills), processes (and the limit) and disk I/O;
  • the container's user and working directory, and which shells it has (bash, sh, BusyBox).

The inventory part comes from vulnboxd and is there even while the agent is not connected; the live part needs the agent, and the screen says when it is missing.

Logs ​

A container's log is its docker logs: the hub reads the last lines (up to 10000) through the agent and searches them — plain text, or a regular expression — on standard output, standard error or both. The live tail follows the log as it is written, as long as the page is open. The agent follows at most 32 logs at once, for all players together; past that, a new live tail is refused as busy until one closes.

Shells ​

Open shell starts docker exec -it in the container, shown in a terminal in the browser:

  • the shell is the best one the image has — bash, then sh, then BusyBox's sh — or one you choose;
  • it runs as the container's own user, or as root when you ask, in the working directory you choose;
  • resize the window and the terminal follows; copy and paste work as in any terminal;
  • each player may have several shells open (4 by default), on one container or many.

A shell ends when you close it, when the shell exits, after 15 minutes without input, or when the connection between the browser, the hub and the agent breaks. Whichever way it ends, the agent kills the shell and everything started from it, background jobs included, so nothing is left running in the service's container. A flood of output (cat of a big file, yes) is fine: the terminal only gets what the browser can draw, the rest waits in the container, and the capture to the hub carries on beside it.

Every session is listed with who opened it, where, how it ended and how much went each way, and is recorded — input, output and resizes, in the asciicast v2 format — so the team can replay it afterwards, or play it with asciinema play.

Restart and inspect ​

Restart is docker restart: the container is stopped (given 10 seconds to exit cleanly by default) and started again, as is. Use it for a container that hangs; a deploy or rollback is the way to change what runs. Inspect shows docker inspect, environment variables and all.

In the hub ​

Containers in the navigation rail opens the overview (/containers, all services or one). It refreshes every 7 seconds. Each service shows its deploy state and ports. Each container shows its state, health, restarts, uptime, CPU and memory; CPU is worked out from two refreshes when the agent gives no rate. When the agent does not answer, a note says why, and the inventory is still listed.

Click a container to open its pane:

The Containers screen: a service with its deploy state and its container with state, CPU and memory, and the container's logs open in a pane beside it.The Containers screen: a service with its deploy state and its container with state, CPU and memory, and the container's logs open in a pane beside it.
  • details: image and digests, user, working directory, networks, ports and resources. Each mount links into the volume browser at that path.
  • logs: search by substring or regular expression, pick a stream, and switch on a live tail.
  • inspect: docker inspect, shown only when you ask, as path = value lines with a filter, or as JSON.
  • shells: one tab per shell you open.

To open a shell, pick it from those the agent found (or type a path), tick "as root" if you need it, and set a working directory. "Shell" in the list opens the first shell found straight away. The terminal is xterm.js: it follows the size of its box, and the hub's warning stays above it while the session is open. Links the container prints are never opened. Shells only live while the screen is open: leaving the screen asks first, then ends them.

Restarting asks for confirmation and shows the warning. The Shell sessions tab lists every session with who opened it, its container and how it ended. It replays a session's recording in a terminal, with play/pause, speed, seeking and long pauses cut short.

The Shell sessions tab: one open session, who opened it, as root, in which container, with which shell.The Shell sessions tab: one open session, who opened it, as root, in which container, with which shell.

Setting it up ​

On the hub, ingest listens on an internal port for the API, and both share a secret:

sh
# ingest
HUB_INGEST_RELAY_LISTEN=0.0.0.0:7444
HUB_RELAY_TOKEN=<openssl rand -hex 24>
# api
HUB_RELAY=<ingest's address>:7444
HUB_RELAY_TOKEN=<the same>
HUB_SHELL_IDLE=15m              # how long a shell may go without input
HUB_SHELL_SESSIONS_PER_USER=4   # shells one player may have open (per API replica)

Keep the relay port inside the cluster: it reaches the agent with the hub's authority. Without it, the Containers screen shows the inventory alone. Shell recordings are kept in the hub's segment store next to the capture, under shells/.

On the vulnbox nothing needs setting up: the agent talks to Docker through its API on the socket vulnboxd uses. What the hub may do is decided there, in the agent's settings, which the hub cannot change:

yaml
agent:
  containers: true          # overview, logs, inspect
  container_restart: true   # restarts
  shell: true               # shells
  shell_sessions: 8         # shells open at once, for the whole team
  shell_idle: 900           # seconds without input before a shell is ended

A hub that could be compromised is one more way into your services: turn shell and container_restart off if you would rather not have that, and use SSH instead.