Skip to content

Commit

Permalink
hopefully feature completed
Browse files Browse the repository at this point in the history
  • Loading branch information
maitrecraft1234 committed Oct 12, 2024
1 parent 4550049 commit aac4965
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ fn run_obfuscator(mut obfuscator: Obfuscator, matches: ArgMatches) -> obfuscator
if run_all || set_options.contains(&&"string".to_string()) {
obfuscator.obfuscate_strings()?;
}
if run_all || set_options.contains(&&"call".to_string()) {
obfuscator.obfuscate_function_calls()?;
}
if run_all || set_options.contains(&&"fn".to_string()) {
if set_options.contains(&&"call".to_string()) {
eprintln!("fn identifier obfuscation was skipped because it is not compatible with call obfuscation");
} else {
obfuscator.obfuscate_functions()?;
}
}
if set_options.contains(&&"call".to_string()) {
obfuscator.obfuscate_function_calls()?;
}
if run_all || set_options.contains(&&"int".to_string()) {
obfuscator.obfuscate_integers()?;
}
Expand All @@ -54,13 +54,13 @@ fn run_obfuscation(code: String, matches: ArgMatches) -> ExitCode {
let obfuscator = match Obfuscator::new(code) {
Ok(ob) => ob,
Err(err) => {
println!("{err}");
eprintln!("{err}");
return ExitCode::SUCCESS;
}
};

if let Err(err) = run_obfuscator(obfuscator, matches) {
println!("{err}");
eprintln!("{err}");
ExitCode::FAILURE
} else {
ExitCode::SUCCESS
Expand Down
10 changes: 6 additions & 4 deletions src/obfuscator/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ impl Obfuscator {

pub fn obfuscate_function_calls(&mut self) -> Result<()> {
let mut shift = 0;
let calls = get_fn_calls(&self.tree);
'outer: for (i, call) in calls.iter().enumerate() {
for cn in calls.iter().take(i) {
let calls = get_fn_calls(&self.tree).into_iter().skip(7);
'outer: for (i, call) in calls.clone().enumerate() {
for cn in calls.clone().take(i) {
if cn.end > call.start {
continue 'outer;
}
Expand All @@ -123,7 +123,9 @@ impl Obfuscator {

shift += hidden.len() as i32 - len as i32;
self.code.replace_range(call, &hidden);
self.reparse(ObfuscatorError::Functions("call replace lead to syntactical error".to_string()))?;
self.reparse(ObfuscatorError::Functions(
"call replace lead to syntactical error".to_string(),
))?;
}
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/obfuscator/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def ohe_string_decode(string):
for i in range(len(string)):
if ord(string[i]) >= 35 and ord(string[i]) <= 125 and 0:
string[i] = chr(ord(string[i]) - 1)
return ''.join(string)
return "".join(string)
def ohe_call_function(function_call_string):
ohe = lambda: eval(function_call_string, globals(), locals())
try:
Expand Down

0 comments on commit aac4965

Please sign in to comment.