diff --git a/.gitignore b/.gitignore index ad67955..0728338 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,8 @@ target # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + + +# Added by cargo + +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..cf1802b --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,186 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "anstream" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" + +[[package]] +name = "anstyle-parse" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys", +] + +[[package]] +name = "clap" +version = "4.5.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9e340e012a1bf4935f5282ed1436d1489548e8f72308207ea5df0e23d2d03f8" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d76b5d13eaa18c901fd2f7fca939fefe3a0727a953561fefdf3b2922b8569d00" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" + +[[package]] +name = "colorchoice" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "netexec_kerberoast_parser" +version = "0.1.0" +dependencies = [ + "clap", +] + +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + +[[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.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "2.0.111" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..13264ca --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "netexec_kerberoast_parser" +version = "0.1.0" +edition = "2024" + +[dependencies] +clap = { version = "4.5.53", features = ["derive"] } diff --git a/README.md b/README.md index 0e7a002..9db24ea 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # netexec_kerberoast_parser parses your netexec kerberoast results and puts them in files for each hashcat type you need! + +# USAGE: +netexec_kerberoast_parser -i {netexec output file} -o {output directory to save hash files to} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..b412168 --- /dev/null +++ b/src/main.rs @@ -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::>()[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!"); +}