From ee6d727838ec8e54851e516199e1be318b060527 Mon Sep 17 00:00:00 2001 From: Martin Nestorov Date: Wed, 4 Sep 2024 10:44:18 +0300 Subject: [PATCH] Bug fixes, addded changelog.md, readme.md updated --- CHANGELOG.md | 8 ++++++++ README.md | 2 ++ config.py | 8 +++++--- main.py | 6 ++++-- 4 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..64aaa52 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,8 @@ +# Changelog + +### 1.0 (2023.05.07) +- Initial release. + +### 1.1 (2024.09.04) +- Added `shlex.quote()` in the `obfuscate_php()` function when constructing the command to ensure that paths with spaces or special characters are handled properly. +- Updated the YAKPRO command in `config.py` to use `os.path.expanduser` to make it dynamic and compatible with user home directories \ No newline at end of file diff --git a/README.md b/README.md index 6b25a40..8f47fb4 100644 --- a/README.md +++ b/README.md @@ -157,6 +157,8 @@ pip install -r requirements.txt ## Usage +:warning: **Important:** The paths specified in `config.py` (especially YAKPRO) are correct and point to the YakPro-Po obfuscator on your system. + 1. Ensure you are in the project directory. 2. Run the script diff --git a/config.py b/config.py index c38e80c..2fa0591 100644 --- a/config.py +++ b/config.py @@ -1,3 +1,5 @@ +import os + # Configure colors for printing messages YELLOW = '\033[93m' BLUE = '\033[94m' @@ -5,8 +7,8 @@ RED = '\033[91m' RESET = '\033[0m' -# Configure YakPro packages path -YAKPRO = ["/home/YOUR_USERNAME/PROJECT_DIR/yakpro-po/yakpro-po.php", "-o"] +# Configure YakPro packages path (use full path and ensure it's correct) +YAKPRO = [os.path.expanduser("/home/YOUR_USERNAME/PROJECT_DIR/yakpro-po/yakpro-po.php"), "-o"] # Log filename -log_filename = 'app.log' \ No newline at end of file +log_filename = 'app.log' diff --git a/main.py b/main.py index c8564b8..f2d43dc 100644 --- a/main.py +++ b/main.py @@ -4,8 +4,9 @@ import shutil from concurrent.futures import ThreadPoolExecutor from tqdm import tqdm -from config import log_filename, YELLOW, BLUE, GREEN, RED, RESET, YAKPRO +from config import (log_filename, YELLOW, BLUE, GREEN, RED, RESET, YAKPRO) from subprocess import call +import shlex # Configure logging logging.basicConfig(filename=log_filename, level=logging.DEBUG, format='%(asctime)s %(levelname)s:%(message)s', datefmt='%Y-%m-%d %H:%M:%S') @@ -42,7 +43,8 @@ def obfuscate_php(input_file, obfuscation_options, create_backup, output_directo output_file = os.path.join(output_directory, f"obfuscated_{os.path.basename(input_file)}") logging.info(f"Obfuscating {input_file}") - command = [YAKPRO] + obfuscation_options + [output_file, input_file] + # Use shlex.quote to handle paths with spaces or special characters + command = YAKPRO + obfuscation_options + [shlex.quote(output_file), shlex.quote(input_file)] call(command) print(f"{GREEN}Obfuscated file saved as {output_file}{RESET}")