diff --git a/src/brute_forcer.rs b/src/brute_forcer.rs index f1aed03..dbb6f04 100644 --- a/src/brute_forcer.rs +++ b/src/brute_forcer.rs @@ -1,6 +1,6 @@ -use std::{time::{Duration, Instant}, sync::{Arc, RwLock}}; +use std::{io::Write, sync::{Arc, RwLock}, time::{Duration, Instant}}; -use crate::discord_invite::{DiscordInvite, DiscordInviteError}; +use crate::{discord_invite::{DiscordInvite, DiscordInviteError}, Args}; use console::Term; use getset::{Getters, MutGetters, Setters}; use rand::seq::IteratorRandom; @@ -24,7 +24,13 @@ impl Bruter { } } - pub fn start(mut self) -> anyhow::Result<()> { + pub fn start(mut self, args: Args) -> anyhow::Result<()> { + let mut outfile = std::fs::OpenOptions::new() + .write(true) + .append(true) + .create(true) + .open(args.outfile) + .unwrap(); let mut rng = rand::thread_rng(); for i in 0..self.iterations { let string: String = random_string::generate( @@ -54,7 +60,8 @@ impl Bruter { &inv.code, start.elapsed().as_millis() ); - self.found_codes.push(inv); + self.found_codes.push(inv.clone()); + outfile.write_fmt(format_args!("https://discord.gg/{}\n", inv.code)).unwrap(); } } } diff --git a/src/main.rs b/src/main.rs index 32df434..36eecde 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,18 +12,18 @@ pub mod tui; #[derive(Parser, Debug, Clone)] pub struct Args{ wordlist: PathBuf, - #[clap(default_value_t = 10)] - iterations: usize, + outfile: PathBuf, + iterations: Option, } fn main() -> anyhow::Result<()>{ let args = Args::parse(); - let mut bruter = Bruter::new(args.iterations); + let mut bruter = Bruter::new(args.iterations.unwrap_or(10)); let mut codes = vec![]; - for w in std::fs::read_to_string(args.wordlist).unwrap().split('\n'){ + for w in std::fs::read_to_string(args.clone().wordlist).unwrap().split('\n'){ codes.push(w.to_string()); } bruter.set_codes(codes); - Bruter::start(bruter).unwrap(); + Bruter::start(bruter, args).unwrap(); Ok(()) } \ No newline at end of file