kaleab49/malware-sandbox-c

GitHub: kaleab49/malware-sandbox-c

该项目是一个跨平台的轻量级恶意软件动态分析沙箱,通过多层隔离技术安全地运行并追踪可疑二进制文件的行为。

Stars: 0 | Forks: 0

# malware-sandbox-c [malware-sandbox](../malware-sandbox) 的极简 C 语言重写版。核心理念相同——隔离并追踪可疑二进制文件——但通过借助现有工具,代码量大幅减少。**现已支持跨平台(Linux + Windows)。** ## 隔离层 | 层级 | Linux | Windows | |-------|-------|---------| | 1 (可选) | 通过 `scripts/fc-run.sh` 运行的 **Firecracker** VM | Windows Sandbox(已规划) | | 2 | Linux **namespaces** (user, pid, mount, net) | **Job Objects**(内存/CPU 限制) | | 3 | **libseccomp** syscall 白名单 | **ETW** API 事件监控 | | 4 | **ptrace** syscall 追踪 + JSON | **Debug API** 进程事件 + JSON | ## 依赖项 ### Linux - `gcc`, `make` - `libseccomp` (Arch: `pacman -S libseccomp`, Debian: `apt install libseccomp-dev`) - 对于 VM 模式:`firecracker` 以及兼容的 kernel + rootfs ### Windows - **MinGW**(通过 `choco install mingw` 或 MSYS2) - 或 **MSVC** (Visual Studio) - 或使用 `build.bat` / `build.ps1` 脚本(无需 `make`) 有关详细的设置,请参阅 [WINDOWS_PORT.md](WINDOWS_PORT.md)。 [cJSON](https://github.com/DaveGamble/cJSON) 已内置于 `third_party/` 目录中,用于生成报告。 ## 构建 ### Linux ``` make ``` ### Windows(选项 1:批处理脚本 - 无需 make) ``` build.bat build.bat clean # to clean ``` ### Windows(选项 2:PowerShell 脚本 - 无需 make) ``` .\build.ps1 .\build.ps1 -Clean # to clean ``` ### Windows(选项 3:使用 make - 需要 MinGW) 首先安装 make: ``` choco install make # via Chocolatey # OR pacman -S make # via MSYS2 ``` 然后: ``` make make clean ``` ## 用法 ### Linux ``` # Host analysis (namespaces + seccomp + ptrace) ./sandbox --target /path/to/binary # 设置 timeout ./sandbox --target ./sample --timeout 60 # 跳过 isolation layers (不安全) ./sandbox --target ./sample --no-sandbox --no-seccomp # VM isolation (Firecracker 由 shell script 处理) ./sandbox --target ./sample --fc-kernel ./vmlinux --fc-rootfs ./rootfs.ext4 ``` ### Windows ``` # Basic analysis (Job Objects + Debug API) sandbox.exe --target C:\path\to\binary.exe # 设置 timeout sandbox.exe --target .\malware.exe --timeout 60 # 跳过 isolation layers (不安全) sandbox.exe --target .\malware.exe --no-sandbox --no-seccomp ``` 报告将写入: - **Linux:** `/tmp/sandbox-report-.json` - **Windows:** `sandbox-report-.json`(当前目录) ## 与 Rust 版本的对比 - **约 400 行 C 代码**,而 Rust 版本包含数千个模块、构建脚本和 QEMU 捆绑代码 - 使用 **libseccomp** 替代了手动编写的 BPF 过滤器 - 使用 **seccomp_syscall_resolve_num_arch** 替代了 400 行的 syscall 表 - 使用 **cJSON**(单一内置文件)替代了 serde - 使用 **getopt_long** 替代了 clap - 使用 **fc-run.sh** 替代了 `vm.rs` 的 VM 编排 原始的 Rust 项目保持在 `../malware-sandbox` 中未作改动。
标签:Gophish, 客户端加密, 恶意软件沙箱, 系统隔离, 行为追踪