dashingsoft / pyarmor

A tool used to obfuscate python scripts, bind obfuscated scripts to fixed machine or expire obfuscated scripts.
http://pyarmor.dashingsoft.com
Other
3.47k stars 293 forks source link

Can't merge for multiple python versions #1873

Closed pedrocs-exo closed 4 months ago

pedrocs-exo commented 4 months ago

I'm trying to obfuscate for multiple python versions as described here.

I have folders 3.11 and 3.12 containing code obfuscated with the related python versions. Each one contains a runtime package folder pyarmor_runtime_00xxxx (xxxx is my registration code). When I run command

python3 -m pyarmor.cli.merge --output multiversion 3.12 3.11

I get the following error INFO start to merge '3.12', '3.11'... INFO scan runtime package in the path "3.11" ERROR no runtime package found

If instead I run

python3 -m pyarmor.cli.merge --runtime-name pyarmor_runtime_00xxx --output multiversion 3.12 3.11

the merge operation completes but folder multiversion/pyarmor_runtime_00xxx only contains the init.py, file pyarmor_runtime.so is missing. And this means a runtime error: ModuleNotFoundError: No module named 'pyarmor_runtime_004652.pyarmor_runtime'

Alternatively, I also tried

python3 -m pyarmor.cli.merge --no-runtime --output multiversion 3.12 3.11

In this case, the merge operation completes and folder multiversion/pyarmor_runtime_00xxx seems ok but it still triggers RuntimeError: unauthorized use of script (1:1102). If I replace folder multiversion/pyarmor_runtime_00xxx with 3.12/pyarmor_runtime_00xxx everything works. Needless to say, my runtime python version is 3.12.

Any suggestion?

jondy commented 4 months ago

Which pyarmor version are you used? If not latest, try to upgrade to latest pyarmor

jondy commented 4 months ago

Also check pyarmor cfg plugins, make sure there is one and only one MultiplePythonPlugin in each Python version

pedrocs-exo commented 4 months ago

Thank you for your quick reply. The pyarmnor version is 8.5.10 which is the latest available on PyPi. And I do have the MultiplePythonPlugin on the cfg:

(..)
Local settings
  plugins = CodesignPlugin DarwinUniversalPlugin MultiPythonPlugin
jondy commented 4 months ago

Please check the content of path 3.12/pyarmor_runtime_00xxxx and 3.11/pyarmor_runtime_00xxxx?

After merged, check the content multipleversion/pyarmor_runtime_00xxxx

I suggest first remove whole 3.12, 3.11 and multipleversion, enable debug option -d to check output log

pyarmor/cli/merge.py is open source, it's just merge two folder files.

pedrocs-exo commented 4 months ago

I took a peek at function merge_runtimes inside pyarmor/cli/merge.py. It copies the init.py of the first runtime package and all the subfolders on every runtime package. It does nothing about the pyarmor_runtime.so files and so the merged folder won't have such a file. Isn't it necessary for runtime decoding? I'm guessing this isn't the expected behaviour.

jondy commented 4 months ago

It's expected behaviours.

If plugin "MultiPythonPlugin" works, the runtime package should be in the subfolder pyXY in the output path after pyarmor gen ...

For example, if output path is dist, it will be dist/pyarmor_runtime_00xxxx/py312/

So please check the output path