1 个不稳定版本
0.1.0 | 2024年5月4日 |
---|
#1369 在 开发工具
53 每月下载量
16KB
289 行
方解石
方解石是碳酸钙(CaCO3)的一种,常见于壳体材料。在此精神下,方解石是一组在 Rust 中生成位置无关 shellcode 必要的工具。
支持的目标
- Windows, x64
- Linux, x64
使用方法
- 目前,仅支持在具有 gnu-build 链(即
x86_64-unknown-linux-gnu
)的 linux-x64 主机上开发。确保您拥有编译此目标代码所需的工具和环境 - 通过
cargo install cargo-aragonite
命令安装cargo-aragonite
构建工具。这是一个薄包装器,它设置了正确的环境、发布配置文件和构建脚本,以生成正确的位置无关 shellcode。 - 使用
aragonite_main
属性注释您的 main 函数。这将处理设置链接器脚本的正确属性,并在提供目标家族时自动进行清理。请参阅examples/src/bin
文件夹中的示例。 - 使用构建工具构建您的 shellcode:
cargo aragonite build
。任何额外的参数都将透明地传递给 cargo。 - 生成的 shellcode 将位于
targets/x86_64-unknown-linux-gnu/aragonite/[binaryname]
详细信息
#[aragonite_main]
属性
家族
可以设置为以下值
值 | 描述 |
---|---|
win |
支持 Windows 目标,通过调用 ExitProcess(0) 函数在 kernel32.dll |
linux |
支持Linux目标,通过调用目标架构的sys_exit(0) 系统调用来自动清理 |
示例
#[aragonite_main(family = "win")]
fn main() {
// my code here, will automatically call ExitProcess(0) at the end of the function
}
架构
可以设置为以下值
值 | 描述 |
---|---|
x64 |
支持x64目标,根据family 属性选择正确的ABI |
示例
#[aragonite_main(family = "win", arch = "x64")]
fn main() {
// my code here, the code for ExitProcess(0) will assume it's running in a 64-bit process
}
no_cleanup
如果指定了family
,则此标志将禁用自动清理代码生成。
示例
#[aragonite_main(no_cleanup, family = "win")]
fn main() {
// my code here, no extra code will be added
}
依赖项
~12–19MB
~256K SLoC