docs: refresh README and screenshots for 2.x, drop em dashes, add scripts/screenshots.sh
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e0d67af3fe
commit
d3c3b91e82
32 files changed
+286
-124
No files matched your search
Executable
+90
@@ -0,0 +1,90 @@
|
||||
#!/usr/bin/env bash
|
||||
# Regera as capturas de tela de docs/img a partir da interface real do Harpia.
|
||||
#
|
||||
# Dados: um servidor HTTP local que se anuncia como Apache 2.4.25 (nenhum dado de terceiros),
|
||||
# varrido de verdade por `harpia scan`, correlacionado com os feeds reais NVD (CPE do Apache
|
||||
# 2.4.25) e CISA KEV. Os feeds são baixados uma vez e ficam em cache.
|
||||
#
|
||||
# scripts/screenshots.sh # grava em docs/img
|
||||
# OUT=/tmp/img scripts/screenshots.sh # grava em outro diretório
|
||||
#
|
||||
# Variáveis: HARPIA_BIN (padrão target/release/harpia, compilado se faltar), OUT, APP_PORT
|
||||
# (porta do serviço sintético, 8080), SERVE_PORT (8788), FEEDS_CACHE, CHROME, PUPPETEER_CORE
|
||||
# (padrões: Chrome do cache do puppeteer e puppeteer-core em ~/.claude/tools/node_modules).
|
||||
# Requer: python3, curl, node, Chrome. A primeira execução precisa de internet (NVD/CISA).
|
||||
set -euo pipefail
|
||||
|
||||
root=$(cd "$(dirname "$0")/.." && pwd)
|
||||
out=${OUT:-$root/docs/img}
|
||||
app_port=${APP_PORT:-8080}
|
||||
serve_port=${SERVE_PORT:-8788}
|
||||
cache=${FEEDS_CACHE:-${XDG_CACHE_HOME:-$HOME/.cache}/harpia-screenshots}
|
||||
bin=${HARPIA_BIN:-$root/target/release/harpia}
|
||||
cpe='cpe:2.3:a:apache:http_server:2.4.25:*:*:*:*:*:*:*'
|
||||
|
||||
work=$(mktemp -d)
|
||||
pids=()
|
||||
cleanup() { for p in "${pids[@]}"; do kill "$p" 2>/dev/null || true; done; rm -rf "$work"; }
|
||||
trap cleanup EXIT
|
||||
|
||||
[ -x "$bin" ] || (cd "$root" && cargo build --release -p harpia-cli)
|
||||
|
||||
# Feeds reais, em cache entre execuções.
|
||||
mkdir -p "$cache" "$out"
|
||||
if [ ! -s "$cache/nvd.json" ]; then
|
||||
echo "baixando CVEs do Apache 2.4.25 (NVD)..."
|
||||
curl -fsS -m 120 -o "$cache/nvd.json" \
|
||||
"https://services.nvd.nist.gov/rest/json/cves/2.0?cpeName=${cpe}&resultsPerPage=2000"
|
||||
fi
|
||||
if [ ! -s "$cache/kev.json" ]; then
|
||||
echo "baixando catálogo KEV (CISA)..."
|
||||
curl -fsS -m 120 -o "$cache/kev.json" \
|
||||
https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json
|
||||
fi
|
||||
mkdir "$work/feeds" && cp "$cache/nvd.json" "$cache/kev.json" "$work/feeds/"
|
||||
|
||||
# Serviço sintético que se anuncia como Apache 2.4.25 em 127.0.0.10 (loopback não exige root).
|
||||
cat > "$work/fake.py" <<PY
|
||||
import sys
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
class H(BaseHTTPRequestHandler):
|
||||
server_version = "Apache/2.4.25"; sys_version = "(Debian)"
|
||||
def do_GET(self):
|
||||
b = b"<html><title>Damn Vulnerable Web Application</title></html>"
|
||||
self.send_response(200); self.send_header("Content-Type", "text/html")
|
||||
self.send_header("Content-Length", str(len(b))); self.end_headers(); self.wfile.write(b)
|
||||
do_HEAD = do_GET
|
||||
def log_message(self, *a): pass
|
||||
HTTPServer(("127.0.0.10", $app_port), H).serve_forever()
|
||||
PY
|
||||
python3 "$work/fake.py" & pids+=($!)
|
||||
|
||||
cat > "$work/harpia.toml" <<TOML
|
||||
[escopo]
|
||||
autorizado = ["127.0.0.0/24"]
|
||||
responsavel = "Equipe de Seguranca <seguranca@exemplo.org>"
|
||||
|
||||
[padrao]
|
||||
cron = "* * * * *"
|
||||
|
||||
[perfis.padrao]
|
||||
tcp = "$app_port"
|
||||
motor = "nativo-sem-raw"
|
||||
vulnerabilidades = true
|
||||
|
||||
[[grupo]]
|
||||
nome = "lab-dvwa"
|
||||
alvos = ["127.0.0.10"]
|
||||
TOML
|
||||
|
||||
for _ in $(seq 1 30); do curl -fsS "http://127.0.0.10:$app_port/" >/dev/null 2>&1 && break; sleep 0.2; done
|
||||
|
||||
cd "$work"
|
||||
"$bin" feeds import feeds --data-dir data --config harpia.toml
|
||||
"$bin" scan --group lab-dvwa --once --config harpia.toml --out sweeps --data-dir data
|
||||
"$bin" serve --bind "127.0.0.1:$serve_port" --config harpia.toml --sweeps sweeps --data-dir data \
|
||||
> serve.log 2>&1 & pids+=($!)
|
||||
for _ in $(seq 1 50); do curl -fsS "http://127.0.0.1:$serve_port/api/health" >/dev/null 2>&1 && break; sleep 0.2; done
|
||||
|
||||
node "$root/scripts/screenshots/shots.mjs" "http://127.0.0.1:$serve_port/" "$out"
|
||||
echo "capturas gravadas em $out"
|
||||
Reference in new issue
Block a user