QQuick / Opy

Obfuscator for Python
Other
362 stars 61 forks source link

PR added new feature (Added exceptions files list for strings obfuscations) #43

Closed emadmahdi closed 6 months ago

emadmahdi commented 6 months ago

This PR adds new feature .. obfuscations of strings now uses a list of files excepted .. It works both ways .. either all files strings obfuscated with an exception files list .. or all files strings not obfuscated with an exception files list.

To improve the performance of big obfuscated python project .. most strings should not be obfuscated .. only critical strings in critical files needs obfuscation .. This PR was done to allow this performance improvement.

BuvinJT commented 6 months ago

Hey, I'll try to check this out and test it sometime soon. It's been quite a while since I've had a chance to work on this repo. If you weren't aware of this fork: https://github.com/BuvinJT/Opy, I'd recommend checking it out if you are planning to use and contribute to this project.

emadmahdi commented 6 months ago

@BuvinJT

Thank you for the suggestion .. I've been using OPY version 1.1.28 & 1.1.29 for several years to obfuscate a project of 80 python source files with 1.5 MB total text size (before obfuscation).

Today I tested the new fork of OPY version 0.9.1.1 and i can say it is not stable enough .. unfortunately for unknown reason i could not create a fork of your new OPY repo to send you the fixes that i did .. so here is a list of the problems i found:

1. Indentation of "imports/froms" is wrong when using TABS .. It works only with SPACES .. here is the fix i did in file "opy_parser.py" to allow it to also works with TABS.

FROM: leadSpaces = SPACE * (len(line) - len(line.lstrip(SPACE)))

TO: if line.startswith(SPACE): leadSpaces = SPACE (len(line) - len(line.lstrip(SPACE))) else: leadSpaces = TAB (len(line) - len(line.lstrip(TAB)))

2. The new feature of "mask_external_modules" .. needs all imports of public modules to be repeated in all the source files of the project .. otherwise it will not be available to other source files even when using "from module import *" which i use in all my project files.

3. The new feature of "mask_external_modules" .. it needs to add all functions of all public modules as "plain names" in the config file and does not always works otherwise it will be obfuscated.

4. Using the module "time" have problem with masking the function "time.time()" and cannot be fixed with "plain names"

5. To use OPY with large files the results should prints only the count of items not the whole contents of all the lists .. here is what i changed in file "opy.py" .. i just added "len()"

print ('Obfuscated files: {0}'.format (len (obfuscatedFileDict)))
print ('Obfuscated words: {0}'.format (len (obfuscatedWordList)))
print ('Obfuscated module imports: {0}'.format (len (opy_parser.obfuscatedModImports)))
print ('Masked identifier imports: {0}'.format (len (opy_parser.maskedIdentifiers)))
print ('Skipped public identifiers: {0}'.format (len (skippedPublicSet)))

Anyways .. at the end i was able to use the new OPY after disabling "mask_external_modules" and fixing TABS as well as function "time" .. though i like the old OPY because it is portable and consist of one file only.

Thank you for this amazing obfuscation tool .. The most important thing with this tool is the fact that it is irreversible .. But it is missing obfuscation of numbers.

emadmahdi commented 6 months ago

Here is the numbers of my project (includes all fixes) .. it is a single module project saved in one folder only:

Obfuscated files: 79 Obfuscated words: 2559 Obfuscated module imports: 35 Masked identifier imports: 24 Skipped public identifiers: 0

emadmahdi commented 6 months ago

@BuvinJT I am working to fix your new opy .. I will get back to you soon.

emadmahdi commented 6 months ago

@BuvinJT @JdeH

Hi, I have created a new OPY full of new features and highly obfuscated .. i would like to know what is your opinion ?!

Do you recommend merging my OPY2 with your OPY or i need to create a new OPY2 in my GitHub account .. It is my first time building something by using another person work as a base for my work ?!

I actually build my OPY2 based on the OPY from BuvinJT .. https://github.com/BuvinJT/Opy .. I don't know if it is you or he is a different person ?!!

Please advice .. What is the best way to publish my OPY2 !!