Closed sla-te closed 4 years ago
Try to obfuscate the scripts with --restrict 0
, for example,
pyarmor obfuscate --restrict 0 foo.py
Yeah, that really worked thanks. Anything else I need to consider?
I think nuitka must change something of the entry script, so it can't be accepted by pyarmor.
Here are some differences of the obfuscated scripts https://pyarmor.readthedocs.io/en/latest/understand-obfuscated-scripts.html#the-differences-of-obfuscated-scripts
I will look into that. What about if I have a folder structure with multiple scripts? I just tried obfuscating all of them manually and after many features were not working anymore.
I get this when I try to start the features:
File "MRTFiles/range_controller.py", line 1, in <module>
__pyarmor__(__name__, __file__,'\x50\x59\x41\x52\x4---verylong)
NameError: name '__pyarmor__' is not defined
This scripts need to be obfuscated separately, for example,
pyarmor obfuscate --no-runtime --exact MRTFiles/range_controller.py
Refer to https://pyarmor.readthedocs.io/en/latest/understand-obfuscated-scripts.html#bootstrap-code
I manually compiled all scripts now now I get this error:
Traceback (most recent call last):
File "MRTFiles/range_controller.py", line 1, in <module>
from pytransform import pyarmor_runtime
ModuleNotFoundError: No module named 'pytransform'
EDIT: After I manually recreated the folder structure and copied the pytransform folder in every other folder it works
Ok, I had to compile every script with --restrict 0 again - Now I get:
Traceback (most recent call last):
File "<C:\Users\user\Desktop\mnwd_tool-obf\dist\MRT.dist\MRT.py>", line 3, in <module>
File "<frozen MRT>", line 17, in <module>
ModuleNotFoundError: No module named 'PySimpleGUI'
after compiling the obfuscated source with nuitka
I'm not familiar with nuitka (pyarmor could pack the scripts with backend tool `PyInstaller). If the scripts have been obfuscated, any dependent module or package imported by the script could not be found by build tool (nuitak or PyInstaller). For PyInstaller, PyArmor does some extra work, I think nuitka need to do some extra work either, refer to https://pyarmor.readthedocs.io/en/latest/how-to-do.html#how-to-pack-obfuscated-scripts
Yes I opened an issue over there and asked the them as well https://github.com/Nuitka/NUITKA-Utilities/issues/26
@jondy can you participate here, nuitka is asking how to find all necessary imports:
@chwba
If i add an import above from pytransform import pyarmor_runtime I get Traceback (most recent call last): File "
", line 267, in protect_pytransform File " ", line 225, in check_obfuscated_script RuntimeError: unexpected obfuscated script
This exception can be eliminated by obfuscated the scripts with --no-cross-protection
pyarmor obfuscate --no-cross-protection --restrict 0 foo.py
I also check the thread you mentioned above, It seems there is no valued advice to find the hidden imports in the obfuscated scripts by nuitka automatically.
With this additional argument and some further "magic" I was able to compile with nuitka. Can you recommend a way to speed the process up? Check here for how I am doing it at the moment: Nuitka/NUITKA-Utilities#26
Create a project to obfuscate all the scripts, for example:
cd /path/to/src
pyarmor init --src "."
This will create a project file .pyarmor_config
in the current path, then config the project with multiple entries
pyarmor config --cross-protection 0 --restrict 0 --entry "foo.py,bar.py,mrt/main.py"
After that, obfuscate all the scripts to dist
pyarmor build --output dist
Once the scripts changed, just run build
again
pyarmor build --output dist
I don't know why pytransform
must be copied to each folder, it could be taken as a common python package with some data files and one binary library (which will be loaded by ctypes
), I think one copy is enough
Thank you for the help. Due to the structure of our app only manually obfuscating every script with the "--exact" argument worked for me.
Hello, i
Create a project to obfuscate all the scripts, for example:
cd /path/to/src pyarmor init --src "."
This will create a project file
.pyarmor_config
in the current path, then config the project with multiple entriespyarmor config --cross-protection 0 --restrict 0 --entry "foo.py,bar.py,mrt/main.py"
After that, obfuscate all the scripts to
dist
pyarmor build --output dist
Once the scripts changed, just run
build
againpyarmor build --output dist
I don't know why
pytransform
must be copied to each folder, it could be taken as a common python package with some data files and one binary library (which will be loaded byctypes
), I think one copy is enough
Hello, i ran these commands and they seem to work however when i tried to use nuitka to compile it to a executable using following command:
nuitka --warn-unusual-code --follow-imports --show-progress --assume-yes-for-downloads --standalone --plugin-enable=multiprocessing --show-modules --show-progress --mingw64 --onefile --include-package-data selenium pytransform --nofollow-import-to=importlib --no-pyi-file --experimental=use_pefile --experimental=use_pefile_recurse --run main.py
I got following issue:
__main__.py: can't find '__main__' module in 'pytransform'
I then looked up the issue in google and only found similar problems from others but their solutions did not solved my problem. I also asked the developer of nuitka and he told me, that this problem is related to pyarmor so i ask here.
@jondy @FuckingToasters @sla-te I used some methods and wasted a lot time on pyarmor and nuikta and now i am able to Work with both same time I was working to protect my script with 4 layers but due to pyarmor trial i am able to do it only 3 layers because of it's big file not encrypting problem my script was much bytes But i tested everything pyarmor and nuikta works for me but still i have problem of pyarmor large script not encryption with trail... LoL due to this thing my one encrypting layer remaining but nuikta and pyarmor working perfectly together for me ❤️
@jondy @FuckingToasters @sla-te I used some methods and wasted a lot time on pyarmor and nuikta and now i am able to Work with both same time I was working to protect my script with 4 layers but due to pyarmor trial i am able to do it only 3 layers because of it's big file not encrypting problem my script was much bytes But i tested everything pyarmor and nuikta works for me but still i have problem of pyarmor large script not encryption with trail... LoL due to this thing my one encrypting layer remaining but nuikta and pyarmor working perfectly together for me ❤️
Can you share how to get pyarmor to work with nuikta?
I obfuscated a simple hello-world.py with pyarmor and then compiled a standalone exe using nuitka and I get this error: