Files
urutau/internal/intel/mitre.go
T
Lucas RayanandClaude Opus 5.5 b7462c14fa
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
feat: 1.2.0 attack intelligence, replay, 30-day history and new interface
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>
2026-11-14 21:45:59 -03:00

139 lines
3.9 KiB
Go

package intel
import (
"sort"
"strings"
"git.lucasrguerra.dev.br/ciberfauna/urutau/internal/core"
)
// TechCtx carries the extra context Techniques needs.
type TechCtx struct {
Tool string // attack-tool label or User-Agent (any case)
Path string // request path (distinguishes wordpress sub-techniques)
Users int // distinct SSH usernames tried by the source
MaxPerUser int // most attempts against a single username
PriorFails bool // ssh-ok preceded by failures from the same IP
}
var techNames = map[string]string{
"T1190": "Exploit Public-Facing Application",
"T1083": "File and Directory Discovery",
"T1059": "Command and Scripting Interpreter",
"T1059.004": "Unix Shell",
"T1505": "Server Software Component",
"T1505.003": "Web Shell",
"T1552": "Unsecured Credentials",
"T1552.001": "Credentials In Files",
"T1213": "Data from Information Repositories",
"T1595": "Active Scanning",
"T1595.001": "Scan IP Blocks",
"T1595.002": "Vulnerability Scanning",
"T1595.003": "Wordlist Scanning",
"T1110": "Brute Force",
"T1110.001": "Password Guessing",
"T1110.003": "Password Spraying",
"T1087": "Account Discovery",
"T1082": "System Information Discovery",
"T1046": "Network Service Discovery",
"T1078": "Valid Accounts",
}
// TechniqueName returns the official MITRE ATT&CK name of a technique id
// ("" when unknown).
func TechniqueName(id string) string { return techNames[id] }
var (
vulnTools = []string{"nuclei", "nikto", "acunetix", "wpscan", "nessus", "openvas", "sqlmap", "burp", "zap", "w3af", "wapiti", "xray", "jaeles"}
wordTools = []string{"dirbuster", "ffuf", "gobuster", "dirsearch", "feroxbuster", "wfuzz", "dirb"}
ipTools = []string{"masscan", "zgrab", "zmap", "nmap", "shodan", "censys"}
)
func hasTool(tool string, list []string) bool {
for _, t := range list {
if strings.Contains(tool, t) {
return true
}
}
return false
}
func famTechs(fam string, ctx TechCtx) []string {
switch fam {
case FamTraversal:
return []string{"T1190", "T1083"}
case FamLog4Shell, FamSQLi, FamXSS, FamIoTCGI:
return []string{"T1190"}
case FamRCE:
return []string{"T1190", "T1059.004"}
case FamWebshell:
return []string{"T1505.003"}
case FamEnvCreds:
return []string{"T1552.001"}
case FamVCS:
return []string{"T1213", "T1552.001"}
case FamBackup, FamPhpMyAdmin, FamAdminPanel, FamGeneric404:
return []string{"T1595.003"}
case FamWordPress:
p := strings.ToLower(ctx.Path)
switch {
case strings.Contains(p, "wp/v2/users"):
return []string{"T1087"}
case strings.Contains(p, "wp-login.php") || strings.Contains(p, "xmlrpc.php"):
return []string{"T1110.001"}
case strings.Contains(p, "/wp-content/plugins/"):
return []string{"T1595.002"}
}
return []string{"T1595.002"}
case FamActuator:
return []string{"T1595.002", "T1082"}
}
return nil
}
// Techniques maps an event category and family to MITRE ATT&CK technique ids
// (sorted, deduplicated).
func Techniques(cat, fam string, ctx TechCtx) []string {
set := map[string]bool{}
for _, t := range famTechs(fam, ctx) {
set[t] = true
}
tool := strings.ToLower(ctx.Tool)
switch core.Category(cat) {
case core.Scanner:
switch {
case hasTool(tool, vulnTools):
set["T1595.002"] = true
case hasTool(tool, wordTools):
set["T1595.003"] = true
case hasTool(tool, ipTools):
set["T1595.001"] = true
default:
set["T1595"] = true
}
case core.Exploit:
set["T1190"] = true
case core.BruteForce:
set["T1110.001"] = true
case core.SSHFail:
if ctx.Users >= 5 && ctx.MaxPerUser <= 3 {
set["T1110.003"] = true
} else {
set["T1110.001"] = true
}
case core.SSHProbe:
set["T1595.001"] = true
set["T1046"] = true
case core.SSHOK:
if ctx.PriorFails {
set["T1078"] = true
}
}
out := make([]string, 0, len(set))
for t := range set {
out = append(out, t)
}
sort.Strings(out)
return out
}