Urutau

Urutau

Lightweight, always-on threat intelligence and privacy-friendly web analytics for self-hosted servers.
Go, single static binary · local-first · authorized use.

Terminal · Interface · Architecture · Configuration · Docker · Support · Roadmap · Changelog

English · Português

--- **Status: stable, v1.0.0.** See [CHANGELOG.md](CHANGELOG.md) for exactly what shipped. Urutau is a small panel that runs on each of your servers (as a container), reads the logs the server already writes, and answers one question: who is attacking me right now? It classifies hostile activity, scores every source IP, keeps a rolling window on disk and serves an embedded dashboard, a JSON API and an exportable blocklist. - **Reads what already exists:** the Traefik JSON access log, `/var/log/auth.log` (sshd) and `/var/log/fail2ban.log`. No agent on the network path, no packet capture, no telemetry. - **Classifies:** `scanner`, `exploit`, `bruteforce`, `ssh-fail`, `ssh-probe`, `ban`, plus the benign `ok`, `notfound` and `ssh-ok`. - **Scores IPs:** every event adds weight to its source IP. A score of 10 or more is **suspicious**; **hostile** needs 50 or more **and** a strong signal (an attack tool, two or more attack categories, a ban, or a clear exploit attempt that was refused). Scanner and exploit probes that got a 2xx or 3xx answer weigh only 0.5. An IP with a successful SSH login is never hostile and never reaches the blocklist. - **Geolocation, offline:** country, city and ASN for every IP from the free DB-IP Lite databases, downloaded and refreshed by Urutau itself, read by a built-in MMDB reader with no dependency. Nothing is looked up online. - **Understands User-Agents:** browser, operating system, device, bots and attack tools. - **Web analytics for legitimate traffic:** unique visitors, pages, referrers, countries, browsers, devices, latency (p50 and p95) and bytes, with a world map, replacing your proxy's analytics. Separate **Threats** and **Traffic** tabs. - **Lightweight:** Go standard library only, one static binary, a soft memory limit of 160 MiB, state in a single snapshot file. No database. - **Live dashboard:** embedded vanilla UI (English and Portuguese, light and dark), updated through Server-Sent Events. - **Blocklist:** hostile, globally routable IPs as plain text or JSON, ready for fail2ban, ipset, nginx or a firewall. IPv6 is aggregated by /64 and exported as `x:x:x:x::/64`. - **Federation:** one instance (the hub) aggregates others with `--peer name=url`, pulling `/api/v1/peer/export`. ## How it works ``` Traefik access.log auth.log (sshd) fail2ban.log │ │ │ └─────────┬───────────┴────────────────────┘ ▼ tail + parse (rotation aware, bounded lines) ▼ classify ──► score per IP ──► state in memory ──► snapshot (/data) │ ┌─────────────────────────┼─────────────────────┐ ▼ ▼ ▼ dashboard (SSE) /api/v1/* JSON blocklist.txt / .json hub ── GET /api/v1/peer/export (peer token) ──► peer A │ ── GET /api/v1/peer/export (peer token) ──► peer B └──► one dashboard for the whole fleet ``` ## Install Run it with Docker Compose (recommended): ```bash cp .env.example .env # set URUTAU_TOKEN (32+ characters, 128+ bits of entropy; `openssl rand -base64 48` works): sed -i "s|^URUTAU_TOKEN=.*|URUTAU_TOKEN=$(openssl rand -base64 48 | tr -d '\n')|" .env docker compose pull && docker compose up -d ``` The dashboard answers at `http://127.0.0.1:8790` and asks for the token. The image is public: `docker pull git.lucasrguerra.dev.br/ciberfauna/urutau:latest`. Or build it locally with `docker compose up -d --build`. To compile from source (Go 1.26.11 or newer, no dependency to fetch): ```bash go build -o urutau ./cmd/urutau URUTAU_TOKEN=$(openssl rand -base64 48) ./urutau serve --data-dir ./data ``` Supported platform matrix for container images: `linux/amd64` and `linux/arm64`. See [docs/docker.md](docs/docker.md) for a Coolify deployment. ## Getting started ```bash # Check the sources and the data directory urutau doctor # Run the daemon and the dashboard urutau serve --bind 127.0.0.1:8790 # Aggregate other instances urutau serve --peer web1=https://urutau.web1.example --peer-token "$URUTAU_PEER_TOKEN" ``` See [docs/cli.md](docs/cli.md) for the command reference and [docs/configuration.md](docs/configuration.md) for every `URUTAU_*` variable. ## Noise and monitoring Your own infrastructure produces events too. Two filters keep it out of the picture: - `--trusted` / `URUTAU_TRUSTED`: CIDRs of trusted origins (your office, your monitors, your other servers). Their events are dropped entirely. `--ignore` remains as an alias. - `--monitor-ua` / `URUTAU_MONITOR_UA`: a regular expression matching monitoring User-Agents (the default includes Uptime-Kuma). A request that matches and is benign is not counted as traffic; it feeds a separate "monitoring" counter. If the same request is a `scanner`, `exploit` or `bruteforce`, it counts as an attack, because a User-Agent is trivial to forge. - `--monitor-from` / `URUTAU_MONITOR_FROM`: CIDRs the monitors really come from. When set, the monitoring User-Agent is honored only from those networks. Without it, only `ok` answers are filtered (a `notfound` from a monitor User-Agent still counts), since anyone can forge the header. - `--domains` / `URUTAU_DOMAINS`: an allowlist of domains for the Traffic tab (exact names or `*.example.com`). A domain only gets a slot after a 2xx answer, and inactive domains are pruned, so random `Host` headers cannot fill the analytics. ## Geolocation and attribution Urutau shows country, city and ASN for every IP using the free **DB-IP Lite** databases. It downloads them by itself into `--geo-dir` and keeps them updated (`--geo-update`); lookups are local, so no IP is ever sent to a third party. > IP geolocation data by [DB-IP](https://db-ip.com), licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). The attribution is also shown in the dashboard. If you redistribute the databases or anything derived from them, keep it. ## Privacy The **Traffic** tab counts legitimate visitors without tracking them. A unique visitor is a hash computed with a salt that changes every day, so it cannot follow a person from one day to the next, and the IP address of a legitimate visitor is never persisted: not in the snapshot, not in a log, not in an export. IP addresses are kept only for activity classified as hostile, which is what a security tool exists to record. Without cookies, fingerprinting or third-party requests, this is designed to need no consent banner, but whether your use is lawful under the LGPD or the GDPR remains your decision as the controller. See [SECURITY.md](SECURITY.md). ## Using the blocklist The blocklist needs the access token as a bearer token. By default it lists IPs with a score of 50 or more in the last 7 days. ```bash curl -fsS -H "Authorization: Bearer $URUTAU_TOKEN" \ "https://urutau.example/api/v1/blocklist.txt?min_score=50&range=7d" ``` **fail2ban** (ban every listed IP, refreshed hourly from cron): ```bash curl -fsS -H "Authorization: Bearer $URUTAU_TOKEN" https://urutau.example/api/v1/blocklist.txt \ | while read -r ip; do fail2ban-client set sshd banip "$ip" >/dev/null; done ``` **ipset** (loaded atomically through a temporary set; `family=4` because `hash:ip` holds no IPv6 prefixes, use a `hash:net family inet6` set for `family=6`): ```bash ipset create urutau-new hash:ip -exist ipset flush urutau-new curl -fsS -H "Authorization: Bearer $URUTAU_TOKEN" https://urutau.example/api/v1/blocklist.txt?family=4 \ | while read -r ip; do ipset add urutau-new "$ip" -exist; done ipset create urutau hash:ip -exist ipset swap urutau-new urutau iptables -C INPUT -m set --match-set urutau src -j DROP 2>/dev/null \ || iptables -I INPUT -m set --match-set urutau src -j DROP ``` **nginx** (a `deny` list, then `nginx -s reload`): ```bash curl -fsS -H "Authorization: Bearer $URUTAU_TOKEN" https://urutau.example/api/v1/blocklist.txt \ | sed 's/^/deny /; s/$/;/' > /etc/nginx/conf.d/urutau-deny.conf nginx -t && nginx -s reload ``` The list only holds globally routable addresses, never anything in `--ignore` or `--trusted`, and an IPv6 attacker is listed as its /64 prefix (`2001:db8:1:2::/64`), which `ipset hash:net`, nginx `deny` and fail2ban accept. Review the list before automating it: a score is a heuristic, and an IP behind a shared NAT can be innocent. ## Security Urutau handles hostile text by design. Every field it reads from a log (paths, User-Agents, user names, hosts) was written by an attacker: it is length-limited, never executed and always escaped before it reaches the page. The dashboard and the API require a token (`URUTAU_TOKEN`, at least 32 characters, e.g. `openssl rand -base64 48`), the session cookie is `HttpOnly` and `SameSite=Strict`, failed logins are rate limited per IP, and the peer token only opens `GET /api/v1/peer/export`. Put it behind a reverse proxy with TLS before exposing it. See [SECURITY.md](SECURITY.md). ## Authorized use Urutau is defensive software. It only reads logs on servers you own or administer, and it never sends traffic to the IPs it lists. Use the blocklist responsibly, on infrastructure you are authorized to protect. ## Development ```bash go test -race ./... go vet ./... scripts/check.sh ``` See **[CONTRIBUTING.md](CONTRIBUTING.md)** and **[docs/architecture.md](docs/architecture.md)**. ## Known limits - Only three sources: Traefik JSON access log, sshd lines from `auth.log` (ISO timestamps) and `fail2ban.log`. - State is kept for 7 days at most (`--retention`), with up to 20,000 tracked IPs. - The dashboard login is a single shared token; there are no user accounts. - Scores are heuristics, not proof of malicious intent. ## Where it's going Summary of the [ROADMAP](ROADMAP.md): | | | |---|---| | **Done (1.0.0)** | Log collection, classification and scoring, offline geolocation, User-Agent parsing, privacy-friendly web analytics, snapshot persistence, dashboard with SSE, token login, blocklist, federation, Docker image and CI/CD | | **Next** | More log sources, webhook alerts, Prometheus metrics | | **Later** | IP reputation enrichment, longer retention | | **Not planned** | Active scanning or counterattack, mandatory cloud services, telemetry | ## License [MIT](LICENSE-MIT) or [Apache-2.0](LICENSE-APACHE), your choice.