Skip to content

Commit

Permalink
Minor refactor/reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
0xTas committed Nov 1, 2022
1 parent 5c1310d commit baeb0bc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
5 changes: 2 additions & 3 deletions src/batch/deobfuscator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. */


use regex::Regex;
use super::CharSet;
use std::{
fs::File,
io::Write,
collections::HashMap
};
use super::CharSet;
use regex::Regex;


/// ### An object that generates cleartext batch commands from obfuscated source commands.<br>
Expand Down
22 changes: 16 additions & 6 deletions src/batch/obfuscator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,22 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. */


use regex::Regex;
use std::{
collections::{HashMap, HashSet},
fs::File,
io::Write
io::Write,
collections::{
HashMap,
HashSet
},
};
use crate::{
input,
batch::{
generate_random_chars,
CharSet
},
};
use crate::{input, batch::{generate_random_chars, CharSet}};
use regex::Regex;


/// ### An object that generates obfuscated batch commands from un-obfuscated source commands.<br>
Expand Down Expand Up @@ -73,7 +82,8 @@ impl BatchObfuscator {
}
}

pub fn enable_echo(&mut self) {
/// Prevents from writing boiler-plate "@echo off" to output script.
pub fn dont_echo(&mut self) {
self.echo_mode = true;
}

Expand All @@ -95,7 +105,7 @@ impl BatchObfuscator {
// Write the script header defining an obfuscated way of assigning further variables.
self.prep_commands.push(String::from(":: VGhpcyBmaWxlIHdhcyBvYmZ1c2NhdGVkIHZpYSBodHRwczovL2dpdGh1Yi5jb20vMHhUYXMvMHhpZGl6M3I="));
self.prep_commands.push(String::from(":: VGhpcyBmaWxlIGNhbiBiZSBwcm9ncmFtYXRpY2FsbHkgZGVvYmZ1c2NhdGVkIHZpYSBodHRwczovL2dpdGh1Yi5jb20vMHhUYXMvMHhpZGl6M3I="));
if !self.echo_mode {self.prep_commands.push(String::from("@echo off"));};
if self.echo_mode {self.prep_commands.push(String::from("@echo off"));};
self.prep_commands.push(format!("set {}=set", self.set_str));
self.prep_commands.push(format!("%{}% {}= ", self.set_str, self.space_str));
self.prep_commands.push(format!("%{}%%{}%{}==", self.set_str, self.space_str, self.eq_str));
Expand Down
25 changes: 16 additions & 9 deletions src/bin/0xidiz3r.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,18 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. */


use oxidizer::wait;
use oxidizer::batch::obfuscator::BatchObfuscator;
use oxidizer::batch::deobfuscator::BatchDeobfuscator;
use clap::Parser;
use std::{fs, process::exit};
use std::{
fs,
process::exit
};
use oxidizer::{
wait,
batch::{
obfuscator::BatchObfuscator,
deobfuscator::BatchDeobfuscator,
},
};


#[derive(Parser, Debug)]
Expand All @@ -37,8 +44,8 @@ struct Args {
#[arg(short, long, default_value_t = false)]
deobfuscate: bool,

/// Don't add "@echo off" to the output script.
#[arg(long, default_value_t = true)]
/// Add "@echo off" to the output script to avoid echoing cleartext commands
#[arg(short, long, default_value_t = false)]
echo_off: bool,

/// Custom name for the output file
Expand All @@ -54,6 +61,7 @@ struct Args {
max: Option<u32>
}


fn main() {

let mut args = Args::parse();
Expand Down Expand Up @@ -81,12 +89,11 @@ fn main() {
let path: String = deobfuscator.write_deobfuscated_script(args.output_file);
println!("\nDumped deobfuscated output to file: {}\nDeobfuscation Complete.", path);


exit(0);
}else {
let mut obfuscator: BatchObfuscator = BatchObfuscator::new();
if !args.echo_off {
obfuscator.enable_echo();
if args.echo_off {
obfuscator.dont_echo();
};

if let Ok(contents) = fs::read_to_string(args.input.trim_end()) {
Expand Down

0 comments on commit baeb0bc

Please sign in to comment.