diff --git a/pentest_tool/src/info_controls.rs b/pentest_tool/src/info_controls.rs index 40bd90f..879ecef 100644 --- a/pentest_tool/src/info_controls.rs +++ b/pentest_tool/src/info_controls.rs @@ -1,6 +1,8 @@ use std::collections::HashMap; use std::fs; use std::fs::read_to_string; +use std::fs::OpenOptions; +use std::hash::Hash; use std::io::BufReader; use std::io::Write; use std::path::PathBuf; @@ -10,6 +12,8 @@ use std::thread; use std::time::Duration; use std::io::stdin; use std::thread::JoinHandle; +use chrono::format; +use reqwest::dns::Name; use walkdir::WalkDir; use clearscreen::clear; use clearscreen; @@ -775,4 +779,114 @@ pub fn get_mssql_column_names(project: &Project) -> Option>{ } }); return Some(db_handle); +} + +pub fn partse_gathercontacts(project: &Project){ + fn format_names(names: Vec<&str>) -> HashMap<&str, Vec>{ + let mut formated_data = HashMap::new(); + let mut flast = Vec::new(); + let mut fdotlast = Vec::new(); + let mut fdashlast = Vec::new(); + let mut firstl = Vec::new(); + let mut firstdotlast = Vec::new(); + let mut firstlast = Vec::new(); + let mut last_vec = Vec::new(); + let mut first_vec = Vec::new(); + for name in names{ + let name_vec: Vec<&str> = name.split("|").collect(); + if name_vec.len() == 2{ + let first = name_vec[0]; + let last = name_vec[1]; + let first_chars: Vec = first.chars().collect(); + let last_chars: Vec = last.chars().collect(); + flast.push(format!("{}{}", &first_chars[0], &last)); + fdotlast.push(format!("{}.{}", &first_chars[0], &last)); + fdashlast.push(format!("{}-{}", &first, &last)); + firstl.push(format!("{}{}", &first, &last_chars[0])); + firstdotlast.push(format!("{}.{}", &first, &last)); + firstlast.push(format!("{}{}", &first, &last)); + last_vec.push(format!("{}", &last)); + first_vec.push(format!("{}", &first)); + } + } + formated_data.insert("flast", flast); + formated_data.insert("fdotlast", fdotlast); + formated_data.insert("fdashlast", fdashlast); + formated_data.insert("firstl", firstl); + formated_data.insert("firstdotlast", firstdotlast); + formated_data.insert("firstlast", firstlast); + formated_data.insert("last", last_vec); + formated_data.insert("fisrt", first_vec); + return formated_data; + } + + let gather_file = get_user_input("path to your gather contacts output?"); + print!(" +supported formats: +flast +f.last +f-last +firstl +first.last +firstlast +last +\n"); + let format = get_user_input("format of usernames?"); + let domain = get_user_input("domain name?"); + let gather_source = fs::read_to_string(gather_file); + if gather_source.is_err(){ + let error = gather_source.err().unwrap(); + println!("error reading gather contacts output!"); + println!("{}", error); + return; + } + let gather_source_string = gather_source.unwrap(); + let gather_source_lines: Vec<&str> = gather_source_string.split("\n").collect(); + let mut names = String::new(); + for line in gather_source_lines{ + if line.len() > 2{ + let line_vec: Vec<&str> = line.split("\t").collect(); + let first = line_vec[1].trim(); + let last = line_vec[2].trim(); + if first.len() > 1 && last.len() >1 { + let name = format!("{}|{}",first, last); + names = format!("{} {}", names, name.trim()); + } + } + } + let users: Vec<&str> = names.split(" ").collect(); + let data = format_names(users); + let mut email_text_path = project.files_folder.clone(); + let mut email_note_path = project.notes_folder.clone(); + email_text_path.push("working/extrapolated_emails.txt"); + email_note_path.push("email_enum.md"); + let email_text_res = OpenOptions::new().append(true).create(true).open(email_text_path); + if email_text_res.is_err(){ + let error = email_text_res.err().unwrap(); + println!("error opening email text file!"); + println!("{}", error); + return; + } + let email_notes_res = OpenOptions::new().append(true).create(true).open(email_note_path); + if email_notes_res.is_err(){ + let error = email_notes_res.err().unwrap(); + println!("error opeing email notes file!"); + println!("{}", error); + return; + } + let mut email_text_file = email_text_res.unwrap(); + let mut email_note_file = email_notes_res.unwrap(); + let note_wriet_res = write!(email_note_file, "# Extrapolated Emails: \n"); + if note_wriet_res.is_err(){ + let error = note_wriet_res.err().unwrap(); + println!("error writing to email notes file!"); + println!("{}", error); + } + println!("data gathered, printing emails and saving files...\n\n"); + for email in &data[&format.to_lowercase().trim()]{ + let outline = format!("{}@{}", email, domain); + println!("{}", &outline); + write!(email_note_file, "{}\n", outline).expect("error writing email notes file!"); + write!(email_text_file, "{}\n", outline).expect("error writing email text file!"); + } } \ No newline at end of file diff --git a/pentest_tool/src/menu.rs b/pentest_tool/src/menu.rs index 3f437c9..de8c9a0 100644 --- a/pentest_tool/src/menu.rs +++ b/pentest_tool/src/menu.rs @@ -98,7 +98,7 @@ pub fn main_menu(mut projects: Vec, config_path: PathBuf, base_files: & -NOTE OPTION 26 WILL SAVE YOUR PROJECTS BEFORE QUITTING +NOTE OPTION 27 WILL SAVE YOUR PROJECTS BEFORE QUITTING base prject folder: {} upcoming project folder: {} @@ -135,8 +135,9 @@ Year: {} 22.) Password Spray (will print password to spray, and wait the obervation window time) 23.) crack password hashes on your cracking rig 24.) Launch bloodhound with the current project's distrobox - 25.) prune unused distroboxes (free up system storage) - 26.) Quit Application + 25.) Parse GatherContacts output file + 26.) prune unused distroboxes (free up system storage) + 27.) Quit Application \n",&base_files.display(), &upcoming_files.display(), active_project.customer, active_project.project_name, active_project.files_folder.display(), active_project.notes_folder.display(), active_project.boxname, terminal, season, year); std::io::stdin().read_line(&mut response).expect("error getting menu input"); clear().expect("error clearing screen"); @@ -168,8 +169,9 @@ Year: {} "22" => info_controls::password_spray_help(&active_project, season, lseason, year, &tools_dir, &config_path), "23" => info_controls::crack_hashes(&cracking_rig, &active_project, &terminal, &rockyou, &rule), "24" => {let bloodhound_handle = box_controls::launch_bloodhound_gui(active_project.clone()).unwrap(); threads.push(bloodhound_handle);}, - "25" => {let prune_thread = box_controls::clean_unused_boxes(&projects, &boxtemplate); if prune_thread.is_some(){threads.push(prune_thread.unwrap());}}, - "26" => {project_controls::save_projects(&projects, &config_path); + "25" => info_controls::partse_gathercontacts(&active_project), + "26" => {let prune_thread = box_controls::clean_unused_boxes(&projects, &boxtemplate); if prune_thread.is_some(){threads.push(prune_thread.unwrap());}}, + "27" => {project_controls::save_projects(&projects, &config_path); let mut stop = String::new(); println!("stop all boxes?\ny/n"); std::io::stdin().read_line(&mut stop).unwrap(); diff --git a/pentest_tool/src/project_controls.rs b/pentest_tool/src/project_controls.rs index 6422438..0cfbbe1 100644 --- a/pentest_tool/src/project_controls.rs +++ b/pentest_tool/src/project_controls.rs @@ -9,7 +9,6 @@ use std::thread; use std::time::Duration; use std::str::FromStr; use crate::get_user_input; -use fs_extra::file; use crate::Project; use crate::box_controls::make_box;