dev-cec/DFIR_Linux_Collector

GitHub: dev-cec/DFIR_Linux_Collector

一款面向 GNU/Linux 的轻量级数字取证采集工具,能够以 JSON、文本和原始格式导出系统工件及内存转储,为事件响应团队提供低影响的证据收集方案。

Stars: 0 | Forks: 0

# DFIR_Linux_Collector ![最近提交](https://img.shields.io/badge/last%20commit-2026-brightgreen) ![发布](https://img.shields.io/badge/release-2026-brightgreen) 用于 GNU/Linux 的独立收集工具 - 对主机的影响极低 - 不使用主机二进制文件(防止 hooking) - 所有二进制文件均包含在可执行文件中 - 以 JSON 格式(日志) / 原始格式(RAM 转储)和文本格式导出 - 使用 AVML 进行 RAM 转储(兼容性参考 https://github.com/microsoft/avml#tested-distributions) - 结果为一个压缩存档和一个校验和文件 参考来源:https://github.com/xophidia/DFIR_Linux_Collector ## 架构 ``` DFIR_Linux_Collector/ ├── dlc.sh → Generic engine ├── rules.json → Collection rules (YAML-like JSON) ├── scripts/ → External scripts (firefox, chrome, ssh, zeitgeist, etc.) ├── tools/ → Bundled binaries (avml, sqlite3) ├── bootstrap.sh → Standalone launcher └── Makefile → Build makeself archive ``` ### 工作原理 1. `dlc.sh` 通过内置的 `jq` 读取 `rules.json` 2. 用户选择一种模式(Light / Medium / Full) 3. 引擎遍历所选模式下的各个类别 4. 每条命令被执行,格式化为 JSON,并补充元数据 5. 复杂功能(antivirus、kernel、RAM 等)仍保留在 bash 中执行 6. 外部脚本(browsers、SSH 等)直接调用 ### 支持的规则格式 | 格式 | 描述 | 示例 | |---|---|---| | `wrap` | 文本输出 → 封装在 `{"key": "value"}` 中 | `uname -a`, `uptime` | | `jsonl` | 输出 → 通过 awk 格式化程序转为 JSONL → 数组 | `env`, `lsmod`, `ps` | | `raw` | 原样复制到文本文件 | `lsof` | | `function` | 专用 bash 函数(复杂逻辑) | `antivirus`, `dump_ram` | | `scripts` | 外部脚本调用 | `firefox.sh`, `c_ssh.sh` | ### 添加新规则 在 `generic`、`network` 或 `process` 类别下的 `rules.json` 中添加一个块: ``` { "name": "hostname", "cmd": "hostname", "output": "gen_hostname.json", "format": "wrap", "key": "hostname" } ``` 对于需要 awk 格式化的表格数据: ``` { "name": "timedatectl", "cmd": "timedatectl", "output": "gen_timedate.json", "format": "jsonl", "formatter": "fmt_timedate", "key": "timedate" } ``` 然后在 `dlc.sh` 中创建 `fmt_timedate` 函数: ``` function fmt_timedate() { awk -F: '{gsub(/^[[:space:]]+/, "", $1); gsub(/^[[:space:]]+/, "", $2); print "{\"key\": \""$1"\", \"value\": \""$2"\"}"}' } ``` ### 收集模式 | 模式 | 包含的类别 | |---|---| | **Light** | generic, network, process, user, artefactsDistribution, exportRawKernelArtefacts, antivirus | | **Medium** | Light + interestFile(MD5 哈希、SUID/SGID、时间线) | | **Full** | Medium + dump_ram (AVML) | 在 `rules.json` 中定义 — 无需修改代码。 ## 兼容性 | 发行版 | 版本 | 正常 | 错误 | 备注 | |---|---|---|---|---| | Ubuntu | 12 - 25 | ✓ | --- | --- | | Debian | 13 (Trixie) | ✓ | --- | --- | | Fedora | 30 | ✓ | --- | --- | | CentOS | 7 | ✓ | --- | --- | | CentOS | 6 | --- | ✗ | Kernel 版本过旧 | 其他发行版尚未测试,仍在进行中 ... ## 内置组件版本 | 组件 | 版本 | |---|---| | Alpine Linux | **v3.23.4** (2026年4月) | | busybox | **1.37.0** (静态) | | apk-tools-static | **3.0.6-r0** | | jq | **1.8.1-r0** | ## 快速开始 ![](https://raw.githubusercontent.com/dev-cec/DFIR_Linux_Collector/main/dlc.gif) ``` git clone https://github.com/xophidia/DFIR_Linux_Collector.git cd DFIR_Linux_Collector ./setup.sh ``` ``` sudo ./DFIR_linux_collector Verifying archive integrity... 100% MD5 checksums are OK. All good. Uncompressing orc 100% ██████╗ ██╗ ██████╗ ██╔══██╗██║ ██╔════╝ ██║ ██║██║ ██║ ██║ ██║██║ ██║ ██████╔╝███████╗╚██████╗ ╚═════╝ ╚══════╝ ╚═════╝ DFIR Linux Collector Case Number : 10 Description : linux_host Examiner Name : Xophidia Hostname : 10_01 Dump generic artifacts + uname ....................✓ + env ......................✓ + uptime ...................✓ ... ``` ## 收集的工件 ### 通用 | 命令 / 文件 | Json | Text | Raw | |---|---|---|---| | env | ✓ | --- | --- | | uptime | ✓ | --- | --- | | uname -a | ✓ | --- | --- | | lsmod | ✓ | --- | --- | | /etc/passwd | ✓ | --- | --- | | /etc/group | ✓ | --- | --- | | date | ✓ | --- | --- | | who | ✓ | --- | --- | | cpuinfo | ✓ | --- | --- | | lsof | --- | ✓ | --- | | sudoers | ✓ | --- | --- | | mount | ✓ | --- | --- | | fstab | ✓ | --- | --- | | last | ✓ | --- | --- | | timedatectl | --- | ✓ | --- | | lastlog | ✓ | --- | --- | | hostname | ✓ | --- | --- | ### SSH | 命令 / 文件 | Json | Text | Raw | |---|---|---|---| | authorized_keys | ✓ | --- | --- | | known_hosts | ✓ | --- | --- | ### 网络 | 命令 / 文件 | Json | Text | Raw | |---|---|---|---| | ip | ✓ | --- | --- | | netstat | ✓ | --- | --- | | arp | ✓ | --- | --- | | ss (sockets) | ✓ | --- | --- | | lsof -i | --- | ✓ | --- | ### 进程 | 命令 / 文件 | Json | Text | Raw | |---|---|---|---| | ps | ✓ | --- | --- | | docker ps | ✓ | --- | --- | | systemctl services | ✓ | --- | --- | ### 浏览器 | 命令 / 文件 | Json | Text | Raw | |---|---|---|---| | Firefox | ✓ | --- | --- | | Google Chrome | ✓ | --- | --- | | Chromium | ✓ | --- | --- | ### 应用程序 | 命令 / 文件 | Json | Text | Raw | |---|---|---|---| | FileZilla (servers.xml, recentservers.xml) | ✓ | --- | ✓ | | Zeitgeist (最近 200 条活动) | ✓ | --- | --- | | 开发者历史记录 (.mysql, .psql, .sqlite, .nano, .lesshst, .wget-hsts, .bashrc) | ✓ | --- | ✓ | ### 日志 | 命令 / 文件 | Json | Text | Raw | |---|---|---|---| | auth.log | --- | ✓ | --- | | syslog | ✓ | --- | --- | ### 主目录 | 命令 / 文件 | Json | Text | Raw | |---|---|---|---| | .gitconfig | ✓ | --- | --- | | .command_history (bash + zsh) | ✓ | --- | ✓ | | .viminfo | --- | ✓ | --- | ### 桌面 | 命令 / 文件 | Json | Text | Raw | |---|---|---|---| | 回收站 | --- | --- | ✓ | | 常用应用 (GNOME) | ✓ | --- | --- | ### 文件 | 命令 / 文件 | Json | Text | Raw | Csv | |---|---|---|---|---| | MD5 哈希 | ✓ | ✓ | --- | --- | | SUID/SGID 权限 | ✓ | --- | --- | --- | | 时间线 | --- | --- | --- | ✓ | ### 转储 | 命令 / 文件 | Json | Text | Raw | |---|---|---|---| | AVML (RAM) | --- | --- | ✓ | | LiME | ✗ | ✗ | ✗ | | /boot/System.map-$(uname -r) | --- | --- | ✓ | | /boot/vmlinuz | --- | --- | ✓ | ### 杀毒软件 | 命令 / 文件 | Json | Text | Raw | |---|---|---|---| | ClamAV | ✓ | --- | --- | ## 许可证 GNU Lesser General Public License
标签:Bash, HTTP工具, 命令控制, 库, 应急响应, 应用安全, 数字取证, 数据采集, 自动化脚本