Skip to content

Commit

Permalink
remove debug prints
Browse files Browse the repository at this point in the history
  • Loading branch information
maitrecraft1234 committed Sep 28, 2024
1 parent 855a608 commit ae0a6df
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 17 deletions.
2 changes: 1 addition & 1 deletion src/obfuscator/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn replace_fn(tree: &mut Tree, code: &str, replace: &str, replacement: &str) ->

impl Obfuscator {
pub fn obfuscate_functions(&mut self) -> Result<()> {
let _ = self.reparse(ObfuscatorError::Booleans);
self.reparse(ObfuscatorError::Booleans)?;
let fns = get_fn(&self.tree, &self.code);
for e in &fns {
self.code = replace_fn(&mut self.tree, &self.code, e, &rand_str());
Expand Down
16 changes: 0 additions & 16 deletions src/obfuscator/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ fn string_encode(sr: &StringRange, s: &str) -> String {
'outer: for (i, c) in s.char_indices() {
for esc in &sr.escapes {
if esc.contains(&(i + sr.range.start + sr.string_start_skip)) {
eprintln!(
"esci = {:?}, {} , c= {c}",
esc,
(i + sr.range.start + sr.string_start_skip)
);
new.push(c);
continue 'outer;
}
Expand All @@ -50,7 +45,6 @@ fn get_strings(tree: &Tree) -> Vec<StringRange> {
let node_type = node.kind();

if node_type == nodetype {
eprintln!("get escapes node type {node_type}");
vec.push(node.byte_range());
}
if !cursor.goto_next_sibling() {
Expand Down Expand Up @@ -98,29 +92,19 @@ fn get_strings(tree: &Tree) -> Vec<StringRange> {
impl Obfuscator {
pub fn obfuscate_strings(&mut self) -> Result<()> {
// strings
eprintln!("strings");
self.code = {
let strings = get_strings(&self.tree);
dbg!(&strings);
for e in &strings {
eprintln!("string = {}", &self.code[e.range.clone()]);
}
let mut code = self.code.clone();
let mut shift = 0;
for e in strings {
eprintln!("loop string");
let str = &self.code
[e.range.start + e.string_start_skip..e.range.end - e.string_end_skip];
eprintln!("string = {str}");
dbg!(&e);

let formated = format!("string_decode(f\"{}\")", string_encode(&e, str));
eprintln!("encoded {}", formated);

let len = e.range.len();
let range = e.range.shift(shift);
code.replace_range(range, &formated);
eprintln!("old len = {}, new len = {}", len, formated.len());
shift += formated.len() as i32 - len as i32;
}
code
Expand Down

0 comments on commit ae0a6df

Please sign in to comment.