dashingsoft / pyarmor

A tool used to obfuscate python scripts, bind obfuscated scripts to fixed machine or expire obfuscated scripts.

Home Page:http://pyarmor.dashingsoft.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] obscured script can not run with cygwin python

shaobo-zhang-senscomm opened this issue · comments

Reproduced steps:
generate scripts with “--platform windows.x86_64 --platform linux.x86_64 --platform darwin.x86_64” parameter.

Expected results:
The obscured script can run in cygwin environment, cygwin python (not windows python).

Actual results:
The obscured script can not run.

  File "/home/shaobo.zhang/scm-auto-obscure/CI/pyarmor_runtime_006272/__init__.py", line 49, in __pyarmor__
    return __import__(name, globals(), locals(), ['__pyarmor__'], level=1)
ModuleNotFoundError: No module named 'pyarmor_runtime_006272.py39.windows_x86_64.pyarmor_runtime'

#1784
This is discussion.
Is there any way to rebuild pyarmor_runtime.pyd for cygwin python?

Does it work to create link python39.dll in cygwin?

For example,

cd /usr/bin
# please make sure `libpython3.9.dll` exists, or it may be libpython3.9m.dll
ln -s libpython3.9.dll python39.dll

It will be solution for cygwin platform

hi @jondy,
it can't work with "ln -s".
libpython3.9.dll looks like a specific file for cygwin.

Could you show cygcheck /path/to/pyarmor_runtime.pyd after create the link?

shaobo.zhang@PC-SSZ060-1 /usr/bin
$ ln -s libpython3.9.dll python39.dll

shaobo.zhang@PC-SSZ060-1 /usr/bin
$ ls | grep python
libpython3.9.dll
python
python3
python3-config
python3.9-config
python3.9.exe
python39.dll

image

It seems it need rebuild the extensions for cygwin.

We can not rebuild python39.dll because it may need cygwin or python development environment.
Could you rebuild pyarmor_runtime.pyd?

I'll rebuild pyarmor_runtime.pyd and pytransform3.pyd in this month

I have built dev extensions
https://pyarmor.dashingsoft.com/downloads/temp/cygwin.x86_64/libs/cp3.9/pytransform3.dll
https://pyarmor.dashingsoft.com/downloads/temp/cygwin.x86_64/libs/cp3.9/pyarmor_runtime.dll

Could you verify it work by cygwin python3.9:

python3.9
>>> import pytransform3

It seems my cygwin is too old to run python3.9, so I can't verify it

image
pytransform3 can import, but pyarmor_runtime can't import, Is that correct ?

import pyarmor_runtime directly will raise python exception, it's OK.

Fixed in 8.5.10

Now there is new package pyarmor.cli.core.cygwin to support Cygwin with Python 3.73.9 (cygwin official download site only provides Python 3.73.9 packages)

hi @jondy
There is a cygwin_x86_64 folder under pyarmor_runtime_006272/py39. But the script does not use it, it still try to find pyarmor_runtime_006272.py39.windows_x86_64.
image

Try to apply this patch
425164d

Traceback (most recent call last):
  File "/home/shaobo.zhang/scm-auto-obscure/CI/start.py", line 3, in <module>
    from pyarmor_runtime_006272 import __pyarmor__
  File "/home/shaobo.zhang/scm-auto-obscure/CI/pyarmor_runtime_006272/__init__.py", line 54, in <module>
    __pyarmor__ = __pyarmor__().__pyarmor__
  File "/home/shaobo.zhang/scm-auto-obscure/CI/pyarmor_runtime_006272/__init__.py", line 53, in __pyarmor__
    return __import__(name, globals(), locals(), ['__pyarmor__'], level=1)
RuntimeError: failed to get api PyCell_Get

I'll check it.

I have re-written pyarmor_runtime.dll, but it still failed

Traceback (most recent call last):
  File "/home/shaobo.zhang/scm-auto-obscure/CI/start.py", line 3, in <module>
    from pyarmor_runtime_006272 import __pyarmor__
  File "/home/shaobo.zhang/scm-auto-obscure/CI/pyarmor_runtime_006272/__init__.py", line 54, in <module>
    __pyarmor__ = __pyarmor__().__pyarmor__
  File "/home/shaobo.zhang/scm-auto-obscure/CI/pyarmor_runtime_006272/__init__.py", line 53, in __pyarmor__
    return __import__(name, globals(), locals(), ['__pyarmor__'], level=1)
ImportError: No such process

I build one dev extension pyarmor_runtime, please download it and overwrite the old one in the package pyarmor/cli/core/cygwin and try it

https://pyarmor.dashingsoft.com/downloads/temp/cygwin.x86_64/libs/cp3.9/pyarmor_runtime.dll

Hi @jondy,
I put this pyarmor_runtime.dll into ~/miniconda3/envs/py39/lib/python3.9/site-packages/pyarmor/cli/core/cygwin/x86_64 (conda envs) and python -m pyarmor.cli -d gen, then license error. I try to register machine again. Register fail. What happen?

(py39) scm@scm-station-01:~$ pyarmor reg pyarmor-key/pyarmor-device-regfile-6272.1.zip
INFO     Python 3.9.19
INFO     Pyarmor 8.5.10 (trial), 000000, non-profits
INFO     Platform linux.x86_64
INFO     register "pyarmor-key/pyarmor-device-regfile-6272.1.zip"
INFO     machine id in group license: m7ce91077065781259273ff775547a154
INFO     got machine id: m7ce91077065781259273ff775547a154
INFO     this machine id matchs group license
INFO     This license registration information:

License Type    : pyarmor-trial
License No.     : pyarmor-vax-000000
License To      :
License Product : non-profits

BCC Mode        : No
RFT Mode        : No

Notes
* Can't obfuscate big script and mix str

I upgrade pyarmor from 8.5.x t0 8.5.10. Will the machine id change while i run pyarmor reg -g 1 ?

Try to remove ~/.pyarmor/.license.token

it works now, thank you very much.