rop 注入

shellcode 注入

绕过 sandbox 限制

rust 中编写一个测试用的 dylib 也很简单

Cargo.toml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
[lib]
crate-type = ["cdylib"]

[profile.release]
opt-level = 3
lto = true
codegen-units = 1
panic = "abort"
strip = true
debug = false

lib.rs

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
use std::process::Command;

fn main() {
    Command::new("sh")
        .arg("-c")
        .arg("open -a Calculator")
        .output()
        .expect("sh exec error!");
}

#[used]
#[link_section = "__DATA,__mod_init_func"]
pub static INITIALIZE: fn() = main;

#[link_section = "__DATA,__mod_init_func"] 基本等同于在C中 __attribute__ ((constructor))