fadhilmohammed/vigil

GitHub: fadhilmohammed/vigil

一款零依赖的 Python 日志取证工具,用于从系统日志中重建攻击时间线并生成专业的事件响应报告。

Stars: 0 | Forks: 0

# VIGIL **Visual Incident Graph and Investigation Log** 一款零依赖的 Python 取证工具,用于从系统日志中重建攻击时间线。VIGIL 接收 auth.log、syslog 和 JSON-lines 日志文件,检测攻击模式,关联跨源相关事件,并生成专业的事件响应叙述。 专为需要在无法安装第三方工具的隔离或受限环境中快速甄别日志数据的事件响应人员、SOC 分析师和安全专业学生而构建。 ``` ══════════════════════════════════════════════════════════════════ ATTACK TIMELINE #1 — Brute Force to Lateral Movement Severity: CRITICAL | Duration: 14m 32s Period: 2024-03-15 02:14:00 → 02:28:32 ══════════════════════════════════════════════════════════════════ [02:14:00] Brute-force attack initiated against web-server-01 SSH service. Source IP 10.0.0.5 attempted 47 password combinations targeting the root account over 3 minutes. [02:17:12] Authentication succeeded for root@web-server-01 — likely credential compromise via brute force. [02:17:45] Privilege escalation observed: deploy user executed sudo su - root within 33 seconds of initial access. [02:19:00] Lateral movement detected: web-server-01 initiated SSH connections to 3 internal hosts within 90 seconds. ══════════════════════════════════════════════════════════════════ ``` ## VIGIL 存在的意义 大多数日志分析工具需要安装软件包、连接云端或进行复杂的设置。VIGIL 只要有 Python 3.9+ 即可运行 —— 无需 pip,无需 venv,无需网络访问。将其放在调查工作站上,指向日志,即可获得时间线。 ## 功能特性 **检测引擎** - **暴力破解检测 (Brute Force Detection)** — 对失败的认证尝试进行滑动窗口分析,并自动提升严重程度。当暴力破解后伴随成功登录时,标记入侵后的成功事件。 - **权限提升链 (Privilege Escalation Chains)** — 识别多步骤提升序列:初始访问 → sudo/su → root shell。跟踪跨事件的完整因果链。 - **横向移动映射 (Lateral Movement Mapping)** — 检测被攻陷主机向内部基础设施发起的出站连接。测量跨主机和子网的横向扩散广度。 - **会话异常检测 (Session Anomaly Detection)** — 标记非工作时间访问、幽灵会话(有开无关或有关无开)、快速会话循环以及来自不同子网的并发登录。 **架构** - **多格式解析**,支持自动检测 — auth.log, syslog (RFC 3164), JSON-lines - **并查集关联引擎**,将相关检测分组为统一的攻击时间线 - **叙述生成器**,生成专业的事件响应摘要 - **可配置阈值** — 时间窗口、严重程度过滤器、工作时间 - **流式解析器** — 无需将大型日志文件完全加载到内存中即可处理 ## 快速开始 ``` # 克隆 repository git clone https://github.com/fadhilmohammed/vigil.git cd vigil # 生成合成测试日志 python -m vigil.synthetic --all # 分析生成的日志 python -m vigil sample_logs/*.log --stats --verbose # 分析您自己的日志 python -m vigil /var/log/auth.log /var/log/syslog --min-severity medium ``` 无需安装步骤。没有依赖项。直接运行即可。 ## 用法 ``` python -m vigil [logfile ...] [options] positional arguments: logfiles One or more log files to analyze options: --format {auto,auth,syslog,json} Force log format (default: auto) --window SECONDS Detection time window (default: 300) --min-severity {info,low,medium,high,critical} Minimum severity to report (default: low) --business-hours START END Business hours, 24h format (default: 06 22) --no-color Disable ANSI color output --verbose Show individual events within detections --stats Show summary statistics --quiet Only output attack timelines --version Show version ``` ## 工作原理 VIGIL 分四个阶段运行: **1. 解析与标准化** — 每个日志文件都会被自动检测并解析为通用的 `LogEvent` 格式。所有时间戳均经过标准化处理,以便进行跨源比较。格式错误的行会被记录并跳过。 **2. 检测** — 四个独立的检测引擎扫描已标准化的事件。每个引擎使用可配置的时间窗口和阈值来识别可疑模式,返回包含严重程度、置信度分数和贡献事件的结构化 `Detection` 对象。 **3. 关联** — 并查集算法将在时间上接近且共享属性(源 IP、目标用户名、主机名)的检测分组为 `AttackTimeline` 对象。暴力破解后跟随登录,再跟随权限提升,将被视为一个连贯的时间线,而不是三个互不相关的警报。 **4. 叙述** — 每个攻击时间线都被转换为专业的事件响应叙述,包含按时间顺序的事件重建、涉及资产摘要以及检测置信度细分。 ## 项目结构 ``` vigil/ ├── models.py # Dataclass definitions (LogEvent, Detection, AttackTimeline) ├── parsers/ # Log format parsers with auto-detection ├── detectors/ # Independent detection engines ├── engine/ # Correlation engine and timeline reconstruction ├── output/ # Narrative generator and terminal formatter ├── synthetic/ # Test log generator with 5 attack scenarios └── utils/ # Timestamp normalization, IP classification ``` ## 检测阈值 | Detector | Default Window | Default Threshold | Severity Range | |---|---|---|---| | Brute Force | 300s | 5 failed attempts | MEDIUM → CRITICAL | | Privilege Escalation | 300s | auth → sudo chain | HIGH → CRITICAL | | Lateral Movement | 3600s | 2+ internal hosts | HIGH → CRITICAL | | Session Anomaly | varies | configurable hours | LOW → HIGH | ## 系统要求 - Python 3.9+ - 零外部依赖 ## 测试 VIGIL 包含一个合成日志生成器,用于创建逼真的测试场景: ``` # 生成所有场景(brute force、priv esc、lateral movement、anomalies) python -m vigil.synthetic --all # 生成特定场景 python -m vigil.synthetic --scenario brute_force ``` ## 退出代码 | Code | Meaning | |---|---| | 0 | Analysis complete, no detections | | 1 | Analysis complete, detections found | | 2 | Error during execution | ## 许可证 MIT
标签:Blueteam, CSV导出, FOFA, ITDR, JSON日志, PB级数据处理, PE 加载器, Python, SOC分析工具, SSH日志, Syslog分析, TGT, 事件关联, 可视化调查, 安全运维, 库, 应急响应, 攻击溯源, 攻防演练, 数字取证, 无后门, 时间线重构, 离线分析, 红队行动, 网络安全, 自动化脚本, 隐私保护, 零依赖