added some functions, note portscanning is borked
still working on it.
This commit is contained in:
@@ -13,6 +13,7 @@ use crate::info_controls;
|
|||||||
use crate::start_pentest;
|
use crate::start_pentest;
|
||||||
use crate::get_user_input;
|
use crate::get_user_input;
|
||||||
use crate::menu;
|
use crate::menu;
|
||||||
|
use crate::portscan_controls;
|
||||||
|
|
||||||
|
|
||||||
fn help(command: Option<String>){
|
fn help(command: Option<String>){
|
||||||
@@ -46,6 +47,7 @@ fn help(command: Option<String>){
|
|||||||
"clear" | "clear screen" | "cls" => {println!("Command:clear\nAliases:clear screen, cls\n\nThis command clears the screen of command output."); return},
|
"clear" | "clear screen" | "cls" => {println!("Command:clear\nAliases:clear screen, cls\n\nThis command clears the screen of command output."); return},
|
||||||
"exit" => {println!("Command:exit\nAliases:(none)\nThis command exits the pentest_tool, it will save all project infomation, and wait for all threads to re-join the main thread before exiting."); return;},
|
"exit" => {println!("Command:exit\nAliases:(none)\nThis command exits the pentest_tool, it will save all project infomation, and wait for all threads to re-join the main thread before exiting."); return;},
|
||||||
"settings" => {println!("\n\nThe settings file is located at ~/.config/pyro_pentest_tool/conf\n\nThe format is setting_name:setting_value.\n\nNeeded settings are\n project_files - the place to store current project files folders\n\n projtect_notes - the place to store current project notes\n\n tools_folder - the place to store custom tools like those downloaded from github\n\n upcoming_files - the place to store upcoming project files folders\n\n upcoming_notes - The place to store upcoming project note files\n\n box_template - the name of the distrobox you want to clone for project boxes\n\n terminal - the command you use to launch a terminal, while running a specific command: Ex: konsole -e \n\n cracking_rig - the user and host you use for a personal cracking rig in the openssh formating: Ex: pyro@cracking_rig or pyro@192.168.1.101 if you do not have a cracking rig the default is @n\n\n rockyou_location - the location on the cracking rig for the rockyou.txt file default is n\n\n rule_location - the location on the cracking rig for the one rule to rule them all file. Default is n\n\n pass_file - this is the location where you store your standard password spray file. If you do not have a custom one this tool provides one. The default is ~/.config/pyro_pentest_tool/passwordspary.md\n\n fingerprint - this is whether you want fingerprint authentication within your distroboxes, takes y/n\n\n vault_name - the name of your obsidian vault, default is notes\n\n"); return;},
|
"settings" => {println!("\n\nThe settings file is located at ~/.config/pyro_pentest_tool/conf\n\nThe format is setting_name:setting_value.\n\nNeeded settings are\n project_files - the place to store current project files folders\n\n projtect_notes - the place to store current project notes\n\n tools_folder - the place to store custom tools like those downloaded from github\n\n upcoming_files - the place to store upcoming project files folders\n\n upcoming_notes - The place to store upcoming project note files\n\n box_template - the name of the distrobox you want to clone for project boxes\n\n terminal - the command you use to launch a terminal, while running a specific command: Ex: konsole -e \n\n cracking_rig - the user and host you use for a personal cracking rig in the openssh formating: Ex: pyro@cracking_rig or pyro@192.168.1.101 if you do not have a cracking rig the default is @n\n\n rockyou_location - the location on the cracking rig for the rockyou.txt file default is n\n\n rule_location - the location on the cracking rig for the one rule to rule them all file. Default is n\n\n pass_file - this is the location where you store your standard password spray file. If you do not have a custom one this tool provides one. The default is ~/.config/pyro_pentest_tool/passwordspary.md\n\n fingerprint - this is whether you want fingerprint authentication within your distroboxes, takes y/n\n\n vault_name - the name of your obsidian vault, default is notes\n\n"); return;},
|
||||||
|
"parse nomral nmap file" | "pnnf" | "parse nmap" | "pn" => {println!("Command:parse normal nmap file\nAliases: pnnf, parse nmap, pn\n\nThis command parses the normal output of an nmap scan (like if you just tee'd or >'d it to a file) and outputs in host:port or int the coablt strike tsv format. It will attempt to find the file within the active project's files folder, and if it can't find the file it will prompt you for input.")},
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,6 +81,7 @@ bloodhound | bh
|
|||||||
parse gather contacts | pgc | parse contacts | pc
|
parse gather contacts | pgc | parse contacts | pc
|
||||||
prune distroboxes | pdb | prune
|
prune distroboxes | pdb | prune
|
||||||
clear | clear screen | cls
|
clear | clear screen | cls
|
||||||
|
parse nomral nmap file | pnnf | parse nmap | pn
|
||||||
help | ? | -h
|
help | ? | -h
|
||||||
")
|
")
|
||||||
}
|
}
|
||||||
@@ -185,6 +188,7 @@ pub fn run_command(cmd: String,
|
|||||||
"bloodhound" | "bh" => {let bloodhound_handle = box_controls::launch_bloodhound_gui(active_project.clone()).unwrap(); return Some(bloodhound_handle);},
|
"bloodhound" | "bh" => {let bloodhound_handle = box_controls::launch_bloodhound_gui(active_project.clone()).unwrap(); return Some(bloodhound_handle);},
|
||||||
"parse gather contacts" | "pgc" | "parse contacts" | "pc" => {info_controls::partse_gathercontacts(&active_project); return None},
|
"parse gather contacts" | "pgc" | "parse contacts" | "pc" => {info_controls::partse_gathercontacts(&active_project); return None},
|
||||||
"prune distroboxes" | "pdb" | "prune" => {let prune_thread = box_controls::clean_unused_boxes(&projects, &boxtemplate); return prune_thread},
|
"prune distroboxes" | "pdb" | "prune" => {let prune_thread = box_controls::clean_unused_boxes(&projects, &boxtemplate); return prune_thread},
|
||||||
|
"parse nomral nmap file" | "pnnf" | "parse nmap" | "pn" => {portscan_controls::parse_normal_nmap_output(&active_project); return None;}
|
||||||
_ => {help(None); println!("\n\n unknown command."); return None;}
|
_ => {help(None); println!("\n\n unknown command."); return None;}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fmt::write;
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::fs::create_dir_all;
|
use std::fs::create_dir_all;
|
||||||
use std::fs::read_to_string;
|
use std::fs::read_to_string;
|
||||||
use std::fs::OpenOptions;
|
use std::fs::OpenOptions;
|
||||||
use std::hash::Hash;
|
|
||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
@@ -14,9 +12,6 @@ use std::thread;
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use std::io::stdin;
|
use std::io::stdin;
|
||||||
use std::thread::JoinHandle;
|
use std::thread::JoinHandle;
|
||||||
use chrono::format;
|
|
||||||
use fs_extra::file;
|
|
||||||
use reqwest::dns::Name;
|
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
use clearscreen::clear;
|
use clearscreen::clear;
|
||||||
use clearscreen;
|
use clearscreen;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::env::home_dir;
|
|
||||||
use std::fs::{File, create_dir_all, remove_dir_all};
|
use std::fs::{File, create_dir_all, remove_dir_all};
|
||||||
use std::io::{read_to_string, Read};
|
use std::io::{read_to_string, Read};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ mod info_controls;
|
|||||||
mod start_pentest;
|
mod start_pentest;
|
||||||
mod cli;
|
mod cli;
|
||||||
mod menu;
|
mod menu;
|
||||||
|
mod portscan_controls;
|
||||||
|
|
||||||
pub fn open_overwrite(path: &PathBuf) -> Option<File>{
|
pub fn open_overwrite(path: &PathBuf) -> Option<File>{
|
||||||
let file_create_res = fs::OpenOptions::new().create(true).write(true).open(path);
|
let file_create_res = fs::OpenOptions::new().create(true).write(true).open(path);
|
||||||
|
|||||||
134
pentest_tool/src/portscan_controls.rs
Normal file
134
pentest_tool/src/portscan_controls.rs
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
use std::fs;
|
||||||
|
use std::io::Write;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use walkdir::WalkDir;
|
||||||
|
use crate::get_user_input;
|
||||||
|
use crate::Project;
|
||||||
|
|
||||||
|
pub fn parse_normal_nmap_output(project: &Project){
|
||||||
|
let mut found_file = false;
|
||||||
|
let mut found_working = false;
|
||||||
|
let mut file_to_parse = PathBuf::new();
|
||||||
|
let mut save_path = PathBuf::new();
|
||||||
|
let files_folder = project.files_folder.clone();
|
||||||
|
println!("scanning files folder for an nmap file...");
|
||||||
|
let walkdir_result = WalkDir::new(files_folder);
|
||||||
|
for entry_res in walkdir_result{
|
||||||
|
if entry_res.is_ok(){
|
||||||
|
let entry = entry_res.unwrap();
|
||||||
|
let entry_name = entry.path().display().to_string();
|
||||||
|
if entry_name.contains("nmap") || entry_name.contains("port scan") || entry_name.contains("proxychains_output"){
|
||||||
|
file_to_parse = entry.into_path();
|
||||||
|
}
|
||||||
|
else if entry.file_type().is_dir(){
|
||||||
|
if entry.file_name().to_ascii_lowercase().to_string_lossy().contains("working"){
|
||||||
|
save_path.push(entry.path());
|
||||||
|
found_working = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found_working{
|
||||||
|
save_path.push(&project.files_folder);
|
||||||
|
}
|
||||||
|
if file_to_parse.display().to_string().len() > 1{
|
||||||
|
println!("we found {}", file_to_parse.display());
|
||||||
|
let res = get_user_input("is the the file you want to parse?");
|
||||||
|
if res.to_lowercase().contains("y"){
|
||||||
|
found_file = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found_file{
|
||||||
|
println!("ooof the right file was not found.");
|
||||||
|
let file_prompt = get_user_input("please enter the full path to the file you want to parse.");
|
||||||
|
file_to_parse.clear();
|
||||||
|
file_to_parse.push(file_prompt);
|
||||||
|
}
|
||||||
|
let file_read_res = fs::read_to_string(file_to_parse);
|
||||||
|
if file_read_res.is_err(){
|
||||||
|
let error = file_read_res.err().unwrap();
|
||||||
|
println!("ooof error reading the file!");
|
||||||
|
println!("{}", error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let nmap_string = file_read_res.unwrap();
|
||||||
|
let sections: Vec<&str> = nmap_string.split("Nmap scan report for").collect();
|
||||||
|
let mut host_ports = Vec::new();
|
||||||
|
for section in sections{
|
||||||
|
let mut host = String::new();
|
||||||
|
for line in section.split("\n").collect::<Vec<&str>>(){
|
||||||
|
if line.contains("."){
|
||||||
|
if !line.contains("latency"){
|
||||||
|
host = line.trim().to_owned();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if line.contains("open"){
|
||||||
|
let port = line.split_whitespace().collect::<Vec<&str>>()[0];
|
||||||
|
host_ports.push(format!("{}:{}", host, port));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println!("done parsing.");
|
||||||
|
if save_path.display().to_string().len() > 1{
|
||||||
|
save_path.push("parsed_namp.txt");
|
||||||
|
println!("default save location is {}", save_path.display());
|
||||||
|
if get_user_input("is this ok?").contains("n"){
|
||||||
|
let user_path = get_user_input("ok where would you like to save it instead?");
|
||||||
|
save_path.clear();
|
||||||
|
save_path.push(user_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
let user_path = get_user_input("where would you like to save the file?");
|
||||||
|
save_path.clear();
|
||||||
|
save_path.push(user_path);
|
||||||
|
}
|
||||||
|
let save_open_res = fs::OpenOptions::new().create(true).append(true).open(&save_path);
|
||||||
|
if save_open_res.is_err(){
|
||||||
|
let error = save_open_res.err().unwrap();
|
||||||
|
println!("oof error opening the save file!");
|
||||||
|
println!("{}", error);
|
||||||
|
if get_user_input("do you want to print the results to the console instead?").to_lowercase().contains("y"){
|
||||||
|
for host in &host_ports{
|
||||||
|
println!("{}", host);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let mut host_port_file = save_open_res.unwrap();
|
||||||
|
save_path.pop();
|
||||||
|
save_path.push("parsed_nmap.tsv");
|
||||||
|
let tsv_open_res = fs::OpenOptions::new().create(true).append(true).open(save_path);
|
||||||
|
if tsv_open_res.is_err(){
|
||||||
|
let error = tsv_open_res.err().unwrap();
|
||||||
|
println!("error opening tsv file!");
|
||||||
|
println!("{}", error);
|
||||||
|
if get_user_input("do you want to print the results to the console instead?").to_lowercase().contains("y"){
|
||||||
|
for host in &host_ports{
|
||||||
|
println!("{}", host);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let mut tsv_file = tsv_open_res.unwrap();
|
||||||
|
for host in &host_ports{
|
||||||
|
let outline = format!("{}\n", host);
|
||||||
|
let split_data: Vec<&str> = host.split(":").collect();
|
||||||
|
let ip = split_data[0];
|
||||||
|
let port_split: Vec<&str> = split_data[1].split("/").collect();
|
||||||
|
let port = port_split[0];
|
||||||
|
let proto = port_split[1];
|
||||||
|
let tsv_outline = format!("{}\t{}\t\t{}\n", ip, port, proto);
|
||||||
|
let host_port_write_res = write!(host_port_file, "{}", outline);
|
||||||
|
let tsv_write_res = write!(tsv_file, "{}", tsv_outline);
|
||||||
|
if host_port_write_res.is_err(){
|
||||||
|
println!("error writing data to file...");
|
||||||
|
}
|
||||||
|
if tsv_write_res.is_err(){
|
||||||
|
println!("error writing data to the tsv file...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user