139 lines
6.4 KiB
Rust
139 lines
6.4 KiB
Rust
use std::{io::stdin, path::PathBuf, process::Command};
|
|
use directories::UserDirs;
|
|
use reqwest::Response;
|
|
use std::process::exit;
|
|
use std::fs;
|
|
|
|
#[derive(Clone)]
|
|
pub struct Project{
|
|
pub customer: String,
|
|
pub project_name: String,
|
|
pub notes_folder: PathBuf,
|
|
pub files_folder: PathBuf,
|
|
pub active: bool,
|
|
pub boxname: String,
|
|
pub stage: String,
|
|
pub id: i32,
|
|
}
|
|
|
|
mod install;
|
|
mod menu;
|
|
mod project_controls;
|
|
mod box_controls;
|
|
mod info_controls;
|
|
mod start_pentest;
|
|
|
|
pub fn get_user_input(prompt: &str) -> String{
|
|
let mut response = String::new();
|
|
loop{
|
|
println!("{}", prompt);
|
|
let result = stdin().read_line(&mut response);
|
|
if result.is_err(){
|
|
println!("we need input here dummy! try again...");
|
|
}
|
|
else{
|
|
result.unwrap();
|
|
break;
|
|
}
|
|
}
|
|
return response.trim_end().to_owned();
|
|
}
|
|
|
|
|
|
fn main() {
|
|
print!("
|
|
⠀⠀⠀⣠⠶⠚⠛⠛⠛⠲⢦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
|
⠀⠀⠀⣴⠟⠁⠀⠀⠀⠀⠀⠀⠀⠻⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
|
⠀⣠⣾⣷⣄⠀⠀⠀⢀⣠⣤⣤⡀⠀⢿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
|
⢸⣿⡿⢃⣸⡶⠂⢠⣿⣿⡿⠁⣱⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
|
⢸⡏⠉⠩⣏⣐⣦⠀⠛⠦⠴⠚⠁⠀⣸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
|
⣼⠧⠶⠶⠶⠿⠶⠶⠖⠚⠛⠉⠁⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⠶⠶⡄⠀⠀
|
|
⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⢠⡟⠀⠀⢹⠀⠀
|
|
⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⢤⢠⡆⠀⢸⡄⠀⠀⠀⠀⠀⠀⢀⡿⠁⠀⠀⡾⠀⠀
|
|
⢹⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠈⡇⠀⠸⣧⣠⠴⠶⠖⠲⢶⡞⠁⠀⢈⡼⢃⠀⠀
|
|
⠸⡆⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⡇⠀⠀⢿⠁⠄⣲⡶⠶⠿⢤⣄⡀⠛⢛⠉⢻⠀
|
|
⠀⢿⡀⠀⠀⠀⠀⠀⠀⠀⢸⠠⣇⠀⠀⠀⠀⠊⠁⠀⠀⠀⠀⠀⠙⢦⠈⠙⠓⣆
|
|
⠀⠈⢷⡀⠀⠀⠀⠀⠀⢠⠏⡀⣬⣹⣦⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠈⡿⠶⠶⠋
|
|
⠀⠀⠈⢷⡀⠀⠀⠀⠀⠘⠛⠛⠋⠀⠀⠀⠀⠀⠀⠄⠀⠀⠀⠀⠀⣼⠃⠀⠀⠀
|
|
⠀⠀⠀⠀⠙⢦⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⠀⠀⣠⡞⠁⠀⠀⠀⠀
|
|
⠀⠀⠀⠀⠀⠀⠈⠛⣷⢶⣦⣤⣄⣀⣠⣤⣤⠀⣶⠶⠶⠶⠛⠁⠀⠀⠀⠀⠀⠀
|
|
⠀⠀⠀⠀⣀⡀⠀⣰⠇⣾⠀⠀⠈⣩⣥⣄⣿⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
|
⠀⠀⠀⠀⢿⡉⠳⡟⣸⠃⠀⠀⠀⠘⢷⣌⠉⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
|
⠀⠀⠀⠀⠀⠙⢦⣴⠏⠀⠀⠀⠀⠀⠀⠉⠳⠶⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
|
");
|
|
let mut config_path = PathBuf::new();
|
|
let user_dirs_res = UserDirs::new();
|
|
if user_dirs_res.is_none(){
|
|
println!("oof couldn't get the config directory the right way, falling back to the stpuid way...");
|
|
let get_home_res = Command::new("echo").arg("$HOME").output();
|
|
if get_home_res.is_err(){
|
|
println!("ooof the stupid way didn't work... this is a bruh moment, gotta fix your environment variabls!!!");
|
|
exit(1);
|
|
}
|
|
let get_home_output = get_home_res.unwrap().stdout;
|
|
let home_string = String::from_utf8_lossy(&get_home_output);
|
|
config_path.push(home_string.trim());
|
|
}
|
|
else{
|
|
let user_dirs = user_dirs_res.unwrap();
|
|
config_path.push(user_dirs.home_dir());
|
|
}
|
|
config_path.push(".config/pyro_pentest_tool/conf");
|
|
if config_path.as_path().exists() == false{
|
|
install::install(&config_path);
|
|
}
|
|
let mut project_base_folder = PathBuf::new();
|
|
let mut project_base_notes = PathBuf::new();
|
|
let mut tools_folder = PathBuf::new();
|
|
let mut terminal_command = String::new();
|
|
let mut box_template = String::new();
|
|
let mut cracking_rig = String::new();
|
|
let mut rockyou = String::new();
|
|
let mut rule = String::new();
|
|
let mut upcoming_files = PathBuf::new();
|
|
let mut upcoming_notes = PathBuf::new();
|
|
let mut pass_spray_file = PathBuf::new();
|
|
let mut fingerprint = false;
|
|
let mut vault_name = 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();
|
|
for line in settings{
|
|
if line.len() > 1{
|
|
let setting_vec: Vec<&str> = line.split(":").collect();
|
|
match setting_vec[0]{
|
|
"Project_files" => project_base_folder.push(setting_vec[1].trim_end()),
|
|
"Project_notes" => project_base_notes.push(setting_vec[1].trim_end()),
|
|
"tools_folder" => tools_folder.push(setting_vec[1].trim_end()),
|
|
"upcoming_files" => upcoming_files.push(setting_vec[1].trim_end()),
|
|
"upcoming_notes" => upcoming_notes.push(setting_vec[1].trim_end()),
|
|
"box_template" => box_template = setting_vec[1].trim_end().to_owned(),
|
|
"terminal" => terminal_command = setting_vec[1].trim_end().to_owned(),
|
|
"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(),
|
|
"pass_file"=> pass_spray_file.push(setting_vec[1]),
|
|
"fingerprint" => {if setting_vec[1].contains("y"){fingerprint = true}},
|
|
"vault_name" => vault_name = setting_vec[1].trim_end().to_owned(),
|
|
_ => println!("error unknown setting: {}", setting_vec[0])
|
|
}
|
|
}
|
|
}
|
|
print!("
|
|
Project Folders: {}
|
|
Note Folders: {}
|
|
Tools Folder: {}
|
|
distrobox template: {}
|
|
terminal_command: {}
|
|
cracking_rig: {}\n
|
|
upcoming project folders: {}
|
|
upcoming project notes: {}
|
|
", &project_base_folder.display(), &project_base_notes.display(), &tools_folder.display(), box_template, terminal_command, cracking_rig, &upcoming_files.display(), &upcoming_notes.display());
|
|
println!("loading project configs...");
|
|
let projects = project_controls::get_projects(&config_path);
|
|
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, &upcoming_files, &upcoming_notes, &pass_spray_file, fingerprint, vault_name);
|
|
}
|