redhoundinfosec/authlog
GitHub: redhoundinfosec/authlog
跨平台的身份验证日志分析与分类工具,支持 Linux 和 Windows,可自动检测暴力破解、入侵指标及权限提升行为。
Stars: 0 | Forks: 0
# authlog
**身份验证日志分析与分类工具**
`authlog` 解析来自 Linux(`auth.log`、`secure`)和 Windows(Security Event XML/JSON 导出)的身份验证日志,并生成结构化的身份验证事件摘要:失败登录、成功登录、权限提升、暴力破解模式以及异常活动。一条命令即可分类处理 auth 活动。
## 适用人群
- 正在对受损系统进行分类的 **事件响应人员**
- 正在审查身份验证模式的 **安全分析师**
- 正在审计访问权限的 **系统管理员**
- 正在验证访问控制的 **合规团队**
## 功能特性
- 通过正则解析 **Linux** `auth.log` / `secure` — sshd、sudo、su 事件
- 解析 **Windows Security Event XML** — 从 Event Viewer (`wevtutil`) 导出
- 解析 **Windows Security Event JSON** — 通过 PowerShell `Get-WinEvent` 导出
- 基于内容检查 **自动检测** 日志格式
- **暴力破解检测** — 在可配置的时间窗口内来自同一来源的 N+ 次失败
- **入侵指标** — 来自同一 IP 的暴力破解后的成功登录
- **权限提升** 跟踪 — sudo、su、Windows Event ID 4672、4648
- **时间线** 和活动高峰时段
- **排名列表** — 失败来源 Top 榜、目标账户 Top 榜
- **输出格式**:彩色文本(默认)、JSON、CSV
- 使用 `--since` 和 `--until` 进行 **时间过滤**
- **退出代码**:`0` = 正常,`1` = 可疑,`2` = 错误
## 安装
### 从源码安装
```
git clone https://github.com/redhoundinfosec/authlog
cd authlog
make build
# Binary: ./bin/authlog
```
### Go install
```
go install github.com/redhoundinfosec/authlog/cmd/authlog@latest
```
## 快速开始
```
# 分析单个 Linux auth log
authlog analyze /var/log/auth.log
# 分析导出为 XML 的 Windows 安全事件
authlog analyze windows-security.xml
# 分析多个文件 — 合并时间线
authlog analyze auth.log backup-auth.log
# JSON 输出到文件
authlog analyze auth.log --format json -o report.json
# 按时间窗口过滤
authlog analyze auth.log --since 2026-04-01 --until 2026-04-02
# 显示前 20 条条目,降低暴力破解阈值
authlog analyze auth.log --top 20 --threshold 3
# 用于 SIEM 导入的 CSV
authlog analyze auth.log --format csv -o events.csv
# Verbose — 显示每个独立事件
authlog analyze auth.log --verbose
# Quiet mode — 单行摘要
authlog analyze auth.log --quiet
```
## CLI 参考
```
Usage: authlog [flags]
Commands:
analyze Parse and summarize authentication events
version Print version information
Flags for analyze:
-f, --format string Output format: text, json, csv (default: text)
-o, --output string Write output to file
--since string Start time filter (RFC3339 or YYYY-MM-DD)
--until string End time filter (RFC3339 or YYYY-MM-DD)
--top int Number of top entries to show (default: 10)
--threshold int Brute force threshold N failures/5 min (default: 5)
--no-color Disable colored output
-q, --quiet Summary line only
-v, --verbose Show individual events
```
## 示例输出
```
authlog v0.1.0 — Authentication Log Analysis
Source: linux-auth.log
Format: linux
Period: 2026-04-03 14:20:01 → 2026-04-03 15:45:00
Total Events: 38
EVENT SUMMARY
├─ Successful logins 8
├─ Failed logins 21
├─ Privilege escalation 5
└─ Other 4
⚠ BRUTE FORCE DETECTED
● 10.0.0.50 → 8 failures in 1m17s targeting: root, admin, user
└─ FOLLOWED BY successful login as admin at 14:25:03 [CRITICAL]
TOP FAILED LOGIN SOURCES
1. 10.0.0.50 8 failures
2. 203.0.113.15 5 failures
3. 45.33.32.156 3 failures
4. 185.220.101.1 3 failures
5. 198.51.100.22 2 failures
TOP TARGETED ACCOUNTS
1. root 14 failures
2. admin 7 failures
3. user 2 failures
PRIVILEGE ESCALATION
├─ admin: sudo: /usr/bin/apt update (14:30:15)
├─ admin: sudo: /bin/systemctl restart nginx (14:32:10)
├─ admin: sudo: /usr/bin/cat /etc/shadow (14:35:22) [WARNING]
├─ admin: sudo: /usr/bin/id (14:40:00)
└─ devops: sudo: /usr/bin/python3 /opt/app/deploy.py (14:41:00)
TIMELINE
2026-04-03 14:00 ██████████████████████████ 28
2026-04-03 15:00 ██ 2
Verdict: SUSPICIOUS — brute force with subsequent successful login detected; sensitive privilege escalation command: /usr/bin/cat /etc/shadow
```
## Windows 事件收集
**通过 Event Viewer 导出 (XML):**
```
wevtutil qe Security /f:xml > windows-security.xml
# 带计数限制:
wevtutil qe Security /c:1000 /rd:true /f:xml > recent-security.xml
```
**通过 PowerShell 导出 (JSON):**
```
Get-WinEvent -LogName Security -MaxEvents 500 | ConvertTo-Json -Depth 5 > security.json
# 按时间过滤:
Get-WinEvent -FilterHashtable @{LogName='Security'; StartTime='2026-04-01'; EndTime='2026-04-03'} |
ConvertTo-Json -Depth 5 > security-filtered.json
```
## 支持的事件 ID
| 事件 ID | 描述 |
|----------|-------------|
| 4624 | 登录成功 |
| 4625 | 登录失败 |
| 4634 | 注销 |
| 4648 | 显式凭据登录 |
| 4672 | 分配特殊权限(管理员登录) |
| 4720 | 已创建用户账户 |
| 4732 | 已将成员添加到安全组 |
## 退出代码
| 代码 | 含义 |
|------|---------|
| 0 | 分析完成,未发现可疑模式 |
| 1 | 检测到可疑模式 |
| 2 | 错误(参数错误、文件不可读、解析失败) |
在脚本中使用退出代码:
```
authlog analyze auth.log --quiet
if [ $? -eq 1 ]; then
echo "ALERT: suspicious auth activity detected"
# page on-call, create ticket, etc.
fi
```
## 构建
```
make build # Build to ./bin/authlog
make test # Run all tests
make test-v # Run tests with verbose output
make lint # golangci-lint
make release # Cross-compile for Linux, macOS, Windows
make clean # Remove build artifacts
```
## 许可证
MIT — 版权所有 2026 Red Hound Information Security LLC。参见 [LICENSE](LICENSE)。
标签:CSV导出, EVTX分析, Go, Linux Auth.log, Linux安全, PE 加载器, Ruby工具, SOC工具, SSH分析, Windows 安全日志, 二进制发布, 免杀技术, 协议分析, 安全运营, 库, 应急响应, 开源工具, 异常检测, 扫描框架, 数字取证, 文档结构分析, 日志审计, 日志解析, 暴力破解检测, 权限提升, 漏洞发现, 红队行动, 自动化脚本, 认证日志, 证书伪造