Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2346988e23 | ||
|
|
5bfa645b3d | ||
|
|
012ba517ab | ||
|
|
649dad5e79 | ||
|
|
2e839adccf | ||
|
|
fc316c2a71 | ||
|
|
31dd862579 | ||
|
|
b85d0e5d79 | ||
|
|
477ac6e360 | ||
|
|
fe6524016f | ||
|
|
967052a4e2 | ||
|
|
2796d31f14 |
@@ -53,11 +53,11 @@ Current engagements: client1 internal pentest, client 2 internal pentest
|
||||
|
||||
This tool automatically creates the file structure, and if you use the start_pentest option populates the markdown note files with the templates I use.
|
||||
|
||||
For example if I get a new internal pentest engagement for client 3 but it hasn't started yet I'll start by creating the folder and note structure using option 4 in the menu system. This would create the folder structure and notes templates in the /home/pyro/pentests/upcomming/client3/internal_pentest and /home/pyro/notes/upcomming/client3/internal_pentest folders respectively. It does not create the distrobox or add it to the tracked project list yet.
|
||||
For example if I get a new internal pentest engagement for client 3 but it hasn't started yet I'll start by creating the folder and note structure using option 4 in the menu system. This would create the folder structure and notes templates in the /home/pyro/pentests/upcomming/client3/internal_pentest and /home/pyro/notes/upcomming/client3/internal_pentest folders respectively. It does not create the distrobox, but it does add it to the list of tracked projects, with a status of upcomming.
|
||||
|
||||
Once the engagement starts I'd run option 6 "import new project - and set up new distrobox" from the menu system. It will ask if you have an existing folder structure to copy over, since I created that structure before with option 4 I would answer y, yes, or anything with the letter y in it. Then it prompts you to past the path to the folders to copy over. Here I browse to /home/pyro/pentests/upcomming in dolphin. I right click on the client3 folder and select "copy path" and then paste that into the terminal. I repeat this process for the notes folder.
|
||||
Once the engagement starts I'd run option 9 to promote a project from upcomming status to current status. This will automatically copy the needed files over, and will clean up the empty directory in the upcomming files directory, but the empty folder in the upcomming notes folder is still not cleaning correctly, I'm working on that.
|
||||
|
||||
It then attempts to guess the client name and project name based on the folder structure, and asks you to confirm. If its correct the project object will be created, the folders will be copied, and a new distrobox will be set up. If it is not correct it will prompt you to correct it, then copy the files, create a new project object, and setup a new distrobox. At the moment it is not very fault tollerant and will fail if there is an existing folder with the same name. I plan to fix that later, but haven't gotten around to it yet. Once the distro box is set up (this takes a while) it will return you to the main menu.
|
||||
It then will create a new distrobox and ask you if you need to set up cobalt strike for the project. if so it'll ask you for the path to your cobalt strike, it'll copy that into the project files folder so that you can run it if needed.
|
||||
|
||||
During the test I use the menu system to spawn new terminals in the distrobox created for the engagement, use the various file generation options to get data in easily usable format for attack operations, etc.
|
||||
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
use core::error;
|
||||
use std::os::unix::thread::JoinHandleExt;
|
||||
use std::process::Command;
|
||||
use std::{path::PathBuf, process};
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::io::stdin;
|
||||
use std::io::Write;
|
||||
use std::thread::{self, JoinHandle, Thread};
|
||||
use std::thread::{self, JoinHandle};
|
||||
use std::time::Duration;
|
||||
use std::str::FromStr;
|
||||
use crate::Project;
|
||||
use crate::{get_user_input, Project};
|
||||
|
||||
pub fn stop_all_boxes(projects: &Vec<Project>){
|
||||
let mut problem_childs: Vec<Project> = Vec::new();
|
||||
@@ -47,6 +43,10 @@ pub fn project_standalone_terminal(project: Project, mut terminal: String){
|
||||
if terminal.contains("profile"){
|
||||
profile = true;
|
||||
}
|
||||
if terminal.contains("!!!"){
|
||||
let terminal_launch_cmd = format!("distrobox enter --root {}", &project.boxname);
|
||||
terminal = terminal.replace("!!!", &terminal_launch_cmd);
|
||||
}
|
||||
let terminal_vec:Vec<&str> = terminal.split(" ").collect();
|
||||
let mut terminal_start = process::Command::new(terminal_vec[0]);
|
||||
let mut first = true;
|
||||
@@ -74,7 +74,7 @@ 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");
|
||||
}
|
||||
|
||||
pub fn make_box(project: &Project, tools_dir: &PathBuf, boxtemplate: &String, new: bool){
|
||||
pub fn make_box(project: &Project, tools_dir: &PathBuf, boxtemplate: &String, new: bool, fingerprint: bool){
|
||||
println!("stopping template box to ensure we can clone it!");
|
||||
let stop_result = Command::new("distrobox").arg("stop").arg("--root").arg(boxtemplate).status();
|
||||
if stop_result.is_err(){
|
||||
@@ -95,55 +95,68 @@ pub fn make_box(project: &Project, tools_dir: &PathBuf, boxtemplate: &String, ne
|
||||
}
|
||||
}
|
||||
let mut box_name_path = project.files_folder.clone();
|
||||
let mut box_name = format!("atarchbox_{}", &project.customer);
|
||||
let box_name = format!("{}_{}", &boxtemplate, &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 --init --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")
|
||||
.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!");
|
||||
let mut distrobox_cmd = String::new();
|
||||
if fingerprint{
|
||||
println!("creating box with shared volume for fingerprints... note you will still need to set up fingerprint authentication in your distrobox");
|
||||
println!("\nfor example, you may need to install fprintd and imagemegick on your template box, and set up the pam files to utilize finger print auth");
|
||||
println!("\nsee https://wiki.archlinux.org/title/Fprint for more information and instructions");
|
||||
distrobox_cmd = format!("distrobox create --root --init --clone {} --volume {} --volume {} --volume /var/lib/fprint:/var/lib/fprint:rw --name {}", boxtemplate, toold_volume, pentest_volume, box_name);
|
||||
}
|
||||
else {
|
||||
distrobox_cmd = format!("distrobox create --root --init --clone {} --volume {} --volume {} --name {}", boxtemplate, toold_volume, pentest_volume, box_name);
|
||||
}
|
||||
println!("{}", distrobox_cmd);
|
||||
let distrobox_cmd_vec: Vec<&str> = distrobox_cmd.split_whitespace().collect();
|
||||
let mut distrobox_cmd_build = process::Command::new("distrobox");
|
||||
let mut first = true;
|
||||
for word in &distrobox_cmd_vec{
|
||||
if first == false{
|
||||
println!("adding {} as an argument for the creation command...", word);
|
||||
distrobox_cmd_build.arg(word);
|
||||
}
|
||||
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);
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
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 --root {} -- sudo -s ln -sf /pentest/boxname /etc/boxname", &box_name);
|
||||
let distrobox_result = distrobox_cmd_build.status();
|
||||
if distrobox_result.is_err(){
|
||||
println!("oooof we ran into trouble creating your distrobox!!");
|
||||
println!("try creating it manually!");
|
||||
println!("{}", distrobox_cmd);
|
||||
}
|
||||
else{
|
||||
if distrobox_result.unwrap().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();
|
||||
if distrobox_start_result.is_err(){
|
||||
println!("ooof did not start successfully try entering it yoruself");
|
||||
println!("distrobox enter --root {} -- sudo -s ln -sf /pentest/boxname /etc/boxname", &box_name);
|
||||
}
|
||||
else if distrobox_start_result.unwrap().success(){
|
||||
println!("distrobox was started as well!!!! good job me!");
|
||||
}
|
||||
else {
|
||||
println!("ooof did not start successfully try entering it yoruself");
|
||||
println!("distrobox enter --root {} -- sudo -s ln -sf /pentest/boxname /etc/boxname", &box_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,6 +198,15 @@ pub fn clean_unused_boxes(projects: &Vec<Project>, boxtemplate: &String) -> Opti
|
||||
}
|
||||
|
||||
pub fn launch_cobalt_strike(project: Project) -> Option<JoinHandle<()>>{
|
||||
let mut check_path = PathBuf::new();
|
||||
check_path.push(&project.files_folder);
|
||||
check_path.push("cobaltstrike/client");
|
||||
if check_path.as_path().exists() == false{
|
||||
println!("looks like you don't have cobalt strike set up on this beacon... try copying your cobalt strike folder to the following path!");
|
||||
println!("{}", &check_path.display());
|
||||
return None;
|
||||
}
|
||||
println!("you will need to enter your sudo password shortly, when you've done that successfully please type END and hit enter");
|
||||
let handle = thread::spawn(move ||{
|
||||
let mut cs_dir = PathBuf::new();
|
||||
cs_dir.push(project.files_folder);
|
||||
@@ -204,5 +226,61 @@ pub fn launch_cobalt_strike(project: Project) -> Option<JoinHandle<()>>{
|
||||
}
|
||||
}
|
||||
});
|
||||
thread::sleep(Duration::from_secs(5));
|
||||
loop{
|
||||
let end = get_user_input("please enter END if the sudo password was enter correctly!");
|
||||
if end == "END".to_string(){
|
||||
break;
|
||||
}
|
||||
}
|
||||
return Some(handle);
|
||||
}
|
||||
|
||||
pub fn launch_bloodhound_gui(project: Project) -> Option<JoinHandle<()>>{
|
||||
let mut bloodhound_command = String::new();
|
||||
let version_response = get_user_input("do you want to use a specific bloodhound version?");
|
||||
if version_response.to_lowercase().contains("y"){
|
||||
bloodhound_command = get_user_input("path to the bloodhound binary you want to use?");
|
||||
}
|
||||
else{
|
||||
bloodhound_command = "bloodhound".to_owned();
|
||||
}
|
||||
let mut neo4j_started = false;
|
||||
let neo4jstart_res = Command::new("distrobox")
|
||||
.arg("enter")
|
||||
.arg("--root")
|
||||
.arg(&project.boxname)
|
||||
.arg("--")
|
||||
.arg("sudo")
|
||||
.arg("neo4j")
|
||||
.arg("start")
|
||||
.status();
|
||||
if neo4jstart_res.is_err(){
|
||||
let error = neo4jstart_res.err().unwrap();
|
||||
println!("errror starting neo4j...");
|
||||
println!("{}", error);
|
||||
}
|
||||
else{
|
||||
neo4j_started = true;
|
||||
thread::sleep(Duration::from_secs(3));
|
||||
}
|
||||
if neo4j_started == false{
|
||||
println!("review previous errors, not spawning bloodhound thread...");
|
||||
return None;
|
||||
}
|
||||
let handle = thread::spawn(move ||{
|
||||
let bloodhound_res = Command::new("distrobox")
|
||||
.arg("enter")
|
||||
.arg("--root")
|
||||
.arg(&project.boxname)
|
||||
.arg("--")
|
||||
.arg(bloodhound_command)
|
||||
.output();
|
||||
if bloodhound_res.is_err(){
|
||||
let error = bloodhound_res.err().unwrap();
|
||||
println!("error starting bloodhound!");
|
||||
println!("{}", error);
|
||||
}
|
||||
});
|
||||
return Some(handle);
|
||||
}
|
||||
@@ -1,28 +1,172 @@
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::write;
|
||||
use std::fs;
|
||||
use std::fs::create_dir_all;
|
||||
use std::fs::read_to_string;
|
||||
use std::fs::OpenOptions;
|
||||
use std::hash::Hash;
|
||||
use std::io::BufReader;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
use std::process;
|
||||
use std::process::Command;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use std::io::stdin;
|
||||
use std::thread::JoinHandle;
|
||||
use chrono::format;
|
||||
use fs_extra::file;
|
||||
use reqwest::dns::Name;
|
||||
use walkdir::WalkDir;
|
||||
use clearscreen::clear;
|
||||
use clearscreen;
|
||||
use rodio::{Decoder, OutputStream, Sink};
|
||||
use crate::get_user_input;
|
||||
use crate::open_overwrite;
|
||||
use crate::open_append;
|
||||
use crate::Project;
|
||||
|
||||
pub fn run_initial_enum(project: &Project){
|
||||
let mut csv = String::new();
|
||||
println!("path to the csv?");
|
||||
std::io::stdin().read_line(&mut csv).unwrap();
|
||||
let status = process::Command::new("initial_recon").arg(&csv).arg(&project.customer).arg(&project.project_name).status().expect("error running initial_recon program");
|
||||
if status.success(){
|
||||
println!("execllent! hosts should be imported to {}/host_notes.md", &project.notes_folder.display());
|
||||
#[derive(Clone)]
|
||||
struct Target {
|
||||
address: String,
|
||||
ports: Vec<String>
|
||||
}
|
||||
else{
|
||||
println!("ooof something went wrong, host notes may not have saved correctly!");
|
||||
|
||||
let mut targets:Vec<Target> = Vec::new();
|
||||
println!("log into nessus and export a report, only checking the host, protocol, and port boxes");
|
||||
let mut host_notes_path = project.notes_folder.clone();
|
||||
let mut attack_notes_path = project.notes_folder.clone();
|
||||
host_notes_path.push("host_notes.md");
|
||||
attack_notes_path.push("attacks");
|
||||
let csv_path = get_user_input("path to nessus report CSV?");
|
||||
let csv_read_res = fs::read_to_string(&csv_path);
|
||||
if csv_read_res.is_err(){
|
||||
let error = csv_read_res.err().unwrap();
|
||||
println!("error reading csv!");
|
||||
println!("{}", error);
|
||||
return;
|
||||
}
|
||||
let csv_data = csv_read_res.unwrap();
|
||||
for line in csv_data.split("\n").collect::<Vec<&str>>(){
|
||||
if line.len() > 1{
|
||||
let data: Vec<&str> = line.split(",").collect();
|
||||
let address = data[0].replace("\"", "").trim().to_owned();
|
||||
let port = data[2].replace("\"", "").trim().to_owned();
|
||||
let protocol = data[1].replace("\"", "").trim().to_owned();
|
||||
if &address == &"Host"{
|
||||
continue;
|
||||
}
|
||||
else if &port == &"0"{
|
||||
continue;
|
||||
}
|
||||
let port_entry = format!("{}:{}", &protocol, &port);
|
||||
let mut is_new = true;
|
||||
for target in &mut targets{
|
||||
if target.address == address{
|
||||
if !target.ports.contains(&port_entry){
|
||||
target.ports.push(port_entry.clone());
|
||||
}
|
||||
is_new = false;
|
||||
}
|
||||
}
|
||||
if is_new{
|
||||
let new_target = Target{address: address.to_owned(), ports: vec![port_entry.clone()]};
|
||||
targets.push(new_target);
|
||||
}
|
||||
}
|
||||
}
|
||||
for target in &targets{
|
||||
let host_notes_open_res = fs::OpenOptions::new().append(true).create(true).open(&host_notes_path);
|
||||
if host_notes_open_res.is_err(){
|
||||
let error = host_notes_open_res.err().unwrap();
|
||||
println!("error opening host notes file!");
|
||||
println!("{}", error);
|
||||
return;
|
||||
}
|
||||
let host_notes = host_notes_open_res.unwrap();
|
||||
let attack_notes_open_res = fs::OpenOptions::new().append(true).create(true).open(&attack_notes_path);
|
||||
if attack_notes_open_res.is_err(){
|
||||
let error = attack_notes_open_res.err().unwrap();
|
||||
println!("error opening attack notes!");
|
||||
println!("{}", error);
|
||||
return;
|
||||
}
|
||||
for target in targets.clone(){
|
||||
let mut output = format!("# {}\n## Ports\n| port | service | attack notes |\n| ----- | ------- | ------------ |\n", target.address);
|
||||
for port in target.ports{
|
||||
output.push_str(format!("| {} | | [[attacks]]\n", port).as_str());
|
||||
}
|
||||
output.push_str("\n");
|
||||
write!(&host_notes, "{}", output).expect("error writing host_notes");
|
||||
println!("{} notes written!", target.address);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build_external_attack_notes(project: &Project){
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Port{
|
||||
number: String,
|
||||
hosts: Vec<String>,
|
||||
}
|
||||
|
||||
let mut ports: Vec<Port> = Vec::new();
|
||||
let mut host_notes_path = project.notes_folder.clone();
|
||||
let mut attack_notes_path = host_notes_path.clone();
|
||||
host_notes_path.push("host_notes.md");
|
||||
attack_notes_path.push("attacks.md");
|
||||
let host_notes_read_res = fs::read_to_string(host_notes_path);
|
||||
if host_notes_read_res.is_err(){
|
||||
let error = host_notes_read_res.err().unwrap();
|
||||
println!("error reading host notes!");
|
||||
println!("{}", error);
|
||||
return;
|
||||
}
|
||||
let host_notes = host_notes_read_res.unwrap();
|
||||
let attack_open_res = fs::OpenOptions::new().append(true).create(true).open(attack_notes_path);
|
||||
if attack_open_res.is_err(){
|
||||
let error = attack_open_res.err().unwrap();
|
||||
println!("error opening attack notes!");
|
||||
println!("{}", error);
|
||||
return;
|
||||
}
|
||||
let attack_notes = attack_open_res.unwrap();
|
||||
for line in host_notes.split("\n").collect::<Vec<&str>>(){
|
||||
let mut current_host = String::new();
|
||||
if line.len() > 1{
|
||||
if line.contains("#"){
|
||||
if !line.contains("##"){
|
||||
current_host = line.split_whitespace().collect::<Vec<&str>>()[1].trim().to_owned();
|
||||
}
|
||||
}
|
||||
if line.contains("|"){
|
||||
let table_data:Vec <&str> = line.split("|").collect();
|
||||
for item in table_data{
|
||||
let mut is_new = true;
|
||||
if item.contains(":"){
|
||||
for port in &mut ports{
|
||||
if port.number == item.trim(){
|
||||
if port.hosts.contains(¤t_host){
|
||||
port.hosts.push(current_host.clone());
|
||||
}
|
||||
is_new = false;
|
||||
}
|
||||
}
|
||||
if is_new{
|
||||
let new_port = Port{number: line.trim().to_owned(), hosts:vec![current_host.clone()]};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for port in ports{
|
||||
let output = format!("# {}\nHOSTS:\n", port.number);
|
||||
for host in port.hosts{
|
||||
// output.push_str("## {}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -581,4 +725,435 @@ pub fn crack_hashes(cracking_rig: &String, project: &Project, terminal: &String,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn get_mssql_column_names(project: &Project) -> Option<JoinHandle<()>>{
|
||||
let mut notes_file = project.notes_folder.clone();
|
||||
notes_file.push("l00t/db_stuff");
|
||||
println!("NOTE: this funtion relies on netexec, make sure its installed properly!");
|
||||
let mut servers = Vec::new();
|
||||
let username = get_user_input("username for the databases?");
|
||||
let password = get_user_input("password for the databases?");
|
||||
let local_auth = get_user_input("Will you be using Windows Authentication for this?").to_lowercase();
|
||||
loop{
|
||||
for server in &servers{
|
||||
println!("{}", server);
|
||||
}
|
||||
let new_server = get_user_input("server to add? (enter DONE when you're finished)");
|
||||
if new_server == "DONE".to_owned(){
|
||||
break;
|
||||
}
|
||||
servers.push(new_server);
|
||||
}
|
||||
let db_handle = thread::spawn(move ||{
|
||||
for server in servers{
|
||||
let mut db_notes_path = notes_file.clone();
|
||||
let mut dbs = Vec::new();
|
||||
if local_auth.contains("n"){
|
||||
let netexec_cmd_res = Command::new("proxychains")
|
||||
.arg("netexec")
|
||||
.arg("mssql")
|
||||
.arg(&server)
|
||||
.arg("-u")
|
||||
.arg(&username)
|
||||
.arg("-p")
|
||||
.arg(&password)
|
||||
.arg("--local-auth")
|
||||
.arg("-q")
|
||||
.arg("\"SELECT name FROM master.sys.databases\"")
|
||||
.output();
|
||||
if netexec_cmd_res.is_err(){
|
||||
let error = netexec_cmd_res.err().unwrap();
|
||||
println!("error running netexec command!");
|
||||
println!("{}", error);
|
||||
}
|
||||
else{
|
||||
let output_string = String::from_utf8(netexec_cmd_res.unwrap().stdout).unwrap();
|
||||
let words: Vec<&str> = output_string.split_whitespace().collect();
|
||||
for word in words {
|
||||
if word.contains("name:"){
|
||||
let db = word.split(":").collect::<Vec<&str>>()[1].to_owned();
|
||||
db_notes_path.push(&db);
|
||||
dbs.push(db);
|
||||
fs::create_dir_all(&db_notes_path).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return Some(db_handle);
|
||||
}
|
||||
|
||||
pub fn partse_gathercontacts(project: &Project){
|
||||
fn format_names(names: Vec<&str>) -> HashMap<&str, Vec<String>>{
|
||||
let mut formated_data = HashMap::new();
|
||||
let mut flast = Vec::new();
|
||||
let mut fdotlast = Vec::new();
|
||||
let mut fdashlast = Vec::new();
|
||||
let mut firstl = Vec::new();
|
||||
let mut firstdotlast = Vec::new();
|
||||
let mut firstlast = Vec::new();
|
||||
let mut last_vec = Vec::new();
|
||||
let mut first_vec = Vec::new();
|
||||
for name in names{
|
||||
let name_vec: Vec<&str> = name.split("|").collect();
|
||||
if name_vec.len() == 2{
|
||||
let first = name_vec[0];
|
||||
let last = name_vec[1];
|
||||
let first_chars: Vec<char> = first.chars().collect();
|
||||
let last_chars: Vec<char> = last.chars().collect();
|
||||
flast.push(format!("{}{}", &first_chars[0], &last));
|
||||
fdotlast.push(format!("{}.{}", &first_chars[0], &last));
|
||||
fdashlast.push(format!("{}-{}", &first, &last));
|
||||
firstl.push(format!("{}{}", &first, &last_chars[0]));
|
||||
firstdotlast.push(format!("{}.{}", &first, &last));
|
||||
firstlast.push(format!("{}{}", &first, &last));
|
||||
last_vec.push(format!("{}", &last));
|
||||
first_vec.push(format!("{}", &first));
|
||||
}
|
||||
}
|
||||
formated_data.insert("flast", flast);
|
||||
formated_data.insert("fdotlast", fdotlast);
|
||||
formated_data.insert("fdashlast", fdashlast);
|
||||
formated_data.insert("firstl", firstl);
|
||||
formated_data.insert("firstdotlast", firstdotlast);
|
||||
formated_data.insert("firstlast", firstlast);
|
||||
formated_data.insert("last", last_vec);
|
||||
formated_data.insert("fisrt", first_vec);
|
||||
return formated_data;
|
||||
}
|
||||
|
||||
let gather_file = get_user_input("path to your gather contacts output?");
|
||||
print!("
|
||||
supported formats:
|
||||
flast
|
||||
f.last
|
||||
f-last
|
||||
firstl
|
||||
first.last
|
||||
firstlast
|
||||
last
|
||||
\n");
|
||||
let format = get_user_input("format of usernames?");
|
||||
let domain = get_user_input("domain name?");
|
||||
let gather_source = fs::read_to_string(gather_file);
|
||||
if gather_source.is_err(){
|
||||
let error = gather_source.err().unwrap();
|
||||
println!("error reading gather contacts output!");
|
||||
println!("{}", error);
|
||||
return;
|
||||
}
|
||||
let gather_source_string = gather_source.unwrap();
|
||||
let gather_source_lines: Vec<&str> = gather_source_string.split("\n").collect();
|
||||
let mut names = String::new();
|
||||
for line in gather_source_lines{
|
||||
if line.len() > 2{
|
||||
let line_vec: Vec<&str> = line.split("\t").collect();
|
||||
let first = line_vec[1].trim();
|
||||
let last = line_vec[2].trim();
|
||||
if first.len() > 1 && last.len() >1 {
|
||||
let name = format!("{}|{}",first, last);
|
||||
names = format!("{} {}", names, name.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
let users: Vec<&str> = names.split(" ").collect();
|
||||
let data = format_names(users);
|
||||
let mut email_text_path = project.files_folder.clone();
|
||||
let mut email_note_path = project.notes_folder.clone();
|
||||
email_text_path.push("working/extrapolated_emails.txt");
|
||||
email_note_path.push("email_enum.md");
|
||||
let email_text_res = OpenOptions::new().append(true).create(true).open(email_text_path);
|
||||
if email_text_res.is_err(){
|
||||
let error = email_text_res.err().unwrap();
|
||||
println!("error opening email text file!");
|
||||
println!("{}", error);
|
||||
return;
|
||||
}
|
||||
let email_notes_res = OpenOptions::new().append(true).create(true).open(email_note_path);
|
||||
if email_notes_res.is_err(){
|
||||
let error = email_notes_res.err().unwrap();
|
||||
println!("error opeing email notes file!");
|
||||
println!("{}", error);
|
||||
return;
|
||||
}
|
||||
let mut email_text_file = email_text_res.unwrap();
|
||||
let mut email_note_file = email_notes_res.unwrap();
|
||||
let note_wriet_res = write!(email_note_file, "# Extrapolated Emails: \n");
|
||||
if note_wriet_res.is_err(){
|
||||
let error = note_wriet_res.err().unwrap();
|
||||
println!("error writing to email notes file!");
|
||||
println!("{}", error);
|
||||
}
|
||||
println!("data gathered, printing emails and saving files...\n\n");
|
||||
for email in &data[&format.to_lowercase().trim()]{
|
||||
let outline = format!("{}@{}", email, domain);
|
||||
println!("{}", &outline);
|
||||
write!(email_note_file, "{}\n", outline).expect("error writing email notes file!");
|
||||
write!(email_text_file, "{}\n", outline).expect("error writing email text file!");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_csportscan(project: &Project){
|
||||
let mut tsv_path = project.files_folder.clone();
|
||||
tsv_path.push("working/tsvs/services.tsv");
|
||||
let mut outfile = tsv_path.clone();
|
||||
outfile.pop();
|
||||
outfile.pop();
|
||||
let mut windows_hosts = Vec::new();
|
||||
let mut ssh_hosts = Vec::new();
|
||||
let mut ftp_hosts = Vec::new();
|
||||
let mut rdp_hosts = Vec::new();
|
||||
let mut dns_hosts = Vec::new();
|
||||
let mut snmp_hosts = Vec::new();
|
||||
let mut web_hosts = Vec::new();
|
||||
let mut telnet_hosts = Vec::new();
|
||||
let mut unknown_ports = Vec::new();
|
||||
|
||||
if !get_user_input("do you have the tsv saved in the project folder under working/tsvs/services.tsv?").to_lowercase().contains("y"){
|
||||
tsv_path.clear();
|
||||
tsv_path.push(get_user_input("ooof ok, please enter the full path to your tsv file."));
|
||||
}
|
||||
let tsv_read_res = read_to_string(tsv_path);
|
||||
if tsv_read_res.is_err(){
|
||||
let error = tsv_read_res.err().unwrap();
|
||||
println!("ooof error reading tsv file!");
|
||||
println!("{}", error);
|
||||
return;
|
||||
}
|
||||
println!("tsv read, parsing lines...");
|
||||
let tsv_string = tsv_read_res.unwrap();
|
||||
let lines: Vec<&str> = tsv_string.split("\n").collect();
|
||||
for line in lines{
|
||||
let words: Vec<&str> = line.split("\t").collect();
|
||||
if words.len() > 1{
|
||||
let host = words[0].to_lowercase().to_owned();
|
||||
let port = words[1].to_lowercase().to_owned();
|
||||
let host_entry = format!("{}:{}", &host, &port);
|
||||
match words[1]{
|
||||
"135" => {if !windows_hosts.contains(&host){windows_hosts.push(host)}},
|
||||
"445" => {if !windows_hosts.contains(&host){windows_hosts.push(host)}},
|
||||
"22" => {if !ssh_hosts.contains(&host){ssh_hosts.push(host);}},
|
||||
"21" => {if !ftp_hosts.contains(&host){ftp_hosts.push(host);}},
|
||||
"23" => {if !telnet_hosts.contains(&host){telnet_hosts.push(host)}},
|
||||
"3389" => {if !rdp_hosts.contains(&host){rdp_hosts.push(host);}},
|
||||
"80" | "443" | "8080" | "8443" | "4433" | "8000" => {if !web_hosts.contains(&host_entry){web_hosts.push(host_entry);}},
|
||||
"53" => {if !dns_hosts.contains(&host){dns_hosts.push(host);}},
|
||||
"161" => {if !snmp_hosts.contains(&host){snmp_hosts.push(host);}},
|
||||
_ => {
|
||||
if words.len() == 3{
|
||||
let banner = words[2].to_lowercase().to_owned();
|
||||
if words[2].to_lowercase().contains("ssh"){
|
||||
if !ssh_hosts.contains(&host_entry){
|
||||
ssh_hosts.push(host_entry);
|
||||
}
|
||||
}
|
||||
else if banner.contains("ftp"){
|
||||
if !ftp_hosts.contains(&host_entry){
|
||||
ftp_hosts.push(host_entry);
|
||||
}
|
||||
}
|
||||
else if banner.contains("nginx") || banner.contains("apache"){
|
||||
if !web_hosts.contains(&host_entry){
|
||||
web_hosts.push(host_entry);
|
||||
}
|
||||
}
|
||||
else{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if words.len() == 2{
|
||||
unknown_ports.push(host_entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
println!("is {} where you want to save your files?", outfile.display());
|
||||
if get_user_input("").to_lowercase().contains("n"){
|
||||
outfile.clear();
|
||||
outfile.push(get_user_input("ok, please enter the full path to the folder you want to save them to."));
|
||||
}
|
||||
print!("
|
||||
{} Windows hosts found!
|
||||
{} SSH hosts found!
|
||||
{} FTP hosts found!
|
||||
{} Telnet hosts found!
|
||||
{} SNMP hosts found!
|
||||
{} DNS hosts found!
|
||||
{} RDP hosts found!
|
||||
{} untagged hosts found!
|
||||
", windows_hosts.len(), ssh_hosts.len(), ftp_hosts.len(), telnet_hosts.len(), snmp_hosts.len(), dns_hosts.len(), rdp_hosts.len(), unknown_ports.len());
|
||||
println!("lines parsed! creating output files...");
|
||||
outfile.push("windows_hosts.txt");
|
||||
let file_option = open_overwrite(&outfile);
|
||||
if file_option.is_some(){
|
||||
let mut windows_file = file_option.unwrap();
|
||||
for host in windows_hosts{
|
||||
let write_res = write!(windows_file, "{}\n", host);
|
||||
if write_res.is_err(){
|
||||
let error = write_res.err().unwrap();
|
||||
println!("oooof error writing windows_hosts.txt!!");
|
||||
println!("{}", error);
|
||||
}
|
||||
else{
|
||||
write_res.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
outfile.pop();
|
||||
outfile.push("ssh_hosts.txt");
|
||||
let file_option = open_overwrite(&outfile);
|
||||
if file_option.is_some(){
|
||||
let mut ssh_file = file_option.unwrap();
|
||||
for host in ssh_hosts{
|
||||
let write_res = write!(ssh_file, "{}\n", host);
|
||||
if write_res.is_err(){
|
||||
let error = write_res.err().unwrap();
|
||||
println!("oooof error writing ssh_hosts.txt!!");
|
||||
println!("{}", error);
|
||||
}
|
||||
else{
|
||||
write_res.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
outfile.pop();
|
||||
outfile.push("telnet_hosts.txt");
|
||||
let file_option = open_overwrite(&outfile);
|
||||
if file_option.is_some(){
|
||||
let mut telnet_file = file_option.unwrap();
|
||||
for host in telnet_hosts{
|
||||
let write_res = write!(telnet_file, "{}\n", host);
|
||||
if write_res.is_err(){
|
||||
let error = write_res.err().unwrap();
|
||||
println!("oooof error writing _hosts.txt!!");
|
||||
println!("{}", error);
|
||||
}
|
||||
else{
|
||||
write_res.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
outfile.pop();
|
||||
outfile.push("ftp_hosts.txt");
|
||||
let file_option = open_overwrite(&outfile);
|
||||
if file_option.is_some(){
|
||||
let mut ftp_file = file_option.unwrap();
|
||||
for host in ftp_hosts{
|
||||
let write_res = write!(ftp_file, "{}\n", host);
|
||||
if write_res.is_err(){
|
||||
let error = write_res.err().unwrap();
|
||||
println!("oooof error writing _hosts.txt!!");
|
||||
println!("{}", error);
|
||||
}
|
||||
else{
|
||||
write_res.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
outfile.pop();
|
||||
outfile.push("snmp_hosts.txt");
|
||||
let file_option = open_overwrite(&outfile);
|
||||
if file_option.is_some(){
|
||||
let mut snmp_file = file_option.unwrap();
|
||||
for host in snmp_hosts{
|
||||
let write_res = write!(snmp_file, "{}\n", host);
|
||||
if write_res.is_err(){
|
||||
let error = write_res.err().unwrap();
|
||||
println!("oooof error writing _hosts.txt!!");
|
||||
println!("{}", error);
|
||||
}
|
||||
else{
|
||||
write_res.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
outfile.pop();
|
||||
outfile.push("dns_hosts.txt");
|
||||
let file_option = open_overwrite(&outfile);
|
||||
if file_option.is_some(){
|
||||
let mut dns_file = file_option.unwrap();
|
||||
for host in dns_hosts{
|
||||
let write_res = write!(dns_file, "{}\n", host);
|
||||
if write_res.is_err(){
|
||||
let error = write_res.err().unwrap();
|
||||
println!("oooof error writing _hosts.txt!!");
|
||||
println!("{}", error);
|
||||
}
|
||||
else{
|
||||
write_res.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
outfile.pop();
|
||||
outfile.push("rdp_hosts.txt");
|
||||
let file_option = open_overwrite(&outfile);
|
||||
if file_option.is_some(){
|
||||
let mut rdp_file = file_option.unwrap();
|
||||
for host in rdp_hosts{
|
||||
let write_res = write!(rdp_file, "{}\n", host);
|
||||
if write_res.is_err(){
|
||||
let error = write_res.err().unwrap();
|
||||
println!("oooof error writing _hosts.txt!!");
|
||||
println!("{}", error);
|
||||
}
|
||||
else{
|
||||
write_res.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
outfile.pop();
|
||||
outfile.push("web_hosts.txt");
|
||||
let file_option = open_overwrite(&outfile);
|
||||
if file_option.is_some(){
|
||||
let mut web_file = file_option.unwrap();
|
||||
for host in web_hosts{
|
||||
let write_res = write!(web_file, "{}\n", host);
|
||||
if write_res.is_err(){
|
||||
let error = write_res.err().unwrap();
|
||||
println!("oooof error writing _hosts.txt!!");
|
||||
println!("{}", error);
|
||||
}
|
||||
else{
|
||||
write_res.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
println!("interesting ports have been written to... writing untagged port files...");
|
||||
outfile.pop();
|
||||
outfile.push("untagged ports");
|
||||
if !outfile.exists(){
|
||||
let untagged_res = create_dir_all(&outfile);
|
||||
if untagged_res.is_err(){
|
||||
let error = untagged_res.err().unwrap();
|
||||
println!("ooof error creating untagged folder!");
|
||||
println!("{}", error);
|
||||
}
|
||||
else{
|
||||
untagged_res.unwrap();
|
||||
}
|
||||
}
|
||||
for line in unknown_ports{
|
||||
let line_vec:Vec<&str> = line.split(":").collect();
|
||||
let host = line_vec[0].to_owned();
|
||||
let port = line_vec[1].to_owned();
|
||||
let file_name = format!("{}_hosts.txt", port);
|
||||
outfile.push(file_name);
|
||||
let write_file_opt = open_append(&outfile);
|
||||
if write_file_opt.is_some(){
|
||||
let mut write_file = write_file_opt.unwrap();
|
||||
let write_res = write!(write_file, "{}\n", host);
|
||||
if write_res.is_err(){
|
||||
let error = write_res.err().unwrap();
|
||||
println!("ooof error writing to file...");
|
||||
println!("{}", error);
|
||||
}
|
||||
}
|
||||
outfile.pop();
|
||||
}
|
||||
println!("DONE all files saved to {}", outfile.display());
|
||||
println!("note if no hosts were found for a protocol their files will be empty.");
|
||||
}
|
||||
@@ -1,252 +1,46 @@
|
||||
use std::collections::HashMap;
|
||||
use std::fs;
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use std::env::home_dir;
|
||||
use std::fs::{File, create_dir_all, remove_dir_all};
|
||||
use std::io::{read_to_string, Read};
|
||||
use std::io::Write;
|
||||
use std::io::stdin;
|
||||
use std::io::copy;
|
||||
use std::process::Command;
|
||||
use std::time::Duration;
|
||||
use reqwest::blocking::get;
|
||||
use std::path::PathBuf;
|
||||
use std::process;
|
||||
use std::{path::Path, path::PathBuf};
|
||||
use std::{process, thread};
|
||||
use std::process::exit;
|
||||
use directories::UserDirs;
|
||||
|
||||
|
||||
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_result = fs::read_to_string("/usr/etc/distrobox/distrobox.conf");
|
||||
if box_config_string_result.is_err(){
|
||||
println!("error reading distrobox config file");
|
||||
}
|
||||
else{
|
||||
let box_rc_file_res = fs::File::create(&dbrcpath);
|
||||
if box_rc_file_res.is_err(){
|
||||
println!("error creating {}", &dbrcpath.display());
|
||||
}
|
||||
else{
|
||||
let mut box_rc_file = box_rc_file_res.unwrap();
|
||||
let box_config_string = box_config_string_result.unwrap();
|
||||
let box_config_lines: Vec<&str> = box_config_string.split("\n").collect();
|
||||
let mut line_write_result = true;
|
||||
while line_write_result{
|
||||
for line in &box_config_lines{
|
||||
let mut _outline = String::new();
|
||||
if line.contains("container_always_pull"){
|
||||
_outline = "container_always_pull=\"0\"".to_owned();
|
||||
}
|
||||
else{
|
||||
_outline = line.to_string();
|
||||
}
|
||||
let box_rc_file_result = box_rc_file.write(_outline.as_bytes());
|
||||
if box_rc_file_result.is_ok(){
|
||||
box_rc_file_result.unwrap();
|
||||
line_write_result = true;
|
||||
}
|
||||
else{
|
||||
line_write_result = false;
|
||||
}
|
||||
}
|
||||
if line_write_result == false{
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
else{
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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\"
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
use crate::get_user_input;
|
||||
|
||||
|
||||
pub fn install(config_path: &PathBuf){
|
||||
let mut _terminal_commands = HashMap::from([
|
||||
("konsole", "konsole -e !!!"),
|
||||
("kde", "konsole -e !!!"),
|
||||
("plasma", "konsole -e !!!"),
|
||||
("gnome", "gnome-terminal -- bash !!!"),
|
||||
("xfce", "xfce4-terminal --execute '!!!'"),
|
||||
("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 mut vault_name = String::new();
|
||||
let folders = vec![¤t_projects, ¤t_notes, &upcoming_projects, &upcoming_notes, &tools];
|
||||
let mut config_folder_path: PathBuf = config_path.clone();
|
||||
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 bell_file_path = config_folder_path.clone();
|
||||
let del_on_fail = config_folder_path.clone();
|
||||
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");
|
||||
let bell_sound_url = "https://github.com/Pyro57000/pentest_tool/raw/refs/heads/main/resources/bell.mp3";
|
||||
let response = get(bell_sound_url).unwrap();
|
||||
@@ -254,102 +48,230 @@ pub fn install(config_path: &PathBuf){
|
||||
let mut bell_file = File::create(bell_file_path).unwrap();
|
||||
copy(&mut response.take(response_length), &mut bell_file).unwrap();
|
||||
println!("bell notification tone sucessfully downloaded!");
|
||||
let mut config_file = fs::File::create(config_path).expect("error creating file");
|
||||
let mut projects_conf_file = fs::File::create(projects_conf_path).expect("error creating projects config file");
|
||||
projects_conf_file.write_all(b"customer:name:notes:files:active:box_name:stage\n").expect("error writing default project info");
|
||||
let mut terminal_response = String::new();
|
||||
let mut template_name = String::new();
|
||||
let mut have_template = String::new();
|
||||
println!("terminal you use? (example: konsole, xfce, gnome, etc)");
|
||||
std::io::stdin().read_line(&mut terminal_response).unwrap();
|
||||
let mut _terminal_command = String::new();
|
||||
if terminal_response.contains("konsole"){
|
||||
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);
|
||||
println!("creating new folders if needed...");
|
||||
for folder in &folders{
|
||||
if !Path::exists(folder){
|
||||
let create_res = create_dir_all(folder);
|
||||
if create_res.is_err(){
|
||||
let error = create_res.err().unwrap();
|
||||
println!("error creating folder {}", folder.display());
|
||||
println!("{}", error);
|
||||
println!("you'll need to create this manually after the install is done!");
|
||||
folder_creation = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
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{
|
||||
println!("no exiting distroboxes created!");
|
||||
println!("let's make one!");
|
||||
template_box_name = get_user_input("name of the distrobox you want to create?");
|
||||
println!("review images listed here: https://distrobox.it/compatibility/#containers-distros");
|
||||
let box_image = get_user_input("image you want to base the template box on?");
|
||||
let template_box_create_res = Command::new("distrobox")
|
||||
.arg("create")
|
||||
.arg("--root")
|
||||
.arg("--image")
|
||||
.arg(&box_image)
|
||||
.arg("--name")
|
||||
.arg(&template_box_name)
|
||||
.arg("--init")
|
||||
.arg("--volume")
|
||||
.arg(&tool_volume)
|
||||
.status();
|
||||
if template_box_create_res.is_err(){
|
||||
let error = template_box_create_res.err().unwrap();
|
||||
println!("error creating template box!");
|
||||
println!("{}", error);
|
||||
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{
|
||||
template_box_create_res.unwrap();
|
||||
}
|
||||
}
|
||||
let mut cracking_rig = String::from("nobody@nothing");
|
||||
let mut rockyou = String::from("n/a");
|
||||
let mut rule = String::from("n/a");
|
||||
let cracking_rig_response = get_user_input("do you have a separate machine to crack passwords on? (not the ambush cracking rig)");
|
||||
if cracking_rig_response.to_lowercase().contains("y"){
|
||||
let rig_ip = get_user_input("ip address or hostname of your cracking rig?");
|
||||
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);
|
||||
}
|
||||
else{
|
||||
println!("ok free loader");
|
||||
}
|
||||
let fingerprint = get_user_input("will you be using fingerprint authentication for your distroboxes?").to_lowercase();
|
||||
let mut terminal = String::new();
|
||||
for desktop in _terminal_commands.keys(){
|
||||
println!("{}", desktop);
|
||||
}
|
||||
let desktop_response = get_user_input("do you use any of these desktops?").to_lowercase();
|
||||
if desktop_response.contains("y"){
|
||||
let default_response = get_user_input("do you use the default terminal for your desktop?").to_lowercase();
|
||||
if default_response.contains("y"){
|
||||
let de = get_user_input("which desktop do you use?");
|
||||
terminal = _terminal_commands[&de.as_str()].to_owned();
|
||||
}
|
||||
}
|
||||
else{
|
||||
_terminal_command = _terminal_commands[terminal_response.trim_end()].to_owned();
|
||||
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");
|
||||
println!("for example for konsole you'd enter");
|
||||
println!("konsole -e !!!");
|
||||
terminal = get_user_input("");
|
||||
}
|
||||
let (files_response, notes_response, tools_response, project_folder_path, project_note_path, cracking_rig, cracking_user, rockyou, rule) = setup_folders(&config_path);
|
||||
print!("
|
||||
This tool is mainly to handle distrobox creation and usage.
|
||||
It's expecting you to have a distrobox that you will use as a template.
|
||||
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!("please set up a distrobox with root as a template and re-run this tool");
|
||||
println!("example distrobox setup command:");
|
||||
println!("distrobox create --root --image archlinux --name template");
|
||||
println!("then enter that distrobox and install all the tools you want and do what ever setup you need");
|
||||
println!("and re-run this tool.");
|
||||
process::Command::new("rm").arg(del_on_fail).spawn().expect("ERROR deleting config folder, please manually clean up");
|
||||
std::process::exit(1);
|
||||
if terminal.contains("konsole"){
|
||||
println!("do you use a specific profile for your attack boxes?");
|
||||
println!("this is pretty specific to Pyro's setup, so you probably don't");
|
||||
if get_user_input("").to_lowercase().contains("y"){
|
||||
let profile_name = get_user_input("what is the name of your profile?");
|
||||
terminal = format!("konsole --profile {}", profile_name);
|
||||
}
|
||||
}
|
||||
let _list = process::Command::new("distrobox").arg("list").arg("--root").status();
|
||||
println!("distrobox template name?");
|
||||
std::io::stdin().read_line(&mut template_name).unwrap();
|
||||
let config_string = format!("Project_files:{}\nProject_notes:{}\ntools_folder:{}\nupcoming_files:{}\nupcoming_notes:{}\nbox_template:{}\nterminal:{}\ncracking_rig:{}@{}\nrockyou_location:{}\nrule_location:{}", 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());
|
||||
config_file.write_all(config_string.as_bytes()).expect("error writing to config file");
|
||||
let default_projectline = format!("default:default:{}:{}:yes:{}:current", ¬es_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");
|
||||
println!("active project folders: {}", &files_response);
|
||||
println!("upcomming project folders: {}", &project_folder_path);
|
||||
println!("active project notes: {}", ¬es_response);
|
||||
println!("upcomming prjoect notes: {}", &project_note_path);
|
||||
println!("tools folder: {}", &tools_response);
|
||||
println!("distrobox template: {}", &template_name);
|
||||
println!("terminal command: {}", &_terminal_command);
|
||||
println!("config file generated and saved to {}\n", config_path.display());
|
||||
|
||||
|
||||
let config_path = &config_folder_path.clone();
|
||||
let mut install_path = config_path.clone();
|
||||
let mut password_spray_template_path = install_path.clone();
|
||||
install_path.push("new_projects.conf");
|
||||
password_spray_template_path.push("passwordspray.md");
|
||||
let pass_file_config_line = format!("\npass_file:{}", password_spray_template_path.display());
|
||||
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, "
|
||||
- [ ] 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!").expect("error writing password spray template");
|
||||
configure_distrobox();
|
||||
std::process::exit(0);
|
||||
println!("many of the fuctions of this tool assume you're using obsidian or some other markdown editor for note taking");
|
||||
let obsidian_used = get_user_input("do you use obsidian for your notes?");
|
||||
if obsidian_used.to_lowercase().contains("y"){
|
||||
vault_name = get_user_input("the name of the vault you're going to use?");
|
||||
}
|
||||
let configuration_string = format!("
|
||||
Project_files:{}
|
||||
Project_notes:{}
|
||||
tools_folder:{}
|
||||
upcoming_files:{}
|
||||
upcoming_notes:{}
|
||||
box_template:{}
|
||||
terminal:{}
|
||||
cracking_rig:{}
|
||||
rockyou_location:{}
|
||||
rule_location:{}
|
||||
pass_file:{}
|
||||
fingerprint:{}
|
||||
vault_name:{}"
|
||||
, ¤t_projects.display(), ¤t_notes.display(), &tools.display(), &upcoming_projects.display(), &upcoming_notes.display(), &template_box_name, &terminal, cracking_rig, rockyou, rule, &password_path.display(), fingerprint, &vault_name);
|
||||
println!("cool everything, all folders and settings have been entered, now let's save this to a config file...");
|
||||
thread::sleep(Duration::from_secs(3));
|
||||
let mut config_file_res = File::create_new(config_path);
|
||||
if config_file_res.is_err(){
|
||||
println!("ooof error creating configuration file...");
|
||||
println!("try creating it manually.");
|
||||
println!("copy the following configuration and save it to {}", config_path.display());
|
||||
print!("{}\n", configuration_string);
|
||||
exit(1);
|
||||
}
|
||||
let mut config_file = config_file_res.unwrap();
|
||||
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(){
|
||||
let error = project_conf_res.err().unwrap();
|
||||
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", ¤t_notes.display(), ¤t_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", ¤t_notes.display(), ¤t_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 mut 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_write_res.is_err(){
|
||||
println!("error writing password file");
|
||||
exit(1);
|
||||
}
|
||||
password_write_res.unwrap();
|
||||
println!("install completed successfully!");
|
||||
println!("re-run this to launch!");
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
use std::{io::stdin, path::PathBuf};
|
||||
use std::{io::stdin, path::PathBuf, process::Command};
|
||||
use directories::UserDirs;
|
||||
use reqwest::Response;
|
||||
use std::fs;
|
||||
use std::process::exit;
|
||||
use std::fs::{self, File};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Project{
|
||||
@@ -22,6 +23,34 @@ mod box_controls;
|
||||
mod info_controls;
|
||||
mod start_pentest;
|
||||
|
||||
pub fn open_overwrite(path: &PathBuf) -> Option<File>{
|
||||
let file_create_res = fs::OpenOptions::new().create(true).write(true).open(path);
|
||||
if file_create_res.is_err(){
|
||||
let error = file_create_res.err().unwrap();
|
||||
println!("error opening {} file!", path.display());
|
||||
println!("{}", error);
|
||||
return None;
|
||||
}
|
||||
else {
|
||||
let file = file_create_res.unwrap();
|
||||
return Some(file);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn open_append(path: &PathBuf) -> Option<File>{
|
||||
let file_create_res = fs::OpenOptions::new().create(true).append(true).open(path);
|
||||
if file_create_res.is_err(){
|
||||
let error = file_create_res.err().unwrap();
|
||||
println!("error opening {} file!", path.display());
|
||||
println!("{}", error);
|
||||
return None;
|
||||
}
|
||||
else {
|
||||
let file = file_create_res.unwrap();
|
||||
return Some(file);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_user_input(prompt: &str) -> String{
|
||||
let mut response = String::new();
|
||||
loop{
|
||||
@@ -60,8 +89,23 @@ fn main() {
|
||||
⠀⠀⠀⠀⢿⡉⠳⡟⣸⠃⠀⠀⠀⠘⢷⣌⠉⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||
⠀⠀⠀⠀⠀⠙⢦⣴⠏⠀⠀⠀⠀⠀⠀⠉⠳⠶⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||
");
|
||||
let user_dirs = UserDirs::new().expect("error getting user directories");
|
||||
let mut config_path = user_dirs.home_dir().to_path_buf();
|
||||
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);
|
||||
@@ -77,6 +121,8 @@ fn main() {
|
||||
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();
|
||||
@@ -95,6 +141,8 @@ fn main() {
|
||||
"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])
|
||||
}
|
||||
}
|
||||
@@ -114,5 +162,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, &upcoming_files, &upcoming_notes, &pass_spray_file);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
use std::clone;
|
||||
use std::path;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::process::exit;
|
||||
use chrono::Datelike;
|
||||
@@ -34,12 +31,27 @@ 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, upcoming_files: &PathBuf, upcoming_notes: &PathBuf, password_spray_file: &PathBuf){
|
||||
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: &PathBuf, upcoming_notes: &PathBuf, password_spray_file: &PathBuf, fingerprint: bool, vault_name: String){
|
||||
let mut loopize = true;
|
||||
let mut new_id = next_project_id(&config_path);
|
||||
let mut threads = Vec::new();
|
||||
let mut threads = Vec::new();
|
||||
loop {
|
||||
let active_project = get_active_project(&projects);
|
||||
let mut notes_folder_string = format!("{}", &active_project.notes_folder.display());
|
||||
let mut obsidian_folder_vec = PathBuf::new();
|
||||
let mut reached_vault_folder = false;
|
||||
for folder in notes_folder_string.split("/").collect::<Vec<&str>>(){
|
||||
if !folder.contains(&vault_name){
|
||||
reached_vault_folder = true;
|
||||
obsidian_folder_vec.push(folder);
|
||||
}
|
||||
else{
|
||||
if reached_vault_folder{
|
||||
obsidian_folder_vec.push(folder);
|
||||
}
|
||||
}
|
||||
}
|
||||
let obsidian_uri = format!("obsidian://open?vault={}&file={}", vault_name, obsidian_folder_vec.display().to_string().replace("/", "%2F"));
|
||||
let mut response = String::new();
|
||||
let now = Local::now();
|
||||
let month = now.month();
|
||||
@@ -101,25 +113,26 @@ pub fn main_menu(mut projects: Vec<Project>, config_path: PathBuf, base_files: &
|
||||
|
||||
|
||||
|
||||
NOTE OPTION 18 WILL SAVE YOUR PROJECTS BEFORE QUITTING
|
||||
NOTE OPTION 28 WILL SAVE YOUR PROJECTS BEFORE QUITTING
|
||||
|
||||
base prject folder: {}
|
||||
upcoming project folder: {}
|
||||
Current Project: {} {}
|
||||
Working Folder: {}
|
||||
Notes Folder: {}
|
||||
Obsidian_uri: {}
|
||||
Box Name: {}
|
||||
Terminal Command: {}
|
||||
Current Season: {}
|
||||
Year: {}
|
||||
General Notes: {}
|
||||
|
||||
Main Menu:
|
||||
1 .) Show Active Project
|
||||
2 .) List Projects
|
||||
3 .) Switch Active Project
|
||||
4 .) create new project with Pyro's default tool
|
||||
4 .) create new project with Pyro's default layout
|
||||
5 .) Save Project Information
|
||||
6 .) Import New Project - and setup new Distrobox
|
||||
6 .) Import New Project to Current projects list - and setup new Distrobox
|
||||
7 .) Remove Project
|
||||
8 .) Print upcoming projects
|
||||
9. ) promote project from upcoming to current
|
||||
@@ -134,12 +147,15 @@ Year: {}
|
||||
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);
|
||||
21.) parse a cs portscan services.tsv file
|
||||
22.) Stop All Distroboxes
|
||||
23.) Password Spray (will print password to spray, and wait the obervation window time)
|
||||
24.) crack password hashes on your cracking rig
|
||||
25.) Launch bloodhound with the current project's distrobox
|
||||
26.) Parse GatherContacts output file
|
||||
27.) prune unused distroboxes (free up system storage)
|
||||
28.) 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, &obsidian_uri);
|
||||
std::io::stdin().read_line(&mut response).expect("error getting menu input");
|
||||
clear().expect("error clearing screen");
|
||||
match response.as_str().trim_end(){
|
||||
@@ -151,14 +167,14 @@ Year: {}
|
||||
"3" => project_controls::switch_project(&mut projects),
|
||||
"4" => {new_id = new_id + 1; start_pentest::start_pentest(&config_path, &mut projects, new_id, upcoming_files, upcoming_notes, &boxtemplate, password_spray_file)},
|
||||
"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, &upcoming_files, &upcoming_notes)},
|
||||
"6" => {new_id = new_id + 1; project_controls::new_project(&mut projects, &base_files, &base_notes, &tools_dir, &boxtemplate, &config_path, new_id, &upcoming_files, &upcoming_notes, fingerprint)},
|
||||
"7" => project_controls::remove_project(&mut projects, &config_path),
|
||||
"8" => project_controls::print_upcoming_projects(&projects),
|
||||
"9" => project_controls::promote_project(&mut projects, &config_path, base_files, base_notes, tools_dir, &boxtemplate),
|
||||
"9" => project_controls::promote_project(&mut projects, &config_path, base_files, base_notes, tools_dir, &boxtemplate, fingerprint),
|
||||
"10" => box_controls::project_standalone_terminal(active_project.clone(), terminal.clone()),
|
||||
"11" => box_controls::project_inline_terminal(active_project.clone()),
|
||||
"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),
|
||||
"13" => box_controls::make_box(&active_project, &tools_dir, &boxtemplate, false, fingerprint),
|
||||
"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),
|
||||
@@ -166,11 +182,14 @@ Year: {}
|
||||
"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);
|
||||
"21" => info_controls::parse_csportscan(&active_project),
|
||||
"22" => box_controls::stop_all_boxes(&projects),
|
||||
"23" => info_controls::password_spray_help(&active_project, season, lseason, year, &tools_dir, &config_path),
|
||||
"24" => info_controls::crack_hashes(&cracking_rig, &active_project, &terminal, &rockyou, &rule),
|
||||
"25" => {let bloodhound_handle = box_controls::launch_bloodhound_gui(active_project.clone()).unwrap(); threads.push(bloodhound_handle);},
|
||||
"26" => info_controls::partse_gathercontacts(&active_project),
|
||||
"27" => {let prune_thread = box_controls::clean_unused_boxes(&projects, &boxtemplate); if prune_thread.is_some(){threads.push(prune_thread.unwrap());}},
|
||||
"28" => {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();
|
||||
@@ -187,6 +206,8 @@ Year: {}
|
||||
let mut enter = String::new();
|
||||
std::io::stdin().read_line(&mut enter).unwrap();
|
||||
}
|
||||
println!("this will hang until all threads are finished.");
|
||||
println!("make sure to close all programs opened with this menu, like cobalt strike or bloodhound.");
|
||||
for thread in threads{
|
||||
thread.join().unwrap();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ 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;
|
||||
|
||||
@@ -68,7 +67,7 @@ pub fn save_projects(projects: &Vec<Project>, config_path: &PathBuf){
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_project(projects: &mut Vec<Project>, project_dir: &PathBuf, notes_dir: &PathBuf, tools_dir: &PathBuf, boxtemplate: &String, config_path: &PathBuf, new_id: i32, upcoming_files: &PathBuf, upcoming_notes: &PathBuf){
|
||||
pub fn new_project(projects: &mut Vec<Project>, project_dir: &PathBuf, notes_dir: &PathBuf, tools_dir: &PathBuf, boxtemplate: &String, config_path: &PathBuf, new_id: i32, upcoming_files: &PathBuf, upcoming_notes: &PathBuf, fingerprint: bool){
|
||||
let mut new_project_dir = PathBuf::new();
|
||||
let mut new_note_dir = PathBuf::new();
|
||||
let mut existing_folders = String::new();
|
||||
@@ -229,7 +228,7 @@ pub fn new_project(projects: &mut Vec<Project>, project_dir: &PathBuf, notes_dir
|
||||
stage: project_stage.to_owned()
|
||||
};
|
||||
if project_stage.contains("current"){
|
||||
make_box(&new_project, &tools_dir, &boxtemplate, true);
|
||||
make_box(&new_project, &tools_dir, &boxtemplate, true, fingerprint);
|
||||
}
|
||||
projects.push(new_project);
|
||||
save_projects(projects, config_path);
|
||||
@@ -343,7 +342,7 @@ pub fn print_upcoming_projects(projects: &Vec<Project>){
|
||||
}
|
||||
}
|
||||
|
||||
pub fn promote_project(projects: &mut Vec<Project>, config_path: &PathBuf, project_dir: &PathBuf, notes_dir: &PathBuf, tools_dir: &PathBuf, boxtemplate: &String){
|
||||
pub fn promote_project(projects: &mut Vec<Project>, config_path: &PathBuf, project_dir: &PathBuf, notes_dir: &PathBuf, tools_dir: &PathBuf, boxtemplate: &String, fingerprint: bool){
|
||||
let working_projects = projects.clone();
|
||||
for project in &working_projects{
|
||||
if project.stage.contains("upcoming"){
|
||||
@@ -434,7 +433,7 @@ pub fn promote_project(projects: &mut Vec<Project>, config_path: &PathBuf, proje
|
||||
}
|
||||
}
|
||||
thread::sleep(Duration::from_secs(3));
|
||||
make_box(&promoted_project, tools_dir, boxtemplate, true);
|
||||
make_box(&promoted_project, tools_dir, boxtemplate, true, fingerprint);
|
||||
projects_to_save.push(promoted_project);
|
||||
}
|
||||
else{
|
||||
|
||||
Reference in New Issue
Block a user