0xJaeg3r/OOSEC-SygnaCTI

GitHub: 0xJaeg3r/OOSEC-SygnaCTI

基于 Agno 框架构建的多 Agent 网络威胁情报平台,协调专业 Agent 从 Telegram、公开网络和暗网收集、关联并生成结构化威胁情报报告。

Stars: 0 | Forks: 0

# Syngnacti **多 Agent 网络威胁情报平台**,基于 [Agno](https://github.com/agno-agi/agno) 框架构建。一个协调一致的 AI Agent 团队从 Telegram 频道、开放网络和暗网收集、关联并报告网络威胁。 ## 工作原理 CTI Manager agent 接收您的查询并将任务委派给专门的 agent。每个 agent 都拥有专用工具和定制的 prompt。Manager 会综合他们的发现并生成结构化的情报报告。 ``` +-----------------------+ | CTI Manager | | (Team Leader/Router) | +----------+------------+ | delegates to team members | +---------------------------+---------------------------+ | | | | +--------v-------+ +------v--------+ +--------v-------+ +------v--------+ | Telegram | | Web Search | | Dark Web | | CTI | | Recon | | Agent | | Investigator | | Reporter | | Specialist | | | | | | | +----------------+ +---------------+ +----------------+ +---------------+ | list_channels | | Tavily web | | search_dark_web| | Synthesizes | | search_channel | | search API | | browse_onion_ | | findings into | | search_multiple| | | | site | | structured | | _channels | | | | | | reports | +----------------+ +---------------+ +----------------+ +---------------+ | | | Telegram API Public Web Tor Network (Telethon) (Tavily) (Playwright + SOCKS5) ``` ### Agent 角色 | Agent | 角色 | 工具 | |-------|------|-------| | **CTI Manager** | 接收查询,委派给专家,解决冲突情报,交付最终报告 | `delegate_task_to_member` (Agno 内置) | | **Telegram Recon Specialist** | 搜索 Telegram 频道以查找 IOC、威胁行为者讨论、泄露公告 | `list_channels`, `search_channel`, `search_multiple_channels` | | **Web Search Agent** | 从供应商公告、CVE 数据库、政府警报中佐证并丰富发现 | Tavily web search | | **Dark Web Investigation Agent** | 查询 .onion 搜索引擎,浏览暗网站点,从论坛/市场提取情报 | `search_dark_web`, `browse_onion_site` | | **CTI Reporter** | 生成结构化情报报告,包含执行摘要、MITRE ATT&CK 映射和建议 | File tools | ### 报告结构 CTI Reporter 按以下格式输出报告: 1. **Executive Summary (执行摘要)** -- 2-3 句话的关键发现 2. **Threat Overview (威胁概览)** -- 谁、什么、为什么 3. **Technical Analysis (技术分析)** -- IOC、映射到 MITRE ATT&CK 的 TTP、杀伤链进展 4. **Impact Assessment (影响评估)** -- 受影响的行业、地区、系统 5. **Recommendations (建议)** -- 优先级的防御行动 6. **Sources (来源)** -- 每项发现的归属(Telegram 频道、网络来源、.onion URL) 每项发现都包含基于来源可靠性和佐证的置信度(高 / 中 / 低)。 ## 前置条件 - Python 3.8+ - 至少一个 LLM API key (OpenAI, Anthropic, 或 Google) - Telegram API credentials (用于 Telegram 收集) - Tor service (用于暗网收集) - Playwright + Chromium (用于暗网浏览) - Tavily API key (用于网络搜索佐证) ## 设置 ### 1. 克隆并创建虚拟环境 ``` git clone https://github.com/your-username/syngnacti.git cd syngnacti python3 -m venv venv source venv/bin/activate # Linux/macOS ``` ### 2. 安装 Python 依赖 ``` pip install -r requirements.txt ``` ### 3. 安装 Playwright 浏览器 ``` playwright install chromium ``` ### 4. 安装并启动 Tor 暗网搜索工具通过 Tor 的 SOCKS5 代理(`127.0.0.1:9050`)路由所有流量。 ``` # 安装 sudo apt install tor # Debian/Ubuntu sudo pacman -S tor # Arch brew install tor # macOS # 启动 sudo systemctl start tor # 开机自启(可选) sudo systemctl enable tor # 验证 ss -tlnp | grep 9050 ``` 您应该看到 Tor 监听在 9050 端口。如果没有,暗网工具将失败并提示“unreachable after 3 attempts”。 ### 5. 配置凭证 在项目根目录创建一个 `.env` 文件: ``` # LLM API key(至少需要一个) OPENAI_API_KEY=sk-... # ANTHROPIC_API_KEY=sk-ant-... # GOOGLE_API_KEY=... # Telegram API(Telegram 收集所需) TELEGRAM_API_ID=12345678 TELEGRAM_API_HASH=abcdef1234567890abcdef1234567890 # Web 搜索(网络验证所需) TAVILY_API_KEY=tvly-... ``` #### 获取 API keys | 服务 | 获取地址 | |---------|----------------| | OpenAI | https://platform.openai.com/api-keys | | Anthropic | https://console.anthropic.com/settings/keys | | Google AI | https://aistudio.google.com/apikey | | Telegram | https://my.telegram.org > API development tools | | Tavily | https://tavily.com | ### 6. 通过 Telegram 认证(一次性) ``` python telegram_search_tool.py auth +1234567890 ``` 输入发送到您手机的验证码。如果启用了 2FA,系统会提示您输入密码。会话将保存到 `sessions/` 并在多次运行中持久化。 ## 使用方法 ### CLI (推荐) ``` python sygna_cli.py ``` 交互式 CLI 提供: - 运行时模型切换 (`/model`) -- 支持 OpenAI, Anthropic, Google, 和 LiteLLM - 对话记忆开关 (`/memory`) -- 在会话间持久化上下文 - Agent 存储开关 (`/storage`) -- 持久化 agent 状态和历史 - MCP server 支持 (`/add-mcp`, `/mcp`) -- 连接外部工具服务器 - 会话状态 (`/status`) -- 查看活跃的 agent、工具和配置 ``` # 使用特定模型启动 python sygna_cli.py --model claude-opus-4-6 # 启用内存和存储启动 python sygna_cli.py --memory --storage # 启用 MCP 支持启动 python sygna_cli.py --mcp ``` 在 CLI 中输入 `/help` 获取完整的命令参考。 ### 快速开始 (脚本模式) ``` python agent.py ``` 这会运行默认的示例任务。编辑 `agent.py:main()` 以更改查询。 ### 编程式使用 ``` from agent import CtiAgentSystem system = CtiAgentSystem(model_name="gpt-5.2") system.run_assessment( "Investigate dark web activity related to credential dumps for African banks" ) ``` ### 示例 prompt ``` Search my Telegram channels for any mentions of LockBit and produce a threat intelligence report What is the latest ransomware landscape? Perform a full investigation across all sources. Investigate dark web activity related to credential dumps targeting the financial sector Find recent CVEs being actively exploited and cross-reference with Telegram threat intel channels Search for threat intelligence related to APT groups targeting healthcare in West Africa ``` ### 使用不同的模型 ``` # OpenAI(默认) system = CtiAgentSystem(model_name="gpt-5.2") # Anthropic system = CtiAgentSystem(model_name="claude-sonnet-4-5-20250929") # Google system = CtiAgentSystem(model_name="gemini-2.5-pro") # 通过 LiteLLM 使用任意模型(后备) system = CtiAgentSystem(model_name="together_ai/meta-llama/Llama-3-70b") ``` ### 可选功能 ``` # 启用对话记忆(跨会话持久化) system = CtiAgentSystem(model_name="gpt-5.2", use_memory=True) # 启用会话存储(会话内的对话历史) system = CtiAgentSystem(model_name="gpt-5.2", use_storage=True) # 连接 MCP tool servers system = CtiAgentSystem( model_name="gpt-5.2", use_mcp=True, mcp_servers=[ {"command": "npx -y @some/mcp-server"}, {"url": "http://localhost:8080/mcp", "transport": "streamable-http"}, ], ) ``` ### 访问单独的 agent ``` system = CtiAgentSystem(model_name="gpt-5.2") # 获取特定 agent 直接使用(绕过 team) telegram_agent = system.get_agent("telegram_search") web_agent = system.get_agent("web_search") dark_web_agent = system.get_agent("dark_web_investigation_agent") reporter = system.get_agent("reports") ``` ## 暗网搜索工具 暗网模块 (`dark_web_search_tool.py`) 可以单独使用或作为 agent 系统的一部分使用。 ### 工作原理 1. 启动通过 Tor SOCKS5 代理路由的无头 Chromium 浏览器 2. 并行查询多个 .onion 搜索引擎(最多 6 个并发) 3. 使用两阶段页面加载策略:快速的 `domcontentloaded` + `networkidle` 等待 JS 渲染的内容 4. 如果直接搜索 URL 失败(例如需要 CSRF token),则回退到加载主页,找到搜索表单并提交 5. 对每个页面进行分类(搜索结果、登录、验证码、错误、目录、内容) 6. 使用 4 种回退解析策略提取结果 7. 将重定向 URL 解析为实际的 .onion 目标地址 8. 通过规范化的 URL 在各引擎间对结果进行去重 ### 独立使用 ``` from dark_web_search_tool import search_dark_web, browse_onion_site # 搜索所有已配置的引擎 results = search_dark_web("ransomware", max_results=10) print(results) # 浏览特定 .onion 站点 page = browse_onion_site("http://example.onion/some-page") print(page) ``` ### 添加搜索引擎 在 `dark_web_search_tool.py` 中编辑 `SEARCH_URLS`: ``` SEARCH_URLS = { "ahmia": "http://juhanurmihxlp77nkq76byazcldy2hlmovfu2epvl5ankdibsot4csyd.onion", "your_engine": "http://your-engine-address.onion/", } ``` 如果您知道引擎的搜索 URL 模式,请将其添加到 `SEARCH_PATTERNS`: ``` SEARCH_PATTERNS = { "ahmia": "/search/?q={q}", "your_engine": "/find?query={q}", } ``` 没有验证模式的引擎将首先回退到 `/search/?q=`,然后是基于表单提交的回退。 ### 页面分类 该工具自动检测并处理: | 页面类型 | 行为 | |-----------|----------| | **Search results** | 通过多策略提取解析结果 | | **Login page** | 报告表单字段以及是否可用注册 | | **Captcha** | 报告该站点受验证码保护 | | **Error page** | 报告错误消息 | | **Directory** | 提取带有描述的 .onion 链接 | | **Content** | 返回页面文本(最多 5000 个字符)| ## Telegram 搜索工具 Telegram 模块 (`telegram_search_tool.py`) 既可用作 CLI 工具,也可用作 agent 函数。 ### CLI 使用 ``` # 列出您所属的所有频道 python telegram_search_tool.py channels # 搜索单个频道 python telegram_search_tool.py search 1234567 "ransomware" --days-back 30 # 搜索多个频道 python telegram_search_tool.py long-search "APT28" 1234567 2345678 --depth 3months # JSON 输出(管道传输至 jq 等) python telegram_search_tool.py search 1234567 "CVE-2024" --json ``` ### CLI 参考 | 命令 | 描述 | |---------|-------------| | `auth ` | 一次性 Telegram 认证 | | `channels` | 列出已加入的频道及其 ID 和成员数 | | `search ` | 搜索单个频道 | | `long-search [id2] ...` | 跨多个频道搜索 | | 标志 | 适用对象 | 描述 | |------|-----------|-------------| | `--limit N` | `search`, `long-search` | 每个频道扫描的最大消息数(默认值:1000)| | `--days-back N` | `search` | 仅搜索过去 N 天 | | `--depth` | `long-search` | `1week`, `1month`, `3months`, `6months`, `1year`, `all` | | `--json` | `channels`, `search`, `long-search` | 输出为 JSON | ## 项目结构 ``` syngnacti/ ├── sygna_cli.py # Interactive CLI — model switching, memory, storage, MCP servers ├── agent.py # CtiAgentSystem class — agent creation, team orchestration, model selection ├── prompt.py # Role prompts for all 5 agents (manager + 4 specialists) ├── tools.py # Tool registry — aggregates CLI, Telegram, and dark web tools ├── telegram_search_tool.py # Telegram OSINT — Telethon-based channel search (CLI + agent tool) ├── dark_web_search_tool.py # Dark web OSINT — Playwright + Tor parallel search engine querying ├── requirements.txt # Python dependencies ├── .env # API credentials (not committed — add to .gitignore) └── sessions/ # Telegram session files (auto-created, not committed) ``` ## 故障排除 ### 暗网搜索:“unreachable after 3 attempts” Tor 未运行或未安装。 ``` # 检查 Tor 是否正在运行 ss -tlnp | grep 9050 # 启动 Tor sudo systemctl start tor ``` ### 暗网搜索未返回结果但引擎可访问 搜索引擎可能需要 CSRF token 或使用仅 JS 的搜索。基于表单的回退可以处理大多数情况,但某些引擎具有非标准的搜索界面。检查调试输出(`agent.py` 中的 `debug_mode=True`)以查看检测到了什么页面类型。 ### Telegram:“Not authenticated. Run 'auth' first.” ``` python telegram_search_tool.py auth +1234567890 ``` ### Telegram:“TELEGRAM_API_ID and TELEGRAM_API_HASH must be set” 将您的 Telegram 凭证添加到 `.env`: ``` TELEGRAM_API_ID=12345678 TELEGRAM_API_HASH=abcdef1234567890abcdef1234567890 ``` 从 https://my.telegram.org > API development tools 获取它们。 ### Playwright:“Browser not found” ``` playwright install chromium ``` ### Agent 直接回答而不是委派 CTI Manager 的 prompt 明确指示其始终进行委派。如果您看到它在没有工具调用的情况下回答,这通常是 LLM 忽略了指令。请尝试: - 使用更强大的模型(GPT-5.2, Claude Opus) - 使查询更具体,以便 manager 可以清楚地路由它 ### “运行 asyncio.run() 时出错:This event loop is already running” 这已由 Telegram 和暗网工具中的 `_run_async()` 自动处理。如果您看到此错误,则意味着变通方法失败了。请确保您使用的是同步包装函数(`search_dark_web`, `browse_onion_site`, `list_channels` 等),而不是直接调用 `_async` 函数。 ## 配置 ### 暗网工具设置 在 `dark_web_search_tool.py` 顶部编辑常量: ``` MAX_RETRIES = 2 # Retry attempts per page load RETRY_DELAY = 5 # Seconds between retries DEFAULT_TIMEOUT = 90_000 # Page load timeout (ms) MAX_CONCURRENT = 6 # Max parallel browser tabs ``` ### Tor 代理 默认值:`socks5://127.0.0.1:9050`。要使用不同的 Tor 实例,请编辑 `dark_web_search_tool.py` 中的 `_launch_tor_browser()`。 ## 免责声明 此工具专为**授权的安全研究、威胁情报和防御性网络安全行动**而设计。它旨在供在法律和道德界限内运作的安全专业人员、SOC 分析师、威胁情报团队和研究人员使用。 - 仅在您被授权访问的系统和平台上使用此工具 - 遵守您所在司法管辖区适用的所有法律和法规 - 暗网浏览带有固有风险 —— 使用适当的操作安全措施 - 作者不对滥用此工具负责 ## 许可证 MIT
标签:Agent, Agno, BeEF, Dark Web, DLL 劫持, ESC4, LLM, LSASS转储, OSINT, PyRIT, Python, Tavily, Telegram监控, Unmanaged PE, 人工智能, 多智能体系统, 大语言模型, 威胁情报, 实时处理, 开发者工具, 情报分析, 数据关联, 无后门, 暗网监控, 爬虫, 特征检测, 用户模式Hook绕过, 网络安全, 网络诊断, 自动化报告, 计算机取证, 逆向工具, 隐私保护, 黄金证书