Skip to content

Commit

Permalink
Bug fixes, addded changelog.md, readme.md updated
Browse files Browse the repository at this point in the history
  • Loading branch information
mnestorov authored Sep 4, 2024
1 parent e5cb9b4 commit ee6d727
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 5 additions & 3 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import os

# Configure colors for printing messages
YELLOW = '\033[93m'
BLUE = '\033[94m'
GREEN = '\033[92m'
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'
log_filename = 'app.log'
6 changes: 4 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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}")
Expand Down

0 comments on commit ee6d727

Please sign in to comment.