split making a distrobox into its own function
this will allow us to write more functions like the newly added one to re-create the current project's distrobox
This commit is contained in:
@@ -1,4 +1,11 @@
|
|||||||
use std::process;
|
use std::{path::PathBuf, process};
|
||||||
|
use std::env;
|
||||||
|
use std::fs;
|
||||||
|
use std::io::stdin;
|
||||||
|
use std::io::Write;
|
||||||
|
use std::thread;
|
||||||
|
use std::time::Duration;
|
||||||
|
use std::str::FromStr;
|
||||||
use crate::Project;
|
use crate::Project;
|
||||||
|
|
||||||
pub fn stop_all_boxes(projects: &Vec<Project>){
|
pub fn stop_all_boxes(projects: &Vec<Project>){
|
||||||
@@ -62,4 +69,68 @@ pub fn project_standalone_terminal(project: Project, mut terminal: String){
|
|||||||
|
|
||||||
pub fn project_inline_terminal(project: Project){
|
pub fn project_inline_terminal(project: Project){
|
||||||
process::Command::new("distrobox").arg("enter").arg("--root").arg(project.boxname).arg("--").arg("script").arg("-a").arg("-B").arg("/pentest/working/terminal.log").status().expect("error opeing konsole");
|
process::Command::new("distrobox").arg("enter").arg("--root").arg(project.boxname).arg("--").arg("script").arg("-a").arg("-B").arg("/pentest/working/terminal.log").status().expect("error opeing konsole");
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn make_box(project: &Project, tools_dir: &PathBuf, boxtemplate: &String){
|
||||||
|
let _distrobox_stop_status = process::Command::new("distrobox").arg("stop").arg("--root").arg(&project.boxname).status().expect("error stopping distrobox");
|
||||||
|
let distrobox_rm_status = process::Command::new("distrobox-rm")
|
||||||
|
.arg("--root")
|
||||||
|
.arg("-f")
|
||||||
|
.arg(&project.boxname)
|
||||||
|
.status().expect("error calling distrobox");
|
||||||
|
if distrobox_rm_status.success(){
|
||||||
|
println!("Distrobox Removal Successful!!!");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
println!("Distrobox Removal Failed, manual removal required!");
|
||||||
|
}
|
||||||
|
let mut box_name_path = project.files_folder.clone();
|
||||||
|
let mut box_name = format!("atarchbox_{}", &project.customer);
|
||||||
|
box_name_path.push("boxname");
|
||||||
|
let mut box_name_file = fs::File::create(box_name_path).expect("Error creating box name file");
|
||||||
|
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 --clone {} --volume {} --volume {} --name {}", boxtemplate, toold_volume, pentest_volume, box_name);
|
||||||
|
let distrobox_result = process::Command::new("distrobox")
|
||||||
|
.arg("create")
|
||||||
|
.arg("--root")
|
||||||
|
.arg("--clone")
|
||||||
|
.arg(boxtemplate)
|
||||||
|
.arg("--volume")
|
||||||
|
.arg(&toold_volume)
|
||||||
|
.arg("--volume")
|
||||||
|
.arg(&pentest_volume)
|
||||||
|
.arg("--name")
|
||||||
|
.arg(&box_name)
|
||||||
|
.status()
|
||||||
|
.expect("error getting distrobox status");
|
||||||
|
if distrobox_result.success(){
|
||||||
|
println!("we made a distrobox oh boy!");
|
||||||
|
let distrobox_start_result = process::Command::new("distrobox")
|
||||||
|
.arg("enter")
|
||||||
|
.arg("--root")
|
||||||
|
.arg(&box_name)
|
||||||
|
.arg("--")
|
||||||
|
.arg("sudo")
|
||||||
|
.arg("-s")
|
||||||
|
.arg("ln")
|
||||||
|
.arg("-sf")
|
||||||
|
.arg("/pentest/boxname")
|
||||||
|
.arg("/etc/boxname")
|
||||||
|
.status()
|
||||||
|
.expect("error getting response from distrobox start");
|
||||||
|
if distrobox_start_result.success(){
|
||||||
|
println!("distrobox was started as well!!!! good job me!");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
println!("ooof did not start successfully try entering it yoruself");
|
||||||
|
println!("distrobox enter --rrot {} -- sudo -s ln -sf /pentest/boxname /etc/boxname", &box_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
println!("ooof distrobox did not work.... try creating it yourself");
|
||||||
|
println!("distrobox create --root --clone {} --volume {} --volume {} --name {}", boxtemplate, &toold_volume, &pentest_volume, &box_name);
|
||||||
|
println!("distrobox enter --rrot {} -- sudo -s ln -sf /pentest/boxname /etc/boxname", &box_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -117,17 +117,18 @@ Year: {}
|
|||||||
7 .) Remove Project
|
7 .) Remove Project
|
||||||
8 .) Open A New Terminal in Current Active Project
|
8 .) Open A New Terminal in Current Active Project
|
||||||
9 .) Open A Terminal In this windows for the current active project
|
9 .) Open A Terminal In this windows for the current active project
|
||||||
10.) Open Project Files Folder In Dolphin
|
10.) re-create the distrobox for the current active project
|
||||||
11.) Open Project Notes Folder In Dolphin
|
11.) Open Project Files Folder In Dolphin
|
||||||
12.) generate userpass file from your obsidian notes
|
12.) Open Project Notes Folder In Dolphin
|
||||||
13.) run pyro's initail enum script on a nessus csv for the current project
|
13.) generate userpass file from your obsidian notes
|
||||||
14.) Print Project Info For Report
|
14.) run pyro's initail enum script on a nessus csv for the current project
|
||||||
15.) Build host discovery cmd command from scope in notes
|
15.) Print Project Info For Report
|
||||||
16.) build portscan command from scope in notes
|
16.) Build host discovery cmd command from scope in notes
|
||||||
17.) Stop All Distroboxes
|
17.) build portscan command from scope in notes
|
||||||
18.) Password Spray (will print password to spray, and wait the obervation window time)
|
18.) Stop All Distroboxes
|
||||||
19.) crack password hashes on your cracking rig
|
19.) Password Spray (will print password to spray, and wait the obervation window time)
|
||||||
20.) Quit Application
|
20.) crack password hashes on your cracking rig
|
||||||
|
21.) 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);
|
\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");
|
std::io::stdin().read_line(&mut response).expect("error getting menu input");
|
||||||
clear().expect("error clearing screen");
|
clear().expect("error clearing screen");
|
||||||
@@ -144,17 +145,18 @@ Year: {}
|
|||||||
"7" => project_controls::remove_project(&mut projects, &config_path),
|
"7" => project_controls::remove_project(&mut projects, &config_path),
|
||||||
"8" => box_controls::project_standalone_terminal(active_project.clone(), terminal.clone()),
|
"8" => box_controls::project_standalone_terminal(active_project.clone(), terminal.clone()),
|
||||||
"9" => box_controls::project_inline_terminal(active_project.clone()),
|
"9" => box_controls::project_inline_terminal(active_project.clone()),
|
||||||
"10" => info_controls::open_in_dolphin("files", active_project.clone()),
|
"10" => box_controls::make_box(&active_project, &tools_dir, &boxtemplate),
|
||||||
"11" => info_controls::open_in_dolphin("notes", active_project.clone()),
|
"11" => info_controls::open_in_dolphin("files", active_project.clone()),
|
||||||
"12" => info_controls::generate_userpass(&active_project),
|
"12" => info_controls::open_in_dolphin("notes", active_project.clone()),
|
||||||
"13" => info_controls::run_initial_enum(&active_project),
|
"13" => info_controls::generate_userpass(&active_project),
|
||||||
"14" =>info_controls::print_report_information(active_project.clone()),
|
"14" => info_controls::run_initial_enum(&active_project),
|
||||||
"15" => info_controls::build_cmd_for_host_discovery(&active_project),
|
"15" =>info_controls::print_report_information(active_project.clone()),
|
||||||
"16" => info_controls::build_cs_portscan_cmd(&active_project),
|
"16" => info_controls::build_cmd_for_host_discovery(&active_project),
|
||||||
"17" => box_controls::stop_all_boxes(&projects),
|
"17" => info_controls::build_cs_portscan_cmd(&active_project),
|
||||||
"18" => info_controls::password_spray_help(&active_project, season, lseason, year, &tools_dir, &config_path),
|
"18" => box_controls::stop_all_boxes(&projects),
|
||||||
"19" => info_controls::crack_hashes(&cracking_rig, &active_project, &terminal, &rockyou, &rule),
|
"19" => info_controls::password_spray_help(&active_project, season, lseason, year, &tools_dir, &config_path),
|
||||||
"20" => {project_controls::save_projects(&projects, &config_path);
|
"20" => info_controls::crack_hashes(&cracking_rig, &active_project, &terminal, &rockyou, &rule),
|
||||||
|
"21" => {project_controls::save_projects(&projects, &config_path);
|
||||||
let mut stop = String::new();
|
let mut stop = String::new();
|
||||||
println!("stop all boxes?\ny/n");
|
println!("stop all boxes?\ny/n");
|
||||||
std::io::stdin().read_line(&mut stop).unwrap();
|
std::io::stdin().read_line(&mut stop).unwrap();
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use std::thread;
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use crate::Project;
|
use crate::Project;
|
||||||
|
use crate::box_controls::make_box;
|
||||||
|
|
||||||
pub fn switch_project(projects: &mut Vec<Project>){
|
pub fn switch_project(projects: &mut Vec<Project>){
|
||||||
for project in projects.clone(){
|
for project in projects.clone(){
|
||||||
@@ -183,54 +184,6 @@ pub fn new_project(projects: &mut Vec<Project>, project_dir: &PathBuf, notes_dir
|
|||||||
}
|
}
|
||||||
thread::sleep(Duration::from_secs(2));
|
thread::sleep(Duration::from_secs(2));
|
||||||
let box_name = format!("atarchbox_{}", customer_name);
|
let box_name = format!("atarchbox_{}", customer_name);
|
||||||
let mut box_name_path = new_project_dir.clone();
|
|
||||||
box_name_path.push("boxname");
|
|
||||||
let mut box_name_file = fs::File::create(box_name_path).expect("Error creating box name file");
|
|
||||||
box_name_file.write_all(&box_name.as_bytes()).expect("error writing boxname to box file");
|
|
||||||
let pentest_volume = format!("{}:/pentest:rw", new_project_dir.display());
|
|
||||||
let toold_volume = format!("{}:/tools:rw", tools_dir.display());
|
|
||||||
println!("distrobox create --root --clone {} --volume {} --volume {} --name {}", boxtemplate, toold_volume, pentest_volume, box_name);
|
|
||||||
let distrobox_result = process::Command::new("distrobox")
|
|
||||||
.arg("create")
|
|
||||||
.arg("--root")
|
|
||||||
.arg("--clone")
|
|
||||||
.arg(boxtemplate)
|
|
||||||
.arg("--volume")
|
|
||||||
.arg(&toold_volume)
|
|
||||||
.arg("--volume")
|
|
||||||
.arg(&pentest_volume)
|
|
||||||
.arg("--name")
|
|
||||||
.arg(&box_name)
|
|
||||||
.status()
|
|
||||||
.expect("error getting distrobox status");
|
|
||||||
if distrobox_result.success(){
|
|
||||||
println!("we made a distrobox oh boy!");
|
|
||||||
let distrobox_start_result = process::Command::new("distrobox")
|
|
||||||
.arg("enter")
|
|
||||||
.arg("--root")
|
|
||||||
.arg(&box_name)
|
|
||||||
.arg("--")
|
|
||||||
.arg("sudo")
|
|
||||||
.arg("-s")
|
|
||||||
.arg("ln")
|
|
||||||
.arg("-sf")
|
|
||||||
.arg("/pentest/boxname")
|
|
||||||
.arg("/etc/boxname")
|
|
||||||
.status()
|
|
||||||
.expect("error getting response from distrobox start");
|
|
||||||
if distrobox_start_result.success(){
|
|
||||||
println!("distrobox was started as well!!!! good job me!");
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
println!("ooof did not start successfully try entering it yoruself");
|
|
||||||
println!("distrobox enter --rrot {} -- sudo -s ln -sf /pentest/boxname /etc/boxname", &box_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
println!("ooof distrobox did not work.... try creating it yourself");
|
|
||||||
println!("distrobox create --root --clone {} --volume {} --volume {} --name {}", boxtemplate, &toold_volume, &pentest_volume, &box_name);
|
|
||||||
println!("distrobox enter --rrot {} -- sudo -s ln -sf /pentest/boxname /etc/boxname", &box_name);
|
|
||||||
}
|
|
||||||
let new_project = Project{customer: customer_name.trim_end().to_owned(),
|
let new_project = Project{customer: customer_name.trim_end().to_owned(),
|
||||||
project_name: project_name.trim_end().to_owned(),
|
project_name: project_name.trim_end().to_owned(),
|
||||||
notes_folder: new_note_dir,
|
notes_folder: new_note_dir,
|
||||||
@@ -239,6 +192,7 @@ pub fn new_project(projects: &mut Vec<Project>, project_dir: &PathBuf, notes_dir
|
|||||||
id: new_id,
|
id: new_id,
|
||||||
boxname: box_name,
|
boxname: box_name,
|
||||||
};
|
};
|
||||||
|
make_box(&new_project, &tools_dir, &boxtemplate);
|
||||||
projects.push(new_project);
|
projects.push(new_project);
|
||||||
save_projects(projects, config_path);
|
save_projects(projects, config_path);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user