diff --git a/pentest_tool/src/start_pentest.rs b/pentest_tool/src/start_pentest.rs index a0408f5..32fbe8a 100644 --- a/pentest_tool/src/start_pentest.rs +++ b/pentest_tool/src/start_pentest.rs @@ -34,12 +34,18 @@ fn create_note_file(path: &PathBuf) -> Option{ fn external(passtemp: &PathBuf, project: &Project){ // using a pathbuf to create files. let mut notes_path = project.notes_folder.clone(); - notes_path.push("general.md"); - let general_notes_result = fs::File::create(¬es_path); - if general_notes_result.is_err(){ - println!("oof we ran into issues making the general notes! try to creat manually!"); + let mut notes_path = project.notes_folder.clone(); + let file_creation_res = fs::create_dir_all(¬es_path); + if file_creation_res.is_err(){ + let error = file_creation_res.err().unwrap(); + println!("error creating notes folder! {}", error); } - else { + else{ + file_creation_res.unwrap(); + } + notes_path.push("general.md"); + let general_notes_result = create_note_file(¬es_path); + if general_notes_result.is_some(){ let mut general_notes = general_notes_result.unwrap(); // for tagging let project_type = "External"; @@ -86,11 +92,8 @@ Planning call notes: } notes_path.pop(); notes_path.push("attacks.md"); - let attack_notes_result = fs::File::create(¬es_path); - if attack_notes_result.is_err(){ - println!("oof we ran into issues making the general notes! try to creat manually!"); - } - else { + let attack_notes_result = create_note_file(¬es_path); + if attack_notes_result.is_some(){ let mut attack_notes = attack_notes_result.unwrap(); writeln!(&mut attack_notes, "#{} #{} #attack", project.customer, "external").expect("error writing tags on attack notes"); write!(&mut attack_notes," @@ -124,21 +127,15 @@ passwords tried: } notes_path.pop(); notes_path.push("host_notes.md"); - let host_notes_result = fs::File::create(¬es_path); - if host_notes_result.is_err(){ - println!("error creating host notes, try manually!"); - } - else{ + let host_notes_result = create_note_file(¬es_path); + if host_notes_result.is_some(){ let mut host_notes = host_notes_result.unwrap(); writeln!(&mut host_notes, "##{} #{} #host_notes", project.customer, "external").expect("error writing tag lin in host notes"); } notes_path.pop(); notes_path.push("findings.md"); - let findings_notes_result = fs::File::create(notes_path); - if findings_notes_result.is_err(){ - println!("error creating host findings file, try manually!"); - } - else{ + let findings_notes_result = create_note_file(¬es_path); + if findings_notes_result.is_some(){ let mut finding_notes = findings_notes_result.unwrap(); writeln!(&mut finding_notes, "#{} #{} #findings", project.customer, "external").expect("error writing tag line on findings"); } @@ -335,6 +332,12 @@ pub fn start_pentest(config_path: &PathBuf, projects: &mut Vec, id: i32 project_files.push(&project_name); project_notes.push(&customer_name); project_notes.push(&project_name); + println!("Files: {}\nNotes: {}\n\n", project_files.display(), project_notes.display()); + let confirm_response = get_user_input("does this look ok?"); + if confirm_response.to_lowercase().contains("n"){ + println!("oof sorry"); + return; + } let mut working = project_files.clone(); create_project_folder(&mut working, "working"); create_project_folder(&mut working, "writing");