worte the tool
This commit is contained in:
89
src/main.rs
Normal file
89
src/main.rs
Normal file
@@ -0,0 +1,89 @@
|
||||
use clap::Parser;
|
||||
use std::{
|
||||
fs::{File, create_dir_all, read_to_string},
|
||||
io::Write,
|
||||
path::PathBuf,
|
||||
};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(
|
||||
version,
|
||||
about,
|
||||
long_about = "parses your netexec output for a kerberoast and puts the hashes in separate files for each hash type."
|
||||
)]
|
||||
struct Args {
|
||||
#[arg(short, long, help = "the output file of netexec")]
|
||||
input: PathBuf,
|
||||
|
||||
#[arg(short, long, help = "the directory to save the hash files to.")]
|
||||
output: PathBuf,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args = Args::parse();
|
||||
let mut file_path = args.output.clone();
|
||||
if !args.output.exists() {
|
||||
create_dir_all(args.output).unwrap();
|
||||
}
|
||||
file_path.push("7500.txt");
|
||||
let mut file_7500 = File::create(&file_path).unwrap();
|
||||
file_path.pop();
|
||||
file_path.push("13100.txt");
|
||||
let mut file_13100 = File::create(&file_path).unwrap();
|
||||
file_path.pop();
|
||||
file_path.push("18200.txt");
|
||||
let mut file_18200 = File::create(&file_path).unwrap();
|
||||
file_path.pop();
|
||||
file_path.push("19600.txt");
|
||||
let mut file_19600 = File::create(&file_path).unwrap();
|
||||
file_path.pop();
|
||||
file_path.push("19700.txt");
|
||||
let mut file_19700 = File::create(&file_path).unwrap();
|
||||
file_path.pop();
|
||||
file_path.push("19800.txt");
|
||||
let mut file_19800 = File::create(&file_path).unwrap();
|
||||
file_path.pop();
|
||||
file_path.push("19900.txt");
|
||||
let mut file_19900 = File::create(&file_path).unwrap();
|
||||
file_path.pop();
|
||||
file_path.push("28800.txt");
|
||||
let mut file_28800 = File::create(&file_path).unwrap();
|
||||
file_path.pop();
|
||||
file_path.push("28900.txt");
|
||||
let mut file_28900 = File::create(&file_path).unwrap();
|
||||
let input_string = read_to_string(args.input).unwrap();
|
||||
let mut hashes = Vec::new();
|
||||
println!("parsing file...");
|
||||
let mut hash_count = 0;
|
||||
for line in input_string.lines() {
|
||||
if line.contains("$krb5") {
|
||||
let hash = line.split_whitespace().collect::<Vec<&str>>()[4];
|
||||
hashes.push(String::from(hash));
|
||||
hash_count += 1;
|
||||
println!("{} hashes loaded!", hash_count);
|
||||
}
|
||||
}
|
||||
println!("hashes loaded, saveing to files...");
|
||||
for hash in hashes {
|
||||
if hash.contains("$krb5pa$23$") {
|
||||
write!(file_7500, "{}\n", hash).unwrap();
|
||||
} else if hash.contains("$krb5tgs$23$*") {
|
||||
write!(file_13100, "{}\n", hash).unwrap();
|
||||
} else if hash.contains("$krb5asrep$23$") {
|
||||
write!(file_18200, "{}\n", hash).unwrap();
|
||||
} else if hash.contains("$krb5tgs$17$") {
|
||||
write!(file_19600, "{}\n", hash).unwrap();
|
||||
} else if hash.contains("$krb5tgs$18$") {
|
||||
write!(file_19700, "{}\n", hash).unwrap();
|
||||
} else if hash.contains("$krb5pa$17$") {
|
||||
write!(file_19800, "{}\n", hash).unwrap();
|
||||
} else if hash.contains("$krb5pa$18$") {
|
||||
write!(file_19900, "{}\n", hash).unwrap();
|
||||
} else if hash.contains("$krb5db$17$") {
|
||||
write!(file_28800, "{}\n", hash).unwrap();
|
||||
} else if hash.contains("$krb5db$18$test$") {
|
||||
write!(file_28900, "{}\n", hash).unwrap();
|
||||
}
|
||||
}
|
||||
println!("DONE!");
|
||||
}
|
||||
Reference in New Issue
Block a user