Feistler/projetoSTG

GitHub: Feistler/projetoSTG

统一编排十八款红蓝队安全工具的攻防运营面板,通过标准化发现模型、授权网关和审计追踪实现集中化安全扫描与报告。

Stars: 0 | Forks: 0

Operação Fantase

安全运营核心 · 引擎 stg

统一的攻防安全工具编排器。
一个界面,统一的发现模型,统一的报告 — 涵盖安全专业人员日常使用的 18 种工具。

python docker license tests status

## 目录 - [概述](#visao-geral) - [架构](#arquitetura) - [6大类别与18个连接器](#as-6-categorias-e-os-18-conectores) - [项目的核心优势](#recursos-que-diferenciam-o-projeto) - [安装说明](#instalacao) - [使用说明](#uso) - [授权范围与审计](#escopo-autorizado-e-auditoria) - [报告](#relatorios) - [Pipelines](#pipelines) - [如何扩展(新连接器)](#como-estender-novo-conector) - [项目结构](#estrutura-do-projeto) - [路线图](#roadmap) ## 概述 大多数团队都在使用几十种孤立的安全工具,每种工具都有自己的输出、格式和操作方式。**STG** 通过一个**模块化核心**解决了这个问题:每种工具都变成了一个**连接器**,并使用同一种语言进行通信:它们都能生成**标准化的 `Findings`**,从而汇总为**统一的报告**(Markdown / HTML / JSON)。 这些工具涵盖了**完整的安全生命周期**: | 视角 | 类别 | |-------|-----------| | 🔴 **红队 / 进攻方** | 侦查、漏洞、Web、密码 | | 🔵 **蓝队 / 防守方** | 网络监控、SIEM 与 Endpoint | ## 架构 ``` ┌──────────────────────────────┐ CLI (stg) │ list · info · scan · pipeline · report · authz └───────────────┬──────────────┘ │ ┌────────────▼────────────┐ │ Runner │ │ autorizacao → execucao │ │ → auditoria │ └─────┬──────────────┬────┘ authorization.yaml │ │ audit.jsonl (append-only) │ │ ┌─────────────▼──────────────▼─────────────┐ │ Registry (18 conectores) │ └─┬─────────┬─────────┬────────┬─────────┬──┘ CommandConnector ApiConnector ... (mesma interface: run/parse) │ │ subprocess seguro HTTP/API │ │ ▼ ▼ ┌──────────────────────────────┐ │ Findings normalizados │ → Reporting (MD · HTML · JSON) └──────────────────────────────┘ ``` 核心设计理念: - **统一契约**(`BaseConnector`):添加工具只需创建一个小类。 - **`CommandConnector`** 封装了安全的 subprocess(不使用 `shell=True`,并带有超时)。 - **`ApiConnector`** 封装了 HTTP 集成(Shodan、Nessus、Wazuh、Splunk、Falcon 等)。 - **优雅降级**:缺失的工具会被标记为 `UNAVAILABLE` 状态,而不会导致崩溃。 ## 6大类别与18个连接器 | # | 类别 | 连接器 | 工具 | 类型 | 需求 | |---|-----------|----------|-----------|------|--------| | 1 | 侦查 | `nmap` | Nmap | CLI | `nmap` 可执行文件 | | 1 | 侦查 | `amass` | Amass | CLI | `amass` 可执行文件 | | 1 | 侦查 | `shodan` | Shodan | API | `SHODAN_API_KEY` | | 2 | 漏洞 | `nikto` | Nikto | CLI | `nikto` 可执行文件 | | 2 | 漏洞 | `nessus` | Nessus | API | Nessus API keys | | 2 | 漏洞 | `openvas` | OpenVAS/GVM | API | `python-gvm` + 凭据 | | 3 | Web | `zap` | OWASP ZAP | API | `ZAP_API_KEY` + daemon | | 3 | Web | `sqlmap` | SQLmap | CLI | `sqlmap` 可执行文件 | | 3 | Web | `burp` | Burp Suite | API | Burp Enterprise/Pro* | | 4 | 密码 | `hashcat` | Hashcat | CLI | `hashcat` 可执行文件 | | 4 | 密码 | `john` | John the Ripper | CLI | `john` 可执行文件 | | 4 | 密码 | `hibp` | Have I Been Pwned | API | `HIBP_API_KEY` | | 5 | 监控 | `wireshark` | Wireshark (tshark) | CLI | `tshark` 可执行文件 | | 5 | 监控 | `suricata` | Suricata | CLI | `suricata` 可执行文件 | | 5 | 监控 | `snort` | Snort | CLI | `snort` 可执行文件 + 规则集 | | 6 | SIEM 与 Endpoint | `wazuh` | Wazuh | API | Wazuh API 凭据 | | 6 | SIEM 与 Endpoint | `splunk` | Splunk | API | `SPLUNK_TOKEN` | | 6 | SIEM 与 Endpoint | `crowdstrike` | CrowdStrike Falcon | API | Falcon 凭据 | ## 项目的核心优势 - 🔒 **授权网关** — 活动连接器在声明的范围之外会被阻止。 - 🧾 **审计追踪** — 每次执行(无论是否授权、被阻止或强制执行)都会生成一条包含用户、主机、目标和命令的不可变 JSONL 记录。 - 🧩 **可插拔连接器** — 每个工具一个类,支持自动发现。 - 📊 **综合报告** — 基于相同的数据源生成 Markdown、HTML(独立文件)和 JSON。 - 🔗 **声明式 Pipelines** — 通过 YAML 串联工具。 - 🐳 **全容器化** — 包含预装开源工具的 Kali Docker 镜像。 - ✅ **经过测试** — 涵盖核心与解析器的测试套件(27 个测试)。 ## Web 面板 除了 CLI,STG 还提供了一个 **Web 面板**(基于 FastAPI),允许您通过浏览器执行所有操作: 选择工具、启动扫描、按严重程度查看结果并下载报告。它 100% 复用了同一个核心引擎。 ``` docker compose up dashboard # depois abra http://localhost:8000 ``` ## 安装说明 ### 推荐方案:Docker(跨平台) ``` # 配置 secrets 和 scope cp .env.example .env # preencha as chaves que for usar cp config/authorization.example.yaml config/authorization.yaml # ajuste seu escopo # 镜像 Build(Kali + open source 工具)。下载约 1.5-2 GB。 docker build -t stg-toolkit . # 使用 docker compose run --rm stg list docker compose run --rm stg scan nmap 192.168.56.10 --report html ``` ### 开发选项(本地 Python) ``` pip install -e ".[dev]" # instala o pacote + ferramentas de teste pytest # roda os 27 testes stg list ``` ## 使用说明 ``` stg version # versao stg list # lista conectores e disponibilidade stg info nmap # detalhes de um conector # 单独扫描 stg scan nmap 192.168.56.10 --opt top_ports=2000 --opt service_detection=true stg scan nikto http://alvo.local --report html --report json stg scan hibp pessoa@empresa.com # passivo (OSINT), nao exige escopo stg scan hashcat hashes.txt --opt mode=0 --opt wordlist=/usr/share/wordlists/rockyou.txt # 超出 scope?STG 会阻止(并审计): stg scan nmap 8.8.8.8 # → BLOQUEADO stg scan nmap 8.8.8.8 --force # → executa, mas registra na auditoria # Declarative Pipeline stg pipeline pipelines/recon.yaml --target empresa.local --report html ``` 各连接器的选项通过 `--opt chave=valor` 传递(数字和 `true/false` 会自动转换)。 ## 授权范围与审计 项目的道德核心。在 `config/authorization.yaml` 中定义您的范围: ``` allow_local_files: true scope: networks: - 192.168.56.0/24 domains: - empresa.local ``` ``` stg authz init # cria um arquivo inicial stg authz check 192.168.56.10 # → AUTORIZADO stg authz check 8.8.8.8 # → FORA DO ESCOPO ``` 每次执行都会在 `stg-data/audit.jsonl` 中生成一条记录: ``` {"timestamp":"2026-06-16T12:00:00Z","user":"feistler","host":"kali","event":"scan", "connector":"nmap","target":"192.168.56.10","authorized":true,"forced":false,"status":"success"} ``` ## 报告 使用 `--report md|html|json`(可重复使用)。文件将输出到 `stg-data/output/`。 HTML 报告是**独立的**(内嵌 CSS,包含严重程度徽章)— 可以直接作为报告附件使用。 ## Pipelines ``` # pipelines/recon.yaml name: recon-basico description: Descoberta de subdominios e portas/servicos. steps: - connector: amass options: { passive: true } - connector: nmap options: { top_ports: 1000 } ``` ## 如何扩展(新连接器) 1. 创建 `stg/connectors//minha_ferramenta.py`,继承 `CommandConnector` 或 `ApiConnector`。 2. 定义元数据(`name`、`tool`、`category`、`requires_*`、`target_types`)。 3. 实现 `build_command()`/`fetch()` 和 `parse()`(返回 `Finding`)。 4. 将该类添加到所在类别目录的 `__init__.py` 的 `CONNECTORS` 中。完成 — 它就会显示在 `stg list` 中。 ``` class MinhaFerramentaConnector(CommandConnector): name = "minha" tool = "Minha Ferramenta" category = Category.RECON requires_binaries = ["minha"] target_types = [TargetType.DOMAIN] def build_command(self, target, options, workdir): return ["minha", "--json", target.value] def parse(self, raw, target): return [self.make_finding("Algo encontrado", target, Severity.MEDIUM)] ``` ## 项目结构 ``` projetoSTG/ ├── stg/ │ ├── cli.py # interface Typer/Rich │ ├── core/ # models, connector, registry, runner, authorization, audit, pipeline │ ├── connectors/ # 6 categorias × 3 ferramentas │ ├── reporting/ # reporter + templates (md/html) │ └── utils/ # shell seguro, logging ├── config/ # config + authorization (exemplos) ├── pipelines/ # pipelines YAML de exemplo ├── tests/ # 27 testes do nucleo e parsers ├── docs/ # ARCHITECTURE, ETHICS, CONNECTORS ├── Dockerfile · docker-compose.yml · Makefile └── pyproject.toml ``` ## 路线图 - [x] Web 面板,复用相同的核心引擎。 - [ ] 支持 PDF 格式报告导出。 - [ ] 在可用时通过 CVSS 标准化严重程度。 - [ ] 更多连接器(Subfinder、httpx、trivy、Nuclei)。 - [ ] 持久化存储结果,以便进行历史记录和差异对比。 ## 许可证 [MIT](LICENSE)。软件按“原样”提供,不提供任何保证。用户需对不当使用承担全部责任。
标签:AV绕过, Docker, FastAPI, PB级数据处理, Python, 安全编排自动化(SOAR), 安全运维, 安全防御评估, 无后门, 请求拦截, 逆向工具