Completely re-wrote the install function.

Trying to get this working on default kali.
This commit is contained in:
pyro57000
2025-04-04 20:17:35 -05:00
parent 31dd862579
commit fc316c2a71
2 changed files with 243 additions and 323 deletions

View File

@@ -1,13 +1,13 @@
use std::collections::HashMap; use std::collections::HashMap;
use std::fs; use std::env::home_dir;
use std::fs::File; use std::fs::{File, create_dir_all, remove_dir_all};
use std::io::Read; use std::io::Read;
use std::io::Write; use std::io::Write;
use std::io::stdin; use std::io::stdin;
use std::io::copy; use std::io::copy;
use std::process::Command; use std::process::Command;
use reqwest::blocking::get; use reqwest::blocking::get;
use std::path::PathBuf; use std::{path::Path, path::PathBuf};
use std::process; use std::process;
use std::process::exit; use std::process::exit;
use directories::UserDirs; use directories::UserDirs;
@@ -15,217 +15,31 @@ use directories::UserDirs;
use crate::get_user_input; use crate::get_user_input;
fn setup_folders(config_path: &PathBuf) -> (String, String, String, String, String, String, String, String, String){
let mut delete_for_cleanup = config_path.clone();
delete_for_cleanup.pop();
let mut failed = false;
let mut new_files_folder = String::new();
let mut new_notes_folder = String::new();
let mut upcomming_files_folder = String::new();
let mut upcomming_notes_folder = String::new();
let mut tools_folder = String::new();
let mut cracking_rig = String::new();
let mut cracking_user = String::new();
let mut rockyou = String::new();
let mut rule = String::new();
while new_files_folder.is_empty() || new_notes_folder.is_empty() || tools_folder.is_empty(){
if new_files_folder.is_empty(){
println!("path to save active project files?");
match stdin().read_line(&mut new_files_folder){
Ok(_r) => (),
Err(_e) => println!("we need input here dummy... We will reprompt on the next loop...")
}
}
if new_notes_folder.is_empty(){
println!("path to save active project notes?");
match stdin().read_line(&mut new_notes_folder){
Ok(_r) => (),
Err(_e) => println!("we need input here dummy... We will reprompt on the next loop...")
}
}
if tools_folder.is_empty(){
println!("path to custom tools (like github tools and what not)");
match stdin().read_line(&mut tools_folder){
Ok(_r) => (),
Err(_e) => println!("we need input here dummy... We will reprompt on the next loop...")
}
}
if upcomming_files_folder.is_empty(){
println!("path to save upcomming project files?");
match stdin().read_line(&mut upcomming_files_folder){
Ok(_r) => (),
Err(_e) => println!("we need input here dummy... We will reprompt on the next loop...")
}
}
if upcomming_notes_folder.is_empty(){
println!("path to save upcomming project notes?");
match stdin().read_line(&mut upcomming_notes_folder){
Ok(_r) => (),
Err(_e) => println!("we need input here dummy... We will reprompt on the next loop...")
}
}
if cracking_rig.is_empty(){
let mut have_rig = String::new();
println!("do you have a separate computer that you can ssh into to crack passwords on?");
match stdin().read_line(&mut have_rig){
Ok(_r) => (),
Err(_e) => println!("we need input here dummy, try again...")
}
have_rig = have_rig.to_lowercase();
if have_rig.contains("y"){
println!("excellent! Whats the IP or hostname?");
loop{
match stdin().read_line(&mut cracking_rig){
Ok(_r) => break,
Err(_e) => println!("we need input here dummy, try again...")
}
}
println!("user to ssh as for the cracking rig?");
loop{
match stdin().read_line(&mut cracking_user){
Ok(_r) => break,
Err(_e) => println!("we need input here dummy, try again...")
}
}
println!("Path to rockyou.txt on the cracking rig?");
loop{
match stdin().read_line(&mut rockyou){
Ok(_r) => break,
Err(_e) => println!("we need input here dummyu try again...")
}
}
println!("Path to one rule to rule them all on the cracking rig?");
loop{
match stdin().read_line(&mut rule){
Ok(_r) => break,
Err(_e) => println!("we need input here dummyu try again...")
}
}
}
else if have_rig.contains("n"){
println!("ooof ok freeloader");
cracking_rig = "n".to_owned();
rule = "n".to_owned();
rockyou = "n".to_owned();
}
}
}
new_files_folder = new_files_folder.trim_end().to_owned();
new_notes_folder = new_notes_folder.trim_end().to_owned();
upcomming_files_folder = upcomming_files_folder.trim_end().to_owned();
upcomming_notes_folder = upcomming_notes_folder.trim_end().to_owned();
tools_folder = tools_folder.trim_end().to_owned();
cracking_rig = cracking_rig.trim_end().to_owned();
cracking_user = cracking_user.trim_end().to_owned();
let new_files_path = PathBuf::from(&new_files_folder.trim_end());
let new_notes_path = PathBuf::from(&new_notes_folder.trim_end());
let upcomming_files_path = PathBuf::from(&upcomming_files_folder.trim_end());
let upcomming_notes_path = PathBuf::from(&upcomming_notes_folder.trim_end());
let tools_path = PathBuf::from(&tools_folder.trim_end());
if new_files_path.exists() == false{
println!("active project file folder does not exist, creating...");
match fs::create_dir_all(&new_files_folder){
Ok(_r) => (),
Err(e) => {println!("Error creating active project files Folder!: {}", e);failed = true;}
}
}
if new_notes_path.exists() == false{
println!("active project notes folder does not exist creating...");
match fs::create_dir_all(new_notes_path){
Ok(_r) => (),
Err(e) => {println!("Error creating active project notes Folder!: {}", e);failed = true;}
}
}
if tools_path.exists() == false{
println!("tools folder does not exist creating...");
match fs::create_dir_all(tools_path){
Ok(_r) => (),
Err(e) => {println!("Error creating tools Folder!: {}", e);failed = true;}
}
}
if upcomming_files_path.exists() == false{
println!("upcomming project files folder does not exist creating...");
match fs::create_dir_all(upcomming_files_path){
Ok(_r) => (),
Err(e) => {println!("Error creating upcomming project files Folder!: {}", e);failed = true;}
}
}
if upcomming_notes_path.exists() == false{
println!("upcomming project notes folder does not exist creating...");
match fs::create_dir_all(upcomming_notes_path){
Ok(_r) => (),
Err(e) => {println!("Error creating upcomming project notes Folder!: {}", e);failed = true;}
}
}
if failed{
println!("install failed, cleaning up files...");
match fs::remove_dir_all(&delete_for_cleanup){
Ok(_r) => println!("cleanup successfull, please correct previously reported errors and rerun"),
Err(e) => println!("cleanup failed!: {}\nManually delete the following folder and retry\n{}", e, delete_for_cleanup.display())
}
exit(1);
}
return (new_files_folder, new_notes_folder, tools_folder, upcomming_files_folder, upcomming_notes_folder, cracking_rig, cracking_user, rockyou, rule);
}
fn configure_distrobox(){
let user_dirs_result = UserDirs::new();
let mut success = false;
let mut dbrcpath = PathBuf::new();
if user_dirs_result.is_some(){
let home = user_dirs_result.unwrap().home_dir().to_path_buf();
dbrcpath.push(home);
dbrcpath.push(".distroboxrc");
let box_config_string = String::from("container_always_pull=\"0\"\ncontainer_generate_entry=1\ncontainer_manager=\"podman\"\ncontainer_name_default=\"ubuntu\"\ncontainer_image_default=\"ghcr.io/ublue-os/ubuntu-toolbox:latest\"\nnon_interactive=\"1\"\nxhost +si:localuser:$USER >/dev/null\nexport PIPEWIRE_RUNTIME_DIR=/dev/null\nexport PATH=$PATH:$HOME/.local/bin\n");
let dbrc_file_res = fs::OpenOptions::new().write(true).create(true).open(dbrcpath);
if dbrc_file_res.is_err(){
let error = dbrc_file_res.err().unwrap();
println!("error opening distroboxrc file!");
println!("{}", error);
}
else{
let mut dibrc_file = dbrc_file_res.unwrap();
let dbrc_write_res = write!(dibrc_file, "{}",box_config_string);
if dbrc_write_res.is_err(){
println!("error writing config to distroboxrc file!");
println!("{}", dbrc_write_res.err().unwrap());
}
else{
let _dbrc_write = dbrc_write_res.unwrap();
success = true;
}
}
}
if success == false{
println!("Error getting user dirs!");
println!("distrobox config failed, please follow the following instructions...");
print!("
copy the distrobox config file to your home folder with the name .distroboxrc
cp /usr/etc/distrobox/distrobox.conf ~/.distroboxrc
Then edit the file to change the line container_always_pull=\"1\" to container_always_pull=\"0\"
");
}
}
pub fn install(config_path: &PathBuf){ pub fn install(config_path: &PathBuf){
let mut _terminal_commands = HashMap::from([ let mut _terminal_commands = HashMap::from([
("konsole", "konsole -e !!!"), ("kde", "konsole -e !!!"),
("plasma", "konsole -e !!!"),
("gnome", "gnome-terminal -- bash !!!"), ("gnome", "gnome-terminal -- bash !!!"),
("xfce", "xfce4-terminal --execute '!!!'"), ("xfce", "xfce4-terminal --execute '!!!'"),
("alacritty", "alacritty -e !!!"), ("alacritty", "alacritty -e !!!"),
]); ]);
let mut folder_creation = true;
let current_projects = PathBuf::from(get_user_input("path to store your active projects?"));
let current_notes = PathBuf::from(get_user_input("path to store your active project notes?"));
let upcoming_projects = PathBuf::from(get_user_input("path to store your upcomming projects?"));
let upcoming_notes = PathBuf::from(get_user_input("path to store your upcomming project notes?"));
let tools = PathBuf::from(get_user_input("path where you store your custom tools (like from github and places)?"));
let folders = vec![&current_projects, &current_notes, &upcoming_projects, &upcoming_notes, &tools];
let mut config_folder_path: PathBuf = config_path.clone(); let mut config_folder_path: PathBuf = config_path.clone();
config_folder_path.pop(); config_folder_path.pop();
let mut password_path = config_folder_path.clone();
password_path.push("password_spray.md");
let mut projects_conf_path = config_folder_path.clone(); let mut projects_conf_path = config_folder_path.clone();
projects_conf_path.push("projects.");
let mut bell_file_path = config_folder_path.clone(); let mut bell_file_path = config_folder_path.clone();
let del_on_fail = config_folder_path.clone(); let del_on_fail = config_folder_path.clone();
projects_conf_path.push("projects.conf"); projects_conf_path.push("projects.conf");
fs::create_dir_all(&config_folder_path).expect("error creating config dir"); create_dir_all(&config_folder_path).expect("error creating config dir");
bell_file_path.push("bell.mp3"); bell_file_path.push("bell.mp3");
let bell_sound_url = "https://github.com/Pyro57000/pentest_tool/raw/refs/heads/main/resources/bell.mp3"; let bell_sound_url = "https://github.com/Pyro57000/pentest_tool/raw/refs/heads/main/resources/bell.mp3";
let response = get(bell_sound_url).unwrap(); let response = get(bell_sound_url).unwrap();
@@ -233,131 +47,221 @@ pub fn install(config_path: &PathBuf){
let mut bell_file = File::create(bell_file_path).unwrap(); let mut bell_file = File::create(bell_file_path).unwrap();
copy(&mut response.take(response_length), &mut bell_file).unwrap(); copy(&mut response.take(response_length), &mut bell_file).unwrap();
println!("bell notification tone sucessfully downloaded!"); println!("bell notification tone sucessfully downloaded!");
let mut config_file = fs::File::create(config_path).expect("error creating file"); println!("creating new folders if needed...");
let mut projects_conf_file = fs::File::create(projects_conf_path).expect("error creating projects config file"); for folder in &folders{
projects_conf_file.write_all(b"customer:name:notes:files:active:box_name:stage\n").expect("error writing default project info"); if !Path::exists(folder){
let mut terminal_response = String::new(); let create_res = create_dir_all(folder);
let mut template_name = String::new(); if create_res.is_err(){
let mut have_template = String::new(); let error = create_res.err().unwrap();
println!("terminal you use? (example: konsole, xfce, gnome, etc)"); println!("error creating folder {}", folder.display());
std::io::stdin().read_line(&mut terminal_response).unwrap(); println!("{}", error);
let mut _terminal_command = String::new(); println!("you'll need to create this manually after the install is done!");
if terminal_response.contains("konsole"){ folder_creation = false;
let mut response_buffer = String::new();
println!("do you already have a custom profile setup?");
println!("this is pretty specific to pyro's setup, I do some special sauce for my konsole stuff");
std::io::stdin().read_line(&mut response_buffer).unwrap();
if response_buffer.to_lowercase().contains("y"){
let mut profile = String::new();
println!("konsole profile name?");
std::io::stdin().read_line(&mut profile).unwrap();
_terminal_command = format!("konsole --profile {}", profile);
} }
} }
}
let tool_volume = format!("{}:/tools:rw", &tools.display());
println!("sweet, now let's get some distrobox stuff out of the way!");
let distrobox_run_res = Command::new("distrobox").arg("list").arg("--root").output();
if distrobox_run_res.is_err(){
let error = distrobox_run_res.err().unwrap();
println!("Distrobox file was not found!");
println!("This usually means that distrobox is not installed.");
println!("please install distrobox, if you're on kali run `sudo apt install distrobox`");
println!("{}", error);
println!("this project heavily relies on distrobox, as its primarily a distrobox mangement tool.");
println!("cleaning up up configuration folders, please install distrobox and re-run this program.");
let cleanup = remove_dir_all(&del_on_fail);
if cleanup.is_err(){
println!("error cleaning up configuration folder!");
println!("please manually delete {} before re-running this install.", &del_on_fail.display());
exit(1);
}
cleanup.unwrap();
exit(1);
}
let distrobox_output = distrobox_run_res.unwrap().stdout;
let distrobox_string = String::from_utf8_lossy(&distrobox_output);
let mut distrobox_names = Vec::new();
let distrobox_output_lines: Vec<&str> = distrobox_string.split("\n").collect();
for line in distrobox_output_lines{
if line.len() > 1{
let name = line.split(" | ").collect::<Vec<&str>>()[1];
distrobox_names.push(name.to_owned());
}
}
let mut have_box = false;
for name in distrobox_names{
if !name.contains("NAME"){
have_box = true;
println!("name")
}
}
let mut template_box_name = String::new();
if have_box{
template_box_name = get_user_input("Name of the distrobox you want to use as a template?");
}
else{ else{
_terminal_command = _terminal_commands[terminal_response.trim_end()].to_owned(); println!("no exiting distroboxes created!");
} println!("let's make one!");
let (files_response, notes_response, tools_response, project_folder_path, project_note_path, cracking_rig, cracking_user, rockyou, rule) = setup_folders(&config_path); template_box_name = get_user_input("name of the distrobox you want to create?");
print!(" println!("review images listed here: https://distrobox.it/compatibility/#containers-distros");
This tool is mainly to handle distrobox creation and usage. let box_image = get_user_input("image you want to base the template box on?");
It's expecting you to have a distrobox that you will use as a template. let template_box_create_res = Command::new("distrobox")
Do you have a distrobox set up to function as your template for all new projects?
");
std::io::stdin().read_line(&mut have_template).unwrap();
if have_template.contains("n"){
println!("ooof buddy, should have had that already... no worries, we'll make one now.");
let new_boxname = get_user_input("name for your template box? (for exmaple I use atarchbox cause its my attacking archbox ;-)");
println!("please review the following link to select an image to use for your distrobox");
println!("https://distrobox.it/compatibility/#containers-distros");
let image_name = get_user_input("which image would you like to use?");
let tools_volume =format!("{}:/tools:rw", &tools_response);
let distrobox_create_res = Command::new("distrobox")
.arg("create") .arg("create")
.arg("--root") .arg("--root")
.arg("--name")
.arg(new_boxname)
.arg("--init")
.arg("--image") .arg("--image")
.arg(image_name) .arg(&box_image)
.arg("--name")
.arg(&template_box_name)
.arg("--init")
.arg("--volume") .arg("--volume")
.arg(tools_volume) .arg(&tool_volume)
.arg("--additional-packages")
.arg("systemd")
.arg("--")
.arg("exit")
.status(); .status();
if distrobox_create_res.is_err(){ if template_box_create_res.is_err(){
let error = distrobox_create_res.err().unwrap(); let error = template_box_create_res.err().unwrap();
println!("ooof we ran into a problem creating your distrobox...."); println!("error creating template box!");
println!("{}", error); println!("{}", error);
println!("you'll have to make it manually, but remember the name you want to use for the next step."); println!("\n\n\nplese create it yourself with the following command.");
println!("\n\ndistrobox create --root --image {}, --name {}, --init --volume {}", &box_image, &template_box_name, &tool_volume);
} }
else{ else{
distrobox_create_res.unwrap(); template_box_create_res.unwrap();
println!("nice, we created a distrobox, remeber the name of your box for the next step!");
} }
} }
let _list = process::Command::new("distrobox").arg("list").arg("--root").status(); let mut cracking_rig = String::from("nobody@nothing");
println!("distrobox template name?"); let mut rockyou = String::from("n/a");
std::io::stdin().read_line(&mut template_name).unwrap(); let mut rule = String::from("n/a");
let mut set_fprint = String::from("no"); let cracking_rig_response = get_user_input("do you have a separate machine to crack passwords on? (not the ambush cracking rig)");
let fprint_answer = get_user_input("do you want to use fingerprint authentication inside the distroboxes?").to_lowercase(); if cracking_rig_response.to_lowercase().contains("y"){
if fprint_answer.contains("y"){ let rig_ip = get_user_input("ip address or hostname of your cracking rig?");
set_fprint = "yes".to_owned(); let rig_user = get_user_input("username to log into your cracking rig with?");
rockyou = get_user_input("location of rockyou.txt on the cracking rig?");
rule = get_user_input("location of one rule to rule them all on the cracking rig?");
cracking_rig = format!("{}@{}", rig_user, rig_ip);
} }
let config_string = format!("Project_files:{}\nProject_notes:{}\ntools_folder:{}\nupcoming_files:{}\nupcoming_notes:{}\nbox_template:{}\nterminal:{}\ncracking_rig:{}@{}\nrockyou_location:{}\nrule_location:{}\nfingerprint:{}", files_response.trim_end(), notes_response.trim_end(), tools_response.trim_end(), &project_folder_path.trim_end(), &project_note_path.trim_end(), template_name.trim_end(), _terminal_command.trim_end(), cracking_user.trim_ascii_end(), cracking_rig.trim_end(), rockyou.trim_end(), rule.trim_end(), set_fprint); else{
config_file.write_all(config_string.as_bytes()).expect("error writing to config file"); println!("ok free loader");
let default_projectline = format!("default:default:{}:{}:yes:{}:current", &notes_response.trim_end(), &files_response.trim_end(), &template_name.trim_end()); }
projects_conf_file.write_all(default_projectline.as_bytes()).expect("error writing default project line"); let fingerprint = get_user_input("will you be using fingerprint authentication for your distroboxes?").to_lowercase();
println!("active project folders: {}", &files_response); let terminal = String::new();
println!("upcomming project folders: {}", &project_folder_path); for desktop in _terminal_commands.keys(){
println!("active project notes: {}", &notes_response); println!("{}", desktop);
println!("upcomming prjoect notes: {}", &project_note_path); let desktop_response = get_user_input("do you use any of these desktops?").to_lowercase();
println!("tools folder: {}", &tools_response); if desktop_response.contains("y"){
println!("distrobox template: {}", &template_name); let default_response = get_user_input("do you use the default terminal for your desktop?").to_lowercase();
println!("terminal command: {}", &_terminal_command); if default_response.contains("y"){
println!("config file generated and saved to {}\n", config_path.display()); let de = get_user_input("which desktop do you use?");
terminal = _terminal_commands[&de];
}
let config_path = &config_folder_path.clone(); }
let mut install_path = config_path.clone(); else{
let mut password_spray_template_path = install_path.clone(); println!("OK, then please enter the command you'd use to launch a new terminal and run a command inside of it, replacing the command with three !s");
install_path.push("new_projects.conf"); println!("for example for konsole you'd enter");
password_spray_template_path.push("passwordspray.md"); println!("konsole -e !!!");
let pass_file_config_line = format!("\npass_file:{}", password_spray_template_path.display()); terminal = get_user_input("");
config_file.write_all(pass_file_config_line.as_bytes()).expect("error writing password spray setting to config file"); }
let mut passpray_file = fs::File::create(password_spray_template_path).expect("error creating passwordspray file"); }
write!(passpray_file, " if terminal.contains("konsole"){
- [ ] useraspass println!("do you use a specific profile for your attack boxes?");
- [ ] Seasonyear! println!("this is pretty specific to Pyro's setup, so you probably don't");
- [ ] Service123! if get_user_input("").to_lowercase().contains("y"){
- [ ] admin let profile_name = get_user_input("what is the name of your profile?");
- [ ] Admin terminal = format!("konsole --profile {}", profile_name);
- [ ] Admin123! }
- [ ] admin123 }
- [ ] admin1 let configuration_string = format!("
- [ ] 1234567 Project_files:{}
- [ ] Seasonyear Project_notes:{}
- [ ] seasonyear! tools_folder:{}
- [ ] seasonyear upcoming_files:{}
- [ ] COMPANYYEAR! upcoming_notes:{}
- [ ] COMPANYYEAR box_template:{}
- [ ] November2024! terminal:{}
- [ ] September2024! cracking_rig:{}
- [ ] October2024! rockyou_location:{}
- [ ] COMPANYfoundingyear! rule_location:{}
- [ ] COMPANYfoundingyear pass_file:{}
- [ ] COMPANYstreetnumber! fingerprint:{}"
- [ ] COMPANYstreetnumber , &current_projects.display(), &current_notes.display(), &tools.display(), &upcoming_projects.display(), &upcoming_notes.display(), &template_box_name, &terminal, cracking_rig, rockyou, rule, &password_path.display(), fingerprint);
- [ ] Password println!("cool everything, all folders and settings have been entered, now let's save this to a config file...");
- [ ] P@ssw0rd let mut config_file_res = File::create_new(config_path);
- [ ] Password1! if config_file_res.is_err(){
- [ ] Password123! println!("ooof error creating configuration file...");
- [ ] Passwordyear! println!("try creating it manually.");
- [ ] P@55w0rd println!("copy the following configuration and save it to {}", config_path.display());
- [ ] Service print!("{}\n", configuration_string);
- [ ] Service! exit(1);
- [ ] Serviceyear!").expect("error writing password spray template"); }
configure_distrobox(); let mut config_file = config_file_res.unwrap();
std::process::exit(0); let config_write_res =write!(config_file, "{}", &configuration_string);
if config_write_res.is_err(){
println!("error writing configuration string to the configuration file!");
println!(" try creating it manually.");
println!("copy the following configuration and save it to {}", &configuration_string);
exit(1);
}
config_write_res.unwrap();
println!("nice the configuration file was written correctly!");
println!("creating project configuration file, and poplulating it with the default project...");
let project_conf_res = File::create_new(&projects_conf_path);
if project_conf_res.is_err(){
println!("ooof error creating the projects configuration file.");
println!("try creating it manually!");
println!("copy the following configuration and save it to {}", &projects_conf_path.display());
println!("customer:name:notes:files:active:time:box_name:stage");
println!("default:default:{}:{}:yes:{}:current", &current_notes.display(), &current_projects.display(), &template_box_name);
exit(1);
}
let mut project_conf_file = project_conf_res.unwrap();
let project_write_res = write!(project_conf_file, "customer:name:notes:files:active:time:box_name:stage\ndefault:default:{}:{}:yes:{}:current", &current_notes.display(), &current_projects.display(), &template_box_name);
if project_write_res.is_err(){
println!("error writing project config file.");
exit(1);
}
project_write_res.unwrap();
let password_file_res = File::create_new(password_path);
if password_file_res.is_err(){
println!("error creating password spray file");
exit(1);
}
let password_file = password_file_res.unwrap();
let password_write_res = write!(password_file, "
- [ ] useraspass
- [ ] Seasonyear!
- [ ] Service123!
- [ ] admin
- [ ] Admin
- [ ] Admin123!
- [ ] admin123
- [ ] admin1
- [ ] 1234567
- [ ] Seasonyear
- [ ] seasonyear!
- [ ] seasonyear
- [ ] COMPANYYEAR!
- [ ] COMPANYYEAR
- [ ] November2024!
- [ ] September2024!
- [ ] October2024!
- [ ] COMPANYfoundingyear!
- [ ] COMPANYfoundingyear
- [ ] COMPANYstreetnumber!
- [ ] COMPANYstreetnumber
- [ ] Password
- [ ] P@ssw0rd
- [ ] Password1!
- [ ] Password123!
- [ ] Passwordyear!
- [ ] P@55w0rd
- [ ] Service
- [ ] Service!
- [ ] Serviceyear!
");
if password_file_res.is_err(){
println!("error writing password file");
exit(1);
}
println!("install completed successfully!");
println!("re-run this to launch!");
} }

View File

@@ -1,6 +1,7 @@
use std::{io::stdin, path::PathBuf}; use std::{io::stdin, path::PathBuf, process::Command};
use directories::UserDirs; use directories::UserDirs;
use reqwest::Response; use reqwest::Response;
use std::process::exit;
use std::fs; use std::fs;
#[derive(Clone)] #[derive(Clone)]
@@ -60,8 +61,23 @@ fn main() {
⠀⠀⠀⠀⢿⡉⠳⡟⣸⠃⠀⠀⠀⠘⢷⣌⠉⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⢿⡉⠳⡟⣸⠃⠀⠀⠀⠘⢷⣌⠉⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠙⢦⣴⠏⠀⠀⠀⠀⠀⠀⠉⠳⠶⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠙⢦⣴⠏⠀⠀⠀⠀⠀⠀⠉⠳⠶⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
"); ");
let user_dirs = UserDirs::new().expect("error getting user directories"); let mut config_path = PathBuf::new();
let mut config_path = user_dirs.home_dir().to_path_buf(); 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"); config_path.push(".config/pyro_pentest_tool/conf");
if config_path.as_path().exists() == false{ if config_path.as_path().exists() == false{
install::install(&config_path); install::install(&config_path);