7 Commits
Author SHA1 Message Date
pyro f621a46954 modified the launch_termianl command to start in the projects files
folder.
2026-09-30 12:41:58 -05:00
pyro b18ada61c7 updated the promote project folder clean up to leave the folders there
if there are still projects.
2026-09-30 11:56:58 -05:00
pyro c2d6174fc9 added scope files to all default note templates. 2026-09-30 10:44:30 -05:00
pyro a37f78a4e7 fixed a bug in the promotion where the folder for the client was not
cleaned out of the upcoming folders.
2026-09-30 10:10:51 -05:00
pyro 7bc5442416 added some install stuff, and started the code for launching odysseus in
the projects distrobox for ai stuff.
2026-09-30 09:41:22 -05:00
pyro 7247e85762 added a step to make sure state infomration is saved before exit, and
updated the parse_scope command to work better.
2026-09-23 11:14:28 -05:00
pyro 0bad1c7b66 added the ability to exclude hosts and net ranges to projects so that
excluded hosts are not touched by the tool.
2026-09-17 13:11:33 -05:00
6 changed files with 215 additions and 18 deletions

No files matched your search

Whitespace-only changes.
View File
Whitespace-only changes.
+162 -14
View File
@@ -32,6 +32,7 @@ use std::sync::{Arc, Mutex, mpsc::Sender, mpsc::channel};
use std::thread; use std::thread;
use std::time::Duration; use std::time::Duration;
use std::time::{self, Instant}; use std::time::{self, Instant};
use trust_dns_resolver::proto::rr::rdata::svcb::SvcParamKey::Port;
use walkdir::WalkDir; use walkdir::WalkDir;
pub struct AppState { pub struct AppState {
@@ -162,6 +163,7 @@ impl AppState {
new_project.load_config(display)?; new_project.load_config(display)?;
let template_box = self.config.get("template_box").unwrap(); let template_box = self.config.get("template_box").unwrap();
let tools = self.config.get("tools").unwrap(); let tools = self.config.get("tools").unwrap();
if template_box != "NONE" || new_project.distrobox {
let db = DistroBox { let db = DistroBox {
name: format!( name: format!(
"{}-{}-{}", "{}-{}-{}",
@@ -178,6 +180,9 @@ impl AppState {
template: template_box.clone(), template: template_box.clone(),
}; };
new_project.db = Some(db); new_project.db = Some(db);
} else {
new_project.db = None;
}
self.projects.push(new_project); self.projects.push(new_project);
} }
} }
@@ -281,6 +286,8 @@ impl AppState {
self.help.push( self.help.push(
"Shortcuts:\nCTRL+P = new_project\nCTRL+s = save\nCTRL_+h = select_host\n".to_string(), "Shortcuts:\nCTRL+P = new_project\nCTRL+s = save\nCTRL_+h = select_host\n".to_string(),
); );
self.help.push("exclude\nexcludes an IP or a cidr network from the scope and all future tool calls.\nexport 192.168.1.1 192.168.2.0/24\n".to_string());
self.help.push("start_odysseus\nstarts the odyssues server in the distrobox of the project.\nUSAGE:\nstart_odysseus port_number\n".to_string());
self.help.push("exit\nquit the tool\n".to_string()); self.help.push("exit\nquit the tool\n".to_string());
self.initialize_modules(); self.initialize_modules();
return Ok(()); return Ok(());
@@ -578,11 +585,24 @@ impl AppState {
let project = self.projects[self.selected_project].clone(); let project = self.projects[self.selected_project].clone();
if let Some(cmd) = self.config.get("term_cmd") { if let Some(cmd) = self.config.get("term_cmd") {
if let Some(db) = project.db { if let Some(db) = project.db {
db.launch_terminal(cmd.to_string()); let _ = self
.main_tx
.send(ToolMessage::Output((rid, format!("launcing distrobox..."))));
db.launch_terminal(
cmd.to_string(),
self.projects[self.selected_project].files.clone(),
);
} else { } else {
if let Some((prog, _)) = cmd.split_once(" ") { if let Some((prog, _)) = cmd.split_once(" ") {
let mut launch_cmd = Command::new(prog); let mut launch_cmd = Command::new(prog);
match launch_cmd.spawn() { launch_cmd.current_dir(&project.files);
if let Some(dir) = launch_cmd.get_current_dir() {
let _ = self.main_tx.send(ToolMessage::Output((
rid,
format!("launcing terminal in {}", dir.display()),
)));
}
match launch_cmd.current_dir(&project.files).spawn() {
Ok(_) => {} Ok(_) => {}
Err(e) => { Err(e) => {
let _ = self.main_tx.send(ToolMessage::Output(( let _ = self.main_tx.send(ToolMessage::Output((
@@ -864,23 +884,52 @@ impl AppState {
} }
"parse_scope" => { "parse_scope" => {
let mut general_path = self.projects[self.selected_project].notes.clone(); let mut general_path = self.projects[self.selected_project].notes.clone();
let mut scope_path = self.projects[self.selected_project].notes.clone();
scope_path.push("scope.md");
general_path.push("general.md"); general_path.push("general.md");
let general_string = read_to_string(general_path)?; let general_string = read_to_string(general_path)?;
if let Some((_, scope_section)) = general_string.split_once("# Scope") { let mut scope_file = OpenOptions::new()
if let Some((scope_section, _)) = scope_section.split_once("#") { .create(true)
scope_section.lines().into_iter().for_each(|line| { .truncate(true)
if line.contains("|") { .write(true)
if !line.contains("Subnet") { .open(scope_path)?;
if !line.contains("--") { general_string
let host = .split_whitespace()
line.split("|").collect::<Vec<&str>>()[1].to_string(); .into_iter()
self.projects[self.selected_project].add_scope(host); .for_each(|word| {
if let Ok(_) = word.trim().parse::<IpNet>() {
if let Err(e) = write!(scope_file, "{}\n", word) {
let _ = self.main_tx.send(ToolMessage::Output((
rid,
format!("Error writing scope file! {e}"),
)));
} }
} else if let Ok(_) = word.trim().parse::<IpAddr>() {
if let Err(e) = write!(scope_file, "{}\n", word) {
let _ = self.main_tx.send(ToolMessage::Output((
rid,
format!("Error writing scope file! {e}"),
)));
}
} else if word.contains(".com")
|| word.contains(".org")
|| word.contains(".gov")
|| word.contains(".site")
|| word.contains(".local")
|| word.contains(".ad")
{
if let Err(e) = write!(scope_file, "{}\n", word) {
let _ = self.main_tx.send(ToolMessage::Output((
rid,
format!("Error writing scope file! {e}"),
)));
} }
} }
}); });
} let _ = self.main_tx.send(ToolMessage::Output((
} rid,
"[success] scope parsed and scope.md written!".to_string(),
)));
} }
"show_config" | "sc" => { "show_config" | "sc" => {
let _ = self let _ = self
@@ -1151,6 +1200,7 @@ impl AppState {
} }
2 => { 2 => {
args_vec[0].split(",").into_iter().for_each(|ip| { args_vec[0].split(",").into_iter().for_each(|ip| {
if !project.exclusions.contains(&ip.to_string()) {
if let Ok(ip) = ip.parse::<IpAddr>() { if let Ok(ip) = ip.parse::<IpAddr>() {
let mut new_host = Host::new(); let mut new_host = Host::new();
new_host.ip = ip.to_string(); new_host.ip = ip.to_string();
@@ -1162,6 +1212,7 @@ impl AppState {
hosts.push(new_host); hosts.push(new_host);
} }
} }
}
}); });
args_vec[1].split(",").into_iter().for_each(|p| { args_vec[1].split(",").into_iter().for_each(|p| {
if p.contains("-") { if p.contains("-") {
@@ -1660,6 +1711,74 @@ impl AppState {
} }
} }
"exclude" => {
if let Some(args) = command_args {
let project = self.projects[self.selected_project].clone();
if args.contains(" ") {
args.split(" ")
.into_iter()
.filter(|ex| !project.exclusions.contains(&ex.to_string()))
.for_each(|ex| {
if let Ok(_) = ex.parse::<IpAddr>() {
self.projects[self.selected_project]
.exclusions
.push(ex.to_string());
} else if let Ok(net) = ex.parse::<IpNet>() {
net.hosts().into_iter().for_each(|ip| {
self.projects[self.selected_project]
.exclusions
.push(ip.to_string());
});
}
});
}
}
}
"start_odysseus" => {
if let Some(args) = command_args {
let working_db = self.projects[self.selected_project].db.clone();
if let Some(db) = working_db {
if let Some(tools_dir) = self.config.get("TOOLS") {
let mut odysseus_path = None;
let entries = WalkDir::new(tools_dir);
entries.into_iter().for_each(|entry| {
if let Ok(entry) = entry {
if entry.file_name().to_string_lossy().contains("odysseus") {
if entry.path().is_dir() {
odysseus_path = Some(entry.into_path());
}
}
}
});
if let Some(path) = odysseus_path {
let tx_clone = self.main_tx.clone();
self.workers.spawn(move||{
let output = db.run_command(format!("cd {}; source venv/bin/activate; python -m uvicorn app:app --host 127.0.0.1 --port {}", path.display(), args.trim()).as_str());
let _ = tx_clone.send(ToolMessage::Output((rid, format!("{}", output))));
});
let _ = self.main_tx.send(ToolMessage::Output((
rid,
"[success] odysseus command ran!".to_string(),
)));
}
}
}
} else {
let _ = self.main_tx.send(ToolMessage::Output((
rid,
"[error] malformed command".to_string(),
)));
let _ = self
.main_tx
.send(ToolMessage::Output((rid, "[error] USAGE:".to_string())));
let _ = self.main_tx.send(ToolMessage::Output((
rid,
"[error] start_odysseus {port number}".to_string(),
)));
}
}
"exit" => { "exit" => {
self.save_all()?; self.save_all()?;
let _ = self.main_tx.send(ToolMessage::AppStateExit); let _ = self.main_tx.send(ToolMessage::AppStateExit);
@@ -1923,6 +2042,7 @@ impl AppState {
} }
} }
let mut db = None; let mut db = None;
let mut distrobx = false;
if template_box != &"NONE".to_string() { if template_box != &"NONE".to_string() {
db = Some(DistroBox { db = Some(DistroBox {
name: format!("{}-{}-{}", template_box, org, name), name: format!("{}-{}-{}", template_box, org, name),
@@ -1934,6 +2054,7 @@ impl AppState {
created: false, created: false,
template: template_box.to_string(), template: template_box.to_string(),
}); });
distrobx = true;
}; };
let mut new_project = Project { let mut new_project = Project {
org_name: org, org_name: org,
@@ -1944,7 +2065,9 @@ impl AppState {
config_folder: project_config_file, config_folder: project_config_file,
current: false, current: false,
db: db, db: db,
distrobox: distrobx,
scope: Vec::new(), scope: Vec::new(),
exclusions: Vec::new(),
}; };
match new_project.save_config() { match new_project.save_config() {
Ok(_) => {} Ok(_) => {}
@@ -1981,8 +2104,24 @@ impl AppState {
rid, rid,
String::from("[success] folders copied!"), String::from("[success] folders copied!"),
)))?; )))?;
let mut old_files = new_project.files.clone();
let mut old_notes = new_project.notes.clone();
old_files.pop();
old_notes.pop();
remove_dir_all(&new_project.files)?; remove_dir_all(&new_project.files)?;
remove_dir_all(&new_project.notes)?; remove_dir_all(&new_project.notes)?;
if let Err(_) = remove_dir(old_files) {
self.main_tx.send(ToolMessage::Output((
rid,
String::from("organization files folder is not empty and will not be deleted."),
)))?;
}
if let Err(_) = remove_dir(old_notes) {
self.main_tx.send(ToolMessage::Output((
rid,
String::from("organization notes folder is not empty and will not be deleted."),
)))?;
}
new_files_path.push(&new_project.name); new_files_path.push(&new_project.name);
new_notes_path.push(&new_project.name); new_notes_path.push(&new_project.name);
new_project.files(new_files_path.clone()); new_project.files(new_files_path.clone());
@@ -1994,9 +2133,13 @@ impl AppState {
)))?; )))?;
self.main_tx.send(ToolMessage::Output(( self.main_tx.send(ToolMessage::Output((
rid, rid,
String::from("creating distrobox..."), String::from("checking if distrobox should be used..."),
)))?; )))?;
if let Some(mut db) = new_project.db { if let Some(mut db) = new_project.db {
self.main_tx.send(ToolMessage::Output((
rid,
String::from("creating distrobox..."),
)))?;
db.volumes = vec![ db.volumes = vec![
new_files_path.display().to_string(), new_files_path.display().to_string(),
new_notes_path.display().to_string(), new_notes_path.display().to_string(),
@@ -2008,6 +2151,11 @@ impl AppState {
rid, rid,
String::from("distrobox sent to rebuild function..."), String::from("distrobox sent to rebuild function..."),
)))?; )))?;
} else {
self.main_tx.send(ToolMessage::Output((
rid,
String::from("Distrobox was not configured at the creation of this project, so no distrobox will be created."),
)))?;
} }
new_project.save_config()?; new_project.save_config()?;
self.projects[self.selected_project] = new_project; self.projects[self.selected_project] = new_project;
+3
View File
@@ -1086,6 +1086,9 @@ pub fn run_tui(
server_lock.action_que.push("disconnect".to_string()); server_lock.action_que.push("disconnect".to_string());
} }
}); });
println!("saving state information");
let _ = state.save_all();
println!("SAVED!");
for handle in handles { for handle in handles {
handle.join().unwrap(); handle.join().unwrap();
} }
+24
View File
@@ -129,6 +129,30 @@ pub fn client_install() -> Result<(), Box<dyn Error>> {
root_config_folder_path.join("victim"), root_config_folder_path.join("victim"),
&options, &options,
)?; )?;
if get_user_input(
"do you want to copy tetanus to your path so you can run it anywhere?",
)?
.contains("y")
{
println!("this will require sudo. Please complete the following sudo prompt.");
if let Ok(exe_path) = env::current_exe() {
if let Ok(res) = Command::new("sudo")
.arg("cp")
.arg(exe_path.display().to_string())
.arg("/usr/bin/tetanus")
.status()
{
if res.success() {
println!("copied to path!");
println!("install completed!");
} else {
eprintln!(
"error copying to path. please copy this executable to your path manually."
);
}
}
}
}
env::set_current_dir("../")?; env::set_current_dir("../")?;
remove_dir_all("./temp")?; remove_dir_all("./temp")?;
} }
+26 -4
View File
@@ -10,6 +10,7 @@ use std::net::IpAddr;
use std::path::PathBuf; use std::path::PathBuf;
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
use std::sync::mpsc::Sender; use std::sync::mpsc::Sender;
use walkdir::WalkDir;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct Project { pub struct Project {
@@ -21,7 +22,9 @@ pub struct Project {
pub hosts: Vec<Host>, pub hosts: Vec<Host>,
pub current: bool, pub current: bool,
pub db: Option<DistroBox>, pub db: Option<DistroBox>,
pub distrobox: bool,
pub scope: Vec<String>, pub scope: Vec<String>,
pub exclusions: Vec<String>,
} }
impl Project { impl Project {
@@ -35,7 +38,9 @@ impl Project {
hosts: Vec::new(), hosts: Vec::new(),
current: false, current: false,
db: None, db: None,
distrobox: false,
scope: Vec::new(), scope: Vec::new(),
exclusions: Vec::new(),
} }
} }
@@ -56,6 +61,7 @@ impl Project {
} }
pub fn add_host(&mut self, mut host: Host) { pub fn add_host(&mut self, mut host: Host) {
if !self.exclusions.contains(&host.ip) {
let mut new_id = 0; let mut new_id = 0;
self.hosts.iter().for_each(|h| { self.hosts.iter().for_each(|h| {
if h.id > new_id { if h.id > new_id {
@@ -68,6 +74,7 @@ impl Project {
self.hosts.push(host); self.hosts.push(host);
} }
} }
}
pub fn config_folder(&mut self, path: PathBuf) { pub fn config_folder(&mut self, path: PathBuf) {
self.config_folder = path; self.config_folder = path;
@@ -106,6 +113,19 @@ impl Project {
self.add_scope(ip.trim().to_string()); self.add_scope(ip.trim().to_string());
}); });
} }
"exclusions" => {
let ips: Vec<&str> = parts[1].split(",").collect();
ips.iter().for_each(|ip| {
self.exclusions.push(ip.to_string());
});
}
"db" => {
if parts[1].contains("false") {
self.distrobox = false;
} else {
self.distrobox = true;
}
}
_ => {} _ => {}
} }
} }
@@ -225,12 +245,14 @@ impl Project {
} }
let mut file = File::create(&self.config_folder)?; let mut file = File::create(&self.config_folder)?;
let mut out_string = format!( let mut out_string = format!(
"org_name: {}\nname: {}\nnotes: {}\nfiles: {}\nscope: {}\n", "org_name: {}\nname: {}\nnotes: {}\nfiles: {}\nscope: {}\nexclusions: {}\ndb: {}\n",
self.org_name, self.org_name,
self.name, self.name,
self.notes.display(), self.notes.display(),
self.files.display(), self.files.display(),
self.scope.join(","), self.scope.join(","),
self.exclusions.join(","),
self.distrobox
); );
if self.current { if self.current {
out_string.push_str("stage: current"); out_string.push_str("stage: current");
@@ -306,7 +328,7 @@ impl DistroBox {
if !added_volumes.contains(&String::from(folder_name)) { if !added_volumes.contains(&String::from(folder_name)) {
create_command create_command
.arg("--volume") .arg("--volume")
.arg(format!("{}:/{}:rw", volume, folder_name)); .arg(format!("{}:/project:rw", volume));
added_volumes.push(folder_name.to_string()); added_volumes.push(folder_name.to_string());
} }
} }
@@ -446,7 +468,7 @@ impl DistroBox {
return Ok(()); return Ok(());
} }
pub fn launch_terminal(&self, cmd: String) { pub fn launch_terminal(&self, cmd: String, dir: PathBuf) {
if let Some((terminal_cmd, args)) = cmd.split_once(" ") { if let Some((terminal_cmd, args)) = cmd.split_once(" ") {
let mut term_cmd = Command::new(terminal_cmd); let mut term_cmd = Command::new(terminal_cmd);
args.split(" ").into_iter().for_each(|arg| { args.split(" ").into_iter().for_each(|arg| {
@@ -462,7 +484,7 @@ impl DistroBox {
term_cmd.arg(arg); term_cmd.arg(arg);
} }
}); });
let _ = term_cmd.spawn(); let _ = term_cmd.current_dir(dir).spawn();
} }
} }