diff --git a/modules/__pycache__/__init__.cpython-310.pyc b/modules/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..f3142b1 Binary files /dev/null and b/modules/__pycache__/__init__.cpython-310.pyc differ diff --git a/modules/__pycache__/m_decoder.cpython-310.pyc b/modules/__pycache__/m_decoder.cpython-310.pyc new file mode 100644 index 0000000..ed7054a Binary files /dev/null and b/modules/__pycache__/m_decoder.cpython-310.pyc differ diff --git a/modules/__pycache__/m_encoder.cpython-310.pyc b/modules/__pycache__/m_encoder.cpython-310.pyc new file mode 100644 index 0000000..ede8dde Binary files /dev/null and b/modules/__pycache__/m_encoder.cpython-310.pyc differ diff --git a/modules/__pycache__/m_obfuscate.cpython-310.pyc b/modules/__pycache__/m_obfuscate.cpython-310.pyc new file mode 100644 index 0000000..c860820 Binary files /dev/null and b/modules/__pycache__/m_obfuscate.cpython-310.pyc differ diff --git a/modules/m_decoder.py b/modules/m_decoder.py index 2d7f12e..263feb3 100644 --- a/modules/m_decoder.py +++ b/modules/m_decoder.py @@ -21,9 +21,7 @@ def __write( value: str ) -> None: - d_path = os.path.join(self.output_dir_path, file_path) - - with open(d_path, 'a+') as f: + with open(file_path, 'a+') as f: f.write(value) def __get_program_struct( @@ -43,7 +41,7 @@ def str_to_hex( def execute( self, - file_path: str, + input_file_path: str, program_struct: Dict, encoding_method: str ) -> None: @@ -51,9 +49,14 @@ def execute( # Set program_struct as class vars self.program_struct = program_struct + # Determine the output file path + input_filename = os.path.basename(input_file_path) + output_filename = os.path.splitext(input_filename)[0] + "_obfuscated.py" + output_file_path = os.path.join(self.output_dir_path, output_filename) + # Write the necessary libraries self.__write( - file_path, + output_file_path, "import base64, codecs \n" ) @@ -61,12 +64,12 @@ def execute( for k, _ in program_struct.items(): encode_part = self.__get_program_struct(k, 'base64_encode') to_write = f"{k} = '{encode_part}'\n" - self.__write(file_path, to_write) + self.__write(output_file_path, to_write) # Write custom encoding method var hex_name = self.str_to_hex(encoding_method) to_write = f"{self.encoding_var} = '{hex_name}' \n" - self.__write( file_path, to_write) + self.__write(output_file_path, to_write) # Write encoding program var to_write = f"{self.execute_var} = \\\n" @@ -81,10 +84,10 @@ def execute( if ith != len(program_struct) - 1: to_write += f" + \\\n" - self.__write(file_path, to_write) + self.__write(output_file_path, to_write) # Write cmd to decode program hex_name = self.str_to_hex(self.execute_var) cmd = f"base64.b64decode(eval('{hex_name}')).decode('utf-8')" to_write = f"\neval(compile({cmd},'', 'exec'))" - self.__write(file_path, to_write) \ No newline at end of file + self.__write(output_file_path, to_write) \ No newline at end of file diff --git a/py_obfuscator.py b/py_obfuscator.py index 92abe71..599109d 100755 --- a/py_obfuscator.py +++ b/py_obfuscator.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3.9 +#!/usr/bin/env python3 import argparse from modules.m_obfuscate import Obfuscate diff --git a/testing_files/index.html b/testing_files/index.html new file mode 100644 index 0000000..7f7556c --- /dev/null +++ b/testing_files/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/testing_files/sample-file.py b/testing_files/sample-file.py new file mode 100644 index 0000000..4648e70 --- /dev/null +++ b/testing_files/sample-file.py @@ -0,0 +1 @@ +print("Hello, World!") \ No newline at end of file diff --git a/testing_files/test-lamba.py b/testing_files/test-lamba.py new file mode 100644 index 0000000..8efc346 --- /dev/null +++ b/testing_files/test-lamba.py @@ -0,0 +1,4 @@ +import json +def lambda_handler(event, context): + for i in range(1, 21): + print(i) diff --git a/testing_files/test1.js b/testing_files/test1.js new file mode 100644 index 0000000..184dfcc --- /dev/null +++ b/testing_files/test1.js @@ -0,0 +1 @@ +console.log("Hello, World!"); diff --git a/testing_files/test2.cpp b/testing_files/test2.cpp new file mode 100644 index 0000000..2bd1e3b --- /dev/null +++ b/testing_files/test2.cpp @@ -0,0 +1 @@ +#include int main() { std::cout << "Hello, World!"; return 0; }