diff --git a/README.md b/README.md index ec508b8..f5a8eb0 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,10 @@

Urutau IP analysis page: verdict, score, critical exposure and recommended actions for one attacker
IP analysis: verdict, evidence and recommended actions for one address.

+

Urutau defense page with the second firewall section
Defense: the second firewall in observe mode, next to the host fail2ban.

+ +

Egress
Egress: scan bursts, beacons and mining from containers.

+ **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. diff --git a/README.pt-BR.md b/README.pt-BR.md index dbc78b0..e34835b 100644 --- a/README.pt-BR.md +++ b/README.pt-BR.md @@ -14,6 +14,10 @@

Página de análise de IP do Urutau: veredito, pontuação, exposição crítica e ações recomendadas para um atacante
Análise de IP: veredito, evidências e ações recomendadas para um endereço.

+

Página Defesa do Urutau com a seção do segundo firewall
Defesa: o segundo firewall em modo observe, ao lado do fail2ban do host.

+ +

Egress
Saída: rajadas de varredura, beacons e mineração em contêineres.

+ **Status: estável, v1.0.0.** Veja o [CHANGELOG.pt-BR.md](CHANGELOG.pt-BR.md) para saber exatamente o que foi entregue. O Urutau é um painel pequeno que roda em cada um dos seus servidores (como container), lê os logs que o servidor já escreve e responde a uma pergunta: quem está me atacando agora? Ele classifica a atividade hostil, pontua cada IP de origem, mantém uma janela móvel em disco e serve um dashboard embutido, uma API JSON e uma blocklist exportável. diff --git a/deploy/host/urutau-containers-map b/deploy/host/urutau-containers-map index 802cf34..66aeb9e 100755 --- a/deploy/host/urutau-containers-map +++ b/deploy/host/urutau-containers-map @@ -11,3 +11,12 @@ docker ps -q | xargs -r docker inspect -f '{{$n := .Name}}{{range .NetworkSettin chgrp adm "$tmp"; chmod 0640 "$tmp" mv -f "$tmp" "$out" trap - EXIT + +# The real upstream resolvers (systemd-resolved hides them behind 127.0.0.53), +# so DNS to the provider resolver is not reported as a bypass. +r=/var/log/urutau/resolv.conf +{ + resolvectl dns 2>/dev/null | tr ' ' '\n' | grep -E '^([0-9]{1,3}\.){3}[0-9]{1,3}$|^[0-9a-fA-F]*:[0-9a-fA-F:]+$' || true + awk '/^nameserver/ {print $2}' /run/systemd/resolve/resolv.conf 2>/dev/null || true +} | grep -vE '^127\.' | sort -u | sed 's/^/nameserver /' > "$r.tmp" +chgrp adm "$r.tmp"; chmod 0640 "$r.tmp"; mv -f "$r.tmp" "$r" diff --git a/docs/img/campaign-detail-dark-pt.png b/docs/img/campaign-detail-dark-pt.png new file mode 100644 index 0000000..3d26473 Binary files /dev/null and b/docs/img/campaign-detail-dark-pt.png differ diff --git a/docs/img/campaign-detail-dark.png b/docs/img/campaign-detail-dark.png new file mode 100644 index 0000000..a0de37c Binary files /dev/null and b/docs/img/campaign-detail-dark.png differ diff --git a/docs/img/campaigns-dark-pt.png b/docs/img/campaigns-dark-pt.png new file mode 100644 index 0000000..9d3eaff Binary files /dev/null and b/docs/img/campaigns-dark-pt.png differ diff --git a/docs/img/campaigns-dark.png b/docs/img/campaigns-dark.png new file mode 100644 index 0000000..69cf93d Binary files /dev/null and b/docs/img/campaigns-dark.png differ diff --git a/docs/img/campaigns-light.png b/docs/img/campaigns-light.png new file mode 100644 index 0000000..7a16bb1 Binary files /dev/null and b/docs/img/campaigns-light.png differ diff --git a/docs/img/campaigns-mobile.png b/docs/img/campaigns-mobile.png new file mode 100644 index 0000000..1643658 Binary files /dev/null and b/docs/img/campaigns-mobile.png differ diff --git a/docs/img/concentration-dark-pt.png b/docs/img/concentration-dark-pt.png new file mode 100644 index 0000000..1b63619 Binary files /dev/null and b/docs/img/concentration-dark-pt.png differ diff --git a/docs/img/concentration-dark.png b/docs/img/concentration-dark.png new file mode 100644 index 0000000..45b319e Binary files /dev/null and b/docs/img/concentration-dark.png differ diff --git a/docs/img/defense-dark-pt.png b/docs/img/defense-dark-pt.png new file mode 100644 index 0000000..f1ece9b Binary files /dev/null and b/docs/img/defense-dark-pt.png differ diff --git a/docs/img/defense-dark.png b/docs/img/defense-dark.png new file mode 100644 index 0000000..56a2f5f Binary files /dev/null and b/docs/img/defense-dark.png differ diff --git a/docs/img/defense-light.png b/docs/img/defense-light.png new file mode 100644 index 0000000..f096909 Binary files /dev/null and b/docs/img/defense-light.png differ diff --git a/docs/img/defense-mobile.png b/docs/img/defense-mobile.png new file mode 100644 index 0000000..e777d01 Binary files /dev/null and b/docs/img/defense-mobile.png differ diff --git a/docs/img/egress-dark-pt.png b/docs/img/egress-dark-pt.png new file mode 100644 index 0000000..8551628 Binary files /dev/null and b/docs/img/egress-dark-pt.png differ diff --git a/docs/img/egress-dark.png b/docs/img/egress-dark.png new file mode 100644 index 0000000..0e0ce67 Binary files /dev/null and b/docs/img/egress-dark.png differ diff --git a/docs/img/egress-light.png b/docs/img/egress-light.png new file mode 100644 index 0000000..ec68f79 Binary files /dev/null and b/docs/img/egress-light.png differ diff --git a/docs/img/egress-mobile.png b/docs/img/egress-mobile.png new file mode 100644 index 0000000..eeee652 Binary files /dev/null and b/docs/img/egress-mobile.png differ diff --git a/docs/img/errors-dark-pt.png b/docs/img/errors-dark-pt.png new file mode 100644 index 0000000..866c26d Binary files /dev/null and b/docs/img/errors-dark-pt.png differ diff --git a/docs/img/errors-dark.png b/docs/img/errors-dark.png new file mode 100644 index 0000000..d03f7b7 Binary files /dev/null and b/docs/img/errors-dark.png differ diff --git a/docs/img/errors-mobile.png b/docs/img/errors-mobile.png new file mode 100644 index 0000000..e34412b Binary files /dev/null and b/docs/img/errors-mobile.png differ diff --git a/docs/img/evolution-dark-pt.png b/docs/img/evolution-dark-pt.png new file mode 100644 index 0000000..68181c2 Binary files /dev/null and b/docs/img/evolution-dark-pt.png differ diff --git a/docs/img/evolution-dark.png b/docs/img/evolution-dark.png new file mode 100644 index 0000000..9c2482a Binary files /dev/null and b/docs/img/evolution-dark.png differ diff --git a/docs/img/geo-brazil-dark-pt.png b/docs/img/geo-brazil-dark-pt.png new file mode 100644 index 0000000..bbbc110 Binary files /dev/null and b/docs/img/geo-brazil-dark-pt.png differ diff --git a/docs/img/geo-brazil-dark.png b/docs/img/geo-brazil-dark.png index 1c158c1..84422c4 100644 Binary files a/docs/img/geo-brazil-dark.png and b/docs/img/geo-brazil-dark.png differ diff --git a/docs/img/geo-pernambuco-dark-pt.png b/docs/img/geo-pernambuco-dark-pt.png new file mode 100644 index 0000000..8b5f65f Binary files /dev/null and b/docs/img/geo-pernambuco-dark-pt.png differ diff --git a/docs/img/geo-pernambuco-dark.png b/docs/img/geo-pernambuco-dark.png index 2fb1665..3b1a205 100644 Binary files a/docs/img/geo-pernambuco-dark.png and b/docs/img/geo-pernambuco-dark.png differ diff --git a/docs/img/geo-world-dark-pt.png b/docs/img/geo-world-dark-pt.png index 2e82d94..2cbce34 100644 Binary files a/docs/img/geo-world-dark-pt.png and b/docs/img/geo-world-dark-pt.png differ diff --git a/docs/img/geo-world-dark.png b/docs/img/geo-world-dark.png index 0874608..2cbb6d5 100644 Binary files a/docs/img/geo-world-dark.png and b/docs/img/geo-world-dark.png differ diff --git a/docs/img/geo-world-light.png b/docs/img/geo-world-light.png index 18b02cb..435405d 100644 Binary files a/docs/img/geo-world-light.png and b/docs/img/geo-world-light.png differ diff --git a/docs/img/integrity-dark-pt.png b/docs/img/integrity-dark-pt.png new file mode 100644 index 0000000..4ac5abe Binary files /dev/null and b/docs/img/integrity-dark-pt.png differ diff --git a/docs/img/integrity-dark.png b/docs/img/integrity-dark.png new file mode 100644 index 0000000..8e404b7 Binary files /dev/null and b/docs/img/integrity-dark.png differ diff --git a/docs/img/ip-analysis-dark-pt.png b/docs/img/ip-analysis-dark-pt.png index 78638ab..c4eee90 100644 Binary files a/docs/img/ip-analysis-dark-pt.png and b/docs/img/ip-analysis-dark-pt.png differ diff --git a/docs/img/ip-analysis-dark.png b/docs/img/ip-analysis-dark.png index 649b933..f383354 100644 Binary files a/docs/img/ip-analysis-dark.png and b/docs/img/ip-analysis-dark.png differ diff --git a/docs/img/ip-analysis-light.png b/docs/img/ip-analysis-light.png index b726f87..609aa02 100644 Binary files a/docs/img/ip-analysis-light.png and b/docs/img/ip-analysis-light.png differ diff --git a/docs/img/ips-dark-pt.png b/docs/img/ips-dark-pt.png index a770cd3..202a000 100644 Binary files a/docs/img/ips-dark-pt.png and b/docs/img/ips-dark-pt.png differ diff --git a/docs/img/ips-dark.png b/docs/img/ips-dark.png index e5058e5..9419940 100644 Binary files a/docs/img/ips-dark.png and b/docs/img/ips-dark.png differ diff --git a/docs/img/ips-mobile.png b/docs/img/ips-mobile.png index 4ce45a2..626bf2a 100644 Binary files a/docs/img/ips-mobile.png and b/docs/img/ips-mobile.png differ diff --git a/docs/img/live-flat-dark-pt.png b/docs/img/live-flat-dark-pt.png new file mode 100644 index 0000000..4e01ba3 Binary files /dev/null and b/docs/img/live-flat-dark-pt.png differ diff --git a/docs/img/live-flat-dark.png b/docs/img/live-flat-dark.png index 366fe16..cf914d9 100644 Binary files a/docs/img/live-flat-dark.png and b/docs/img/live-flat-dark.png differ diff --git a/docs/img/live-flat-light.png b/docs/img/live-flat-light.png index 4aadedf..21260b6 100644 Binary files a/docs/img/live-flat-light.png and b/docs/img/live-flat-light.png differ diff --git a/docs/img/live-flat-mobile.png b/docs/img/live-flat-mobile.png index c7d5bcc..cdf1523 100644 Binary files a/docs/img/live-flat-mobile.png and b/docs/img/live-flat-mobile.png differ diff --git a/docs/img/live-globe-dark-pt.png b/docs/img/live-globe-dark-pt.png index e3da071..09f2cdc 100644 Binary files a/docs/img/live-globe-dark-pt.png and b/docs/img/live-globe-dark-pt.png differ diff --git a/docs/img/live-globe-dark.png b/docs/img/live-globe-dark.png index 278c8e5..dabe356 100644 Binary files a/docs/img/live-globe-dark.png and b/docs/img/live-globe-dark.png differ diff --git a/docs/img/mitre-dark-pt.png b/docs/img/mitre-dark-pt.png new file mode 100644 index 0000000..23b521b Binary files /dev/null and b/docs/img/mitre-dark-pt.png differ diff --git a/docs/img/mitre-dark.png b/docs/img/mitre-dark.png new file mode 100644 index 0000000..19b14c2 Binary files /dev/null and b/docs/img/mitre-dark.png differ diff --git a/docs/img/overview-dark-pt.png b/docs/img/overview-dark-pt.png index a26efaa..8864440 100644 Binary files a/docs/img/overview-dark-pt.png and b/docs/img/overview-dark-pt.png differ diff --git a/docs/img/overview-dark.png b/docs/img/overview-dark.png index a42407d..0596a5e 100644 Binary files a/docs/img/overview-dark.png and b/docs/img/overview-dark.png differ diff --git a/docs/img/overview-light.png b/docs/img/overview-light.png index 1aecd70..5b4db47 100644 Binary files a/docs/img/overview-light.png and b/docs/img/overview-light.png differ diff --git a/docs/img/overview-mobile.png b/docs/img/overview-mobile.png index 29ddc8e..487922e 100644 Binary files a/docs/img/overview-mobile.png and b/docs/img/overview-mobile.png differ diff --git a/docs/img/protocol-dark-pt.png b/docs/img/protocol-dark-pt.png new file mode 100644 index 0000000..38029d5 Binary files /dev/null and b/docs/img/protocol-dark-pt.png differ diff --git a/docs/img/protocol-dark.png b/docs/img/protocol-dark.png new file mode 100644 index 0000000..69dde9b Binary files /dev/null and b/docs/img/protocol-dark.png differ diff --git a/docs/img/replay-dark-pt.png b/docs/img/replay-dark-pt.png index ed7e696..d2c5981 100644 Binary files a/docs/img/replay-dark-pt.png and b/docs/img/replay-dark-pt.png differ diff --git a/docs/img/replay-dark.png b/docs/img/replay-dark.png index dc708fd..1b3dc1e 100644 Binary files a/docs/img/replay-dark.png and b/docs/img/replay-dark.png differ diff --git a/docs/img/reports-dark-pt.png b/docs/img/reports-dark-pt.png new file mode 100644 index 0000000..f228caf Binary files /dev/null and b/docs/img/reports-dark-pt.png differ diff --git a/docs/img/reports-dark.png b/docs/img/reports-dark.png new file mode 100644 index 0000000..fca3686 Binary files /dev/null and b/docs/img/reports-dark.png differ diff --git a/docs/img/search-dark-pt.png b/docs/img/search-dark-pt.png new file mode 100644 index 0000000..3c2679e Binary files /dev/null and b/docs/img/search-dark-pt.png differ diff --git a/docs/img/search-dark.png b/docs/img/search-dark.png new file mode 100644 index 0000000..027c92f Binary files /dev/null and b/docs/img/search-dark.png differ diff --git a/docs/img/sessions-dark-pt.png b/docs/img/sessions-dark-pt.png new file mode 100644 index 0000000..933f8d3 Binary files /dev/null and b/docs/img/sessions-dark-pt.png differ diff --git a/docs/img/sessions-dark.png b/docs/img/sessions-dark.png new file mode 100644 index 0000000..2289dbd Binary files /dev/null and b/docs/img/sessions-dark.png differ diff --git a/docs/img/slo-dark-pt.png b/docs/img/slo-dark-pt.png new file mode 100644 index 0000000..29d483a Binary files /dev/null and b/docs/img/slo-dark-pt.png differ diff --git a/docs/img/slo-dark.png b/docs/img/slo-dark.png new file mode 100644 index 0000000..2998145 Binary files /dev/null and b/docs/img/slo-dark.png differ diff --git a/docs/img/slo-light.png b/docs/img/slo-light.png new file mode 100644 index 0000000..81b8991 Binary files /dev/null and b/docs/img/slo-light.png differ diff --git a/docs/img/slo-mobile.png b/docs/img/slo-mobile.png new file mode 100644 index 0000000..46407a1 Binary files /dev/null and b/docs/img/slo-mobile.png differ diff --git a/docs/img/sources-dark-pt.png b/docs/img/sources-dark-pt.png index b9bf590..a4f1735 100644 Binary files a/docs/img/sources-dark-pt.png and b/docs/img/sources-dark-pt.png differ diff --git a/docs/img/sources-dark.png b/docs/img/sources-dark.png index 928b0f0..3a95567 100644 Binary files a/docs/img/sources-dark.png and b/docs/img/sources-dark.png differ diff --git a/docs/img/survival-dark-pt.png b/docs/img/survival-dark-pt.png new file mode 100644 index 0000000..47d3052 Binary files /dev/null and b/docs/img/survival-dark-pt.png differ diff --git a/docs/img/survival-dark.png b/docs/img/survival-dark.png new file mode 100644 index 0000000..57890c5 Binary files /dev/null and b/docs/img/survival-dark.png differ diff --git a/docs/img/threats-dark-pt.png b/docs/img/threats-dark-pt.png index 4129e62..28a69cb 100644 Binary files a/docs/img/threats-dark-pt.png and b/docs/img/threats-dark-pt.png differ diff --git a/docs/img/threats-dark.png b/docs/img/threats-dark.png index 3ea455a..84f2827 100644 Binary files a/docs/img/threats-dark.png and b/docs/img/threats-dark.png differ diff --git a/docs/img/threats-mobile.png b/docs/img/threats-mobile.png index 21f8dda..f321666 100644 Binary files a/docs/img/threats-mobile.png and b/docs/img/threats-mobile.png differ diff --git a/docs/img/traffic-dark-pt.png b/docs/img/traffic-dark-pt.png index 0248e0b..1e44777 100644 Binary files a/docs/img/traffic-dark-pt.png and b/docs/img/traffic-dark-pt.png differ diff --git a/docs/img/traffic-dark.png b/docs/img/traffic-dark.png index 692be3c..723f6ca 100644 Binary files a/docs/img/traffic-dark.png and b/docs/img/traffic-dark.png differ diff --git a/docs/interface.md b/docs/interface.md index 01d1aa4..5215204 100644 --- a/docs/interface.md +++ b/docs/interface.md @@ -53,6 +53,36 @@ A side rail (a tab bar on phones) holds the pages. Each page opens with a senten

Sources and hosts page: instances, log sources and blocklist
Sources and hosts.

+

Page: Sessions
Sessions: the stages of each attacker, with a replay link.

+ +

Page: Campaigns
Campaigns: coordinated groups of addresses (Gantt and similarity).

+ +

Page: Campaign detail
Campaign detail: members, timeline and shared traits.

+ +

Page: Search
Search: filter the event registry by IP, path, family and status.

+ +

Page: MITRE ATT&CK
MITRE ATT&CK: techniques observed, by tactic.

+ +

Page: Defense, with the second firewall
Defense: coverage of the host fail2ban and the second firewall (observe mode).

+ +

Page: Egress traffic
Egress: outbound connections of the host and containers, with scan bursts, beacons and mining.

+ +

Page: Evolution
Evolution: how attacks change over time.

+ +

Page: Concentration
Concentration: how much of the hostility a few sources or networks account for.

+ +

Page: Survival
Survival: how long attackers keep coming back.

+ +

Page: Errors
Errors: response classes, targets and hosts.

+ +

Page: Services
Services: availability and latency of each service.

+ +

Page: Protocols and TLS
Protocols and TLS: HTTP and TLS versions by class.

+ +

Page: Integrity
Integrity: health of the log sources and the registry.

+ +

Page: Reports
Reports: the exportable report.

+

Overview in the light theme Overview on a phone
The light theme on a desktop and the phone layout (a tab bar replaces the side rail).

## Page groups @@ -112,3 +142,7 @@ State and city boundaries on the Geography page are from [Natural Earth](https:/ An invalid `range` or period answers 400, and `range` in the responses is an object `{name,from,to,step,clipped}` (`step` is the timeline granularity in seconds). API clients send `Authorization: Bearer `. The peer token is accepted only by `/api/v1/peer/export`, `/api/v1/peer/stream` and `/api/v1/peer/period`; every other route answers 403 to it. + +

Defense Defense
Defense, egress and campaigns in the light theme and on a phone.

+ +

Egress Egress

diff --git a/docs/pt-BR/interface.md b/docs/pt-BR/interface.md index 27090a8..ee48645 100644 --- a/docs/pt-BR/interface.md +++ b/docs/pt-BR/interface.md @@ -50,6 +50,36 @@ Uma barra lateral (barra de abas no celular) reúne as páginas. Cada página ab

Página Fontes e hosts: instâncias, fontes de log e blocklist
Fontes e hosts.

+

Página: Sessões
Sessões: as etapas de cada atacante, com link para o replay.

+ +

Página: Campanhas
Campanhas: grupos coordenados de endereços (Gantt e similaridade).

+ +

Página: Detalhe da campanha
Detalhe da campanha: membros, linha do tempo e traços em comum.

+ +

Página: Busca
Busca: filtre o registro de eventos por IP, caminho, família e status.

+ +

Página: MITRE ATT&CK
MITRE ATT&CK: técnicas observadas, por tática.

+ +

Página: Defesa, com o segundo firewall
Defesa: cobertura do fail2ban do host e do segundo firewall (modo observe).

+ +

Página: Tráfego de saída
Saída: conexões de saída do host e dos contêineres, com rajadas de varredura, beacons e mineração.

+ +

Página: Evolução
Evolução: como os ataques mudam ao longo do tempo.

+ +

Página: Concentração
Concentração: quanto da hostilidade poucas fontes ou redes explicam.

+ +

Página: Sobrevivência
Sobrevivência: por quanto tempo os atacantes continuam voltando.

+ +

Página: Erros
Erros: classes de resposta, alvos e hosts.

+ +

Página: Serviços
Serviços: disponibilidade e latência de cada serviço.

+ +

Página: Protocolos e TLS
Protocolos e TLS: versões de HTTP e TLS por classe.

+ +

Página: Integridade
Integridade: saúde das fontes de log e do registro.

+ +

Página: Relatórios
Relatórios: o relatório exportável.

+

Visão geral no tema claro Visão geral no celular
O tema claro no desktop e o layout de celular (uma barra de abas substitui a lateral).

## Grupos de páginas @@ -109,3 +139,7 @@ Os limites de estados e cidades da página Geografia são do [Natural Earth](htt Um `range` ou período inválido responde 400, e `range` nas respostas é um objeto `{name,from,to,step,clipped}` (`step` é a granularidade da linha do tempo em segundos). Clientes da API enviam `Authorization: Bearer `. O token de peer só é aceito por `/api/v1/peer/export`, `/api/v1/peer/stream` e `/api/v1/peer/period`; todas as outras rotas respondem 403 a ele. + +

Defense Defense
Defesa, saída e campanhas no tema claro e no celular.

+ +

Egress Egress

diff --git a/scripts/screenshots.sh b/scripts/screenshots.sh index efd39b6..fba3363 100755 --- a/scripts/screenshots.sh +++ b/scripts/screenshots.sh @@ -42,6 +42,8 @@ for port in "$hub_port" "$peer_port" "$login_port"; do done export TZ=UTC +# Hidden demo-only switch: reserved ranges count as public for the second firewall (see internal/enforce/policy.go). +export URUTAU_DEMO_RESERVED_PUBLIC=1 mkdir -p "$out" "$work/bin" (cd "$root" && go build -trimpath -o "$work/bin/urutau" ./cmd/urutau && go build -o "$work/bin/demo" ./scripts/screenshots/demo) urutau="$work/bin/urutau" @@ -51,7 +53,8 @@ demo="$work/bin/demo" "$demo" geo "$work/geo" "$demo" logs "$work/hub/logs" edge-1 1 "$demo" logs "$work/peer/logs" edge-2 2 -"$demo" check "$work"/hub/logs/* "$work"/peer/logs/* # fails on any IP outside the reserved ranges +"$demo" egress "$work/hub/egress" +"$demo" check "$work"/hub/logs/* "$work"/peer/logs/* "$work"/hub/egress/* # fails on any IP outside the reserved ranges export URUTAU_PEER_TOKEN=$(openssl rand -base64 48 | tr -d '\n') start() { # start name port dir [extra flags...] @@ -62,7 +65,9 @@ start() { # start name port dir [extra flags...] pids+=($!) } start edge-2 "$peer_port" "$work/peer" --location "39.0438,-77.4874,edge-2" -start edge-1 "$hub_port" "$work/hub" --location "50.1109,8.6821,edge-1" --peer "edge-2=http://127.0.0.1:$peer_port" +start edge-1 "$hub_port" "$work/hub" --location "50.1109,8.6821,edge-1" \ + --enforce observe --egress on --egress-log "$work/hub/egress/egress.log" --egress-containers "$work/hub/egress/containers.map" \ + --egress-workloads "ciberlab=name:ciberlab:scanner" --peer "edge-2=http://127.0.0.1:$peer_port" # A third, short-lived instance with authentication on, only for the login page. mkdir -p "$work/login/data" diff --git a/scripts/screenshots/demo/egress.go b/scripts/screenshots/demo/egress.go new file mode 100644 index 0000000..e65ce60 --- /dev/null +++ b/scripts/screenshots/demo/egress.go @@ -0,0 +1,75 @@ +package main + +import ( + "fmt" + "math/rand" + "net/netip" + "os" + "path/filepath" + "time" +) + +// Dados de demonstração da análise de saída (egress): um log no formato do +// kernel/rsyslog com o prefixo "URUTAU-EGRESS: " e o mapa ip -> contêiner. Origens +// privadas (10.x/172.x); destinos só nas faixas reservadas de documentação. +const ( + ipCiberlab = "172.18.0.20" // workload scanner: rajadas de varredura + ipBeacon = "10.0.3.15" // beacon regular (60 s) para um IP que também ataca a entrada + ipMiner = "10.0.3.22" // porta de mineração 3333 + ipWeb = "10.0.3.5" + ipAPI = "10.0.3.6" + ipC2 = "203.0.113.45" // mesmo atacante dos logs de entrada + ipPool = "198.51.100.200" +) + +func egressLine(t time.Time, src, dst string, dport int, proto string, sport int) string { + return fmt.Sprintf("%s edge-1 kernel: [%d.%06d] URUTAU-EGRESS: IN=br-demo OUT=enp0s6 MAC=02:42:ac:12:00:01 SRC=%s DST=%s LEN=60 TOS=0x00 PREC=0x00 TTL=63 ID=%d DF PROTO=%s SPT=%d DPT=%d WINDOW=64240 RES=0x00 SYN URGP=0", + t.UTC().Format("2006-01-02T15:04:05.000000+00:00"), 1000+t.Unix()%100000, t.Nanosecond()/1000, src, dst, t.Unix()%65000, proto, sport, dport) +} + +func writeEgress(dir string) error { + if err := os.MkdirAll(dir, 0o755); err != nil { + return err + } + now := time.Now().UTC() + r := rand.New(rand.NewSource(7)) + var ls []line + add := func(t time.Time, src, dst string, dport int) { + ls = append(ls, line{t, egressLine(t, src, dst, dport, "TCP", 30000+r.Intn(30000))}) + } + // tráfego normal (443) a poucos destinos, nas últimas 30 h + web := []string{"198.18.10.10", "198.18.10.11", "198.51.100.30", "203.0.113.80", "192.0.2.80"} + for t := now.Add(-30 * time.Hour); t.Before(now); t = t.Add(time.Duration(40+r.Intn(120)) * time.Second) { + src := ipWeb + if r.Intn(3) == 0 { + src = ipAPI + } + add(t, src, web[r.Intn(len(web))], 443) + } + // beacon: 60 s +- jitter, nas últimas 5 h + for t := now.Add(-5 * time.Hour); t.Before(now); t = t.Add(time.Duration(60000+r.Intn(5000)-2500) * time.Millisecond) { + add(t, ipBeacon, ipC2, 8443) + } + // mineração: ligações repetidas ao pool, porta 3333 + for t := now.Add(-3 * time.Hour); t.Before(now); t = t.Add(time.Duration(20+r.Intn(40)) * time.Minute) { + for k := 0; k < 3; k++ { + add(t.Add(time.Duration(k)*time.Second), ipMiner, ipPool, 3333) + } + } + // ciberlab: rajadas de varredura em faixas reservadas + for _, ago := range []time.Duration{26 * time.Hour, 20 * time.Hour, 14 * time.Hour, 9 * time.Hour, 5 * time.Hour, 2 * time.Hour, 25 * time.Minute} { + start := now.Add(-ago) + for i := 0; i < 400; i++ { + dst := netip.AddrFrom4([4]byte{198, byte(18 + r.Intn(2)), byte(r.Intn(256)), byte(1 + r.Intn(254))}).String() + port := []int{22, 80, 443, 3389, 8080, 445}[r.Intn(6)] + add(start.Add(time.Duration(i)*150*time.Millisecond), ipCiberlab, dst, port) + } + } + // uma resolução 2001:db8 para o exemplo IPv6 + ls = append(ls, line{now.Add(-time.Hour), egressLine(now.Add(-time.Hour), "fd00::5", "2001:db8::53", 443, "TCP", 40000)}) + if err := writeLines(filepath.Join(dir, "egress.log"), ls, now); err != nil { + return err + } + m := fmt.Sprintf("%s ciberlab\n%s shop-beacon\n%s worker-miner\n%s web-frontend\n%s api-backend\nfd00::5 web-frontend\n", ipCiberlab, ipBeacon, ipMiner, ipWeb, ipAPI) + return os.WriteFile(filepath.Join(dir, "containers.map"), []byte(m), 0o644) +} diff --git a/scripts/screenshots/demo/logs.go b/scripts/screenshots/demo/logs.go index 6a22fb8..e61df0c 100644 --- a/scripts/screenshots/demo/logs.go +++ b/scripts/screenshots/demo/logs.go @@ -205,10 +205,36 @@ type traefik struct { Referer string `json:"request_Referer,omitempty"` Duration int64 `json:"Duration"` Size int64 `json:"DownstreamContentSize"` + Proto string `json:"RequestProtocol,omitempty"` + Scheme string `json:"RequestScheme,omitempty"` + TLSVer string `json:"TLSVersion,omitempty"` + TLSCipher string `json:"TLSCipher,omitempty"` +} + +// protoOf varia o protocolo conforme o cliente: navegadores em HTTP/2 e HTTP/3, +// ferramentas e scanners em HTTP/1.1 (TLS 1.2) e alguns em HTTP/1.0 sem TLS. +func protoOf(ip netip.Addr, ua string) (proto, scheme, ver, cipher string) { + h := 0 + for _, c := range ip.String() { + h = h*31 + int(c) + } + browser := strings.Contains(ua, "Chrome/") || strings.Contains(ua, "Safari/") || strings.Contains(ua, "Firefox/") + switch { + case browser && !strings.Contains(ua, "bot") && h%4 == 0: + return "HTTP/3.0", "https", "1.3", "TLS_AES_128_GCM_SHA256" + case browser && h%7 != 0: + return "HTTP/2.0", "https", "1.3", "TLS_AES_256_GCM_SHA384" + case h%5 == 0: + return "HTTP/1.0", "http", "", "" + case h%3 == 0: + return "HTTP/1.1", "https", "1.2", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" + } + return "HTTP/1.1", "https", "1.3", "TLS_AES_128_GCM_SHA256" } func webLine(t time.Time, ip netip.Addr, domain, method, path string, status int, ua, ref string, dur time.Duration, size int64) line { - b, _ := json.Marshal(traefik{ip.String(), domain, method, path, status, t.UTC().Format("2006-01-02T15:04:05.000000000Z"), ua, ref, int64(dur), size}) + pr, sc, tv, tc := protoOf(ip, ua) + b, _ := json.Marshal(traefik{ip.String(), domain, method, path, status, t.UTC().Format("2006-01-02T15:04:05.000000000Z"), ua, ref, int64(dur), size, pr, sc, tv, tc}) return line{t, string(b)} } diff --git a/scripts/screenshots/demo/main.go b/scripts/screenshots/demo/main.go index 75d59ca..0d617f0 100644 --- a/scripts/screenshots/demo/main.go +++ b/scripts/screenshots/demo/main.go @@ -6,6 +6,7 @@ // demo geo grava dbip-city-lite-*.mmdb e dbip-asn-lite-*.mmdb // demo logs [seed] grava access.log, auth.log e fail2ban.log // demo live :... acrescenta eventos ao vivo, até o tempo acabar +// demo egress grava egress.log e containers.map (análise de saída) // demo check ... falha se achar IP fora das faixas reservadas package main @@ -13,6 +14,7 @@ import ( "fmt" "net/netip" "os" + "path/filepath" "regexp" "strconv" "strings" @@ -56,6 +58,8 @@ func run(a []string) error { dirs, hosts = append(dirs, d), append(hosts, h) } return live(dirs, hosts, time.Duration(secs)*time.Second) + case "egress": + return writeEgress(a[1]) case "check": return check(a[1:]) } @@ -80,6 +84,10 @@ func check(files []string) error { continue // versão de navegador (Chrome/130.0.0.0), não um endereço } ip, err := netip.ParseAddr(m) + base := filepath.Base(f) + if err == nil && ip.IsPrivate() && (base == "egress.log" || base == "containers.map") { + continue // origens dos contêineres (10.x/172.x/fd00::) + } if err != nil || reserved(ip) { continue } diff --git a/scripts/screenshots/shots.mjs b/scripts/screenshots/shots.mjs index fb0cc5e..5dd9f14 100644 --- a/scripts/screenshots/shots.mjs +++ b/scripts/screenshots/shots.mjs @@ -1,6 +1,7 @@ // Captures the Urutau dashboard for docs/img. // Usage (called by scripts/screenshots.sh): node shots.mjs // +// Covers every page registered in internal/server/web/pages.json plus the campaign detail. // Desktop 1440x900 in the dark theme (English, plus Portuguese for the pages the // pt-BR docs show), a few pages in the light theme, and a few at 390x844 (phone). // File names: -dark.png, -dark-pt.png, -light.png, -mobile.png. @@ -17,26 +18,77 @@ const DESKTOP = { width: 1440, height: 900, deviceScaleFactor: 1 }; const PHONE = { width: 390, height: 844, deviceScaleFactor: 2, isMobile: true, hasTouch: true }; const ATTACKER = "203.0.113.45"; // the multi-vector attacker of the demo data -// pages: id (file name), hash, settle time, optional prepare(page) +// pages: id (file name), hash, settle time (ms, after the page reports ready), optional prepare(page), +// optional ready (CSS selector that must exist) and minPanels (panels with data). +const R = (id, route, extra = {}) => ({ id, hash: `#/${route}`, wait: 1500, ...extra }); const pages = [ { id: "overview", hash: "#/overview?r=7d", wait: 3500 }, { id: "threats", hash: "#/threats?r=24h", wait: 3500 }, { id: "geo-world", hash: "#/geo?r=30d", wait: 3500 }, { id: "geo-brazil", hash: "#/geo/BR?r=30d", wait: 3500 }, { id: "geo-pernambuco", hash: "#/geo/BR/Pernambuco?r=30d", wait: 3500 }, - { id: "live-flat", hash: "#/live?r=24h", wait: 14000, prepare: (p) => liveMode(p, "flat") }, - { id: "live-globe", hash: "#/live?r=24h", wait: 14000, prepare: (p) => liveMode(p, "globe") }, + { id: "live-flat", hash: "#/live?r=24h", wait: 14000, prepare: (p) => liveMode(p, "flat"), live: true }, + { id: "live-globe", hash: "#/live?r=24h", wait: 14000, prepare: (p) => liveMode(p, "globe"), live: true }, { id: "traffic", hash: "#/traffic?r=30d", wait: 3500 }, { id: "ips", hash: "#/ips?r=7d", wait: 3500 }, { id: "ip-analysis", hash: `#/ip/${ATTACKER}?r=7d`, wait: 4500 }, // starts in the middle of the escalation of the demo attacker (about 25 h ago) and plays on - { id: "replay", hash: () => `#/replay?r=2d&speed=300&t=${encodeURIComponent(new Date(Date.now() - (25 * 60 + 50) * 60e3).toISOString())}`, wait: 3500 }, + { id: "replay", hash: () => `#/replay?r=2d&speed=300&t=${encodeURIComponent(new Date(Date.now() - (25 * 60 + 50) * 60e3).toISOString())}`, wait: 3500, live: true }, { id: "sources", hash: "#/sources?r=24h", wait: 3500 }, + // pages of the later versions + R("sessions", "sessions?r=7d"), + R("campaigns", "campaigns?r=30d"), + { id: "campaign-detail", hash: async () => `#/campaigns/${await firstCampaign()}?r=30d`, wait: 2500 }, + R("search", `search?r=7d&ip=${ATTACKER}`, { wait: 2500 }), + R("mitre", "mitre?r=30d"), + R("defense", "defense?r=7d", { wait: 2500, full: true }), + R("evolution", "evolution?r=30d", { wait: 2500 }), + R("concentration", "concentration?r=30d", { wait: 2500 }), + R("survival", "survival?r=30d", { wait: 2500 }), + R("errors", "errors?r=7d", { wait: 2500 }), + R("slo", "slo?r=7d", { wait: 2500 }), + R("protocol", "protocol?r=7d", { wait: 2500 }), + R("integrity", "integrity?r=7d"), + R("reports", "reports?r=7d"), + R("egress", "egress?r=7d", { wait: 2500, full: true }), ]; const darkEN = pages.map((p) => p.id); -const darkPT = ["overview", "threats", "geo-world", "live-globe", "traffic", "ips", "ip-analysis", "replay", "sources"]; -const light = ["overview", "geo-world", "live-flat", "ip-analysis"]; -const mobile = ["overview", "threats", "live-flat", "ips"]; +const darkPT = darkEN; // the pt-BR docs show every page +const light = ["overview", "geo-world", "live-flat", "ip-analysis", "defense", "egress", "campaigns", "slo"]; +const mobile = ["overview", "threats", "live-flat", "ips", "defense", "egress", "campaigns", "errors", "slo"]; + +async function firstCampaign() { + const r = await fetch(`${hub}/api/v1/campaigns?range=30d`); + const j = await r.json(); + const c = (j.campaigns || [])[0]; + if (!c) throw new Error("no campaign in the demo data (campaign-detail)"); + return encodeURIComponent(c.id); +} + +// Waits until the page left the loading state, then fails when the capture would be an +// error, a disabled feature or nothing but empty states. +async function waitReady(page, id) { + try { + await page.waitForFunction(() => { + const v = document.querySelector("#view"); + return v && (v.innerText || "").trim().length > 80 && !v.querySelector(".skeleton"); + }, { timeout: 25000, polling: 300 }); + } catch { throw new Error(`${id}: still loading after 25 s (skeleton or no content)`); } +} +async function checkData(page, id) { + const r = await page.evaluate(() => { + const v = document.querySelector("#view"); + const panels = v.querySelectorAll(".panel").length; + const empties = v.querySelectorAll(".state-empty").length; + const txt = v.innerText || ""; + return { panels, empties, len: txt.trim().length, txt: txt.slice(0, 200).replace(/\s+/g, " ") }; + }); + const bad = /Could not load data|Não foi possível carregar|disabled|desativad|desligad/i.test(r.txt); + if (bad || r.len < 80 || (r.panels > 0 && r.empties >= r.panels) || (r.panels === 0 && r.empties > 0)) { + throw new Error(`${id}: capture has no data (panels=${r.panels} empty=${r.empties}) "${r.txt}"`); + } +} +const failures = []; async function liveMode(page, mode) { try { await page.evaluate((m) => localStorage.setItem("urutau.live.mode", m), mode); } catch {} @@ -51,7 +103,10 @@ async function replayPlay(page) { const browser = await puppeteer.launch({ executablePath: chrome, args: ["--no-sandbox", "--use-gl=angle", "--use-angle=swiftshader", "--enable-unsafe-swiftshader", "--ignore-gpu-blocklist"], defaultViewport: DESKTOP }); -async function shoot(p, { theme, lang, viewport, suffix }) { +async function shoot(p, o) { + try { await shoot1(p, o); } catch (e) { failures.push(e.message); console.error("FAIL", e.message); for (const pg of (await browser.pages()).slice(1)) await pg.close().catch(() => {}); } +} +async function shoot1(p, { theme, lang, viewport, suffix }) { const page = await browser.newPage(); await page.setViewport(viewport); await page.evaluateOnNewDocument((th, lg) => { @@ -59,13 +114,15 @@ async function shoot(p, { theme, lang, viewport, suffix }) { }, theme, lang); await page.goto(hub + "/", { waitUntil: "domcontentloaded" }); if (p.prepare) await p.prepare(page); - const hash = typeof p.hash === "function" ? p.hash() : p.hash; + const hash = typeof p.hash === "function" ? await p.hash() : p.hash; await page.goto(hub + "/" + hash, { waitUntil: "domcontentloaded" }); await page.evaluate((h) => { location.hash = h; }, hash); + const name = `${p.id}-${suffix}`; + await waitReady(page, name); await sleep(p.wait); if (p.id === "replay") await replayPlay(page); - const name = `${p.id}-${suffix}`; - await page.screenshot({ path: `${out}/${name}.png` }); + await checkData(page, name); + await page.screenshot({ path: `${out}/${name}.png`, fullPage: !!p.full && viewport === DESKTOP }); console.log("ok", name); await page.close(); } @@ -91,3 +148,4 @@ try { } finally { await browser.close(); } +if (failures.length) { console.error(`\n${failures.length} capture(s) failed:\n - ` + failures.join("\n - ")); process.exit(1); }