deoktr/raudit

GitHub: deoktr/raudit

一款轻量高效的 Linux 安全配置审计工具,基于 CIS、STIG 等标准对系统进行基线检查并输出结构化报告。

Stars: 0 | Forks: 1

# rAudit rAudit 是一个 Linux 安全审计工具,旨在帮助您创建自己的安全审计检查。 目标: - 快速且可靠的审计。 - 易于扩展和创建您自己的检查。 - 易于维护。 - 同时适用于服务器和工作站。 - 人类可读或 [OCSF Compliance Finding](https://schema.ocsf.io/1.7.0/classes/compliance_finding) JSON 输出格式。 ## 安装 安装预编译的 Github 发行版: ``` # 下载并 verify curl -fsSL -O https://github.com/deoktr/raudit/releases/latest/download/raudit-x86_64-unknown-linux-gnu.tar.gz curl -fsSL -O https://github.com/deoktr/raudit/releases/latest/download/raudit-x86_64-unknown-linux-gnu.sha256 sha256sum -c raudit-x86_64-unknown-linux-gnu.sha256 # 安装 tar -xzf raudit-x86_64-unknown-linux-gnu.tar.gz sudo install -m 0755 raudit /usr/local/bin/raudit # 验证安装 raudit --version # 清理 rm raudit raudit-x86_64-unknown-linux-gnu.sha256 raudit-x86_64-unknown-linux-gnu.tar.gz ``` ## 使用方法 默认情况下,所有检查都会运行,您可以通过过滤特定需求来减少检查数量,并且为了获得更清晰的输出,可以不打印已通过的检查: 工作站: ``` raudit --tags workstation --tags-exclude paranoid,useless --no-print-passed ``` 服务器: ``` raudit --tags server --tags-exclude paranoid,useless --no-print-passed ``` 生成遵循 [OCSF Compliance Finding (class 2003, schema 1.7.0)](https://schema.ocsf.io/1.7.0/classes/compliance_finding) 的 JSON 报告: ``` raudit --json > report.json ```
示例 JSON 输出: ``` raudit --json --filters USR_001 ``` ``` { "findings": [ { "activity_id": 1, "activity_name": "Create", "category_uid": 2, "category_name": "Findings", "class_uid": 2003, "class_name": "Compliance Finding", "type_uid": 200301, "finding_info": { "uid": "USR_001", "title": "Ensure that root is the only user with UID 0", "desc": "Multiple accounts with UID 0 have unrestricted root-level access, making it impossible to trace privileged actions to a specific user." }, "compliance": { "standards": [ "rAudit" ], "status_id": 1, "status": "Pass" }, "metadata": { "version": "1.7.0", "product": { "name": "raudit", "version": "0.30.0" } }, "severity_id": 5, "severity": "Critical", "status_id": 4, "status": "Resolved", "time": 1773777067196 } ], "stats": { "total": 1, "pass": 1, "fail": 0, "warning": 0, "unknown": 0, "fail_critical": 0, "fail_high": 0, "fail_medium": 0, "fail_low": 0, "fail_informational": 0 }, "metadata": { "version": "1.7.0", "product": { "name": "raudit", "version": "0.30.0" } } } ```
用法: ``` Audit Linux systems security configurations Usage: raudit [OPTIONS] Options: --tags [...] Comma-separated list of tags to include [env: TAGS=] --tags-exclude [...] Comma-separated list of tags to exclude [env: TAGS_EXCLUDE=] --filters [...] Comma-separated list of ID prefixes to include [env: FILTERS=] --filters-exclude [...] Comma-separated list of ID prefixes to exclude [env: FILTERS_EXCLUDE=] --severity Minimum severity level to include (includes specified level and above) [env: SEVERITY=] --severity-exact [...] Comma-separated list of exact severity levels to include [env: SEVERITY_EXACT=] --log-level Log level [env: LOG_LEVEL=] [default: info] [possible values: error, warn, info, debug, trace] --no-parallelization Disable multi-threading parallelization [env: NO_PARALLELIZATION=] --no-print-checks Disable print of individual checks [env: NO_PRINT_CHECKS=] --no-print-passed Disable print of passed checks [env: NO_PRINT_PASSED=] --no-print-description Disable print of check description [env: NO_PRINT_DESCRIPTION=] --no-print-fix Disable print of check fix if it failed [env: NO_PRINT_FIX=] --no-stats Disable print of stats [env: NO_STATS=] --no-colors Disable colored output [env: NO_COLORS=] --no-time Disable timer [env: NO_TIME=] --no-skip Disable automatic skipping of rules [env: NO_SKIP=] --json Generate JSON output [env: JSON=] -h, --help Print help -V, --version Print version ``` ## 规则 默认的内置规则基于多种来源,包括 CIS、STIG、Mozilla、ArchLinux wiki。您应该根据自身的需求对其进行自定义。 一些模块可以帮助完成特定的配置检查。 支持的内容: - 挂载点及其选项。 - 内核参数。 - 内核编译参数。 - Sysctl 参数。 - Docker 和 Podman。 - Login.defs 配置。 - Modprobe,包括黑名单和禁用的模块。 - PAM 规则。 - OpenSSH 服务器服务和配置。 - Sudo 配置。 - 用户和用户组。 - Uptime。 - Systemd 配置。 - 进程。 - Audit 规则和配置。 - Grub 配置。 - GDM 配置。 - Shell 配置。 - APT 包管理器配置。 - Hosts 配置。 - AppArmor。 - Bin。 - Cron 服务和配置。 - 漏洞利用缓解。 - Nginx。 计划支持: - SELinux。 - IP 和 nftables。 - Systemd units。 - Apache。 - Redis。 - MySQL。 - Squid。 - PostgreSQL。 - ProFTPD。 - Firejail。 ## 本地构建 使用 `cargo` 从源码构建: ``` cargo build --release ``` 将在 `./target/release/raudit` 中生成可执行文件。 ## 开发 测试: ``` cargo test ``` 本地运行: ``` cargo run -- --help ``` ## 安全 使用 [cargo-audit](https://github.com/RustSec/rustsec/tree/main/cargo-audit) 来审计依赖项中是否存在具有安全漏洞的 crates,该检查在 Github CI 中执行。 您也可以手动运行审计: ``` cargo install cargo-audit --locked cargo audit ``` ## 性能测试 使用命令:`hyperfine -i ./target/release/raudit`: ``` Benchmark 1: ./target/release/raudit Time (mean ± σ): 116.5 ms ± 5.3 ms [User: 89.7 ms, System: 127.8 ms] Range (min … max): 110.6 ms … 132.7 ms 24 runs ``` ## 来源 - [Linux self-protection.rst](https://github.com/torvalds/linux/blob/master/Documentation/security/self-protection.rst) - [Tails kernel_hardening](https://tails.net/contribute/design/kernel_hardening/) - [Kicksecure/security-misc](https://github.com/Kicksecure/security-misc) ## 替代方案 - [lynis](https://github.com/CISOfy/lynis) - [kernel-hardening-checker](https://github.com/a13xp0p0v/kernel-hardening-checker) - [konstruktoid/hardening](https://github.com/konstruktoid/hardening) ## TODO - 提供更详细的错误日志 - 为复杂的配置创建自定义解析器(如 sudo、nginx 等) - 允许用户指定配置路径,并支持 globing 匹配 - 在启动时检查权限(是否为 root),并在需要时警告用户 - 使用 [OPA](https://www.openpolicyagent.org/) 来定义规则? - 优化性能,将 String 转换为 &str - 在 JSON 报告中添加元数据,如开始/结束时间、耗时、版本、用户名、主机名等。 - 添加文档,包括用户文档和开发文档 - 添加检查超时机制,如果耗时过长则直接停止,甚至可以通过 ctrl+c 终止? - 为部分规则添加白名单配置,例如将受信任的用户加入 docker 组白名单,而不是直接判定检查失败,从而避免强制管理员创建配置 - 添加检查以避免检查名称冲突 - 使用宏 `run!()` 来记录命令 - 修复代码中所有的 TODO 和 FIXME 规则: - 在所有 systemd 服务上运行 `systemd-analyze security ...` 并根据结果报告错误 - 确保 DNS 支持 DNSSEC 并使用 DoT、DoH 或 DNSCRYPT 进行安全加密 - 通过运行 `timedatectl` 确保 NTP 已配置 - 确保 NTP 配置了 NTS - 确保使用了 logrotate - 确保使用了 rsyslog - 确保安全启动 (Secure Boot) 和 TPM 已正确设置 - 确保 LSM 在启动时配置为 AppArmor 或 SELinux - 确保某些进程使用了 AppArmor 配置文件 - 确保某些进程使用了 firejail - 确保 `/tmp` 由 systemd 的 `tmp.mount` 单元管理,并在关机时进行清理 - 确保已加固 systemd 服务(使用沙箱选项),通过 `systemctl cat` 查看 - 确保不需要的 cron 任务已被禁用 ## 许可证 rAudit 采用 [GPLv3](./LICENSE) 许可证授权。
标签:DNS 解析, JSON报告, OCSF, Rust, 关系图谱, 可视化界面, 基线检查, 子域名枚举, 安全合规, 工作站安全, 开源安全工具, 系统安全, 网络代理, 网络流量审计, 自定义审计规则, 逆向工程平台, 通知系统, 配置核查