Skip to content

Commit 477ac6e

Browse files
committed
Added logic and settings for enabling fingerprint
authentication within distro box
1 parent fe65240 commit 477ac6e

File tree

5 files changed

+105
-63
lines changed

5 files changed

+105
-63
lines changed

pentest_tool/src/box_controls.rs

Lines changed: 54 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub fn project_inline_terminal(project: Project){
7070
process::Command::new("distrobox").arg("enter").arg("--root").arg(project.boxname).arg("--").arg("script").arg("-a").arg("-B").arg("/pentest/working/terminal.log").status().expect("error opeing konsole");
7171
}
7272

73-
pub fn make_box(project: &Project, tools_dir: &PathBuf, boxtemplate: &String, new: bool){
73+
pub fn make_box(project: &Project, tools_dir: &PathBuf, boxtemplate: &String, new: bool, fingerprint: bool){
7474
println!("stopping template box to ensure we can clone it!");
7575
let stop_result = Command::new("distrobox").arg("stop").arg("--root").arg(boxtemplate).status();
7676
if stop_result.is_err(){
@@ -91,55 +91,68 @@ pub fn make_box(project: &Project, tools_dir: &PathBuf, boxtemplate: &String, ne
9191
}
9292
}
9393
let mut box_name_path = project.files_folder.clone();
94-
let mut box_name = format!("atarchbox_{}", &project.customer);
94+
let box_name = format!("{}_{}", &boxtemplate, &project.customer);
9595
box_name_path.push("boxname");
9696
let mut box_name_file = fs::File::create(box_name_path).expect("Error creating box name file");
9797
box_name_file.write_all(&box_name.as_bytes()).expect("error writing boxname to box file");
9898
let pentest_volume = format!("{}:/pentest:rw", &project.files_folder.display());
9999
let toold_volume = format!("{}:/tools:rw", tools_dir.display());
100-
println!("distrobox create --root --init --clone {} --volume {} --volume {} --name {}", boxtemplate, toold_volume, pentest_volume, box_name);
101-
let distrobox_result = process::Command::new("distrobox")
102-
.arg("create")
103-
.arg("--root")
104-
.arg("--init")
105-
.arg("--unshare-all")
106-
.arg("--clone")
107-
.arg(boxtemplate)
108-
.arg("--volume")
109-
.arg(&toold_volume)
110-
.arg("--volume")
111-
.arg(&pentest_volume)
112-
.arg("--name")
113-
.arg(&box_name)
114-
.status()
115-
.expect("error getting distrobox status");
116-
if distrobox_result.success(){
117-
println!("we made a distrobox oh boy!");
118-
let distrobox_start_result = process::Command::new("distrobox")
119-
.arg("enter")
120-
.arg("--root")
121-
.arg(&box_name)
122-
.arg("--")
123-
.arg("sudo")
124-
.arg("-s")
125-
.arg("ln")
126-
.arg("-sf")
127-
.arg("/pentest/boxname")
128-
.arg("/etc/boxname")
129-
.status()
130-
.expect("error getting response from distrobox start");
131-
if distrobox_start_result.success(){
132-
println!("distrobox was started as well!!!! good job me!");
100+
let mut distrobox_cmd = String::new();
101+
if fingerprint{
102+
println!("creating box with shared volume for fingerprints... note you will still need to set up fingerprint authentication in your distrobox");
103+
println!("\nfor example, you may need to install fprintd and imagemegick on your template box, and set up the pam files to utilize finger print auth");
104+
println!("\nsee https://wiki.archlinux.org/title/Fprint for more information and instructions");
105+
distrobox_cmd = format!("distrobox create --root --init --clone {} --volume {} --volume {} --volume /var/lib/fprint:/var/lib/fprint:rw --name {}", boxtemplate, toold_volume, pentest_volume, box_name);
106+
}
107+
else {
108+
distrobox_cmd = format!("distrobox create --root --init --clone {} --volume {} --volume {} --name {}", boxtemplate, toold_volume, pentest_volume, box_name);
109+
}
110+
println!("{}", distrobox_cmd);
111+
let distrobox_cmd_vec: Vec<&str> = distrobox_cmd.split_whitespace().collect();
112+
let mut distrobox_cmd_build = process::Command::new("distrobox");
113+
let mut first = true;
114+
for word in &distrobox_cmd_vec{
115+
if first == false{
116+
println!("adding {} as an argument for the creation command...", word);
117+
distrobox_cmd_build.arg(word);
133118
}
134119
else{
135-
println!("ooof did not start successfully try entering it yoruself");
136-
println!("distrobox enter --rrot {} -- sudo -s ln -sf /pentest/boxname /etc/boxname", &box_name);
120+
first = false;
137121
}
138122
}
139-
else{
140-
println!("ooof distrobox did not work.... try creating it yourself");
141-
println!("distrobox create --root --clone {} --volume {} --volume {} --name {}", boxtemplate, &toold_volume, &pentest_volume, &box_name);
142-
println!("distrobox enter --root {} -- sudo -s ln -sf /pentest/boxname /etc/boxname", &box_name);
123+
let distrobox_result = distrobox_cmd_build.status();
124+
if distrobox_result.is_err(){
125+
println!("oooof we ran into trouble creating your distrobox!!");
126+
println!("try creating it manually!");
127+
println!("{}", distrobox_cmd);
128+
}
129+
else{
130+
if distrobox_result.unwrap().success(){
131+
println!("we made a distrobox oh boy!");
132+
let distrobox_start_result = process::Command::new("distrobox")
133+
.arg("enter")
134+
.arg("--root")
135+
.arg(&box_name)
136+
.arg("--")
137+
.arg("sudo")
138+
.arg("-s")
139+
.arg("ln")
140+
.arg("-sf")
141+
.arg("/pentest/boxname")
142+
.arg("/etc/boxname")
143+
.status();
144+
if distrobox_start_result.is_err(){
145+
println!("ooof did not start successfully try entering it yoruself");
146+
println!("distrobox enter --root {} -- sudo -s ln -sf /pentest/boxname /etc/boxname", &box_name);
147+
}
148+
else if distrobox_start_result.unwrap().success(){
149+
println!("distrobox was started as well!!!! good job me!");
150+
}
151+
else {
152+
println!("ooof did not start successfully try entering it yoruself");
153+
println!("distrobox enter --root {} -- sudo -s ln -sf /pentest/boxname /etc/boxname", &box_name);
154+
}
155+
}
143156
}
144157
}
145158

pentest_tool/src/install.rs

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ use std::io::Read;
55
use std::io::Write;
66
use std::io::stdin;
77
use std::io::copy;
8+
use std::process::Command;
89
use reqwest::blocking::get;
910
use std::path::PathBuf;
1011
use std::process;
1112
use std::process::exit;
1213
use directories::UserDirs;
1314

15+
use crate::get_user_input;
16+
1417

1518
fn setup_folders(config_path: &PathBuf) -> (String, String, String, String, String, String, String, String, String){
1619
let mut delete_for_cleanup = config_path.clone();
@@ -286,18 +289,47 @@ Do you have a distrobox set up to function as your template for all new projects
286289
");
287290
std::io::stdin().read_line(&mut have_template).unwrap();
288291
if have_template.contains("n"){
289-
println!("please set up a distrobox with root as a template and re-run this tool");
290-
println!("example distrobox setup command:");
291-
println!("distrobox create --root --image archlinux --name template");
292-
println!("then enter that distrobox and install all the tools you want and do what ever setup you need");
293-
println!("and re-run this tool.");
294-
process::Command::new("rm").arg(del_on_fail).spawn().expect("ERROR deleting config folder, please manually clean up");
295-
std::process::exit(1);
292+
println!("ooof buddy, should have had that already... no worries, we'll make one now.");
293+
let new_boxname = get_user_input("name for your template box? (for exmaple I use atarchbox cause its my attacking archbox ;-)");
294+
println!("please review the following link to select an image to use for your distrobox");
295+
println!("https://distrobox.it/compatibility/#containers-distros");
296+
let image_name = get_user_input("which image would you like to use?");
297+
let tools_volume =format!("{}:/tools:rw", &tools_response);
298+
let distrobox_create_res = Command::new("distrobox")
299+
.arg("create")
300+
.arg("--root")
301+
.arg("--name")
302+
.arg(new_boxname)
303+
.arg("--init")
304+
.arg("--image")
305+
.arg(image_name)
306+
.arg("--volume")
307+
.arg(tools_volume)
308+
.arg("--additional-packages")
309+
.arg("systemd")
310+
.arg("--")
311+
.arg("exit")
312+
.status();
313+
if distrobox_create_res.is_err(){
314+
let error = distrobox_create_res.err().unwrap();
315+
println!("ooof we ran into a problem creating your distrobox....");
316+
println!("{}", error);
317+
println!("you'll have to make it manually, but remember the name you want to use for the next step.");
318+
}
319+
else{
320+
distrobox_create_res.unwrap();
321+
println!("nice, we created a distrobox, remeber the name of your box for the next step!");
322+
}
296323
}
297324
let _list = process::Command::new("distrobox").arg("list").arg("--root").status();
298325
println!("distrobox template name?");
299326
std::io::stdin().read_line(&mut template_name).unwrap();
300-
let config_string = format!("Project_files:{}\nProject_notes:{}\ntools_folder:{}\nupcoming_files:{}\nupcoming_notes:{}\nbox_template:{}\nterminal:{}\ncracking_rig:{}@{}\nrockyou_location:{}\nrule_location:{}", files_response.trim_end(), notes_response.trim_end(), tools_response.trim_end(), &project_folder_path.trim_end(), &project_note_path.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());
327+
let mut set_fprint = String::from("no");
328+
let fprint_answer = get_user_input("do you want to use fingerprint authentication inside the distroboxes?").to_lowercase();
329+
if fprint_answer.contains("y"){
330+
set_fprint = "yes".to_owned();
331+
}
332+
let config_string = format!("Project_files:{}\nProject_notes:{}\ntools_folder:{}\nupcoming_files:{}\nupcoming_notes:{}\nbox_template:{}\nterminal:{}\ncracking_rig:{}@{}\nrockyou_location:{}\nrule_location:{}\nfingerprint:{}", files_response.trim_end(), notes_response.trim_end(), tools_response.trim_end(), &project_folder_path.trim_end(), &project_note_path.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(), set_fprint);
301333
config_file.write_all(config_string.as_bytes()).expect("error writing to config file");
302334
let default_projectline = format!("default:default:{}:{}:yes:{}:current", &notes_response.trim_end(), &files_response.trim_end(), &template_name.trim_end());
303335
projects_conf_file.write_all(default_projectline.as_bytes()).expect("error writing default project line");

pentest_tool/src/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ fn main() {
7777
let mut upcoming_files = PathBuf::new();
7878
let mut upcoming_notes = PathBuf::new();
7979
let mut pass_spray_file = PathBuf::new();
80+
let mut fingerprint = false;
8081
println!("\nconfig already generated\nloading config file...\n");
8182
let settings_string = fs::read_to_string(&config_path).expect("error reading config file");
8283
let settings: Vec<&str> = settings_string.split("\n").collect();
@@ -95,6 +96,7 @@ fn main() {
9596
"rockyou_location" => rockyou = setting_vec[1].trim_end().to_owned(),
9697
"rule_location" => rule = setting_vec[1].trim_end().to_owned(),
9798
"pass_file"=> pass_spray_file.push(setting_vec[1]),
99+
"fingerprint" => {if setting_vec[1].contains("y"){fingerprint = true}},
98100
_ => println!("error unknown setting: {}", setting_vec[0])
99101
}
100102
}
@@ -114,5 +116,5 @@ fn main() {
114116
println!("Enter to start main menu");
115117
let mut enter = String::new();
116118
std::io::stdin().read_line(&mut enter).unwrap();
117-
menu::main_menu(projects, config_path, &project_base_folder, &project_base_notes, &tools_folder, box_template, terminal_command, cracking_rig, rockyou, rule, &upcoming_files, &upcoming_notes, &pass_spray_file);
119+
menu::main_menu(projects, config_path, &project_base_folder, &project_base_notes, &tools_folder, box_template, terminal_command, cracking_rig, rockyou, rule, &upcoming_files, &upcoming_notes, &pass_spray_file, fingerprint);
118120
}

pentest_tool/src/menu.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
use core::time;
2-
use std::clone;
3-
use std::path;
4-
use std::path::Path;
51
use std::path::PathBuf;
62
use std::process::exit;
73
use chrono::Datelike;
8-
use chrono::Duration;
94
use clearscreen::clear;
105
use clearscreen;
116
use chrono::Local;
@@ -36,7 +31,7 @@ fn get_active_project(projects: &Vec<Project>) -> &Project{
3631
return active_project
3732
}
3833

39-
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, upcoming_files: &PathBuf, upcoming_notes: &PathBuf, password_spray_file: &PathBuf){
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, upcoming_files: &PathBuf, upcoming_notes: &PathBuf, password_spray_file: &PathBuf, fingerprint: bool){
4035
let mut loopize = true;
4136
let mut new_id = next_project_id(&config_path);
4237
let mut threads = Vec::new();
@@ -154,14 +149,14 @@ Year: {}
154149
"3" => project_controls::switch_project(&mut projects),
155150
"4" => {new_id = new_id + 1; start_pentest::start_pentest(&config_path, &mut projects, new_id, upcoming_files, upcoming_notes, &boxtemplate, password_spray_file)},
156151
"5" => project_controls::save_projects(&projects, &config_path),
157-
"6" => {new_id = new_id + 1; project_controls::new_project(&mut projects, &base_files, &base_notes, &tools_dir, &boxtemplate, &config_path, new_id, &upcoming_files, &upcoming_notes)},
152+
"6" => {new_id = new_id + 1; project_controls::new_project(&mut projects, &base_files, &base_notes, &tools_dir, &boxtemplate, &config_path, new_id, &upcoming_files, &upcoming_notes, fingerprint)},
158153
"7" => project_controls::remove_project(&mut projects, &config_path),
159154
"8" => project_controls::print_upcoming_projects(&projects),
160-
"9" => project_controls::promote_project(&mut projects, &config_path, base_files, base_notes, tools_dir, &boxtemplate),
155+
"9" => project_controls::promote_project(&mut projects, &config_path, base_files, base_notes, tools_dir, &boxtemplate, fingerprint),
161156
"10" => box_controls::project_standalone_terminal(active_project.clone(), terminal.clone()),
162157
"11" => box_controls::project_inline_terminal(active_project.clone()),
163158
"12" => {let cs_thread = box_controls::launch_cobalt_strike(active_project.clone()); if cs_thread.is_some(){threads.push(cs_thread.unwrap());}},
164-
"13" => box_controls::make_box(&active_project, &tools_dir, &boxtemplate, false),
159+
"13" => box_controls::make_box(&active_project, &tools_dir, &boxtemplate, false, fingerprint),
165160
"14" => info_controls::open_in_dolphin("files", active_project.clone()),
166161
"15" => info_controls::open_in_dolphin("notes", active_project.clone()),
167162
"16" => info_controls::generate_userpass(&active_project),

pentest_tool/src/project_controls.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub fn save_projects(projects: &Vec<Project>, config_path: &PathBuf){
6868
}
6969
}
7070

71-
pub fn new_project(projects: &mut Vec<Project>, project_dir: &PathBuf, notes_dir: &PathBuf, tools_dir: &PathBuf, boxtemplate: &String, config_path: &PathBuf, new_id: i32, upcoming_files: &PathBuf, upcoming_notes: &PathBuf){
71+
pub fn new_project(projects: &mut Vec<Project>, project_dir: &PathBuf, notes_dir: &PathBuf, tools_dir: &PathBuf, boxtemplate: &String, config_path: &PathBuf, new_id: i32, upcoming_files: &PathBuf, upcoming_notes: &PathBuf, fingerprint: bool){
7272
let mut new_project_dir = PathBuf::new();
7373
let mut new_note_dir = PathBuf::new();
7474
let mut existing_folders = String::new();
@@ -229,7 +229,7 @@ pub fn new_project(projects: &mut Vec<Project>, project_dir: &PathBuf, notes_dir
229229
stage: project_stage.to_owned()
230230
};
231231
if project_stage.contains("current"){
232-
make_box(&new_project, &tools_dir, &boxtemplate, true);
232+
make_box(&new_project, &tools_dir, &boxtemplate, true, fingerprint);
233233
}
234234
projects.push(new_project);
235235
save_projects(projects, config_path);
@@ -343,7 +343,7 @@ pub fn print_upcoming_projects(projects: &Vec<Project>){
343343
}
344344
}
345345

346-
pub fn promote_project(projects: &mut Vec<Project>, config_path: &PathBuf, project_dir: &PathBuf, notes_dir: &PathBuf, tools_dir: &PathBuf, boxtemplate: &String){
346+
pub fn promote_project(projects: &mut Vec<Project>, config_path: &PathBuf, project_dir: &PathBuf, notes_dir: &PathBuf, tools_dir: &PathBuf, boxtemplate: &String, fingerprint: bool){
347347
let working_projects = projects.clone();
348348
for project in &working_projects{
349349
if project.stage.contains("upcoming"){
@@ -434,7 +434,7 @@ pub fn promote_project(projects: &mut Vec<Project>, config_path: &PathBuf, proje
434434
}
435435
}
436436
thread::sleep(Duration::from_secs(3));
437-
make_box(&promoted_project, tools_dir, boxtemplate, true);
437+
make_box(&promoted_project, tools_dir, boxtemplate, true, fingerprint);
438438
projects_to_save.push(promoted_project);
439439
}
440440
else{

0 commit comments

Comments
 (0)