Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a37f78a4e7 | ||
|
|
7bc5442416 | ||
|
|
7247e85762 |
No files matched your search
+118
-17
@@ -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 {
|
||||||
@@ -282,6 +283,7 @@ impl AppState {
|
|||||||
"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("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(());
|
||||||
@@ -583,6 +585,19 @@ impl AppState {
|
|||||||
} 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 prog {
|
||||||
|
"konsole" => {
|
||||||
|
launch_cmd
|
||||||
|
.arg(format!("--workdir {}", project.files.display()));
|
||||||
|
}
|
||||||
|
"xfce4-terminal" => {
|
||||||
|
launch_cmd.arg(format!(
|
||||||
|
"--working-directory={}",
|
||||||
|
project.files.display()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
match launch_cmd.spawn() {
|
match launch_cmd.spawn() {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
@@ -865,23 +880,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
|
||||||
@@ -1687,6 +1731,50 @@ impl AppState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"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);
|
||||||
@@ -2009,8 +2097,12 @@ impl AppState {
|
|||||||
rid,
|
rid,
|
||||||
String::from("[success] folders copied!"),
|
String::from("[success] folders copied!"),
|
||||||
)))?;
|
)))?;
|
||||||
remove_dir_all(&new_project.files)?;
|
let mut old_files = new_project.files.clone();
|
||||||
remove_dir_all(&new_project.notes)?;
|
let mut old_notes = new_project.notes.clone();
|
||||||
|
old_files.pop();
|
||||||
|
old_notes.pop();
|
||||||
|
remove_dir_all(&old_files)?;
|
||||||
|
remove_dir_all(&old_notes)?;
|
||||||
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());
|
||||||
@@ -2022,9 +2114,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(),
|
||||||
@@ -2036,6 +2132,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;
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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")?;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -318,7 +318,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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user