diff --git a/src/actions.rs b/src/actions.rs index ad1cf64..1709d61 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -3,8 +3,8 @@ // SPDX-License-Identifier: GPL-3.0-or-later pub mod ads; -pub mod file; -pub mod mutex; -pub mod namepipe; -pub mod ppid; -pub mod service; +pub mod drivers; +pub mod files; +pub mod mutexes; +pub mod pipes; +pub mod processes; diff --git a/src/actions/ads.rs b/src/actions/ads.rs index 1b335d2..de82c04 100644 --- a/src/actions/ads.rs +++ b/src/actions/ads.rs @@ -2,93 +2,4 @@ // // SPDX-License-Identifier: GPL-3.0-or-later -// Alternate Data Stream -// -// Last update 20240224 - -use base64::engine::{general_purpose, Engine}; -use clap::Parser; -use regex_generate::{Generator, DEFAULT_MAX_REPEAT}; -use std::path::Path; - -#[derive(Parser)] -pub struct ADS { - #[clap( - short = 'f', - long, - required = true, - help = "Full path filename (regex)" - )] - filename: String, - #[clap(short = 'a', long, required = true, help = "ADS to use")] - ads: String, - #[clap( - short = 'd', - long, - required = false, - default_value = "V2VsY29tZSB0byB0aGUgV0FH", - help = "Data to write in base64" - )] - data: String, -} - -fn create_ads(fullpath: String, adsname: String, hex_data: Vec) -> bool { - let file_base: &Path = Path::new(&fullpath); - if !file_base.exists() { - println!("Missing base file for ADS !"); - return false; - } - let full_ads_name: String = format!("{}:{}", fullpath, adsname); - let file_ads: &Path = Path::new(&full_ads_name); - let ret_file: Result<(), std::io::Error> = std::fs::write(file_ads, hex_data); - match ret_file { - Ok(_) => return true, - Err(_) => return false, - } -} - -impl ADS { - /* Version 20230908 */ - pub fn run(&self) -> i32 { - println!("Alternate Data Stream"); - - if self.filename.len() > 0 { - let mut generator: Generator = - match Generator::new(&self.filename, rand::thread_rng(), DEFAULT_MAX_REPEAT) { - Ok(generator) => generator, - Err(_) => { - println!("Regex expressions are malformed."); - - return 1; - } - }; - let mut buffer: Vec = vec![]; - generator.generate(&mut buffer).unwrap(); - let fullname: String = match String::from_utf8(buffer) { - Ok(string) => string, - Err(_) => { - println!("Filename contains non-utf8 characters."); - - return 1; - } - }; - let barrow_ads: String = self.ads.to_string(); - let payload: Vec = match general_purpose::STANDARD.decode(self.data.as_str()) { - Ok(decoded) => decoded, - Err(_) => { - println!("Could not decode the data."); - - return 1; - } - }; - let ret_ads: bool = create_ads(fullname, barrow_ads, payload); - if ret_ads == true { - return 0; - } else { - return 1; - } - } - - return 1; - } -} +pub mod create; diff --git a/src/actions/ads/create.rs b/src/actions/ads/create.rs new file mode 100644 index 0000000..4543055 --- /dev/null +++ b/src/actions/ads/create.rs @@ -0,0 +1,111 @@ +// SPDX-FileCopyrightText: 2023 The WAG development team +// +// SPDX-License-Identifier: GPL-3.0-or-later + +// Alternate Data Stream +// +// Last update 20240224 + +use base64::engine::{general_purpose, Engine}; +use clap::Parser; +use regex_generate::{Generator, DEFAULT_MAX_REPEAT}; +use std::path::Path; + +#[derive(Parser)] +pub struct Create { + #[clap( + short = 'f', + long, + required = true, + help = "Full path filename (regex)" + )] + filename: String, + #[clap(short = 'a', long, required = true, help = "ADS to use")] + ads: String, + #[clap( + short = 'd', + long, + required = false, + default_value = "V2VsY29tZSB0byB0aGUgV0FH", + help = "Data to write in base64" + )] + data: String, +} + +fn create_ads(fullpath: String, adsname: String, hex_data: Vec) -> bool { + let file_base: &Path = Path::new(&fullpath); + if !file_base.exists() { + println!("Missing base file for ADS, try to create it"); + let folder: &Path = file_base.parent().unwrap(); + + let ret_folder: Result<(), std::io::Error> = std::fs::create_dir_all(folder); + match ret_folder { + Ok(_) => println!("The folder is valid"), + Err(_) => return false, + } + let ret_file: Result<(), std::io::Error> = std::fs::write( + file_base, + vec![ + 87, 105, 110, 100, 111, 119, 115, 32, 65, 114, 116, 101, 102, 97, 99, 116, 32, 71, + 101, 110, 101, 114, 97, 116, 111, 114, + ], + ); + match ret_file { + Ok(_) => println!("The base file is created"), + Err(_) => return false, + } + } + let full_ads_name: String = format!("{}:{}", fullpath, adsname); + let file_ads: &Path = Path::new(&full_ads_name); + let ret_file: Result<(), std::io::Error> = std::fs::write(file_ads, hex_data); + match ret_file { + Ok(_) => return true, + Err(_) => return false, + } +} + +impl Create { + /* Version 20230908 */ + pub fn run(&self) -> i32 { + println!("Alternate Data Stream"); + + if self.filename.len() > 0 { + let mut generator: Generator = + match Generator::new(&self.filename, rand::thread_rng(), DEFAULT_MAX_REPEAT) { + Ok(generator) => generator, + Err(_) => { + println!("Regex expressions are malformed."); + + return 1; + } + }; + let mut buffer: Vec = vec![]; + generator.generate(&mut buffer).unwrap(); + let fullname: String = match String::from_utf8(buffer) { + Ok(string) => string, + Err(_) => { + println!("Filename contains non-utf8 characters."); + + return 1; + } + }; + let barrow_ads: String = self.ads.to_string(); + let payload: Vec = match general_purpose::STANDARD.decode(self.data.as_str()) { + Ok(decoded) => decoded, + Err(_) => { + println!("Could not decode the data."); + + return 1; + } + }; + let ret_ads: bool = create_ads(fullname, barrow_ads, payload); + if ret_ads == true { + return 0; + } else { + return 1; + } + } + + return 1; + } +} diff --git a/src/actions/drivers.rs b/src/actions/drivers.rs new file mode 100644 index 0000000..de82c04 --- /dev/null +++ b/src/actions/drivers.rs @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2023 The WAG development team +// +// SPDX-License-Identifier: GPL-3.0-or-later + +pub mod create; diff --git a/src/actions/service.rs b/src/actions/drivers/create.rs similarity index 99% rename from src/actions/service.rs rename to src/actions/drivers/create.rs index 7da993b..af13d73 100644 --- a/src/actions/service.rs +++ b/src/actions/drivers/create.rs @@ -19,7 +19,7 @@ use windows::{ }; #[derive(Parser)] -pub struct BYOVD { +pub struct Create { #[clap( short = 'n', long, @@ -112,7 +112,7 @@ fn create_driver_service(name: &String, details: &String, path: &String) -> bool } } -impl BYOVD { +impl Create { /* Version 20230908 */ pub fn run(&self) -> i32 { println!("Bring Your Own Vulnerable Driver"); diff --git a/src/actions/files.rs b/src/actions/files.rs new file mode 100644 index 0000000..de82c04 --- /dev/null +++ b/src/actions/files.rs @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2023 The WAG development team +// +// SPDX-License-Identifier: GPL-3.0-or-later + +pub mod create; diff --git a/src/actions/file.rs b/src/actions/files/create.rs similarity index 98% rename from src/actions/file.rs rename to src/actions/files/create.rs index d15c06a..ebd623b 100644 --- a/src/actions/file.rs +++ b/src/actions/files/create.rs @@ -25,7 +25,7 @@ use regex_generate::{Generator, DEFAULT_MAX_REPEAT}; use std::{io::Result as IOResult, path::Path, thread, time, time::Duration}; #[derive(Parser)] -pub struct FileCreate { +pub struct Create { #[clap( short = 'f', long, @@ -83,7 +83,7 @@ fn create_file(fullpath: String, hex_data: Vec) -> bool { return false; } -impl FileCreate { +impl Create { pub fn run(&self) -> i32 { if self.admin && !match is_administrator() { diff --git a/src/actions/mutexes.rs b/src/actions/mutexes.rs new file mode 100644 index 0000000..de82c04 --- /dev/null +++ b/src/actions/mutexes.rs @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2023 The WAG development team +// +// SPDX-License-Identifier: GPL-3.0-or-later + +pub mod create; diff --git a/src/actions/mutex.rs b/src/actions/mutexes/create.rs similarity index 98% rename from src/actions/mutex.rs rename to src/actions/mutexes/create.rs index a41fa7b..fa0358b 100644 --- a/src/actions/mutex.rs +++ b/src/actions/mutexes/create.rs @@ -18,7 +18,7 @@ use windows::{ }; #[derive(Parser)] -pub struct Mutex { +pub struct Create { #[clap( short = 'n', long, @@ -37,7 +37,7 @@ fn create_mutex(name: &String, wait: u64) { let _res_server_pipe: WindowsResult<()> = unsafe { CloseHandle(mutex_handle.unwrap()) }; } -impl Mutex { +impl Create { pub fn run(&self) -> i32 { println!("Create Mutex"); diff --git a/src/actions/pipes.rs b/src/actions/pipes.rs new file mode 100644 index 0000000..de82c04 --- /dev/null +++ b/src/actions/pipes.rs @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2023 The WAG development team +// +// SPDX-License-Identifier: GPL-3.0-or-later + +pub mod create; diff --git a/src/actions/namepipe.rs b/src/actions/pipes/create.rs similarity index 98% rename from src/actions/namepipe.rs rename to src/actions/pipes/create.rs index fc76838..5d7348b 100644 --- a/src/actions/namepipe.rs +++ b/src/actions/pipes/create.rs @@ -20,7 +20,7 @@ use clap::Parser; use std::{thread, time}; #[derive(Parser)] -pub struct NamePipe { +pub struct Create { #[clap( short = 'n', long, @@ -50,7 +50,7 @@ fn create_name_pipe(name: &String, wait: u64) { let _res_server_pipe: WindowsResult<()> = unsafe { CloseHandle(server_pipe.unwrap()) }; } -impl NamePipe { +impl Create { pub fn run(&self) -> i32 { println!("Create NamePipe"); diff --git a/src/actions/processes.rs b/src/actions/processes.rs new file mode 100644 index 0000000..6b0160d --- /dev/null +++ b/src/actions/processes.rs @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2023 The WAG development team +// +// SPDX-License-Identifier: GPL-3.0-or-later + +pub mod spoofing; diff --git a/src/actions/ppid.rs b/src/actions/processes/spoofing.rs similarity index 99% rename from src/actions/ppid.rs rename to src/actions/processes/spoofing.rs index feeacf1..5d9a341 100644 --- a/src/actions/ppid.rs +++ b/src/actions/processes/spoofing.rs @@ -32,7 +32,7 @@ use windows::{ use std::{thread, time::Duration}; #[derive(Parser)] -pub struct PPID { +pub struct Spoofing { #[clap( short = 'e', long, @@ -129,7 +129,7 @@ fn create_ppid(name: &String) -> bool { } } -impl PPID { +impl Spoofing { /* Version 20240209 */ pub fn run(&self) -> i32 { println!("PPID spoofing"); diff --git a/src/cli.rs b/src/cli.rs index 597aa57..daf8248 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -3,7 +3,9 @@ // SPDX-License-Identifier: GPL-3.0-or-later use crate::actions::{ - ads::ADS, file::FileCreate, mutex::Mutex, namepipe::NamePipe, ppid::PPID, service::BYOVD, + ads::create::Create as ADSCreate, drivers::create::Create as DriversCreate, + files::create::Create as FileCreate, mutexes::create::Create as MutexCreate, + pipes::create::Create as PipesCreate, processes::spoofing::Spoofing as ProcessesSpoofing, }; use clap::Parser; @@ -36,13 +38,13 @@ enum Commands { #[clap(arg_required_else_help = true)] FileCreate(FileCreate), #[clap(arg_required_else_help = true)] - ADS(ADS), + ADS(ADSCreate), #[clap(arg_required_else_help = true)] - NamePipe(NamePipe), + NamePipe(PipesCreate), #[clap(arg_required_else_help = true)] - Mutex(Mutex), + Mutex(MutexCreate), #[clap(arg_required_else_help = true)] - BYOVD(BYOVD), + BYOVD(DriversCreate), #[clap(arg_required_else_help = true)] - PPID(PPID), + PPID(ProcessesSpoofing), }