koushikchowdary6/ssh-log-threat-detector

GitHub: koushikchowdary6/ssh-log-threat-detector

基于规则离线解析 SSH auth.log 的小型 SOC 检测工具,标记暴力破解、密码喷洒等常见攻击行为。

Stars: 0 | Forks: 0

# SSH Auth-Log 威胁检测器 🛡️ [![CI](https://static.pigsec.cn/wp-content/uploads/repos/cas/ad/ad5834178f7599af9fdda11629d49cae07f2997beec49821b2920eff5bfd50e7.svg)](https://github.com/koushikchowdary6/ssh-log-threat-detector/actions/workflows/ci.yml) 一个小巧、透明的 **SOC 检测工具。** 将其指向 Linux 的 `auth.log`, 它便会用分析师能够读懂并信任的简单规则来标记 SSH 攻击 —— 没有黑盒,没有 ML,只有清晰的逻辑和证据。 在您提供的日志文件上离线运行。 ## 检测项 | 规则 | 严重性 | 逻辑 | |---|---|---| | `successful_login_after_bruteforce` | CRITICAL | 一个 IP 在 ≥5 次失败尝试**之后**登录成功 —— 可能是成功的入侵 | | `ssh_brute_force` | HIGH | 来自单个源 IP 的 ≥5 次失败登录 | | `password_spraying` | HIGH | 一个 IP 尝试了 ≥5 个不同的用户名 | | `root_login_attempt` | MEDIUM | 直接以 `root` 身份进行的登录尝试 | ## 用法 ``` python src/log_detector.py examples/auth.log # human-readable python src/log_detector.py /var/log/auth.log --json cat auth.log | python src/log_detector.py - ``` 当任何警报触发时,退出代码为非零,因此它可以作为触发器放入 cron job 或 pipeline 中。 示例: ``` [CRITICAL] successful_login_after_bruteforce — 203.0.113.5 203.0.113.5 logged in as 'oracle' after 6 failed attempts -- possible successful brute force [HIGH] ssh_brute_force — 203.0.113.5 6 failed logins from 203.0.113.5 (targets: ['admin', 'oracle', 'postgres', 'root', 'test']) ``` ## 测试 ``` pip install pytest && python -m pytest tests/ -v ``` 8 个测试覆盖了日志解析和每一条检测规则,包括验证正常的 登录不会引发警报。 ## 范围与客观说明 阈值为固定的默认值,且解析器针对标准的 OpenSSH `auth.log` 格式 —— 它是一个专注的演示工具,而不是完整的 SIEM。它 可以与基于规则的平台(如 Sigma)自然结合(参见我的 [SigmaForge](https://github.com/koushikchowdary6/sigmaforge) 项目)。 ## 作者 Koushik Chowdary — [LinkedIn](https://linkedin.com/in/koushik-chowdary) · [GitHub](https://github.com/koushikchowdary6)
标签:AMSI绕过, Python, 云计算, 威胁检测, 安全规则引擎, 安全运营, 扫描框架, 无后门, 红队行动, 规则引擎, 逆向工具