Create main.rs

This commit is contained in:
Pyro57000
2024-06-11 20:17:22 +00:00
committed by GitHub
parent 6cb42c9625
commit dd29bc66ab

112
initial_recon/src/main.rs Normal file
View File

@@ -0,0 +1,112 @@
use std::fs;
use std::env;
use std::str;
use std::io::Write;
struct Target{
host_address: String,
subdomains: String,
url: String,
ports: Vec<String>,
}
fn get_subdomains(mut targets: Vec<Target>){
let mut loopize = true;
let mut domains: Vec<String> = Vec::new();
while loopize{
let mut domain = String::new();
println!("domain to research? (enter DONE when done)");
std::io::stdin().read_line(&mut domain).unwrap();
if domain.contains("DONE"){
loopize = false;
break
}
domains.push(domain.clone());
}
for domain in domains{
let mut return_string = String::new();
let output = std::process::Command::new("gobuster")
.arg("dns")
.arg("-d")
.arg(domain)
.arg("-w")
.arg("/home/work_folder/FRSecure/hacking_tools/wordlists/SecLists/Discovery/DNS/subdomains-top1million-110000.txt")
.output()
.expect("Error running gobuster command");
return_string.push_str(match str::from_utf8(&output.stdout){Ok(val) => val, Err(_) => panic!("got a non UFT-8 data from it")});
}
}
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() != 4{
print!{"
This program is mean to take the output of nessus and build the notes in obsidian note for you.
export a nessus report as a csv with the default columns selected then point this program at it
USAGE:
inital_recon /path/to/nessus/csv org_name Project_name
"}
}
else{
let mut targets: Vec<Target> = Vec::new();
// pentest notes is the path to your obsidian folder with pentest notes in it
let pentest_notes = "/home/pyro/syncs/work_folder/FRSecure/notes/Hack_Notes/pentest_notes/current";
let company_name = &args[2];
let project_name = &args[3];
let project_folder_path = format!("{}/{}/{}", pentest_notes, company_name,project_name);
let host_notes = format!("{}/{}",project_folder_path, "host_notes.md");
let attack_notes = format!("{}/{}", project_folder_path, "attacks.md");
let nessus_csv = fs::read_to_string(&args[1]).expect("Failed to read nessus file");
let nessus_lines: Vec<&str> = nessus_csv.split("\n").collect();
for line in nessus_lines{
let mut new = false;
if line.len() != 0{
let split_line: Vec<&str> = line.split(",").collect();
let ip = split_line[0];
let port = split_line[2];
for target in &mut targets{
if target.host_address == ip.to_owned(){
let mut new_port = true;
for existing_port in &target.ports{
if port == existing_port{
new_port = false;
}
}
if new_port == true{
target.ports.push(port.to_owned());
}
new = true;
//println!("{}", new);
}
}
if new == false{
//println!("{}", new);
let new_target = Target{host_address: ip.to_owned(), ports: vec!(port.to_owned()), url: "".to_owned(), subdomains: "".to_owned()};
targets.push(new_target);
}
}
}
println!("attempting to create {}", &host_notes);
let mut out_notes = fs::File::create(&host_notes).expect("error creating new notes file");
for target in targets{
writeln!(&mut out_notes, "\n# {}", target.host_address);
write!(&mut out_notes, "Domain Name:
port|service|attack_notes
----|-------|------------- ");
for port in target.ports{
let out_port = port.trim();
if out_port != "0".to_owned(){
write!(&mut out_notes, "
{}|", out_port);
}
}
writeln!(&mut out_notes, "\n\n----");
}
}
}