fixed the nmap scanning function!
This commit is contained in:
@@ -9,6 +9,9 @@ use dns_lookup::lookup_host;
|
|||||||
use crate::get_user_input;
|
use crate::get_user_input;
|
||||||
use crate::Project;
|
use crate::Project;
|
||||||
use crate::open_append;
|
use crate::open_append;
|
||||||
|
use crate::print_error;
|
||||||
|
use crate::print_success;
|
||||||
|
use crate::print_informational;
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub fn run_dns_enumeration(project: &Project, given_domains: Option<&Vec<String>>, standalone: bool) -> Option<JoinHandle<()>>{
|
pub fn run_dns_enumeration(project: &Project, given_domains: Option<&Vec<String>>, standalone: bool) -> Option<JoinHandle<()>>{
|
||||||
@@ -66,6 +69,7 @@ pub fn run_dns_enumeration(project: &Project, given_domains: Option<&Vec<String>
|
|||||||
println!("{}", error.to_string().red());
|
println!("{}", error.to_string().red());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
print_success("DNS Enumeration Done, Writing to file...");
|
||||||
let output_string = output_string_res.unwrap();
|
let output_string = output_string_res.unwrap();
|
||||||
let lines: Vec<&str> = output_string.split("\n").collect();
|
let lines: Vec<&str> = output_string.split("\n").collect();
|
||||||
let mut out_data = String::new();
|
let mut out_data = String::new();
|
||||||
@@ -110,8 +114,8 @@ pub fn run_dns_enumeration(project: &Project, given_domains: Option<&Vec<String>
|
|||||||
if standalone{
|
if standalone{
|
||||||
out_data.push_str("\n---\n");
|
out_data.push_str("\n---\n");
|
||||||
}
|
}
|
||||||
println!("From DNS Enumeration Thread: Finished gathering data for {} writing to notes...", domain);
|
|
||||||
write!(enumeration_file, "{}", &out_data).unwrap();
|
write!(enumeration_file, "{}", &out_data).unwrap();
|
||||||
|
print_success("DNS Records: Gathered | Notes: Written | DNS Record Thread OUT!");
|
||||||
let remove_res = remove_file("dns_temp.csv");
|
let remove_res = remove_file("dns_temp.csv");
|
||||||
if remove_res.is_err(){
|
if remove_res.is_err(){
|
||||||
println!("From DNS Enumeration Thread: error removing temporay data file!");
|
println!("From DNS Enumeration Thread: error removing temporay data file!");
|
||||||
@@ -129,8 +133,7 @@ pub fn bruteforce_subs(project: &Project, given_domains: Option<&Vec<String>>, g
|
|||||||
let enumeration_file_res = OpenOptions::new().append(true).create(true).open(enumeration_path);
|
let enumeration_file_res = OpenOptions::new().append(true).create(true).open(enumeration_path);
|
||||||
if enumeration_file_res.is_err(){
|
if enumeration_file_res.is_err(){
|
||||||
let error = enumeration_file_res.err().unwrap();
|
let error = enumeration_file_res.err().unwrap();
|
||||||
println!("{}","error opening enumeration notes file!".red());
|
print_error("FROM GOBUSTER THREAD: error opening enumeration notes file!", error.to_string());
|
||||||
println!("{}", error.to_string().red());
|
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let mut enumeration_file = enumeration_file_res.unwrap();
|
let mut enumeration_file = enumeration_file_res.unwrap();
|
||||||
@@ -187,10 +190,10 @@ pub fn bruteforce_subs(project: &Project, given_domains: Option<&Vec<String>>, g
|
|||||||
println!("{}", error.to_string().red());
|
println!("{}", error.to_string().red());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
println!("sleeping for 10 seconds to allow for sudo password input.");
|
print_informational("sleeping for 10 seconds to allow for sudo password input.");
|
||||||
sleep(Duration::from_secs(10));
|
sleep(Duration::from_secs(10));
|
||||||
let gobuser_output = gobuster_cmd_res.unwrap().stdout;
|
let gobuser_output = gobuster_cmd_res.unwrap().stdout;
|
||||||
println!("From Gobuster Thread: Sudomain enumeration Done!");
|
print_success("Gobuster enumeration Done!");
|
||||||
let gobuster_string = String::from_utf8_lossy(&gobuser_output);
|
let gobuster_string = String::from_utf8_lossy(&gobuser_output);
|
||||||
let mut domain_names = Vec::new();
|
let mut domain_names = Vec::new();
|
||||||
let lines: Vec<&str> = gobuster_string.split("\n").collect();
|
let lines: Vec<&str> = gobuster_string.split("\n").collect();
|
||||||
@@ -224,6 +227,7 @@ pub fn bruteforce_subs(project: &Project, given_domains: Option<&Vec<String>>, g
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
write_res.unwrap();
|
write_res.unwrap();
|
||||||
|
print_success("Subdomains: Bruteforced | Enumeration notes: Written | Gobuster thread out!");
|
||||||
});
|
});
|
||||||
return Some(gobuster_thread);
|
return Some(gobuster_thread);
|
||||||
}
|
}
|
||||||
@@ -285,7 +289,7 @@ pub fn dns_squatting(project: &Project, given_domains: Option<&Vec<String>>, sta
|
|||||||
println!("{}", error.to_string().red());
|
println!("{}", error.to_string().red());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
println!("sleeping for 10 seconds to allow for sudo password input.");
|
print_informational("sleeping for 10 seconds to get sudo password.");
|
||||||
sleep(Duration::from_secs(10));
|
sleep(Duration::from_secs(10));
|
||||||
let twist_output_vec = twist_output.unwrap().stdout;
|
let twist_output_vec = twist_output.unwrap().stdout;
|
||||||
let output_string = String::from_utf8_lossy(&twist_output_vec);
|
let output_string = String::from_utf8_lossy(&twist_output_vec);
|
||||||
@@ -301,6 +305,7 @@ pub fn dns_squatting(project: &Project, given_domains: Option<&Vec<String>>, sta
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
print_success("Domains: Squatted | Notes: Written | DNSTwist thread OUT!");
|
||||||
return Some(squatting_thread);
|
return Some(squatting_thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,6 +331,7 @@ pub fn do_all_dns_enumeration(project: &Project) -> Option<JoinHandle<()>>{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let wordlist = get_user_input("path to wordlist for sub domain bruteforcing?");
|
let wordlist = get_user_input("path to wordlist for sub domain bruteforcing?");
|
||||||
|
print_informational("target data gathered. Spawning threads to do enumeration...");
|
||||||
let working_project = project.clone();
|
let working_project = project.clone();
|
||||||
let all_dns_handle = spawn(move ||{
|
let all_dns_handle = spawn(move ||{
|
||||||
let mut write_success = true;
|
let mut write_success = true;
|
||||||
@@ -357,6 +363,7 @@ pub fn do_all_dns_enumeration(project: &Project) -> Option<JoinHandle<()>>{
|
|||||||
}
|
}
|
||||||
write!(enumeration_file, "\n---\n").unwrap();
|
write!(enumeration_file, "\n---\n").unwrap();
|
||||||
}
|
}
|
||||||
|
print_success("All DNS Enum threads finished, notes have been written. DNS Enumeration Thread OUT!");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return Some(all_dns_handle);
|
return Some(all_dns_handle);
|
||||||
|
|||||||
@@ -29,6 +29,19 @@ mod enumeration;
|
|||||||
mod tool_controls;
|
mod tool_controls;
|
||||||
mod configuration;
|
mod configuration;
|
||||||
|
|
||||||
|
pub fn print_error(message: &str ,error: String){
|
||||||
|
println!("{}", message.red());
|
||||||
|
println!("{}", error.red());
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn print_success<T>(message: T) where T: AsRef<str> {
|
||||||
|
println!("{}", message.as_ref().green());
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn print_informational<T>(message: T) where T: AsRef<str>{
|
||||||
|
println!("{}", message.as_ref());
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
if file_create_res.is_err(){
|
if file_create_res.is_err(){
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use std::thread::{sleep, spawn, JoinHandle};
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
use crate::get_user_input;
|
use crate::{get_user_input, print_error, print_informational, print_success};
|
||||||
use crate::Project;
|
use crate::Project;
|
||||||
use crate::open_overwrite;
|
use crate::open_overwrite;
|
||||||
use crate::open_append;
|
use crate::open_append;
|
||||||
@@ -318,7 +318,7 @@ pub fn parse_csportscan(project: &Project){
|
|||||||
outfile.clear();
|
outfile.clear();
|
||||||
outfile.push(get_user_input("ok, please enter the full path to the folder you want to save them to."));
|
outfile.push(get_user_input("ok, please enter the full path to the folder you want to save them to."));
|
||||||
}
|
}
|
||||||
print!("
|
let host_number_results = format!("
|
||||||
{} Windows hosts found!
|
{} Windows hosts found!
|
||||||
{} SSH hosts found!
|
{} SSH hosts found!
|
||||||
{} FTP hosts found!
|
{} FTP hosts found!
|
||||||
@@ -328,7 +328,8 @@ pub fn parse_csportscan(project: &Project){
|
|||||||
{} RDP hosts found!
|
{} RDP hosts found!
|
||||||
{} untagged 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());
|
", 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...");
|
print_success(host_number_results);
|
||||||
|
print_informational("data gathered, writing to notes...");
|
||||||
outfile.push("windows_hosts.txt");
|
outfile.push("windows_hosts.txt");
|
||||||
let file_option = open_overwrite(&outfile);
|
let file_option = open_overwrite(&outfile);
|
||||||
if file_option.is_some(){
|
if file_option.is_some(){
|
||||||
@@ -342,6 +343,7 @@ pub fn parse_csportscan(project: &Project){
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
write_res.unwrap();
|
write_res.unwrap();
|
||||||
|
print_success("windows hosts file written!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -359,6 +361,7 @@ pub fn parse_csportscan(project: &Project){
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
write_res.unwrap();
|
write_res.unwrap();
|
||||||
|
print_success("ssh hosts file written!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -376,6 +379,7 @@ pub fn parse_csportscan(project: &Project){
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
write_res.unwrap();
|
write_res.unwrap();
|
||||||
|
print_success("telnet hosts file written!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -393,6 +397,7 @@ pub fn parse_csportscan(project: &Project){
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
write_res.unwrap();
|
write_res.unwrap();
|
||||||
|
print_success("fpt hosts file written!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -410,6 +415,7 @@ pub fn parse_csportscan(project: &Project){
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
write_res.unwrap();
|
write_res.unwrap();
|
||||||
|
print_success("snmp hosts file written!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -427,6 +433,7 @@ pub fn parse_csportscan(project: &Project){
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
write_res.unwrap();
|
write_res.unwrap();
|
||||||
|
print_success("dns hosts file written!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -444,6 +451,7 @@ pub fn parse_csportscan(project: &Project){
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
write_res.unwrap();
|
write_res.unwrap();
|
||||||
|
print_success("rdp hosts file written!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -461,10 +469,11 @@ pub fn parse_csportscan(project: &Project){
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
write_res.unwrap();
|
write_res.unwrap();
|
||||||
|
print_success("web hosts file written!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println!("interesting ports have been written to... writing untagged port files...");
|
print_informational("tagged port files have been written to, saving untagged ports...");
|
||||||
outfile.pop();
|
outfile.pop();
|
||||||
outfile.push("untagged ports");
|
outfile.push("untagged ports");
|
||||||
if !outfile.exists(){
|
if !outfile.exists(){
|
||||||
@@ -476,6 +485,7 @@ pub fn parse_csportscan(project: &Project){
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
untagged_res.unwrap();
|
untagged_res.unwrap();
|
||||||
|
print_success("untagged port file written!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for line in unknown_ports{
|
for line in unknown_ports{
|
||||||
@@ -496,7 +506,7 @@ pub fn parse_csportscan(project: &Project){
|
|||||||
}
|
}
|
||||||
outfile.pop();
|
outfile.pop();
|
||||||
}
|
}
|
||||||
println!("DONE all files saved to {}", outfile.display());
|
print_success(format!("DONE all files saved to {}", outfile.display()));
|
||||||
println!("note if no hosts were found for a protocol their files will be empty.");
|
println!("note if no hosts were found for a protocol their files will be empty.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -526,7 +536,7 @@ pub fn run_nmap_portscan(project: &Project) -> Option<JoinHandle<()>>{
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let mut targets = targets_res.unwrap();
|
let mut targets = targets_res.unwrap();
|
||||||
println!("Got targets from scope!");
|
print_success("Got targets from scope!");
|
||||||
for target in &targets{
|
for target in &targets{
|
||||||
println!("{}", target);
|
println!("{}", target);
|
||||||
}
|
}
|
||||||
@@ -579,7 +589,16 @@ pub fn run_nmap_portscan(project: &Project) -> Option<JoinHandle<()>>{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let proxy = get_user_input("will you be using proxychains for this scan?").to_lowercase().contains("y");
|
let proxy = get_user_input("will you be using proxychains for this scan?").to_lowercase().contains("y");
|
||||||
println!("sweet we have what we need!");
|
print_success("sweet we have what we need!");
|
||||||
|
print_informational("Targets:");
|
||||||
|
for target in &targets{
|
||||||
|
print_informational(format!("{}", target));
|
||||||
|
}
|
||||||
|
print_informational("\nPorts:");
|
||||||
|
for port in &ports_to_scan{
|
||||||
|
print_informational(format!("{}", port));
|
||||||
|
}
|
||||||
|
print_informational("\n");
|
||||||
println!("building portscan command...");
|
println!("building portscan command...");
|
||||||
let working_project = project.clone();
|
let working_project = project.clone();
|
||||||
let mut save_path = project.files_folder.clone();
|
let mut save_path = project.files_folder.clone();
|
||||||
@@ -591,8 +610,8 @@ pub fn run_nmap_portscan(project: &Project) -> Option<JoinHandle<()>>{
|
|||||||
save_path.push("services.tsv");
|
save_path.push("services.tsv");
|
||||||
let mut enumeration_notes_path = project.notes_folder.clone();
|
let mut enumeration_notes_path = project.notes_folder.clone();
|
||||||
enumeration_notes_path.push("enumeration.md");
|
enumeration_notes_path.push("enumeration.md");
|
||||||
println!("{}", save_path.display());
|
|
||||||
let mut nmap_output = Vec::new();
|
let mut nmap_output = Vec::new();
|
||||||
|
print_informational(format!("{}", ports_to_scan.join(",")));
|
||||||
let nmap_thread = spawn(move || {
|
let nmap_thread = spawn(move || {
|
||||||
if proxy{
|
if proxy{
|
||||||
let port_scancmd_res = Command::new("distrobox")
|
let port_scancmd_res = Command::new("distrobox")
|
||||||
@@ -644,6 +663,7 @@ pub fn run_nmap_portscan(project: &Project) -> Option<JoinHandle<()>>{
|
|||||||
if nmap_log_file.is_some(){
|
if nmap_log_file.is_some(){
|
||||||
let mut nmap_log_file = nmap_log_file.unwrap();
|
let mut nmap_log_file = nmap_log_file.unwrap();
|
||||||
write!(nmap_log_file, "{}", nmap_output_string).unwrap();
|
write!(nmap_log_file, "{}", nmap_output_string).unwrap();
|
||||||
|
print_success("nmap log file written!");
|
||||||
}
|
}
|
||||||
let mut host_ports = Vec::new();
|
let mut host_ports = Vec::new();
|
||||||
let host_sections: Vec<&str> = nmap_output_string.split("Nmap scan report ").collect();
|
let host_sections: Vec<&str> = nmap_output_string.split("Nmap scan report ").collect();
|
||||||
@@ -690,8 +710,7 @@ pub fn run_nmap_portscan(project: &Project) -> Option<JoinHandle<()>>{
|
|||||||
let mut services_file = services_file_open_res.unwrap();
|
let mut services_file = services_file_open_res.unwrap();
|
||||||
let enumeration_open_res = open_append(&enumeration_notes_path);
|
let enumeration_open_res = open_append(&enumeration_notes_path);
|
||||||
if enumeration_open_res.is_none(){
|
if enumeration_open_res.is_none(){
|
||||||
println!("error opening enumeration notes file!");
|
print_error("error opening enumeration notes file!", "".to_owned());
|
||||||
println!("scan data will not be saved to enumeration notes!");
|
|
||||||
}
|
}
|
||||||
let services_write_res = write!(services_file, "host\tport\tbanner\tnotes\n");
|
let services_write_res = write!(services_file, "host\tport\tbanner\tnotes\n");
|
||||||
if services_write_res.is_err(){
|
if services_write_res.is_err(){
|
||||||
@@ -707,10 +726,16 @@ pub fn run_nmap_portscan(project: &Project) -> Option<JoinHandle<()>>{
|
|||||||
let mut host_all_ports: HashMap<String, Vec<String>> = HashMap::new();
|
let mut host_all_ports: HashMap<String, Vec<String>> = HashMap::new();
|
||||||
for host in &host_ports{
|
for host in &host_ports{
|
||||||
write!(services_file, "{}\n", host).unwrap();
|
write!(services_file, "{}\n", host).unwrap();
|
||||||
let host_data: Vec<&str> = host.split_whitespace().collect();
|
let host_data: Vec<&str> = host.split("\t").collect();
|
||||||
|
println!("#####");
|
||||||
|
println!("{}", host);
|
||||||
|
println!("address: {}", host_data[0]);
|
||||||
|
println!("port: {}", host_data[1]);
|
||||||
|
println!("service: {}", host_data[2]);
|
||||||
|
println!("#####");
|
||||||
let address = host_data[0].to_owned();
|
let address = host_data[0].to_owned();
|
||||||
let port = host_data[1].to_owned();
|
let port = host_data[1].to_owned();
|
||||||
let service = host_data[2..].join(" ");
|
let service = host_data[2].to_owned();
|
||||||
if host_all_ports.contains_key(&address){
|
if host_all_ports.contains_key(&address){
|
||||||
host_all_ports.get_mut(&address).unwrap().push(format!("{}:{}", port, service));
|
host_all_ports.get_mut(&address).unwrap().push(format!("{}:{}", port, service));
|
||||||
}
|
}
|
||||||
@@ -730,13 +755,13 @@ pub fn run_nmap_portscan(project: &Project) -> Option<JoinHandle<()>>{
|
|||||||
let parts: Vec<&str> = port_entry.split(":").collect();
|
let parts: Vec<&str> = port_entry.split(":").collect();
|
||||||
let port = parts[0];
|
let port = parts[0];
|
||||||
let services = parts[1];
|
let services = parts[1];
|
||||||
write!(enumeration_file, "| {} | {} |\n", port, services).unwrap();
|
write!(enumeration_file, "| {} | {} | {} |\n", host, port, services).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
write!(enumeration_file, "---\n").unwrap();
|
write!(enumeration_file, "\n---\n").unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println!("FROM NMAP THREAD: Parsing done! You're scan results are saved in cobalt strike services.tsv format at {}", save_path.display());
|
print_success(format!("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));
|
sleep(Duration::from_secs(10));
|
||||||
return Some(nmap_thread);
|
return Some(nmap_thread);
|
||||||
@@ -823,9 +848,9 @@ pub fn build_nmap_command(project: &Project){
|
|||||||
let targets_string = targets.join(" ");
|
let targets_string = targets.join(" ");
|
||||||
println!("\nYour portscan command is:");
|
println!("\nYour portscan command is:");
|
||||||
if get_user_input("will you be using proxychains for this scan?").to_lowercase().contains("y"){
|
if get_user_input("will you be using proxychains for this scan?").to_lowercase().contains("y"){
|
||||||
println!("\n\nproxychains nmap -sT -p {} {} -Pn | tee {}", ports_string, targets_string, save_path.display());
|
print_success(format!("\n\nproxychains nmap -sT -p {} {} -Pn | tee {}", ports_string, targets_string, save_path.display()));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
println!("nmap -p {} {} -Pn | tee {}", ports_string, targets_string, save_path.display());
|
print_success(format!("nmap -p {} {} -Pn | tee {}", ports_string, targets_string, save_path.display()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user