neutrinoguy/timehammer

GitHub: neutrinoguy/timehammer

一款用于测试 IoT 和嵌入式设备 NTP 协议安全性的跨平台工具,支持多种时间攻击模拟和客户端模糊测试。

Stars: 0 | Forks: 0

TimeHammer Logo

# TimeHammer 🔨⏰ 一款独立的跨平台 NTP 安全测试工具,专为 IoT、IIoT 和嵌入式设备测试而设计。 ![Go Version](https://img.shields.io/badge/Go-1.21+-00ADD8?style=flat&logo=go) ![License](https://img.shields.io/badge/License-MIT-green.svg) ![Platform](https://img.shields.io/badge/Platform-Windows%20%7C%20Linux%20%7C%20macOS-lightgrey) ## ⚠️ 免责声明 **本工具仅用于安全测试目的。** - ❌ 请勿在生产系统上使用 - ❌ 未经授权请勿使用 - ❌ 请勿在您不拥有/控制的网络上使用 - ✅ 仅在隔离的测试环境中使用 - ✅ 测试前请获取适当的授权 - ✅ 记录所有测试活动 作者不对本工具的滥用行为负责。 ## 🌟 功能特性 ### 核心功能 - **跨平台**:Windows、Linux 和 macOS 单一二进制文件 - **TUI 界面**:基于 tview + tcell 的精美终端 UI - **独立运行**:创建自己的数据目录 (`./.timehammer/`) - **NTP/SNTP 支持**:完整的 RFC 5905 (NTPv4) 和 SNTP 支持 - **可配置端口**:标准端口 123、自定义端口或自动回退 - **多接口**:绑定到特定网络接口 - **上游同步**:与公共 NTP 服务器同步 (time.google.com 等) - **多客户端**:支持 50-100+ 个并发客户端 - **时区支持**:配置服务器以本地时间偏移响应(例如 "America/New_York") ### 安全测试模式 🔓 - **时间欺骗** - 向客户端发送虚假时间(未来/过去) - **渐进式时间漂移** - 缓慢漂移时间以规避检测 - **死亡之吻** - CVE-2015-7704/7705 攻击模拟 - **Stratum 操控** - 声称更高级别 (stratum 1) - **闰秒注入** - 测试闰秒处理漏洞 - **时间戳翻转** - Y2K38 和 NTP Era 1 测试 - **时钟阶跃攻击** - 突然的巨大时间跳跃 - **客户端模糊测试** - 随机变异 NTP 字段以测试鲁棒性 ### 日志与导出 - TUI 实时日志查看器 - 客户端指纹识别(实现检测) - JSON/CSV 日志导出 - 会话录制与回放 ## 📦 安装 ### 从源码构建 ``` # 克隆 repository git clone https://github.com/neutrinoguy/timehammer.git cd timehammer # 构建 go build -o timehammer ./cmd/timehammer # 运行 ./timehammer ``` ### 跨平台编译 ``` # Linux (amd64) GOOS=linux GOARCH=amd64 go build -o timehammer-linux-amd64 ./cmd/timehammer # Windows (amd64) GOOS=windows GOARCH=amd64 go build -o timehammer-windows-amd64.exe ./cmd/timehammer # macOS (amd64) GOOS=darwin GOARCH=amd64 go build -o timehammer-darwin-amd64 ./cmd/timehammer # macOS (arm64 - Apple Silicon) GOOS=darwin GOARCH=arm64 go build -o timehammer-darwin-arm64 ./cmd/timehammer ``` ## 🚀 使用 ### TUI 模式(默认) ``` ./timehammer ``` ### 无头模式 ``` ./timehammer --headless ``` ### 键盘快捷键 | 按键 | 操作 | |-----|--------| | `F1` | 仪表盘 | | `F2` | 查看日志 | | `F3` | 编辑配置 | | `F4` | 攻击模式 / 安全测试 | | `F5` | 会话管理 | | `F10` | 启动/停止服务器 | | `F12` / `Esc` | 退出 | | `Ctrl+S` | 保存配置 | | `Ctrl+E` | 导出日志 (JSON & CSV) | | `Ctrl+R` | 切换会话录制 | | `Ctrl+U` | 强制上游同步 | | `?` | 显示帮助 | ## ⚙️ 配置 配置存储在 `./.timehammer/config.yaml` 中: ``` server: interface: "" # Empty = all interfaces port: 123 # Standard NTP port alt_port: 1123 # Fallback if 123 is busy max_clients: 100 ntp_version: 4 stratum: 2 timezone: "UTC" # IANA Timezone (e.g. America/New_York) upstream: servers: - address: time.google.com port: 123 priority: 1 enabled: true - address: time.cloudflare.com port: 123 priority: 2 enabled: true sync_interval: 60 timeout: 5 security: enabled: false active_attack: "" time_spoofing: offset_secs: 3600 # 1 hour into future kiss_of_death: code: "DENY" rollover: target_year: 2038 mode: "y2k38" ``` ## 🔓 安全攻击 ### 时间欺骗 向客户端发送受控的虚假时间。适用于测试: - 证书过期处理 - Token/Session 过期 - 定时任务行为 ### 渐进式时间漂移 缓慢向前或向后漂移时间以规避检测。测试: - 漂移检测机制 - 长期时间容差 ### 死亡之吻 发送 KoD 数据包以禁用客户端同步。基于: - CVE-2015-7704 - CVE-2015-7705 ### Stratum 操控 声称是 stratum 1(GPS 同步)服务器。测试: - 服务器选择算法 - Stratum 偏好漏洞 ### 闰秒注入 注入闰秒标志。测试: - 闰秒处理漏洞 - 闰秒事件期间的系统稳定性 ### 时间戳翻转 发送接近翻转边界的时间戳: - **Y2K38**:Unix 32 位时间戳溢出(2038 年 1 月 19 日) - **NTP Era 1**:NTP 时间戳翻转(2036 年 2 月 7 日) ### 时钟阶跃攻击 突然的巨大时间跳跃。测试: - 阶跃 vs 微调行为 - 应用程序韧性 ### 客户端模糊测试 随机变异 NTP 协议字段以测试客户端稳定性和错误处理: - **Header 模糊测试**:无效的版本、模式、stratum - **时间戳模糊测试**:零值、最大值、不匹配的时间戳 - **逻辑模糊测试**:无效的轮询间隔、精度、根延迟 ## 📁 文件结构 ``` ./.timehammer/ ├── config.yaml # Configuration file ├── timehammer.log # Log file ├── sessions/ # Session recordings │ └── session_*.json └── exports/ # Exported logs ├── logs_*.json └── logs_*.csv ``` ## 🔧 故障排除 ### 端口 123 已被占用 在 **macOS** 上: ``` sudo lsof -i :123 sudo launchctl unload /System/Library/LaunchDaemons/org.ntp.ntpd.plist ``` 在 **Linux** 上: ``` sudo ss -tulpn | grep :123 sudo systemctl stop systemd-timesyncd # 或 sudo systemctl stop ntp ``` 在 **Windows** 上(以管理员身份): ``` netstat -ano | findstr :123 net stop w32time ``` ## 📄 许可证 本项目采用 MIT 许可证授权 - 详情请参阅 [LICENSE](LICENSE) 文件。 ## 🙏 致谢 - [beevik/ntp](https://github.com/beevik/ntp) - NTP 客户端库 - [rivo/tview](https://github.com/rivo/tview) - TUI 框架 - [gdamore/tcell](https://github.com/gdamore/tcell) - 终端库 ## ⚡ 相关项目 - [Chrony](https://chrony.tuxfamily.org/) - 多功能 NTP 实现 - [ntpd](https://www.ntp.org/) - 参考 NTP 实现 - [Roughtime](https://roughtime.googlesource.com/roughtime) - 安全时间协议 ## 🤖 AI 鸣谢 使用 `Claude Opus 4.5` 和 Google Antigravity 🤖 用 ❤️ 构建
标签:Cloudflare, DoS攻击, EVTX分析, EVTX分析, Golang, Go语言, IIoT, Kiss-of-Death, MITRE ATT&CK, NTP, SNTP, Spoofing, TUI, Y2K38, 云资产清单, 协议分析, 反取证, 安全编程, 安全评估, 嵌入式设备, 工业控制安全, 日志审计, 时钟漂移, 时间同步, 时间欺骗, 权限提升, 物联网安全, 程序破解, 终端UI, 网络安全, 逆向工程, 防御绕过, 隐私保护