docs: screenshots of every page, egress and enforce demo data
Release / Plan (reuse the published image?) (push) Successful in 5s
Release / ci (push) Skipped
Release / Build image (amd64) (push) Skipped
Release / Build image (arm64) (push) Skipped
Release / Publish tags (push) Successful in 14s
Release / Gitea release (push) Skipped
Release / Plan (reuse the published image?) (push) Successful in 5s
Release / ci (push) Skipped
Release / Build image (amd64) (push) Skipped
Release / Build image (arm64) (push) Skipped
Release / Publish tags (push) Successful in 14s
Release / Gitea release (push) Skipped
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c33cca22e3
commit
5d3374ee11
81 files changed
+271
-14
No files matched your search
@@ -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)
|
||||
}
|
||||
@@ -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)}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// demo geo <dir> grava dbip-city-lite-*.mmdb e dbip-asn-lite-*.mmdb
|
||||
// demo logs <dir> <edge-1|edge-2> [seed] grava access.log, auth.log e fail2ban.log
|
||||
// demo live <segundos> <dir>:<host>... acrescenta eventos ao vivo, até o tempo acabar
|
||||
// demo egress <dir> grava egress.log e containers.map (análise de saída)
|
||||
// demo check <arquivo>... 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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user