Skip to content

Commit

Permalink
formating fix
Browse files Browse the repository at this point in the history
  • Loading branch information
maitrecraft1234 committed Sep 23, 2024
1 parent 9ef948d commit a5f5bef
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
44 changes: 24 additions & 20 deletions src/obfuscator/dead_code_entry_points.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,37 @@ fn insert_dead_branches(code: &str, attempt: usize) -> String {
for _ in 0..iterations {
let line = rng.gen_range(init::OBFUSCATOR_HELPER_FUNCTIONS.lines().count()..lines);

new_code = new_code.lines().enumerate().map(|(i, l)| {
if i == line {
let indent = figure_out_indentation(l);
let mut line = DEAD_CODE_ENTRY_POINT[rng.gen_range(0..DEAD_CODE_ENTRY_POINT.len())]
new_code = new_code
.lines()
.enumerate()
.map(|(i, l)| {
if i == line {
let indent = figure_out_indentation(l);
let mut line = DEAD_CODE_ENTRY_POINT
[rng.gen_range(0..DEAD_CODE_ENTRY_POINT.len())]
.to_string();
line.insert_str(0, " ".repeat(indent).as_str());
line.push('\n');
line.push_str(" ".repeat(indent + 4).as_str());
line.push_str(RANDOM_USELESS_CODE[rng.gen_range(0..RANDOM_USELESS_CODE.len())]);
line.push('\n');
line.push_str(l);
line.push('\n');
line
} else {
let mut l = l.to_string();
l.push('\n');
l
}
})
.collect::<String>();
line.insert_str(0, " ".repeat(indent).as_str());
line.push('\n');
line.push_str(" ".repeat(indent + 4).as_str());
line.push_str(RANDOM_USELESS_CODE[rng.gen_range(0..RANDOM_USELESS_CODE.len())]);
line.push('\n');
line.push_str(l);
line.push('\n');
line
} else {
let mut l = l.to_string();
l.push('\n');
l
}
})
.collect::<String>();
}
new_code
}

impl Obfuscator {
pub fn insert_dead_branches(&mut self) -> Result<()> {
let attempts :usize = 5;
let attempts: usize = 5;
let old = self.code.clone();

self.code = insert_dead_branches(&self.code, 0);
Expand Down
2 changes: 1 addition & 1 deletion src/obfuscator/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl std::error::Error for ObfuscatorError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Self::PythonSyntaxCheck(err) => Some(err),
_ => None
_ => None,
}
}
}

0 comments on commit a5f5bef

Please sign in to comment.