Skip to content

Commit 761f71c

Browse files
committed
modified the install to avoid the newlines
in folder names added hash cracking function, though this doesn't work yet...
1 parent 882afe0 commit 761f71c

File tree

4 files changed

+199
-15
lines changed

4 files changed

+199
-15
lines changed

pentest_tool/src/info_controls.rs

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use core::hash;
12
use std::fs;
23
use std::fs::read_to_string;
34
use std::io::BufReader;
@@ -7,6 +8,7 @@ use std::path::PathBuf;
78
use std::process;
89
use std::result;
910
use std::thread;
11+
use std::thread::spawn;
1012
use std::time::Duration;
1113
use std::io::stdin;
1214
use walkdir::WalkDir;
@@ -460,4 +462,127 @@ pub fn password_spray_help(project: &Project, season: String, lseason: String, y
460462
sink.sleep_until_end();
461463
clear().unwrap();
462464
}
465+
}
466+
467+
pub fn crack_hashes(cracking_rig: &String, project: &Project, terminal: &String, rockyou: &String, rule: &String){
468+
let mut hash_file = String::new();
469+
println!("trying to automatically find hashes.txt file...");
470+
let find_result = find_file(&project.files_folder, "hashes.txt");
471+
if find_result.is_some(){
472+
hash_file = find_result.unwrap();
473+
println!("hash file found!");
474+
let mut res = String::new();
475+
println!("is {} the file you want to crack?", hash_file);
476+
match stdin().read_line(&mut res){
477+
Ok(_r) => (),
478+
Err(_e) => {println!("we need input here dummy! returning..."); return;}
479+
}
480+
res = res.to_lowercase();
481+
if res.contains("n"){
482+
println!("ooof ok, where is the file you want then?");
483+
loop{
484+
match stdin().read_line(&mut hash_file){
485+
Ok(_r) => break,
486+
Err(_e) => println!("we need input here dummy! try again...")
487+
}
488+
}
489+
}
490+
if res.contains("y"){
491+
println!("nice! checking for cracking directory...");
492+
let listing_res = process::Command::new("ssh").arg(&cracking_rig).arg("'ls ~'").output();
493+
if listing_res.is_err(){
494+
println!("Error checking for cracking directory!");
495+
println!("Error: {}", listing_res.unwrap_err());
496+
}
497+
else{
498+
let listing_stdout = listing_res.unwrap().stdout;
499+
let listing = String::from_utf8_lossy(&listing_stdout);
500+
if listing.contains("hash_cracking") == false{
501+
println!("no folder found, creating it...");
502+
let mkdir = process::Command::new("ssh").arg(&cracking_rig).arg("'mkdir ~/hash_cracking'").status();
503+
if mkdir.is_err(){
504+
println!("error creating directory! try again...");
505+
println!("Error: {}", mkdir.unwrap_err());
506+
return;
507+
}
508+
}
509+
let scp_arg = format!("'scp {} {}:~/hash_cracking/{}'", &hash_file, cracking_rig, &hash_file);
510+
let scp_res = process::Command::new("ssh").arg(&cracking_rig).arg(scp_arg).status();
511+
if scp_res.is_err(){
512+
println!("error uploading hashes file!");
513+
println!("Error: {}", scp_res.unwrap_err());
514+
return;
515+
}
516+
println!("nice, hach file uploaded! determining correct terminal command...");
517+
let terminal = terminal.split(" ").collect::<Vec<&str>>()[0];
518+
process::Command::new(terminal).arg("-e").arg("ssh").arg(&cracking_rig);
519+
let mut hash_type_res = String::new();
520+
let mut cracking_arg = String::new();
521+
let mut crack_box = String::new();
522+
let mut crack_box_res = String::new();
523+
println!("do you use a distrobox to crack passwords?");
524+
loop{
525+
match stdin().read_line(&mut crack_box_res){
526+
Ok(_r) => break,
527+
Err(_e) => println!("we need input here dummy, try again")
528+
}
529+
}
530+
crack_box_res = crack_box_res.to_lowercase();
531+
if crack_box_res.contains("y"){
532+
println!("What's the distrobox's name?");
533+
loop{
534+
match stdin().read_line(&mut crack_box){
535+
Ok(_r) => break,
536+
Err(_e) => println!("we need input here dummy, try again!")
537+
}
538+
}
539+
}
540+
else{
541+
crack_box = "no".to_owned();
542+
}
543+
544+
if crack_box == "no".to_owned(){
545+
cracking_arg = format!("sudo hashcat -m ||MODE|| -a 0 -r {} /home/{}/hash_cracking/{} {}", rule, cracking_rig.split("@").collect::<Vec<&str>>()[1], &hash_file, &rockyou);
546+
}
547+
else{
548+
cracking_arg = format!("distrobox enter --root {} -- sudo -S hashcat -m ||MODE|| -a 0 -r {} /home/{}/hash_cracking/{} {}", crack_box, rule, cracking_rig.split("@").collect::<Vec<&str>>()[1], &hash_file, &rockyou);
549+
}
550+
loop{
551+
println!("Hash type?");
552+
print!("
553+
1.) kerberos
554+
2.) ntlm
555+
3.) other
556+
");
557+
let _res = stdin().read_line(&mut hash_type_res);
558+
if _res.is_err(){
559+
println!("we need input here dummy! try again...");
560+
}
561+
else{
562+
match hash_type_res.as_str(){
563+
"1\n" => {cracking_arg = cracking_arg.replace("||MODE||", "19700"); break;},
564+
"2\n" => {cracking_arg = cracking_arg.replace("||MODE||", "1000"); break;},
565+
"3\n" => {let mut mode = String::new();
566+
println!("code for the mode you want to use?");
567+
loop{
568+
match stdin().read_line(&mut mode){
569+
Ok(_r) => break,
570+
Err(_e) => println!("we need input here dummy, try again...")
571+
}
572+
}
573+
cracking_arg = cracking_arg.replace("||MODE||", &mode);
574+
break;
575+
},
576+
_ => println!("unknown selection... try again...")
577+
}
578+
}
579+
}
580+
let spaw_res = process::Command::new(terminal).arg("-e").arg("ssh").arg(&cracking_rig).arg(cracking_arg).spawn();
581+
if spaw_res.is_err(){
582+
println!("error spawing new terminal to ssh with!");
583+
println!("ERROR: {}", spaw_res.unwrap_err());
584+
}
585+
}
586+
}
587+
}
463588
}

pentest_tool/src/install.rs

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::process;
1111
use std::process::exit;
1212

1313

14-
fn setup_folders(config_path: &PathBuf) -> (String, String, String, String, String){
14+
fn setup_folders(config_path: &PathBuf) -> (String, String, String, String, String, String, String, String, String){
1515
let mut delete_for_cleanup = config_path.clone();
1616
delete_for_cleanup.pop();
1717
let mut failed = false;
@@ -20,6 +20,10 @@ fn setup_folders(config_path: &PathBuf) -> (String, String, String, String, Stri
2020
let mut upcomming_files_folder = String::new();
2121
let mut upcomming_notes_folder = String::new();
2222
let mut tools_folder = String::new();
23+
let mut cracking_rig = String::new();
24+
let mut cracking_user = String::new();
25+
let mut rockyou = String::new();
26+
let mut rule = String::new();
2327
while new_files_folder.is_empty() || new_notes_folder.is_empty() || tools_folder.is_empty(){
2428
if new_files_folder.is_empty(){
2529
println!("path to save active project files?");
@@ -56,12 +60,62 @@ fn setup_folders(config_path: &PathBuf) -> (String, String, String, String, Stri
5660
Err(_e) => println!("we need input here dummy... We will reprompt on the next loop...")
5761
}
5862
}
63+
if cracking_rig.is_empty(){
64+
let mut have_rig = String::new();
65+
println!("do you have a separate computer that you can ssh into to crack passwords on?");
66+
match stdin().read_line(&mut have_rig){
67+
Ok(_r) => (),
68+
Err(_e) => println!("we need input here dummy, try again...")
69+
}
70+
have_rig = have_rig.to_lowercase();
71+
if have_rig.contains("y"){
72+
println!("excellent! Whats the IP or hostname?");
73+
loop{
74+
match stdin().read_line(&mut cracking_rig){
75+
Ok(_r) => break,
76+
Err(_e) => println!("we need input here dummy, try again...")
77+
}
78+
}
79+
println!("user to ssh as for the cracking rig?");
80+
loop{
81+
match stdin().read_line(&mut cracking_user){
82+
Ok(_r) => break,
83+
Err(_e) => println!("we need input here dummy, try again...")
84+
}
85+
}
86+
println!("Path to rockyou.txt on the cracking rig?");
87+
loop{
88+
match stdin().read_line(&mut rockyou){
89+
Ok(_r) => break,
90+
Err(_e) => println!("we need input here dummyu try again...")
91+
}
92+
}
93+
println!("Path to one rule to rule them all on the cracking rig?");
94+
loop{
95+
match stdin().read_line(&mut rule){
96+
Ok(_r) => break,
97+
Err(_e) => println!("we need input here dummyu try again...")
98+
}
99+
}
100+
}
101+
else if have_rig.contains("n"){
102+
println!("ooof ok freeloader");
103+
cracking_rig = "n".to_owned();
104+
}
105+
}
59106
}
107+
new_files_folder = new_files_folder.trim_end().to_owned();
108+
new_notes_folder = new_notes_folder.trim_end().to_owned();
109+
upcomming_files_folder = upcomming_files_folder.trim_end().to_owned();
110+
upcomming_notes_folder = upcomming_notes_folder.trim_end().to_owned();
111+
tools_folder = tools_folder.trim_end().to_owned();
112+
cracking_rig = cracking_rig.trim_end().to_owned();
113+
cracking_user = cracking_user.trim_end().to_owned();
60114
let new_files_path = PathBuf::from(&new_files_folder);
61115
let new_notes_path = PathBuf::from(&new_notes_folder);
62116
let upcomming_files_path = PathBuf::from(&upcomming_files_folder);
63117
let upcomming_notes_path = PathBuf::from(&upcomming_notes_folder);
64-
let tools_path = PathBuf::from(&tools_folder);
118+
let tools_path = PathBuf::from(&tools_folder.trim_end());
65119
if new_files_path.exists() == false{
66120
println!("active project file folder does not exist, creating...");
67121
match fs::create_dir_all(&new_files_folder){
@@ -106,7 +160,7 @@ fn setup_folders(config_path: &PathBuf) -> (String, String, String, String, Stri
106160
}
107161
exit(1);
108162
}
109-
return (new_files_folder, new_notes_folder, tools_folder, upcomming_files_folder, upcomming_notes_folder);
163+
return (new_files_folder, new_notes_folder, tools_folder, upcomming_files_folder, upcomming_notes_folder, cracking_rig, cracking_user, rockyou, rule);
110164
}
111165

112166

@@ -156,7 +210,7 @@ pub fn install(config_path: &PathBuf){
156210
else{
157211
_terminal_command = _terminal_commands[terminal_response.trim_end()].to_owned();
158212
}
159-
let (files_response, notes_response, tools_response, project_folder_path, project_note_path) = setup_folders(&config_path);
213+
let (files_response, notes_response, tools_response, project_folder_path, project_note_path, cracking_rig, cracking_user, rockyou, rule) = setup_folders(&config_path);
160214
print!("
161215
This tool is mainly to handle distrobox creation and usage.
162216
It's expecting you to have a distrobox that you will use as a template.
@@ -175,7 +229,7 @@ Do you have a distrobox set up to function as your template for all new projects
175229
let _list = process::Command::new("distrobox").arg("list").arg("--root").status();
176230
println!("distrobox template name?");
177231
std::io::stdin().read_line(&mut template_name).unwrap();
178-
let config_string = format!("Project_files:{}\nProject_notes:{}\ntools_folder:{}\nbox_template:{}\nterminal:{}", files_response.trim_end(), notes_response.trim_end(), tools_response.trim_end(),template_name.trim_end(), _terminal_command.trim_end());
232+
let config_string = format!("Project_files:{}\nProject_notes:{}\ntools_folder:{}\nbox_template:{}\nterminal:{}\ncracking_rig:{}@{}\nrockyou_location:{}\nrule_location:{}", files_response.trim_end(), notes_response.trim_end(), tools_response.trim_end(),template_name.trim_end(), _terminal_command.trim_end(), cracking_user.trim_ascii_end(), cracking_rig.trim_end(), rockyou.trim_end(), rule.trim_end());
179233
config_file.write_all(config_string.as_bytes()).expect("error writing to config file");
180234
let default_projectline = format!("default:default:{}:{}:yes:{}", &notes_response.trim_end(), &files_response.trim_end(), &template_name.trim_end());
181235
projects_conf_file.write_all(default_projectline.as_bytes()).expect("error writing default project line");
@@ -195,10 +249,6 @@ Do you have a distrobox set up to function as your template for all new projects
195249
install_path.push("new_projects.conf");
196250
password_spray_template_path.push("passwordspray.md");
197251
let password_spray_template_path = install_path.clone();
198-
let mut conf_file = fs::File::create(install_path).expect("error creating config file");
199-
write!(conf_file, "project_folder_path:{}
200-
project_notes_path:{}
201-
", project_folder_path.trim_end(), project_note_path.trim_end()).expect("error writing config file");
202252
let mut passpray_file = fs::File::create(password_spray_template_path).expect("error creating passwordspray file");
203253
write!(passpray_file, "
204254
- [ ] useraspass

pentest_tool/src/main.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ fn main() {
5353
let mut tools_folder = PathBuf::new();
5454
let mut terminal_command = String::new();
5555
let mut box_template = String::new();
56+
let mut cracking_rig = String::new();
57+
let mut rockyou = String::new();
58+
let mut rule = String::new();
5659
println!("\nconfig already generated\nloading config file...\n");
5760
let settings_string = fs::read_to_string(&config_path).expect("error reading config file");
5861
let settings: Vec<&str> = settings_string.split("\n").collect();
@@ -65,6 +68,9 @@ fn main() {
6568
"tools_folder" => tools_folder.push(setting_vec[1].trim_end()),
6669
"box_template" => box_template = setting_vec[1].trim_end().to_owned(),
6770
"terminal" => terminal_command = setting_vec[1].trim_end().to_owned(),
71+
"cracking_rig" => cracking_rig = setting_vec[1].trim_end().to_owned(),
72+
"rockyou_location" => rockyou = setting_vec[1].trim_ascii_end().to_owned(),
73+
"rule_location" => rule = setting_vec[1].trim_end().to_owned(),
6874
_ => println!("error unknown setting: {}", setting_vec[0])
6975
}
7076
}
@@ -74,12 +80,13 @@ fn main() {
7480
Note Folders: {}
7581
Tools Folder: {}
7682
distrobox template: {}
77-
terminal_command: {}\n
78-
", project_base_folder.display(), project_base_notes.display(), tools_folder.display(), box_template, terminal_command);
83+
terminal_command: {}
84+
cracking_rig: {}\n
85+
", project_base_folder.display(), project_base_notes.display(), tools_folder.display(), box_template, terminal_command, cracking_rig);
7986
println!("loading project configs...");
8087
let projects = project_controls::get_projects(&config_path);
8188
println!("Enter to start main menu");
8289
let mut enter = String::new();
8390
std::io::stdin().read_line(&mut enter).unwrap();
84-
menu::main_menu(projects, config_path, &project_base_folder, &project_base_notes, &tools_folder, box_template, terminal_command);
91+
menu::main_menu(projects, config_path, &project_base_folder, &project_base_notes, &tools_folder, box_template, terminal_command, cracking_rig, rockyou, rule);
8592
}

pentest_tool/src/menu.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn get_active_project(projects: &Vec<Project>) -> &Project{
3131
return active_project
3232
}
3333

34-
pub fn main_menu(mut projects: Vec<Project>, config_path: PathBuf, base_files: &PathBuf, base_notes: &PathBuf, tools_dir: &PathBuf, boxtemplate: String, terminal: String){
34+
pub fn main_menu(mut projects: Vec<Project>, config_path: PathBuf, base_files: &PathBuf, base_notes: &PathBuf, tools_dir: &PathBuf, boxtemplate: String, terminal: String, cracking_rig: String, rockyou: String, rule: String){
3535
let mut loopize = true;
3636
let mut new_id = next_project_id(&config_path);
3737
loop {
@@ -126,7 +126,8 @@ Year: {}
126126
16.) build portscan command from scope in notes
127127
17.) Stop All Distroboxes
128128
18.) Password Spray (will print password to spray, and wait the obervation window time)
129-
19.) Quit Application
129+
19.) crack password hashes on your cracking rig
130+
20.) Quit Application
130131
\n", active_project.customer, active_project.project_name, active_project.files_folder.display(), active_project.notes_folder.display(), active_project.boxname, terminal, season, year);
131132
std::io::stdin().read_line(&mut response).expect("error getting menu input");
132133
clear().expect("error clearing screen");
@@ -152,7 +153,8 @@ Year: {}
152153
"16" => info_controls::build_cs_portscan_cmd(&active_project),
153154
"17" => box_controls::stop_all_boxes(&projects),
154155
"18" => info_controls::password_spray_help(&active_project, season, lseason, year, &tools_dir, &config_path),
155-
"19" => {project_controls::save_projects(&projects, &config_path);
156+
"19" => info_controls::crack_hashes(&cracking_rig, &active_project, &terminal, &rockyou, &rule),
157+
"20" => {project_controls::save_projects(&projects, &config_path);
156158
let mut stop = String::new();
157159
println!("stop all boxes?\ny/n");
158160
std::io::stdin().read_line(&mut stop).unwrap();

0 commit comments

Comments
 (0)