diff --git a/pentest_tool/src/info_controls.rs b/pentest_tool/src/info_controls.rs index 015faf1..a101fa5 100644 --- a/pentest_tool/src/info_controls.rs +++ b/pentest_tool/src/info_controls.rs @@ -97,6 +97,7 @@ pub fn run_initial_enum(project: &Project){ for port in target.ports{ output.push_str(format!("| {} | | [[attacks]]\n", port).as_str()); } + output.push_str("\n---\n"); output.push_str("\n"); write!(&host_notes, "{}", output).expect("error writing host_notes"); println!("{} notes written!", target.address); @@ -105,71 +106,80 @@ pub fn run_initial_enum(project: &Project){ } pub fn build_external_attack_notes(project: &Project){ - #[derive(Clone)] struct Port{ - number: String, - hosts: Vec, + service: String, + hosts: Vec } let mut ports: Vec = Vec::new(); let mut host_notes_path = project.notes_folder.clone(); - let mut attack_notes_path = host_notes_path.clone(); host_notes_path.push("host_notes.md"); + let mut attack_notes_path = project.notes_folder.clone(); attack_notes_path.push("attacks.md"); let host_notes_read_res = fs::read_to_string(host_notes_path); if host_notes_read_res.is_err(){ let error = host_notes_read_res.err().unwrap(); - println!("error reading host notes!"); + println!("error reading host notes"); println!("{}", error); return; } - let host_notes = host_notes_read_res.unwrap(); - let attack_open_res = fs::OpenOptions::new().append(true).create(true).open(attack_notes_path); - if attack_open_res.is_err(){ - let error = attack_open_res.err().unwrap(); - println!("error opening attack notes!"); - println!("{}", error); - return; - } - let attack_notes = attack_open_res.unwrap(); - for line in host_notes.split("\n").collect::>(){ - let mut current_host = String::new(); - if line.len() > 1{ - if line.contains("#"){ - if !line.contains("##"){ - current_host = line.split_whitespace().collect::>()[1].trim().to_owned(); + let host_notes_string = host_notes_read_res.unwrap(); + let host_parts: Vec<&str> = host_notes_string.split("---").collect(); + let mut host = String::new(); + for part in host_parts{ + let lines: Vec<&str> = part.split("\n").collect(); + for line in lines{ + if line.contains("# "){ + if !line.contains("## "){ + host = line.split("# ").collect::>()[1].to_owned(); } } if line.contains("|"){ - let table_data:Vec <&str> = line.split("|").collect(); - for item in table_data{ - let mut is_new = true; - if item.contains(":"){ - for port in &mut ports{ - if port.number == item.trim(){ - if port.hosts.contains(¤t_host){ - port.hosts.push(current_host.clone()); + if line.contains(":"){ + let entries: Vec<&str> = line.split("|").collect(); + let service = entries[2].trim().to_owned(); + for entry in entries{ + if entry.contains(":"){ + let port_number = entry.trim().to_owned(); + let mut new = true; + for port in &mut ports{ + if port.service == service{ + new = false; + let host_entry = format!("{} {}", host.clone(), port_number.clone()); + port.hosts.push(host_entry); } - is_new = false; } - } - if is_new{ - let new_port = Port{number: line.trim().to_owned(), hosts:vec![current_host.clone()]}; + match new{ + true => {let new_port = Port{service: service.clone(), hosts: vec![format!("{} {}", host.clone(), port_number.clone())]}; ports.push(new_port);}, + false => () + } } } } } } + println!("{} parsed!", host); } - for port in ports{ - let output = format!("# {}\nHOSTS:\n", port.number); + println!("parsed host_notes.md, writing to attacks.md..."); + let attack_open_res = open_append(&attack_notes_path); + if attack_open_res.is_none(){ + println!("ooof error opening attack notes, returning..."); + return; + } + let mut attack_file = attack_open_res.unwrap(); + write!(attack_file, "\n---\n").expect("since we used the open options already this should never fail."); + for port in ports.clone(){ + write!(attack_file, "# {}\n", port.service).expect("since we used the open options already this should never fail."); + write!(attack_file, "HOSTS:\n").expect("since we used the open options already this should never fail."); for host in port.hosts{ - // output.push_str("## {}"); + write!(attack_file, "## {}\n\n", host).expect("since we used the open options already this should never fail."); + write!(attack_file, "\n---\n").expect("since we used the open options already this should never fail."); } } } + pub fn build_cmd_for_host_discovery(project: &Project){ let mut cobalt_strike_response = String::new(); let mut need_shell = false; diff --git a/pentest_tool/src/menu.rs b/pentest_tool/src/menu.rs index 3ecbea2..8fa920f 100644 --- a/pentest_tool/src/menu.rs +++ b/pentest_tool/src/menu.rs @@ -113,7 +113,7 @@ pub fn main_menu(mut projects: Vec, config_path: PathBuf, base_files: & -NOTE OPTION 28 WILL SAVE YOUR PROJECTS BEFORE QUITTING +NOTE OPTION 29 WILL SAVE YOUR PROJECTS BEFORE QUITTING base prject folder: {} upcoming project folder: {} @@ -144,17 +144,18 @@ General Notes: {} 15.) Open Project Notes Folder In Dolphin 16.) generate userpass file from your obsidian notes 17.) run pyro's initail enum script on a nessus csv for the current project - 18.) Print Project Info For Report - 19.) Build host discovery cmd command from scope in notes - 20.) build portscan command from scope in notes - 21.) parse a cs portscan services.tsv file - 22.) Stop All Distroboxes - 23.) Password Spray (will print password to spray, and wait the obervation window time) - 24.) crack password hashes on your cracking rig - 25.) Launch bloodhound with the current project's distrobox - 26.) Parse GatherContacts output file - 27.) prune unused distroboxes (free up system storage) - 28.) Quit Application + 18.) build external attack notes from host_notes + 19.) Print Project Info For Report + 20.) Build host discovery cmd command from scope in notes + 21.) build portscan command from scope in notes + 22.) parse a cs portscan services.tsv file + 23.) Stop All Distroboxes + 24.) Password Spray (will print password to spray, and wait the obervation window time) + 25.) crack password hashes on your cracking rig + 26.) Launch bloodhound with the current project's distrobox + 27.) Parse GatherContacts output file + 28.) prune unused distroboxes (free up system storage) + 29.) 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, &obsidian_uri); std::io::stdin().read_line(&mut response).expect("error getting menu input"); clear().expect("error clearing screen"); @@ -179,17 +180,18 @@ General Notes: {} "15" => info_controls::open_in_dolphin("notes", active_project.clone()), "16" => info_controls::generate_userpass(&active_project), "17" => info_controls::run_initial_enum(&active_project), - "18" => info_controls::print_report_information(active_project.clone()), - "19" => info_controls::build_cmd_for_host_discovery(&active_project), - "20" => info_controls::build_cs_portscan_cmd(&active_project), - "21" => info_controls::parse_csportscan(&active_project), - "22" => box_controls::stop_all_boxes(&projects), - "23" => info_controls::password_spray_help(&active_project, season, lseason, year, &tools_dir, &config_path), - "24" => info_controls::crack_hashes(&cracking_rig, &active_project, &terminal, &rockyou, &rule), - "25" => {let bloodhound_handle = box_controls::launch_bloodhound_gui(active_project.clone()).unwrap(); threads.push(bloodhound_handle);}, - "26" => info_controls::partse_gathercontacts(&active_project), - "27" => {let prune_thread = box_controls::clean_unused_boxes(&projects, &boxtemplate); if prune_thread.is_some(){threads.push(prune_thread.unwrap());}}, - "28" => {project_controls::save_projects(&projects, &config_path); + "18" => info_controls::build_external_attack_notes(&active_project), + "19" => info_controls::print_report_information(active_project.clone()), + "20" => info_controls::build_cmd_for_host_discovery(&active_project), + "21" => info_controls::build_cs_portscan_cmd(&active_project), + "22" => info_controls::parse_csportscan(&active_project), + "23" => box_controls::stop_all_boxes(&projects), + "24" => info_controls::password_spray_help(&active_project, season, lseason, year, &tools_dir, &config_path), + "25" => info_controls::crack_hashes(&cracking_rig, &active_project, &terminal, &rockyou, &rule), + "26" => {let bloodhound_handle = box_controls::launch_bloodhound_gui(active_project.clone()).unwrap(); threads.push(bloodhound_handle);}, + "27" => info_controls::partse_gathercontacts(&active_project), + "28" => {let prune_thread = box_controls::clean_unused_boxes(&projects, &boxtemplate); if prune_thread.is_some(){threads.push(prune_thread.unwrap());}}, + "29" => {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();