refactor for managing upcoming and current

projects!
This commit is contained in:
pyro57000
2025-03-05 14:55:56 -06:00
parent d50625167b
commit 7765640e0e
4 changed files with 108 additions and 34 deletions

View File

@@ -93,10 +93,12 @@ pub fn make_box(project: &Project, tools_dir: &PathBuf, boxtemplate: &String, ne
box_name_file.write_all(&box_name.as_bytes()).expect("error writing boxname to box file");
let pentest_volume = format!("{}:/pentest:rw", &project.files_folder.display());
let toold_volume = format!("{}:/tools:rw", tools_dir.display());
println!("distrobox create --root --init --clone {} --volume {} --volume {} --name {}", boxtemplate, toold_volume, pentest_volume, box_name);
println!("distrobox create --root --init --unshare-all --clone {} --volume {} --volume {} --name {}", boxtemplate, toold_volume, pentest_volume, box_name);
let distrobox_result = process::Command::new("distrobox")
.arg("create")
.arg("--root")
.arg("--init")
.arg("--unshare-all")
.arg("--clone")
.arg(boxtemplate)
.arg("--volume")

View File

@@ -10,6 +10,7 @@ pub struct Project{
pub files_folder: PathBuf,
pub active: bool,
pub boxname: String,
pub stage: String,
pub id: i32,
}
@@ -56,6 +57,8 @@ fn main() {
let mut cracking_rig = String::new();
let mut rockyou = String::new();
let mut rule = String::new();
let mut upcoming_files = String::new();
let mut upcoming_notes = String::new();
println!("\nconfig already generated\nloading config file...\n");
let settings_string = fs::read_to_string(&config_path).expect("error reading config file");
let settings: Vec<&str> = settings_string.split("\n").collect();
@@ -71,6 +74,8 @@ fn main() {
"cracking_rig" => cracking_rig = setting_vec[1].trim_end().to_owned(),
"rockyou_location" => rockyou = setting_vec[1].trim_end().to_owned(),
"rule_location" => rule = setting_vec[1].trim_end().to_owned(),
"upcoming_files" => upcoming_files = setting_vec[1].trim_end().to_owned(),
"upcoming_notes" => upcoming_notes = setting_vec[1].trim_end().to_owned(),
_ => println!("error unknown setting: {}", setting_vec[0])
}
}
@@ -88,5 +93,5 @@ fn main() {
println!("Enter to start main menu");
let mut enter = String::new();
std::io::stdin().read_line(&mut enter).unwrap();
menu::main_menu(projects, config_path, &project_base_folder, &project_base_notes, &tools_folder, box_template, terminal_command, cracking_rig, rockyou, rule);
menu::main_menu(projects, config_path, &project_base_folder, &project_base_notes, &tools_folder, box_template, terminal_command, cracking_rig, rockyou, rule, upcoming_files, upcoming_notes);
}

View File

@@ -1,3 +1,4 @@
use std::clone;
use std::path::PathBuf;
use std::process::exit;
use chrono::Datelike;
@@ -31,7 +32,7 @@ fn get_active_project(projects: &Vec<Project>) -> &Project{
return active_project
}
pub fn main_menu(mut projects: Vec<Project>, config_path: PathBuf, base_files: &PathBuf, base_notes: &PathBuf, tools_dir: &PathBuf, boxtemplate: String, terminal: String, cracking_rig: String, rockyou: String, rule: String){
pub fn main_menu(mut projects: Vec<Project>, config_path: PathBuf, base_files: &PathBuf, base_notes: &PathBuf, tools_dir: &PathBuf, boxtemplate: String, terminal: String, cracking_rig: String, rockyou: String, rule: String, upcoming_files: String, upcoming_notes: String){
let mut loopize = true;
let mut new_id = next_project_id(&config_path);
loop {
@@ -115,20 +116,22 @@ Year: {}
5 .) Save Project Information
6 .) Import New Project - and setup new Distrobox
7 .) Remove Project
8 .) Open A New Terminal in Current Active Project
9 .) Open A Terminal In this windows for the current active project
10.) re-create the distrobox for the current active project
11.) Open Project Files Folder In Dolphin
12.) Open Project Notes Folder In Dolphin
13.) generate userpass file from your obsidian notes
14.) run pyro's initail enum script on a nessus csv for the current project
15.) Print Project Info For Report
16.) Build host discovery cmd command from scope in notes
17.) build portscan command from scope in notes
18.) Stop All Distroboxes
19.) Password Spray (will print password to spray, and wait the obervation window time)
20.) crack password hashes on your cracking rig
21.) Quit Application
8 .) Print upcoming projects
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.) Quit Application
\n", 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");
@@ -143,20 +146,22 @@ Year: {}
"5" => project_controls::save_projects(&projects, &config_path),
"6" => {new_id = new_id + 1; project_controls::new_project(&mut projects, &base_files, &base_notes, &tools_dir, &boxtemplate, &config_path, new_id)},
"7" => project_controls::remove_project(&mut projects, &config_path),
"8" => box_controls::project_standalone_terminal(active_project.clone(), terminal.clone()),
"9" => box_controls::project_inline_terminal(active_project.clone()),
"10" => box_controls::make_box(&active_project, &tools_dir, &boxtemplate, false),
"11" => info_controls::open_in_dolphin("files", active_project.clone()),
"12" => info_controls::open_in_dolphin("notes", active_project.clone()),
"13" => info_controls::generate_userpass(&active_project),
"14" => info_controls::run_initial_enum(&active_project),
"15" =>info_controls::print_report_information(active_project.clone()),
"16" => info_controls::build_cmd_for_host_discovery(&active_project),
"17" => info_controls::build_cs_portscan_cmd(&active_project),
"18" => box_controls::stop_all_boxes(&projects),
"19" => info_controls::password_spray_help(&active_project, season, lseason, year, &tools_dir, &config_path),
"20" => info_controls::crack_hashes(&cracking_rig, &active_project, &terminal, &rockyou, &rule),
"21" => {project_controls::save_projects(&projects, &config_path);
"8" => project_controls::print_upcoming_projects(&projects),
"9" => project_controls::promote_project(&mut projects, &config_path),
"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" => {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();

View File

@@ -7,6 +7,7 @@ use std::process;
use std::thread;
use std::time::Duration;
use std::str::FromStr;
use crate::project_controls;
use crate::Project;
use crate::box_controls::make_box;
@@ -53,13 +54,13 @@ pub fn save_projects(projects: &Vec<Project>, config_path: &PathBuf){
let mut _outline = String::new();
if project.active{
if active_set == false{
_outline = format!("{}yes:{}\n", default, project.boxname);
_outline = format!("{}yes:{}:{}\n", default, project.boxname, project.stage);
active_set = true;
}
}
else{
_outline = format!("{}no:{}\n", default, project.boxname);
_outline = format!("{}no:{}:{}\n", default, project.boxname, project.stage);
}
save_file.write_all(_outline.as_bytes()).expect("error writing outline");
}
@@ -71,6 +72,7 @@ pub fn new_project(projects: &mut Vec<Project>, project_dir: &PathBuf, notes_dir
let mut existing_folders = String::new();
let mut customer_name = String::new();
let mut project_name = String::new();
let mut project_stage = String::new();
println!("do you have an existing notes and folder structure to copy over?\ny/n");
std::io::stdin().read_line(&mut existing_folders).unwrap();
if existing_folders.contains("y") || existing_folders.contains("Y"){
@@ -182,6 +184,25 @@ pub fn new_project(projects: &mut Vec<Project>, project_dir: &PathBuf, notes_dir
fs::create_dir_all(&new_project_dir).expect("error creating new files folder");
fs::create_dir_all(&new_note_dir).expect("error creating new notes folder");
}
loop{
let mut stage_response = String::new();
println!("what stage is this project in?");
print!("
1.) current
2.) upcoming
");
let stage_result = stdin().read_line(&mut stage_response);
if stage_result.is_err(){
println!("we need input here dummy, try again...");
}
else{
match &stage_response.trim_end(){
&"1" => {project_stage = "current".to_owned(); break;},
&"2" => {project_stage = "upcoming".to_owned(); break;},
_ => println!("unknown option, try again...")
}
}
}
thread::sleep(Duration::from_secs(2));
let box_name = format!("atarchbox_{}", customer_name);
let new_project = Project{customer: customer_name.trim_end().to_owned(),
@@ -191,6 +212,7 @@ pub fn new_project(projects: &mut Vec<Project>, project_dir: &PathBuf, notes_dir
active: false,
id: new_id,
boxname: box_name,
stage: project_stage.to_owned()
};
make_box(&new_project, &tools_dir, &boxtemplate, true);
projects.push(new_project);
@@ -281,7 +303,8 @@ pub fn get_projects(config_path: &PathBuf) -> Vec<Project>{
active = true;
}
}
let new_project = Project{customer: customer, project_name: project, files_folder: project_folder, notes_folder: notes_folder, active: active, id: first, boxname: boxname};
let project_stage = settings[6].to_owned();
let new_project = Project{customer: customer, project_name: project, files_folder: project_folder, notes_folder: notes_folder, active: active, id: first, boxname: boxname, stage: project_stage};
println!("{} {} LOADED!", &new_project.customer, &new_project.project_name);
projects.push(new_project);
}
@@ -289,3 +312,42 @@ pub fn get_projects(config_path: &PathBuf) -> Vec<Project>{
}
return projects
}
pub fn print_upcoming_projects(projects: &Vec<Project>){
for project in projects{
if project.stage.contains("upcoming"){
println!("{}:{}", project.customer, project.project_name);
}
}
}
pub fn promote_project(projects: &mut Vec<Project>, config_path: &PathBuf){
let working_projects = projects.clone();
for project in &working_projects{
if project.stage.contains("upcoming"){
println!("{}.) {}:{}", project.id, project.customer, project.project_name);
}
}
println!("which project to promote?");
let mut selection = String::new();
let result = stdin().read_line(&mut selection);
if result.is_err(){
println!("we need input here dummy try again....");
}
result.unwrap();
let promote_id: i32 = selection.trim_end().parse().unwrap();
let mut projects_to_save = Vec::new();
for project in &working_projects{
if project.id == promote_id{
let mut promoted_project = project.clone();
promoted_project.stage = "current".to_owned();
projects_to_save.push(promoted_project);
}
else{
projects_to_save.push(project.clone());
}
}
projects.clear();
projects.append(&mut projects_to_save);
save_projects(&projects_to_save, config_path);
}