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.32k stars 282 forks source link

Segfault testing pyarmor 3.8.10 on Banana PI #18

Closed jondy closed 6 years ago

jondy commented 6 years ago

I'm trying the last version of pyarmor (3.8.10) on Banana PI 3.4.113-sun8i #18 SMP PREEMPT armv7l

I downloaded _pytransform.so from http://pyarmor.dashingsoft.com/downloads/platforms/bananapi/_pytransform.so

When I test pyarmor 3.8.10 with the examples queens, I got the following output:

root@tlbox-13:/usr/src/pyarmor-3.8.10/src# pyarmor obfuscate 
--src=examples/simple --entry=queens.py "*.py" 
INFO     Obfuscate scripts in path "examples/simple" ... 
INFO     Obfuscate scripts with mode 8 
INFO     Save obfuscated scripts to "dist" 
INFO            examples/simple/queens.py -> dist/queens.py 
INFO     Make runtime files 
INFO     Update entry script dist/queens.py 
INFO     Obfuscate 1 scripts OK. 

Unfortunately, when I test the cypher code, I got a Segfault error.

root@tlbox-13:/usr/src/pyarmor-3.8.10/src/dist# python queens.py Segmentation fault

I also have tested pyarmor 3.8.10 with other versions of _pytransform.so you had sent me several months ago, and which were working, but now the result is the same: Segfault.

I would appreciate any clue you could give me in order to solve this issue.

jondy commented 6 years ago

In the core file you sent to me, I found python interpreter is "/usr/bin/python-dbg".

If Py_TRACE_REFS or Py_DEBUG is defined when building python interpreter, pyarmor won't work.

So could you try a non-debug version of python to run pyarmor.py?

netman73 commented 6 years ago

I have disabled the use of python-dbg and now it obfuscates the example code, but unfortunately I still have an error when I run the script.

$ python pyarmor.py obfuscate --src=examples/simple --entry=queens.py "*.py" Trace log mode enabled and log to '_pytransform.log' INFO Obfuscate scripts in path "examples/simple" ... INFO Obfuscate scripts with mode 8 INFO Save obfuscated scripts to "dist" INFO examples/simple/queens.py -> dist/queens.py INFO Make runtime files INFO Update entry script dist/queens.py INFO Obfuscate 1 scripts OK.

$ cd dist $ python queens.py Trace log mode enabled and log to '_pytransform.log' Traceback (most recent call last): File "queens.py", line 3, in xef\x67\xa0\x3d\x06\xec\x62\x0a\xb4\x8b\x44\xc4\xc2\x3f\x5f\xb9\x16\x62\x36\x76\xc6\x5b\xe5\x19\x2b\xdb\x23\x01\x13\xdc\x97\xfe\x3d\x84\x80\x3e\x91\xf2\xab\x92\x01\xa0\x4c\x6e\xdd\xc9\xf9\xcf\xe4\x35\x1e\x97\x0e\x97\x89\xf6\x42\x02\x63\x54\x18\x16\xf6\x91\xfd\x13\xdb\x34\x45\xa9\xa6\x23\x63\xd6\x79\x5b\xaf\x93\xc7\x4d\x56\x33\x5d\x25\x71\x84\x92\x35\xe5\x5d\x37\x26\x3d\x90\x98\x61\x0e\xd3\xbc\xad\xd1\xed\x06\x93\xb6\x78\x61\x56\xf1\xd5\xef\x06\x5e\x90\x85\xd0\xbd\x91\x29\x88\x03\x73\x03\x5f\xaf\xa3\x70\x23\x52\x51\x64\x24\x88\x14\x12\x66\x4d\x98\xba\x01\xb0\x0a\x88\xf6\x5d\xb6\x63\xab\x70\x0e\xb7\x0e\x21\x96\x41\xc4\x16\x21\x9b\x3a\xdb\xf4\x66\xcd\x7e\x11\x7b\x9e\x47\xcc\xca\x9c\x06\x66\xdd\x71\xca\xc4\xc8\x71\x49\x62\x18\x22\xbc\xef\xf7\x59\xff\x44\x41\x05\xfe\xe7\x28\x38\x3a\x84\x5a\x98\x9c\x10\xa4\x24\x21\x5d\x55\x80\xbc\x90\x6e\x95\x30\xed\x88\x3a\xf1\xc5\x7f\xe1\x3a\x64\x4b\x82\x7f\x4a\x19\x27\xf4\xca\x90\x36\x5d\x16\x52\x70\x33\x20\xb3\x72\xc1\x81\xf0\xb2\x46\x02\x8a\x78\x31\x10\xa2\x13\x2c\x5d\x85\x2a\xef\x60\x8e\xdc\xa4\x28\xc8\x3e\xa9\x2a\x72\x6e\x3c\x44\xe0\xb5\x52\xae\x83\x87\x5c\x4e\xfa\xac\x9a\xdd\xdc\x76\xcc\xc4\xf6\x54\xc1\x8c\xab\x7a\x1d\x3a\x68\x00\x94\xe2\x08\x69\xcf\xae\x30\xf8\x61\x01\x58\x0c\x42\x91\x57\x3b\x58\x1e\x99\x1c\x20\xbc\x9f\x3a\x63\x1a\xa7\x8c\xea\x9e\x98\x42\x92\x27\x16\x57\xf7\x15\x7f\xe2\x00\x18\xbf\xc4\xe2\x5b\xe7\x6d\x44\x3c\xd7\x78\xa2\x5e\x23\xdc\xcd\x60\x75\xea\x9c\xb2\xd7\x64\x01\x2a\xee\x1f\x83\x55\x54\xef\xd0\xa2\x37\xf6\x8d\x4e\x05\xc4\x01\x57\xd7\xbd\x4f\x8a\x37\xc7\x77\x05\x40\xb6\x63\x7d\x18\xdc\x27\x82\x41\xdd\xdb\x3f\x8c\xd4\xbc\x34\x52\x3d\x15\x1d\x7e\x6a\x10\x1c\x87\x93\x1a\xcf\x30\xbc\x74\x7e\x75\xd5\x97\x50\x1b\xa2\xdb\xa5\xf5\x47\x01\x65\xe5\x09\xed\x80\x76\xe1\x62\xe0\x79\xc6\xe0\x33\x86\xc4\xde\x2d\xbc\xfa\x5a\xbd\x91\x78\x06\x75\x6f\x30', 1) MemoryError

Any ideas?

jondy commented 6 years ago

Run obfuscated script with -d, it will print more error messages:

cd dist
python -d queens.py
netman73 commented 6 years ago

I'm sorry, I don't see any diference.

$ python -d queens.py Trace log mode enabled and log to '_pytransform.log' Traceback (most recent call last): File "queens.py", line 3, in

xef\x67\xa0\x3d\x06\xec\x62\x0a\xb4\x8b\x44\xc4\xc2\x3f\x5f\xb9\x16\x62\x36\x76\xc6\x5b\xe5\x19\x2b\xdb\x23\x01\x13\xdc\x97\xfe\x3d\x84\x80\x3e\x91\xf2\xab\x92\x01\xa0\x4c\x6e\xdd\xc9\xf9\xcf\xe4\x35\x1e\x97\x0e\x97\x89\xf6\x42\x02\x63\x54\x18\x16\xf6\x91\xfd\x13\xdb\x34\x45\xa9\xa6\x23\x63\xd6\x79\x5b\xaf\x93\xc7\x4d\x56\x33\x5d\x25\x71\x84\x92\x35\xe5\x5d\x37\x26\x3d\x90\x98\x61\x0e\xd3\xbc\xad\xd1\xed\x06\x93\xb6\x78\x61\x56\xf1\xd5\xef\x06\x5e\x90\x85\xd0\xbd\x91\x29\x88\x03\x73\x03\x5f\xaf\xa3\x70\x23\x52\x51\x64\x24\x88\x14\x12\x66\x4d\x98\xba\x01\xb0\x0a\x88\xf6\x5d\xb6\x63\xab\x70\x0e\xb7\x0e\x21\x96\x41\xc4\x16\x21\x9b\x3a\xdb\xf4\x66\xcd\x7e\x11\x7b\x9e\x47\xcc\xca\x9c\x06\x66\xdd\x71\xca\xc4\xc8\x71\x49\x62\x18\x22\xbc\xef\xf7\x59\xff\x44\x41\x05\xfe\xe7\x28\x38\x3a\x84\x5a\x98\x9c\x10\xa4\x24\x21\x5d\x55\x80\xbc\x90\x6e\x95\x30\xed\x88\x3a\xf1\xc5\x7f\xe1\x3a\x64\x4b\x82\x7f\x4a\x19\x27\xf4\xca\x90\x36\x5d\x16\x52\x70\x33\x20\xb3\x72\xc1\x81\xf0\xb2\x46\x02\x8a\x78\x31\x10\xa2\x13\x2c\x5d\x85\x2a\xef\x60\x8e\xdc\xa4\x28\xc8\x3e\xa9\x2a\x72\x6e\x3c\x44\xe0\xb5\x52\xae\x83\x87\x5c\x4e\xfa\xac\x9a\xdd\xdc\x76\xcc\xc4\xf6\x54\xc1\x8c\xab\x7a\x1d\x3a\x68\x00\x94\xe2\x08\x69\xcf\xae\x30\xf8\x61\x01\x58\x0c\x42\x91\x57\x3b\x58\x1e\x99\x1c\x20\xbc\x9f\x3a\x63\x1a\xa7\x8c\xea\x9e\x98\x42\x92\x27\x16\x57\xf7\x15\x7f\xe2\x00\x18\xbf\xc4\xe2\x5b\xe7\x6d\x44\x3c\xd7\x78\xa2\x5e\x23\xdc\xcd\x60\x75\xea\x9c\xb2\xd7\x64\x01\x2a\xee\x1f\x83\x55\x54\xef\xd0\xa2\x37\xf6\x8d\x4e\x05\xc4\x01\x57\xd7\xbd\x4f\x8a\x37\xc7\x77\x05\x40\xb6\x63\x7d\x18\xdc\x27\x82\x41\xdd\xdb\x3f\x8c\xd4\xbc\x34\x52\x3d\x15\x1d\x7e\x6a\x10\x1c\x87\x93\x1a\xcf\x30\xbc\x74\x7e\x75\xd5\x97\x50\x1b\xa2\xdb\xa5\xf5\x47\x01\x65\xe5\x09\xed\x80\x76\xe1\x62\xe0\x79\xc6\xe0\x33\x86\xc4\xde\x2d\xbc\xfa\x5a\xbd\x91\x78\x06\x75\x6f\x30', 1) MemoryError

Regards, Miguel.

2018-04-12 15:46 GMT+02:00 Jondy notifications@github.com:

Run obfuscated script with -d, it will print more error messages:

cd dist python -d queens.py

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dashingsoft/pyarmor/issues/18#issuecomment-380810774, or mute the thread https://github.com/notifications/unsubscribe-auth/AEtPEKfjyCuuPNA027PvHKMg5MffoaPrks5tn1rIgaJpZM4TRiRc .

jondy commented 6 years ago

Generally, if the python version used to obfuscate script is different from the python version to run obfuscated scripts, it will report MemoryError. But in this case it seems python version is same.

I'll build a temporary version to trace the detail in the log file.

jondy commented 6 years ago

Download this temporary version

http://pyarmor.dashingsoft.com/downloads/platforms/bananapi/temp/_pytransform.so md5sum: eac47e07b9fa0a657ff1436038c1fe90

Save it to src/dist directly, then

python queens.py

Show the content of _pytransform.log

netman73 commented 6 years ago

Trace log for pytransform 3.3.6: Python version: 2.7 PT-IM-00 WR-PA-00 WR-PA-01 WR-PA-02 Member offset 8, 20, 24 Sizeof int, Py_ssize_t, PyObject* is 4, 4, 4 WR-PA-03 WR-PA-04 WR-PA-05.1 WR-PA-05.2 PT-IM-01 PT-ITC-00 PT-ITC-01 PT-ITC-02 PT-ITC-03 PT-ITC-04 PT-ITC-05 PT-ITC-06 PT-IM-02 LC-IV-00 LC-IV-01 LC-IV-02 LC-IV-03 LC-IV-04 LC-IV-05 LC-IV-06 LC-IV-07 LC-IV-08 LC-IV-09 LC-IV-10 LC-IV-11 LC-IV-12 LC-IV-13 LC-IV-14 LC-IV-15 PT-IM-03 PT-VL-00 LC-CL-00 LC-CPL-00 LC-CPL-01 LC-CPL-02 LC-CPL-03 LC-CPL-04 LC-CPL-05, trial days is 9999 LC-CL-01 Invalid input packet. Verify rsa key failed LC-CL-02 PT-TP-00 PT-TP-03: 0, 0 Load code object failed pyarmor: marshal loads failed

jondy commented 6 years ago

Download this temporary version

http://pyarmor.dashingsoft.com/downloads/platforms/bananapi/temp/_pytransform.so md5sum: 7d333a2a44b06a2949871d320100fa71

Save it to src/dist directly, then

python queens.py

Show the last 10 lines of _pytransform.log and last message of exception

netman73 commented 6 years ago

LC-CPL-05, trial days is 9999 LC-CL-01 Invalid input packet. Verify rsa key failed LC-CL-02 PT-TP-00 PT-TP-03: 0, 0 Marshal loads python_marshal_loads: load code object failed pyarmor: marshal loads failed

ValueError: bad marshal data (unknown type code)

2018-04-12 17:41 GMT+02:00 Jondy notifications@github.com:

Download this temporary version

http://pyarmor.dashingsoft.com/downloads/platforms/ bananapi/temp/_pytransform.so md5sum: 7d333a2a44b06a2949871d320100fa71

Save it to src/dist directly, then

python queens.py

Show the last 10 lines of _pytransform.log and last message of exception

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dashingsoft/pyarmor/issues/18#issuecomment-380850173, or mute the thread https://github.com/notifications/unsubscribe-auth/AEtPEFXi0Uri2MsQS-JtHUCYOZvz9Tp8ks5tn3WOgaJpZM4TRiRc .

jondy commented 6 years ago

Download this temporary version to /usr/src/pyarmor/src http://pyarmor.dashingsoft.com/downloads/platforms/bananapi/temp/_pytransform.so md5sum: 4763582eda013a6558e90bc3764b74c4

Then run the following commands

python pyarmor.py obfuscate --src=examples/simple --entry=queens.py "*.py"

cd dist
python queens.py

Send me the following files (base path is /usr/src/pyarmor/src):

I need to check the output of each step to find why marshal loads failed.

netman73 commented 6 years ago

Here are you are. requested_files.tar.gz

jondy commented 6 years ago

I check the files, the reason maybe is that the cached file examples/simple/.pyarmor_capsule.zip caused this problem. When you first created this file, the license is a trial license. Later, you replaced the trial license with your normal license file. But examples/simple/.pyarmor_capsule.zip is still old, and the trial license in capsule is transfered to dist. So the solution is

  cd /usr/src/pyarmor/src
  rm examples/simple/.pyarmor_capsule.zip

  python pyarmor.py obfuscate --src=examples/simple --entry=queens.py "*.py"
  cd dist
  python queens.py

If it works, then pyarmor3.8.10 should work on Banana PI with non-debug version of python.

If it doesn't work, send me all the files as before, I hope it will not happen, :)

netman73 commented 6 years ago

It's the "Murphy's Law": "Anything that can go wrong will go wrong" requested_files.tar.gz

jondy commented 6 years ago

How about clone a refresh pyarmor from github, for example

mkdir -p /usr/another
cd /usr/another
git clone https://github.com/dashingsoft/pyarmor.git
cd pyarmor/src
wget http://pyarmor.dashingsoft.com/downloads/platforms/bananapi/temp/_pytransform.so

python pyarmor.py obfuscate --src=examples/simple --entry=queens.py "*.py"
cd dist
python queens.py
netman73 commented 6 years ago

It worked!