cleaned up all the warnings so it should compile without any!

This commit is contained in:
Pyro57000
2025-05-28 09:39:02 -05:00
parent 33450cb1ba
commit 6959e77d57
11 changed files with 196 additions and 121 deletions

View File

@@ -74,6 +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");
}
#[allow(unused)]
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();
@@ -236,6 +237,7 @@ pub fn launch_cobalt_strike(project: Project) -> Option<JoinHandle<()>>{
return Some(handle);
}
#[allow(unused)]
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?");

View File

@@ -1,4 +1,3 @@
use std::os::unix::thread;
use std::path::PathBuf;
use std::process::exit;
use std::thread::JoinHandle;
@@ -128,7 +127,7 @@ pub fn next_project_id(config_path: &PathBuf) -> i32{
}
return new_id;
}
#[allow(unused)]
pub fn run_command(cmd: String,
mut projects: &mut Vec<Project>,
config_path: PathBuf,

View File

@@ -1,10 +1,11 @@
use std::{fmt::write, path::PathBuf};
use std::path::PathBuf;
use std::fs::read_to_string;
use std::io::Write;
use crate::{get_user_input, open_overwrite, Project};
use crate::{get_user_input, open_overwrite};
#[allow(unused)]
pub fn generate_tool_config(config_dir: &PathBuf){
let mut config_file_path = config_dir.clone();
println!("{}", config_file_path.display());

View File

@@ -6,15 +6,15 @@ use std::io::Write;
use std::time::Duration;
use dns_lookup::lookup_host;
use crate::get_user_input;
use crate::info_controls::get_scope_entries;
use crate::Project;
use crate::open_append;
#[allow(unused)]
pub fn run_dns_enumeration(project: &Project, given_domains: Option<&Vec<String>>, standalone: bool) -> Option<JoinHandle<()>>{
let notes_folder = project.notes_folder.clone();
let mut enumeration = notes_folder.clone();
enumeration.push("enumeration.md");
let mut enumeration_file_res = open_append(&enumeration);
let enumeration_file_res = open_append(&enumeration);
if enumeration_file_res.is_none(){
println!("error opening enumeration_file!");
println!("try creating it manually.");
@@ -56,7 +56,8 @@ pub fn run_dns_enumeration(project: &Project, given_domains: Option<&Vec<String>
println!("{}", error);
return;
}
//sleep(Duration::from_secs(10));
println!("sleping for 10 seconds to allow for sudo password input.");
sleep(Duration::from_secs(10));
let output_string_res = read_to_string("dns_temp.csv");
if output_string_res.is_err(){
let error = output_string_res.err().unwrap();
@@ -120,6 +121,7 @@ pub fn run_dns_enumeration(project: &Project, given_domains: Option<&Vec<String>
return Some(dns_handle);
}
#[allow(unused)]
pub fn bruteforce_subs(project: &Project, given_domains: Option<&Vec<String>>, given_wordlist: Option<String>, standalone: bool) -> Option<JoinHandle<()>>{
let mut enumeration_path = project.notes_folder.clone();
enumeration_path.push("enumeration.md");
@@ -184,6 +186,8 @@ pub fn bruteforce_subs(project: &Project, given_domains: Option<&Vec<String>>, g
println!("{}", error);
return;
}
println!("sleeping for 10 seconds to allow for sudo password input.");
sleep(Duration::from_secs(10));
let gobuser_output = gobuster_cmd_res.unwrap().stdout;
println!("From Gobuster Thread: Sudomain enumeration Done!");
let gobuster_string = String::from_utf8_lossy(&gobuser_output);
@@ -280,6 +284,8 @@ pub fn dns_squatting(project: &Project, given_domains: Option<&Vec<String>>, sta
println!("{}", error);
return;
}
println!("sleeping for 10 seconds to allow for sudo password input.");
sleep(Duration::from_secs(10));
let twist_output_vec = twist_output.unwrap().stdout;
let output_string = String::from_utf8_lossy(&twist_output_vec);
let output_lines = output_string.split("\n");

View File

@@ -1,28 +1,21 @@
use std::collections::HashMap;
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 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_controls::get_projects;
use crate::Project;
#[allow(unused)]
pub fn run_initial_enum(project: &Project){
#[derive(Clone)]
struct Target {
@@ -101,7 +94,7 @@ pub fn run_initial_enum(project: &Project){
}
}
pub fn build_external_attack_notes(project: &Project){
/*pub fn build_external_attack_notes(project: &Project){
#[derive(Clone)]
struct Port{
service: String,
@@ -173,7 +166,7 @@ pub fn build_external_attack_notes(project: &Project){
write!(attack_file, "\n---\n").expect("since we used the open options already this should never fail.");
}
}
}
}*/
pub fn generate_userpass(project: &Project){
let mut outlines = Vec::new();
@@ -200,7 +193,7 @@ pub fn generate_userpass(project: &Project){
}
}
pub fn open_in_dolphin(folder: &str, project: Project){
/*pub fn open_in_dolphin(folder: &str, project: Project){
let mut to_open = PathBuf::new();
match folder{
"notes" => to_open.push(project.notes_folder),
@@ -210,7 +203,7 @@ pub fn open_in_dolphin(folder: &str, project: Project){
process::Command::new("dolphin")
.arg(to_open)
.spawn().expect("error opening dolphin");
}
}*/
pub fn print_report_information(project: &Project){
let scope = get_scope_entries(project);
@@ -364,6 +357,7 @@ fn nefarious_config(tools_dir: &PathBuf) -> String{
}
}
#[allow(unused)]
fn msolspray_config(tools_dir: &PathBuf) -> String{
let mut msolspray_path = String::new();
let mut outline = String::new();
@@ -451,6 +445,7 @@ fn msolspray_config(tools_dir: &PathBuf) -> String{
return outline;
}
#[allow(unused)]
pub fn password_spray_help(project: &Project, season: String, lseason: String, year: i32, tools_dir: &PathBuf, config_path: &PathBuf){
let mut wait_time:u64 = 0;
let mut wait_time_response = String::new();
@@ -595,7 +590,7 @@ pub fn password_spray_help(project: &Project, season: String, lseason: String, y
}
}
pub fn crack_hashes(cracking_rig: &String, project: &Project, terminal: &String, rockyou: &String, rule: &String){
/*pub fn crack_hashes(cracking_rig: &String, project: &Project, terminal: &String, rockyou: &String, rule: &String){
let mut hash_file = String::new();
println!("trying to automatically find hashes.txt file...");
let find_result = find_file(&project.files_folder, "hashes.txt");
@@ -775,7 +770,7 @@ pub fn get_mssql_column_names(project: &Project) -> Option<JoinHandle<()>>{
}
});
return Some(db_handle);
}
}*/
pub fn partse_gathercontacts(project: &Project){
fn format_names(names: Vec<&str>) -> HashMap<&str, Vec<String>>{
@@ -896,9 +891,9 @@ last
}
}
pub fn get_all_host_addresses(project: &Project){
/*pub fn get_all_host_addresses(project: &Project){
println!("to do");
}
}*/
pub fn get_scope_entries(project: &Project) -> Option<Vec<String>>{
let mut general_path = project.notes_folder.clone();

View File

@@ -1,20 +1,18 @@
use std::collections::HashMap;
use std::fs::{File, create_dir_all, remove_dir_all};
use std::io::{read_to_string, Read};
use std::io::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::Path, path::PathBuf};
use std::{process, thread};
use std::thread;
use std::process::exit;
use directories::UserDirs;
use crate::get_user_input;
#[allow(unused)]
pub fn install(config_path: &PathBuf){
let mut _terminal_commands = HashMap::from([
("kde", "konsole -e !!!"),

View File

@@ -1,6 +1,5 @@
use std::{io::stdin, path::PathBuf, process::Command};
use directories::UserDirs;
use reqwest::Response;
use std::process::exit;
use std::fs::{self, File};

View File

@@ -1,10 +1,11 @@
use std::fs::{self, OpenOptions};
use std::collections::HashMap;
use std::fs;
use std::fs::{read_to_string, create_dir_all};
use std::io::Write;
use std::path::PathBuf;
use std::process::Command;
use chrono::format::format;
use reqwest::blocking::get;
use std::thread::{sleep, spawn, JoinHandle};
use std::time::Duration;
use walkdir::WalkDir;
use crate::get_user_input;
use crate::Project;
@@ -498,8 +499,8 @@ pub fn parse_csportscan(project: &Project){
println!("note if no hosts were found for a protocol their files will be empty.");
}
pub fn run_nmap_portscan(project: &Project){
let files_folder = project.files_folder.clone();
#[allow(unused)]
pub fn run_nmap_portscan(project: &Project) -> Option<JoinHandle<()>>{
let notes_folder = project.notes_folder.clone();
let mut ports_to_scan = vec![String::from("80"), String::from("443"),
String::from("161"),
@@ -516,13 +517,12 @@ pub fn run_nmap_portscan(project: &Project){
String::from("1433"),
String::from("3306"),
String::from("2222"),];
let mut save_path = files_folder.clone();
let mut general_notes = notes_folder.clone();
general_notes.push("general.md");
println!("building targets from scope in general notes...");
let targets_res = info_controls::get_scope_entries(project);
if targets_res.is_none(){
return;
return None;
}
let mut targets = targets_res.unwrap();
println!("Got targets from scope!");
@@ -558,7 +558,7 @@ pub fn run_nmap_portscan(project: &Project){
}
if get_user_input("continue?").to_lowercase().contains("n"){
println!("ok exiting this function, feel free to try again...");
return;
return None;
}
targets = modified_targets;
}
@@ -577,83 +577,168 @@ pub fn run_nmap_portscan(project: &Project){
}
}
}
let proxy = get_user_input("will you be using proxychains for this scan?").to_lowercase();
let proxy = get_user_input("will you be using proxychains for this scan?").to_lowercase().contains("y");
println!("sweet we have what we need!");
println!("building portscan command...");
let port_string = ports_to_scan.join(",");
let hosts_string = targets.join(" ");
let mut scan_results = String::new();
if proxy.contains("y"){
println!("running command, this may take a bit of time...");
let command_res = Command::new("distrobox")
let working_project = project.clone();
let mut save_path = project.files_folder.clone();
save_path.push("working");
if !save_path.exists(){
save_path.clear();
save_path = project.files_folder.clone();
}
save_path.push("services.tsv");
let mut enumeration_notes_path = project.notes_folder.clone();
enumeration_notes_path.push("enumeration.md");
println!("{}", save_path.display());
let mut nmap_output = Vec::new();
let nmap_thread = spawn(move || {
if proxy{
let port_scancmd_res = Command::new("distrobox")
.arg("enter")
.arg("--root")
.arg(project.boxname.to_owned())
.arg(working_project.boxname)
.arg("--")
.arg("proxychains")
.arg("namp")
.arg("nmap")
.arg("-sT")
.arg("-p")
.arg(port_string)
.arg(hosts_string)
.arg(ports_to_scan.join(","))
.arg(targets.join(" "))
.output();
if command_res.is_err(){
let error = command_res.err().unwrap();
println!("error running portscan command!");
if port_scancmd_res.is_err(){
let error = port_scancmd_res.err().unwrap();
println!("FROM NMAP THREAD: error running portscan!");
println!("{}", error);
return;
}
let output = command_res.unwrap().stdout;
scan_results = String::from_utf8_lossy(&output).into_owned();
nmap_output = port_scancmd_res.unwrap().stdout;
}
else{
let command_res = Command::new("distrobox")
let port_scancmd_res = Command::new("distrobox")
.arg("enter")
.arg("--root")
.arg(project.boxname.to_owned())
.arg(working_project.boxname)
.arg("--")
.arg("proxychains")
.arg("namp")
.arg("nmap")
.arg("-sT")
.arg("-p")
.arg(port_string)
.arg(hosts_string)
.arg(ports_to_scan.join(","))
.arg(targets.join(" "))
.output();
if command_res.is_err(){
let error = command_res.err().unwrap();
println!("error running portscan command!");
if port_scancmd_res.is_err(){
let error = port_scancmd_res.err().unwrap();
println!("FROM NMAP THREAD: error running portscan!");
println!("{}", error);
return;
}
let output = command_res.unwrap().stdout;
scan_results = String::from_utf8_lossy(&output).into_owned();
nmap_output = port_scancmd_res.unwrap().stdout;
}
save_path.push("working/nmap_output.txt");
println!("going to save to {}", save_path.display());
if get_user_input("is that ok?").to_lowercase().contains("n"){
save_path.clear();
save_path.push(get_user_input("where do you want to save it then? (full path)"));
println!("FROM NMAP THREAD: nmap scan finished, parsing the results...");
let nmap_output_string = String::from_utf8_lossy(&nmap_output);
let mut nmap_log_path = save_path.clone();
nmap_log_path.pop();
nmap_log_path.push("nmap.log");
let nmap_log_file = open_append(&nmap_log_path);
if nmap_log_file.is_some(){
let mut nmap_log_file = nmap_log_file.unwrap();
write!(nmap_log_file, "{}", nmap_output_string).unwrap();
}
let save_file_res = OpenOptions::new().create(true).append(true).open(save_path);
if save_file_res.is_err(){
let error = save_file_res.err().unwrap();
println!("error opening save file!");
println!("{}", error);
if get_user_input("output results to console?").to_lowercase().contains("y"){
println!("{}", &scan_results);
let mut host_ports = Vec::new();
let host_sections: Vec<&str> = nmap_output_string.split("Nmap scan report ").collect();
for section in host_sections{
let mut host = String::new();
let mut ports = Vec::new();
let lines: Vec<&str> = section.split("\n").collect();
let mut port_section = false;
for line in lines{
if line.contains("for "){
if !line.contains("(not scanned)"){
host = line.split(" ").collect::<Vec<&str>>()[1..].join(" ").to_owned();
}
}
else if line.contains("Host is up"){
port_section = true;
}
else if port_section{
if line.contains("open"){
let words: Vec<&str> = line.split_whitespace().collect();
if words.len() >= 3{
let port = words [0];
let service = words [2];
let port_entry = format!("{}:{}", port, service);
ports.push(port_entry);
}
}
}
}
for port in ports{
let entry_words: Vec<&str> = port.split(":").collect();
let port = entry_words[0];
let service = entry_words[1];
let host_entry = format!("{}\t{}\t{}", host, port, service);
host_ports.push(host_entry);
}
}
let services_file_open_res = open_overwrite(&save_path);
if services_file_open_res.is_none(){
println!("FROM NMAP THREAD: error opening the services.tsv file to write!");
println!("FROM NMAP THREAD: exiting");
return;
}
let mut save_file = save_file_res.unwrap();
let write_res = write!(save_file, "{}", scan_results);
if write_res.is_err(){
let error = write_res.err().unwrap();
println!("error writing results to file!");
let mut services_file = services_file_open_res.unwrap();
let enumeration_open_res = open_append(&enumeration_notes_path);
if enumeration_open_res.is_none(){
println!("error opening enumeration notes file!");
println!("scan data will not be saved to enumeration notes!");
}
let services_write_res = write!(services_file, "host\tport\tbanner\tnotes\n");
if services_write_res.is_err(){
let error = services_write_res.err().unwrap();
println!("FROM NMAP THREAD: error writing to the services.tsv file!");
println!("{}", error);
if get_user_input("print results to console instead?").to_lowercase().contains("y"){
println!("{}", scan_results);
return;
}
let mut enumeration_write = false;
if enumeration_open_res.is_some(){
enumeration_write = true;
}
let mut host_all_ports: HashMap<String, Vec<String>> = HashMap::new();
for host in &host_ports{
write!(services_file, "{}\n", host).unwrap();
let host_data: Vec<&str> = host.split_whitespace().collect();
let address = host_data[0].to_owned();
let port = host_data[1].to_owned();
let service = host_data[2..].join(" ");
if host_all_ports.contains_key(&address){
host_all_ports.get_mut(&address).unwrap().push(format!("{}:{}", port, service));
}
else {
host_all_ports.insert(address, vec![format!("{}:{}", port, service)]);
}
}
if enumeration_write{
let mut enumeration_file = enumeration_open_res.unwrap();
let write_res = write!(enumeration_file, "\n# Port Scan\n");
if write_res.is_ok(){
write_res.unwrap();
for host in host_all_ports.keys(){
write!(enumeration_file, "## {}\n| HOST | PORT | SERVICE |\n| ---- | ---- | ------- |\n", host).unwrap();
for port_entry in &host_all_ports[host]{
println!("{}", port_entry);
let parts: Vec<&str> = port_entry.split(":").collect();
let port = parts[0];
let services = parts[1];
write!(enumeration_file, "| {} | {} |\n", port, services).unwrap();
}
}
write!(enumeration_file, "---\n").unwrap();
}
}
println!("FROM NMAP THREAD: Parsing done! You're scan results are saved in cobalt strike services.tsv format at {}", save_path.display());
});
sleep(Duration::from_secs(10));
return Some(nmap_thread);
}
pub fn build_nmap_command(project: &Project){

View File

@@ -68,6 +68,7 @@ pub fn save_projects(projects: &Vec<Project>, config_path: &PathBuf){
}
}
#[allow(unused)]
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();

View File

@@ -75,18 +75,7 @@ Planning call notes:
* password attacks
* password sprays 3-12 hours
* lock out policy -
## Enumeration in progress
### DNS Bruteforcing
| domain name | IP | inscope? |
| ----------- | -- | -------- |
# Attack Surface Enumeration
| IP | host notes | needs? |
| -- | ---------- | ------ |\n").expect("faile to write pentest notes");
|\n").expect("faile to write pentest notes");
}
notes_path.pop();

View File

@@ -1,6 +1,6 @@
use std::path::PathBuf;
use walkdir::WalkDir;
use crate::{get_user_input, Project};
use crate::get_user_input;
pub fn sharp_persist_command(tools_dir: &PathBuf){
let filename = "SharPersist.exe";