qmadev/acquire-builder

GitHub: qmadev/acquire-builder

为 Dissect Acquire 数字取证工具构建跨平台独立可执行文件,支持配置嵌入和输出加密的编译工具链。

Stars: 3 | Forks: 1

# 获取 Builder 为 Windows、Linux 和 Mac 构建独立的 [acquire](https://github.com/fox-it/acquire) 二进制文件。这些二进制文件是结合 [python-build-standalone](https://github.com/astral-sh/python-build-standalone) 发行版和 Rust 构建的。使用 [pyo3](https://github.com/PyO3/pyo3),我成功地将 python 静态链接到了 Rust 二进制文件中,这与 [PyOxidizer](https://github.com/indygreg/PyOxidizer) 的功能基本相同。为什么要使用这个项目而不是直接使用 PyOxidizer? - 支持 Python 3.11 - 支持 acquire 的输出加密 - 静态 ucrt/vcrt - 专为 acquire 打造。 我没有像 PyOxidizer 那样创建复杂的内存模块加载器。必要的 python 资源是从作为二进制文件一部分的 zip 文件中加载的。这样,在运行 python 解释器和加载资源时,就不会向磁盘写入任何额外的文件。 ## 快速开始 ``` # 从 repository releases 下载 binaries $ ./acquire-builder download # 从头编译 standalone binary $ ./acquire-builder compile ``` ## 使用方法 ``` Usage: acquire-builder [OPTIONS] Commands: compile Compile new standalone binaries download Download standalone binaries from GitHub release help Print this message or the help of the given subcommand(s) Options: -c, --config-file Path to your custom acquire config file -o, --output-dir Path to store output files [default: build] --acquire-version Acquire version to use. Will use the latest version as default --dissect-version Dissect version to use. Will use the latest version as default -p, --python-exe Path to local python executable -v, --verbose... More output per occurrence -q, --quiet... Less output per occurrence -h, --help Print help ``` 使用这个项目有两种方式。这两种方式都会生成一个独立的 acquire 可执行文件。 1. 在编译模式下运行。这将从头开始编译项目。如果你想自己对二进制文件做一些修改,这可能很不错。不支持交叉编译。 2. 在下载模式下运行。这个仓库托管了包含预编译可执行文件的发布版本,这样你就不必自己编译了。这是最快且最简单的选项。将为所有支持的平台生成二进制文件。 对于这两种模式,都需要一个本地 python 解释器。默认情况下,构建器将使用 `python3` 命令后的任何解释器,但你可以使用 `--python-exe` 标志指定 python 解释器的完整路径。你还可以指定想要使用的 acquire 版本和 dissect 版本。只需提供版本号,例如 `3.21`,或者甚至是 `3.22.dev3`(如果你想使用开发版本)。 你可以使用 `--config-file` 标志添加一个 acquire `config.py` 文件,它看起来应该像这样: ``` PUBKEY = """ -----BEGIN RSA PUBLIC KEY----- MIIBCgKCAQEA3uiQuKBjLmeV+Ey3G9lduYUbD5m/l63XACxtUOoHWkZko4UQCQu0 Z22Cp2GN3KGIVGHegTw4OicTC3Pdje5KOlIIZSe2YCMbVp1vr3kzWGpWFQemw+j0 B+I1QbH1Zv0FVjrY42mPBqgGqNnre10I44npvX8pFVuUvh2JCIcjKaWQ7LifQLZa LsD74J+CQoBe5lW7vrTDWmPMJLRn9JlAh80xZUEG2XL8BF4ShVcLaAP+rk2ymNJD GLtgfN67KpF8L7ziyLOb3yUdBdLA8e6k9r37QS6F6cV4NTFWVsciaUaqHax2olzn YCfc5bW9lqm3+5XI0f8WO1BvVPg7VvdSjwIDAQAB -----END RSA PUBLIC KEY----- """ CONFIG = { "arguments": ["--profile", "full", "--auto-upload"], "public_key": PUBKEY, "upload": { "mode": "cloud", "endpoint": "storage.googleapis.com", "access_id": "mCQgJ5N8fEBqUzR3t4iP", "access_key": "rbsoiJKM3vDnmZfBV4X7FaqQgezkHWN0PCytlOwT", "bucket": "asdf", "folder": "asdf", } } ``` 你需要自己创建这个文件。构建器不会为你做这件事。它所做的只是将该文件嵌入到独立可执行文件中。 你可以使用 openssl 生成密钥对: ``` openssl genrsa -traditional -out private.key 2048 openssl rsa -traditional -outform PEM -in private.key -RSAPublicKey_out -out public.key ``` 运行构建器后,你的二进制文件将在 `bin` 文件夹中准备就绪! ## 待办事项 - 增加对 Python 3.14 的支持 - 增加对 acquire/dissect.target(本地)开发版的支持 - 为以下模块添加 pystandalone 功能: * dissect/hypervisor/descriptor/vmx.py * dissect/apfs/objects/keybag.py * dissect/target/loaders/itunes.py ## 注意事项 对于 Linux,我们只编译 musl 发行版。如果你想从头编译,请确保从 Linux musl 发行版(如 Alpine Linux)进行编译。我推荐使用 Rust Alpine docker 镜像。 我在几台虚拟机上进行了测试运行: - Windows Server 2012 R2 - Windows 10 - ESXi 7 - Fedora 39 - MacOS 26 我预计现代/主流 Linux 发行版以及 Server 2012 R2 及以上的 Windows 版本不会出现问题。我没有 Apple Silicon Mac,所以不知道在那上面的运行效果如何。不过它在 Github runner 上似乎运行良好。如果你遇到问题,并且确定这不是 acquire 本身的问题,请随时提出 issue! ## 致谢 借鉴了一些代码/灵感: * https://github.com/indygreg/PyOxidizer * https://github.com/littledivy/aead-gcm-stream * https://github.com/Legrandin/pycryptodome * acquire/dissect 代码库中所有对 `_pystandalone` 的引用
标签:Acquire, DAST, Dissect框架, DNS 反向解析, IP 地址批量处理, MacOS, PyO3, PyOxidizer替代, Python打包, Raspberry Pi, Rust, 二进制构建, 内存执行, 取证工具, 可执行文件, 可视化界面, 安全工具开发, 恶意软件分析, 数字取证, 无文件执行, 环境打包, 网络流量审计, 自动化构建, 自动化脚本, 输出加密, 通知系统, 静态编译