diff --git a/pentest_tool/src/box_controls.rs b/pentest_tool/src/box_controls.rs index fdd9c04..fa9ee91 100644 --- a/pentest_tool/src/box_controls.rs +++ b/pentest_tool/src/box_controls.rs @@ -182,4 +182,28 @@ pub fn clean_unused_boxes(projects: &Vec, boxtemplate: &String) -> Opti thread::sleep(Duration::from_secs(3)); println!("this will take some time, but its running on a different thread so you can continue working!"); return Some(handle); +} + +pub fn launch_cobalt_strike(project: Project) -> Option>{ + let sh_cmd = format!("sh -c \"cd /pentest/cobaltstrike/client && ./cobaltstrike\""); + let handle = thread::spawn(move ||{ + let mut cs_dir = PathBuf::new(); + cs_dir.push(project.files_folder); + cs_dir.push("cobaltstrike/client"); + let cd_res = env::set_current_dir(&cs_dir); + if cd_res.is_ok(){ + let cobalt_strike_launch_result = Command::new("distrobox") + .arg("enter") + .arg("--root").arg(project.boxname) + .arg("--") + .arg("./cobaltstrike") + .status(); + if cobalt_strike_launch_result.is_err(){ + let error = cobalt_strike_launch_result.err().unwrap(); + println!("error launching cobalt strike!"); + println!("{}", error); + } + } + }); + return Some(handle); } \ No newline at end of file diff --git a/pentest_tool/src/menu.rs b/pentest_tool/src/menu.rs index 3e7ab42..8251de1 100644 --- a/pentest_tool/src/menu.rs +++ b/pentest_tool/src/menu.rs @@ -125,19 +125,20 @@ Year: {} 9. ) promote project from upcoming to current 10.) Open A New Terminal in Current Active Project 11.) Open A Terminal In this windows for the current active project - 12.) re-create the distrobox for the current active project - 13.) Open Project Files Folder In Dolphin - 14.) Open Project Notes Folder In Dolphin - 15.) generate userpass file from your obsidian notes - 16.) run pyro's initail enum script on a nessus csv for the current project - 17.) Print Project Info For Report - 18.) Build host discovery cmd command from scope in notes - 19.) build portscan command from scope in notes - 20.) Stop All Distroboxes - 21.) Password Spray (will print password to spray, and wait the obervation window time) - 22.) crack password hashes on your cracking rig - 23.) prune unused distroboxes (free up system storage) - 24.) Quit Application + 12.) open current project's cobalt strike + 13.) re-create the distrobox for the current active project + 14.) Open Project Files Folder In Dolphin + 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.) Stop All Distroboxes + 22.) Password Spray (will print password to spray, and wait the obervation window time) + 23.) crack password hashes on your cracking rig + 24.) prune unused distroboxes (free up system storage) + 25.) 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"); @@ -156,19 +157,20 @@ Year: {} "9" => project_controls::promote_project(&mut projects, &config_path, base_files, base_notes, tools_dir, &boxtemplate), "10" => box_controls::project_standalone_terminal(active_project.clone(), terminal.clone()), "11" => box_controls::project_inline_terminal(active_project.clone()), - "12" => box_controls::make_box(&active_project, &tools_dir, &boxtemplate, false), - "13" => info_controls::open_in_dolphin("files", active_project.clone()), - "14" => info_controls::open_in_dolphin("notes", active_project.clone()), - "15" => info_controls::generate_userpass(&active_project), - "16" => info_controls::run_initial_enum(&active_project), - "17" => info_controls::print_report_information(active_project.clone()), - "18" => info_controls::build_cmd_for_host_discovery(&active_project), - "19" => info_controls::build_cs_portscan_cmd(&active_project), - "20" => box_controls::stop_all_boxes(&projects), - "21" => info_controls::password_spray_help(&active_project, season, lseason, year, &tools_dir, &config_path), - "22" => info_controls::crack_hashes(&cracking_rig, &active_project, &terminal, &rockyou, &rule), - "23" => {let prune_thread = box_controls::clean_unused_boxes(&projects, &boxtemplate); if prune_thread.is_some(){threads.push(prune_thread.unwrap());}}, - "24" => {project_controls::save_projects(&projects, &config_path); + "12" => {let cs_thread = box_controls::launch_cobalt_strike(active_project.clone()); if cs_thread.is_some(){threads.push(cs_thread.unwrap());}}, + "13" => box_controls::make_box(&active_project, &tools_dir, &boxtemplate, false), + "14" => info_controls::open_in_dolphin("files", active_project.clone()), + "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" => box_controls::stop_all_boxes(&projects), + "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 prune_thread = box_controls::clean_unused_boxes(&projects, &boxtemplate); if prune_thread.is_some(){threads.push(prune_thread.unwrap());}}, + "25" => {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 9c8b5c9..32a99bf 100644 --- a/pentest_tool/src/project_controls.rs +++ b/pentest_tool/src/project_controls.rs @@ -4,12 +4,12 @@ use std::io::stdin; use std::io::Write; use std::path::PathBuf; use std::process; +use std::process::Command; 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; @@ -366,9 +366,9 @@ pub fn promote_project(projects: &mut Vec, config_path: &PathBuf, proje let mut new_files_dir = project_dir.clone(); let mut new_notes_dir = notes_dir.clone(); new_files_dir.push(&promoted_project.customer); - new_files_dir.push(&promoted_project.project_name); new_notes_dir.push(&promoted_project.customer); - new_notes_dir.push(&promoted_project.project_name); + fs::create_dir_all(&new_files_dir).unwrap(); + fs::create_dir_all(&new_notes_dir).unwrap(); let folder_move_success = process::Command::new("mv") .arg("-i") .arg(&project.files_folder) @@ -381,19 +381,58 @@ pub fn promote_project(projects: &mut Vec, config_path: &PathBuf, proje .status().expect("unable to call the system mv command"); if folder_move_success.success(){ println!("we copied the project folder correctly!!"); + let mut remove_folder = PathBuf::new(); + remove_folder.push(&project.files_folder); + remove_folder.pop(); + let remove_files_res = fs::remove_dir_all(remove_folder); + if remove_files_res.is_err(){ + println!("error removing the original files folder form the upcomming folder, manual cleanup required"); + } + else{ + remove_files_res.unwrap(); + println!("upcoming files folder cleanup successful!"); + } } else{ println!("failed to copy the project folder, try to move it manually!"); } if note_move_success.success(){ println!("we copied the notes folder correctly!!"); + let mut remove_folder = PathBuf::new(); + remove_folder.push(&project.files_folder); + remove_folder.pop(); + let remove_notes_res = fs::remove_dir_all(remove_folder); + if remove_notes_res.is_err(){ + println!("error removing the original notes folder form the upcomming folder, manual cleanup required"); + } + else{ + remove_notes_res.unwrap(); + println!("upcoming notes folder cleanup successful!"); + } } else{ println!("failed to copy the notes folder, try to move it manually!"); } + new_files_dir.push(&promoted_project.project_name); + new_notes_dir.push(&promoted_project.project_name); promoted_project.files_folder = new_files_dir; promoted_project.notes_folder = new_notes_dir; promoted_project.stage = "current".to_owned(); + let cs_response = get_user_input("will you need to be using cobalt strike for this project?"); + if cs_response.to_lowercase().contains("y"){ + let cs_path = get_user_input("path to your current cobalt strike directory?"); + let copy_result = Command::new("cp").arg("-R").arg(&cs_path).arg(&promoted_project.files_folder).status(); + if copy_result.is_err(){ + println!("oof we had an error copying... you'll have to copy this manually"); + } + else{ + let copy_exit = copy_result.unwrap(); + if copy_exit.success() == false{ + println!("oof we had an error copying... you'll have to copy this manually"); + println!("run cp -R {} {}", &cs_path, &promoted_project.files_folder.display()); + } + } + } thread::sleep(Duration::from_secs(3)); make_box(&promoted_project, tools_dir, boxtemplate, true); projects_to_save.push(promoted_project);