Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
rustdllproxy — 生成 Rust 编写的代理 DLL | Kitploit
工具/GitHubGitHub/johnswiftc/rustdllproxy
Payload生成持久化机制后渗透利用渗透测试红队Payload 开发
GitHubjohnswiftc/rustdllproxy

rustdllproxy

生成 Rust 编写的代理 DLL

查看仓库
56442个月前Kitploit 审核通过

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

rustdllproxy


一个 Rust crate 工具,用于轻松生成和开发 Windows 应用程序的代理 DLL。

安装

root@kitploit:~
cargo install rustdllproxy

兼容性

该 crate 目前仅支持标准 DLL PE 格式。

当前限制

  • 使用自定义代码对函数进行 Hook 时,必须知道函数签名
    • 可以使用反汇编器和逆向工程工具(如 Ghidra)来获取。

命令

Rustdllproxy 附带两个子命令:

命令用途
rustdllproxy new根据一个或多个现有 DLL 生成一个新的代理 cdylib crate。
rustdllproxy build将 .def 文件与 src/lib.rs 同步并构建该 crate。
root@kitploit:~
rustdllproxy --help        # top-level help
rustdllproxy new --help    # generation flags
rustdllproxy build --help  # build flags

创建新 Crate

关于策略的简要说明

在生成 crate 之前,请决定你希望代理如何工作。一种典型模式是搜索顺序劫持:首先将目标 DLL 重命名为类似 target_.dll 的名称,然后将编译后的代理用作 target.dll。这会形成一个类似 binary -> target.dll -> target_.dll 的调用流。

根据你的使用场景,有多种路径可选。但如果需要重命名被代理的底层 DLL,请相应更新生成的 .def 文件。


root@kitploit:~
rustdllproxy new -p path/to/target_.dll -n my_proxy

提示: rustdllproxy 是使用 clap 构建的 CLI。运行 rustdllproxy --help 查看所有选项和标志。

编写 Hook

该宏库支持 3 种主要 Hook 类型:prehook、posthook 和 fullhook。

Hook 实现步骤

  1. 将 #[no_mangle] 指令替换为 Hook 宏(保留 //<dllname>.dll 尾部注释)

    root@kitploit:~
    #[prehook("dllbeingproxied.dll", "function_name")] //dllbeingproxied.dll
    
  2. 填写函数签名(将输入声明为 mut 以便修改它们)

  3. 使用 rustdllproxy build 构建。

Hook 类型

prehook

在原始函数之前执行代码。允许你添加功能或修改输入变量。

root@kitploit:~
#[prehook("target.dll", "my_function")] //target.dll
fn my_function(mut param1: i32, mut param2: &str) {
    // Your code here - executes before original function
    param1 *= 2;  // Modify parameters if needed
}

posthook

在原始函数之后执行代码。使用神奇的 ret 变量查看和修改返回值。

root@kitploit:~
#[posthook("target.dll", "calculate")] //target.dll
fn calculate(input: i32) -> i32 {
    // Original function executes first
    // Then your code runs with access to 'ret'
    ret = ret * 2;  // Modify return value
}

注意: ret 变量会自动定义为可变的。如果不需要,则无需引用它。

fullhook

提供对函数执行的完全控制。手动管理返回值和函数调用。

root@kitploit:~
#[fullhook("target.dll", "do_multi_add")] //target.dll
fn do_multi_add(mut a: i32, mut b: i32, mut c: i32) -> i32 {
    // Pre-processing
    a += 10;
    b += 20;

    // Call original function with magic func()
    let mut return_value: i32 = func(a, b, c);

    // Post-processing
    return_value *= 2;

    // Must explicitly return the value
    return_value
}

构建 Crate

在代理 crate 目录中运行(或将其作为第一个参数传入):

root@kitploit:~
rustdllproxy build [PATH] [--profile <name>] [--no-build] [-- <extra cargo args>]

注意事项

  • .def 文件在每次构建时都会完全重新生成,手动修改将被覆盖。如果你需要对 rustdllproxy 的构建方式进行手动修改,可以使用 cargo 来实现。
  • 构建系统依赖生成的注释、.def 导出项和 Hook 名称,在构建前获取底层 DLL 的名称。如果信息不足,则会抛出错误,说明如何恢复。

示例工作流

假设你想通过 DLL 搜索顺序劫持来修改办公软件中使用的 office.dll:

步骤 1:准备原始 DLL

root@kitploit:~
# Rename the original DLL
mv office.dll office_.dll

步骤 2:生成代理 Crate

root@kitploit:~
rustdllproxy new -p office_.dll -n office_proxy

步骤 3:实现 Hook

root@kitploit:~
#[prehook("office_.dll", "open_window")] //office_.dll
fn open_window() {
    // Your custom code here...
    println!("Window is about to open!");
}

步骤 4:构建与部署

root@kitploit:~
cd office_proxy
rustdllproxy build

构建文件位于 /target 目录下

DLL 捆绑注意事项

可以用单个 crate 代理多个目标 DLL。该功能很少使用,并且带有一些重要注意事项。

捆绑多个 DLL 时:

  • 由于导出顺序,函数序号可能会改变
  • 这通常不会造成问题,因为现代软件为了兼容性会使用导出名称
  • 主要适用于分析和自定义应用程序开发

更新日志

发布说明位于 CHANGELOG.md。

贡献

欢迎贡献!请随时提交 issue 和 pull request。

下载工具
标志默认值作用
PATH.代理 crate 根目录的路径。
--profile <name>releaseCargo 构建配置文件(release、dev、自定义)。
--no-buildoff重新生成 .def 文件,但跳过 cargo build。
-- <args>—原样转发给 cargo build。