Coder Social home page Coder Social logo

dashingsoft / pyarmor Goto Github PK

View Code? Open in Web Editor NEW
3.1K 44.0 272.0 5.09 MB

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

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

License: Other

Python 81.57% Makefile 1.08% Shell 15.63% Batchfile 1.20% C 0.11% Roff 0.40%
python obfuscation obfuscate python-script obfuscate-scripts

pyarmor's People

Contributors

adamasnaldo avatar alecharing avatar asudox avatar axxyhtrx avatar carlosmarin avatar cikay avatar gospodima avatar guglie avatar guyshe-jfrog avatar jondy avatar joonis avatar kaoh avatar matthiasverstraete avatar muslashwhy avatar namoshizun avatar nicholaswon47 avatar nickk9 avatar nsdkin avatar ohad83 avatar rabbit0w0 avatar raindrum avatar ramushetty avatar samcomber avatar snakers4 avatar solomidhero avatar svenskithesource avatar timgates42 avatar versatilesft avatar ybalcanci avatar yzdann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyarmor's Issues

Error with binding encrypted script to one machine

Hi all,
I was following the webapp tutorial and got the error "Invalid trial license file, size is 208 != 256" after replacing the license.lic with the one generated by hard disk serial number.

Any idea why this happened? (The hard disk serial number is correct). Does it have anything to do the number of digits of the serial number? I found the number in the tutorial has 20 digits, but mine has only 15 digits
I am running the code on Ubuntu 16.04 and python3..5.2.

Thank you very much

Yifan

pyarmor.py: error: unrecognized arguments: exclude

I give this tutorial https://github.com/dashingsoft/pyarmor/blob/master/src/user-guide.md
part: "obfuscate odoo module"
make git clone v3.6.1
last commit a736bdc from Feb 27, 2018
command:

    ./pyarmor config --output=dist/web-login --disable-restrict-mode=1 \
                     --manifest "global-include *.py, exclude __manifest__.py"

and get this error:

pyarmor.py: error: unrecognized arguments: exclude __manifest__.py

I also try:
--manifest "global-include *.py; exclude __manifest__.py"
--manifest "global-include *.py exclude *__manifest__.py"
--manifest "global-include *.py, global-exclude __manifest__.py"

(As you can see "exclude" here https://pypi.python.org/pypi/pyarmor/1.7.1)
--manifest "global-include *.py" --exclude "__manifest__.py"
--manifest "global-include *.py" -exclude="__manifest__.py"
--manifest "global-include *.py" -exclude=__manifest__.py

pyarmor加密工程问题

您好.
按照您的提示删除了一些无法编译的文件后, 执行build成功.
构建项目脚本如下:
pyarmor init --src=/root/server_automation --entry=run.py projects/server

但运行程序时报如下错误
image

How to get hardware information as a return value from a function?

Thank you for the response. I have an another query regarding that,

The issue is that we are using pyinstaller which will manage all this without installing pyarmor or python in the target machine by creating a bundled exe. As there are several machines, we have chosen this option.

I was able to get the hdinfo of pyarmor using the _pytransform.dll and pytransform.py but I wasn't able to catch it as a return value of the function show_hd_info and instead, it directly outputs to stdout. I want to get the output of hdinfo directly into a program. Even better if it happens with a single call, within the program itself without using subprocess calls to catch stdout.

Can you help me with that or point to a resource where I could get exact deterministic outputs as hdinfo?

Wrong value of __file__

The value of __ files __ seems to be hardcoded pointing to the original source file.

Is it possible to fix this?

'gbk' codec can't decode byte 0xa1 in position 28: illegal multibyte sequence

I encouter an issue when run below code, please advise, thanks!
pyarmor obfuscate xx.py

INFO Obfuscate scripts in path "D:\Project\xx" ...
INFO Use cached capsule C:\Users\admin.pyarmor_capsule.zip
INFO Patch entry script xx.py ...
'gbk' codec can't decode byte 0xa1 in position 28: illegal multibyte sequence

Loading _pytransform.so failed

i am try obfuscate my python script in raspberry pi but i had facing the below issue
Load /home/pi/.local/lib/python3.5/site-packages/pyarmor/platforms/linux32/_pytransform.so failed:
/home/pi/.local/lib/python3.5/site-packages/pyarmor/platforms/linux32/_pytransform.so: cannot open shared object file: No such file or directory

pyarmor version is 4.5.4

Application built with pyinstaller does not start

Hey. How can I fix this issue?

I have simple script:

image

I obfuscate the script:
pyarmor obfuscate --src . -O obfuscated --entry start.py

image

Now I build with PyInstaller:

pyinstaller --noconfirm --log-level=WARN --onefile --distpath=. --clean --paths . "./obfuscated/start.py"

And I get an error while running the built application:

start.exe
Traceback (most recent call last):
File "site-packages\PyInstaller\loader\pyiboot01_bootstrap.py", line 149, in init
File "ctypes_init_.py", line 348, in init
OSError: [WinError 126] Не найден указанный модуль

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "pytransform.py", line 207, in load_library
File "ctypes_init
.py", line 426, in LoadLibrary
File "site-packages\PyInstaller\loader\pyiboot01_bootstrap.py", line 151, in init
main.PyInstallerImportError: Failed to load dynlib/dll 'C:\Temp\_MEI87362\_pytransform.dll'. Most probably this dynlib/dll was not found when the application was frozen.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "start.py", line 2, in
print('result: {sum}'.format(sum=x*y))
File "pytransform.py", line 239, in pyarmor_runtime
File "pytransform.py", line 233, in pyarmor_init
File "pytransform.py", line 213, in _load_library
pytransform.PytransformError: ('Could not load _pytransform from "%s"', 'C:\Temp\_MEI87362')
[4644] Failed to execute script start

Here is the contents of the application directory:
_pytransform.dll build license.lic obfuscated product.key pyshield.key pyshield.lic start.exe start.py

Pyarmor on alpine image

Dear

We try to run pyarmored code in an Alpine docker image. But we get the following error:

      File "/xxxx/pytransform.py", line 237, in _load_library
        m = cdll.LoadLibrary(os.path.join(libpath, '_pytransform.so'))
      File "/usr/local/lib/python3.6/ctypes/__init__.py", line 426, in LoadLibrary
        return self._dlltype(name)
      File "/usr/local/lib/python3.6/ctypes/__init__.py", line 348, in __init__
        self._handle = _dlopen(self._name, mode)
    OSError: Error relocating /xxxx/_pytransform.so: __snprintf_chk: symbol not found

Via Google we find similar issues pointing out that the error is related to the _pytransform.so the glibc toolchain instead of musl.
Is there a way to have the pytransform library build for musl?

Thanks a lot!

pytransform error

I'm using Python 3.6.4
I used the web ui to obfuscate my project
I then opened the dist folder and tried to run my entry point python file and i got this error:

Traceback (most recent call last): File ".\test.py", line 1, in <module> from pytransform import pyarmor_runtime ModuleNotFoundError: No module named 'pytransform'
I tried to install pytransform using pip install pytransform but it failed. so i tried to get it directly from the repo using pip install git+https://github.com/rock-learning/pytransform.git and then i got the following error:

Traceback (most recent call last): File ".\test.py", line 1, in <module> from pytransform import pyarmor_runtime ImportError: cannot import name 'pyarmor_runtime'

Where obfuscated *.pyc files? Only *.py files obfuscated.

In Mechanism https://github.com/dashingsoft/pyarmor/blob/master/src/mechanism.md
described 2 ways to protect Python Scripts by Pyarmor:

  • Obfuscate byte code of each code object (*.pyc files)
  • Obfuscate whole(source) code object of python module (*.py files)

I build project and get obfuscated py-files
__pyarmor__(__name__, b'${obfuscated_code}')

But I want to get obfuscated pyc-files, because they march more secure.
How to get obfuscated byte code?

This is my project .pyarmor_conf:
{
"version": "1.0.1",
"name": "my_mod",
"title": "my_mod",
"src": "/opt/odoo/addons/my_mod",
"manifest": "global-include *.py, exclude __manifest__.py",
"entry": "__init__.py",
"output": "dist/my_mod",
"capsule": ".pyarmor_capsule.zip",
"runtime_path": null,
"disable_restrict_mode": 1,
"obf_module_mode": "des",
"obf_code_mode": "des",
"build_time": 1519901163.5200913
}

Does the capsule generated on purchasing pyarmor registration bind to a project i.e if anyone replaces the capsule I gave with the capsule available on github, will they be able to use my code then?

When a project is created by Pyarmor (run command init), a project capsule named .pyarmor_capsule.zip is generated in project path. It's used to decrypt the source scripts.

In the trial version, all the .pyarmor_capsule.zip are same. In the normal version, this capsule is random. No one can run your obfuscated code except there is a license.lic generated by pyarmor with this project capsule. The license.lic generated by capsule of project A doesn't work in project B.

How to build with custom packages

How do I get pyarmor to include custom packages that are outside the main source directory.

e.g. I have various python modules in /some/common/path/mypackage and my application source code in /my/app/path, and my application imports mypackage.foo using from mypacakge import foo

pyarmor obfuscate --recursive --src=/my/app/path --entry=myapp.py

This command doesn't seem to add the package/modules, and the trying to run the app fails saying something like:

  File "<frozen Main_Frame_WXG>", line 11, in <module>
ModuleNotFoundError: No module named 'mypackage'

I've also tried setting PYTHONPATH but it doesn't make any difference.

PYTHONPATH=/some/common/path pyarmor obfuscate --recursive --src=/my/app/path --entry=myapp.py

I also tried adding multiple --src= lines, but it seems only the last one is used.

Pyarmor Restriction

hi
sry just i have a question

pyarmor Restriction for time use or tools limited?
i want know for this question

Faild to get harddisk information.

When I run "pyarmor hdinfo" in windows by administrator , I could get the hardisk information.
But I run the same command in linux , it shows:

`usr01@dovm2:~$ pyarmor hdinfo
/dev/nvme0n1p2: Permission denied
Faild to get harddisk information.

Mac address: '6c:0b:84:aa:c4:d9'

Ip address: '192.168.10.221'

Domain name: '(none)'
usr01@dovm2:$ ^Carmor hdinfo
usr01@dovm2:
$ whereis pyarmor
pyarmor: /home/usr01/.local/bin/pyarmor
usr01@dovm2:~$ sudo /home/usr01/.local/bin/pyarmor hdinfo
Faild to get harddisk information.

Mac address: '6c:0b:84:aa:c4:d9'

Ip address: '192.168.10.221'

Domain name: '(none)'`

I couldn't get the harddisk info, even though I use sudo command.

Segfault testing pyarmor 3.8.10 on Banana PI

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.

No library _pytransform.so found after update to 4.5.0

After update to version 4.5.0 a get error when building:
RuntimeError: No library /usr/lib/python3.6/site-packages/pyarmor/platforms/linux_x86_64/_pytransform.so found

Downgrade to 4.4.3 helps.

Whole error message is here:

$ pyarmor build

Traceback (most recent call last):
  File "/usr/bin/pyarmor", line 7, in <module>
    from pyarmor.pyarmor import main_entry
  File "/usr/lib/python3.6/site-packages/pyarmor/pyarmor.py", line 49, in <module>
    from utils import make_capsule, obfuscate_scripts, make_runtime, \
  File "/usr/lib/python3.6/site-packages/pyarmor/utils.py", line 50, in <module>
    search_pytransform(PYARMOR_PATH)
  File "/usr/lib/python3.6/site-packages/pyarmor/utils.py", line 48, in search_pytransform
    raise RuntimeError('No library %s found' % src)
RuntimeError: No library /usr/lib/python3.6/site-packages/pyarmor/platforms/linux_x86_64/_pytransform.so found

ModuleNotFoundError: No module named 'pyarmor2'

I had trid "pip install pyarmor; pyarmor" in windows10 and ubuntu 16.04 server, it show the errors below:
win10:
Traceback (most recent call last): File "c:\users\yanjie\appdata\local\programs\python\python36\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "c:\users\yanjie\appdata\local\programs\python\python36\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\yanjie\AppData\Local\Programs\Python\Python36\Scripts\pyarmor.exe\__main__.py", line 9, in <module> File "c:\users\yanjie\appdata\local\programs\python\python36\lib\site-packages\pyarmor\__init__.py", line 7, in main from pyarmor2 import main as main_entry ModuleNotFoundError: No module named 'pyarmor2'
ubuntu:
Traceback (most recent call last): File "/home/usr01/yanjie/pyarmor/venv/bin/pyarmor", line 11, in <module> sys.exit(main()) File "/home/usr01/yanjie/pyarmor/venv/lib/python3.5/site-packages/pyarmor/__init__.py", line 7, in main from pyarmor2 import main as main_entry ImportError: No module named 'pyarmor2'

pyarmor pack --type cx_Freeze hello.py

When I do the command : pyarmor pack --type cx_Freeze hello.py. I get the error : No such file or directory: 'Y:\tiantu\pyarmor\examples\hello\build\exe.win-amd64-3.6\python36.zip'. Thx

Unable to run pip-installed pyarmor

Hello,

I was going to try pyarmor on my Mac and ran pip install pyarmor, which worked fine. But when I run pyarmor this is what I get:

$ pyarmor
Traceback (most recent call last):
  File "/usr/local/bin/pyarmor", line 11, in <module>
    sys.exit(main_entry())
  File "/usr/local/lib/python2.7/site-packages/pyarmor/__init__.py", line 7, in main_entry
    from pyarmor.pyarmor import main
  File "/usr/local/lib/python2.7/site-packages/pyarmor/pyarmor.py", line 49, in <module>
    from utils import make_capsule, obfuscate_scripts, make_runtime, \
  File "/usr/local/lib/python2.7/site-packages/pyarmor/utils.py", line 55, in <module>
    search_pytransform(PYARMOR_PATH)
  File "/usr/local/lib/python2.7/site-packages/pyarmor/utils.py", line 49, in search_pytransform
    raise RuntimeError('No library %s found', src)
RuntimeError: ('No library %s found', '/usr/local/lib/python2.7/site-packages/pyarmor/platforms/macosx_x86_64/_pytransform.dylib')

My Python was installed through Homebrew.

Any idea what might be the problem?

Question regarding Pyarmor licensing mechanism

Hello,

We just bought a license of pyarmor for a commercial project for which I am the main developer.

I installed pyarmor into a conda environment using pip.

That installed a license file with the python package here:

/home/awagner/miniconda3/lib/python3.5/site-packages/pyarmor/license.lic

Is that the file that we're supposed to replace with our purchased license?

Is the uniqueness of this file what prevents our customers from downloading pyarmor and generating licenses for our product themselves? Or would that have been impossible even without a paid pyarmor license?

I am asking because there is a chance pip will overwrite that file in the future with a trial license, and I need to make sure we don't accidentally ship unprotected code.

Thanks,
Andrew

error on build project

I give this tutorial https://github.com/dashingsoft/pyarmor/blob/master/src/user-guide.md
part: "obfuscate odoo module"
make git clone v3.6.1
last commit a736bdc from Feb 27, 2018

I created project by command:
python pyarmor.py init --src=/opt/odoo/addons/my_mod --entry=init.py projects/my_mod

my .pyarmor_config:
{
"version": "1.0.1",
"name": "my_mod",
"title": "my_mod",
"src": "/opt/odoo/addons/my_mod",
"manifest": "global-include *.py, exclude __manifest__.py",
"entry": "__init__.py",
"output": "dist",
"capsule": ".pyarmor_capsule.zip",
"runtime_path": null,
"disable_restrict_mode": true,
"obf_module_mode": "des",
"obf_code_mode": "des",
"build_time": 1519829413.5447803
}
I corrected by hand this config: set up "disable_restrict_mode": true
and add ", exclude manifest.py" to manifest.

Then I build project by command:
./pyarmor build
Any errors ,but in building log: INFO Obfuscate 0 scripts with mode 8
In the 'dist' directory there were only files: init.py, _pytransform.so, license.lic, product.key, pyshield.key, pyshield.lic and pytransform.py

I went to projects/my_mod and add DEBUG in pyarmor:
/home/jacon/anaconda2/envs/pyarmor3.6/bin/python -d /opt/pyarmor/v3.6.1/pyarmor/src/pyarmor.py $*

Then run build again: ./pyarmor build
(pyarmor3.6) jacon@uut:/opt/pyarmor/v3.6.1/pyarmor/src/projects/my_mod$ ./pyarmor build
File "/opt/pyarmor/v3.6.1/pyarmor/src/pyarmor.py", line 739, in
main2(sys.argv[1:])
File "/opt/pyarmor/v3.6.1/pyarmor/src/pyarmor2.py", line 444, in main
version=_version_info())
File "/opt/pyarmor/v3.6.1/pyarmor/src/pyarmor2.py", line 431, in _version_info
if get_registration_code() == '':
File "/opt/pyarmor/v3.6.1/pyarmor/src/utils.py", line 172, in get_registration_code
code = pytransform.get_registration_code()
File "/opt/pyarmor/v3.6.1/pyarmor/src/pytransform.py", line 71, in wrap
raise PytransformError(format_message(errmsg, *args, **kwargs))
File "/opt/pyarmor/v3.6.1/pyarmor/src/pytransform.py", line 44, in init
self._print_stack()
File "/opt/pyarmor/v3.6.1/pyarmor/src/pytransform.py", line 54, in _print_stack
print_stack()
INFO Build project ...
INFO Enable increment build
INFO Search scripts from /opt/odoo/addons/my_mod
INFO Obfuscate 0 scripts with mode 8
INFO Save obfuscated scripts to dist
INFO Make runtime files to dist
INFO Generate no restrict mode license file: dist/license.lic
INFO Insert bootstrap code to entry script dist/init.py
INFO Build project OK.

Then I went to pytransform.py -> dllmethod -> wrap
and add print(errmsg) to line 70
build and get errmgs = b'Invalid input packet.\nDecode rsa key failed\nGet registration code failed'

Resume:

  1. error in project building
  2. this error generate new error while printing error on display
  3. my *.py files not obfuscated

Use new obfuscation mode to improve performance

  • Encrypt
    • Compile source to code objects, or load .pyc as code objects
    • Iterate code object, co_code of each code object will be wrapped by an armor as the following format
    0 JUMP_ABSOLUTE            n = 3 + len(bytecode)

         ...                                   here it's obfuscation bytecode by des or some other algorithms

n + 3:
    0 LOAD_GLOBAL              ? (armor)
    3 CALL_FUNCTION            0
    6 POP_TOP
    7 JUMP_ABSOLUTE            0
  • Decrypt
    • For each encrypted code object, first op is jump to n + 3
    • At n + 3, it will call a PyCFunction to decrypt those obfuscation bytecode
    • When it returns, jump to first op of really bytecode

By this way, no import hooker, no setprofile/settrace required. The performance will be improved remarkably.

Get DLL error

I am installing on Mac.

Downloaded code from https://pypi.python.org/pypi/pyarmor

$ python pyarmor.py capsule brian
INFO Searching pytransform library ...
ERROR No library /Users/bbullard/Downloads/pyarmor-3.1.3/platforms/macosx_10_12_intel/_pytransform.dll found

Can you advise what I should do?

Separated runtime and product.key

When building a project with a separated runtime folder, the file product.key is created in the runtimes folder and also in the dist folder. Is this required or just a bug?

exe file

Hi,
there is way use pyarmor with pyinstaller?
thank you

PyArmor on Maya 2018

Hello,

We are very interested in PyArmor to distribute Python modules used in Maya 2018
and in order to be able to execute pyarmor in Maya it needs to be compiled with a
specific compiler, the one from Visual Studio 2015.

Is PyArmor 64bits dll compiled with VS2015?
Could you recompile it? We could then test pyarmor in Maya 2018.

Best regards,
David Deckeur
Lead Developer
Superprod Studio

OSError: exception: access violation reading

hi,
I check pyarmor on 2 different computers both windows 10 , 3 different framework - python 3.5, 3.6 and annaconda .
in all of them i get this error: OSError: exception: access violation reading XXXX

someone have idea why?
thank you

_pytransform.dylib incompatible in OSX 10.14

Prebuilt _pytransform.dylib is not compatible with OSX 10.14.2:

% pyarmor
Load /usr/local/lib/python2.7/site-packages/pyarmor/platforms/darwin64/_pytransform.dylib failed:
dlopen(/usr/local/lib/python2.7/site-packages/pyarmor/platforms/darwin64/_pytransform.dylib, 6): no suitable image found. Did find:
/usr/local/lib/python2.7/site-packages/pyarmor/platforms/darwin64/_pytransform.dylib: malformed mach-o image: __TEXT segment maps start of file but is writable
/usr/local/lib/python2.7/site-packages/pyarmor/platforms/darwin64/_pytransform.dylib: malformed mach-o image: __TEXT segment maps start of file but is writable

How to distribute obfuscated scripts to many machines and different platforms(linux, windows and mac)

Hi, I looked at the GitHub repo and ran the trial version for one simple case. I want to purchase the product. But before that, I am trying to understand how does the licensing work and how should I use it while distributing my product.

The use case is as follows:

I have built a product. Now one my clients wants to use this product in 50 machines as a standalone software. Now what i want is following:

Full security of my source code ie he should not be able to reverse engineer and understand the code

he should be allowed to install this product only on 50 machines and not more than that. Note that these machines will not have any internet access.

By the way, the client's machines have win7 os. But i want a solution which should work across all the platform (linux, windows and Mac)

Also, what kind of support will you provide once i purchase the pyarmor ?

Wrong dist path using pyarmor.py build

Using pyarmor.py build /path/to/project creates the dist folder in the current working directory. Shouldn't the target dist be located in the specified project directory?

multiprocessing issue: AttributeError: '__main__' object has no attribute 'f'

Obfuscate the following script and run it:

from multiprocessing import Process
import os

def info(title):
    print(title)
    print('module name:', __name__)
    if hasattr(os, 'getppid'):  # only available on Unix
        print('parent process:', os.getppid())
    print('process id:', os.getpid())

def f(name):
    info('function f')
    print('hello', name)

if __name__ == '__main__':
    info('main line')
    p = Process(target=f, args=('bob',))
    p.start()
    p.join()

It reports error:

...
AttributeError: Can't get attribute 'f' on <module '__main__' (built-in)>
...

Load _pytransfrom failed in linux x86_64 by subprocess.Popen

I am two projects that will be using the pyArmor soon. I have run tests in the past without problems. I am now building my project on an AWS server. When the app starts it reports "Cound not load library _pytransform." I assume the "Cound" should be "Could"

Traceback:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "pytransform.py", line 183, in <module>
    _pytransform = _load_library()
  File "pytransform.py", line 175, in _load_library
    raise PytransformError('Cound not load library _pytransform.')
pytransform.PytransformError: Cound not load library _pytransform.

NOTES:
pyarmor 3.1.3

AWS uname -a: Linux ip-172-31-36-76 4.4.0-1035-aws #44-Ubuntu SMP Tue Sep 12 17:27:47 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

The App:

------------------------------------------------------------------------
#! /usr/bin/env python
import time
import subprocess
import pyimcore

Arg = ['import pytransform\npytransform.exec_file("Main.pye")']
NewApplication = subprocess.Popen(['python','-c']+Arg)

try:
        while(True):
                time.sleep(1.0)
finally:
        NewApplication.terminate()
        StartTime = time.time()
        while (NewApplication.poll() is None):
                if (time.time()-StartTime>10):
                        break
-------------------------------------------------------------------------

About the spam

Hello, I recently received an email which was suspected to have been sent from you.

In my opinion. The wording of this email is likely to recommend the commercial license for a software. I think you may have crawled the Python developer's mailbox on GitHub and sent the email. I received the email which has a clear address pointing to your project and relates website pages. And the sender's address and the name of your project are highly coincident. The language expression of the email is similar to selling your software commercial license and encourages the recipient to try the relevant software.

Due to my operational errors, the key evidence (the email) was deleted, so now I have no valid evidence to prove your behavior. If this is indeed done by yours. Firstly, I condemn it. And then, in my personality I think this behavior violates your ethics as a developer, harassing the developer, and disrupting the developer's development activities. I hope that you could send an apology letter to the users who were sent the email.

If it isn't done by you, I make a apologize here and apologize for what I had interfered the development activities and projects of yours.

I hope that you could be frank and honest with each other, which in order to create a better Internet and developer community environment. Best wish to you that the projects of yours will be developed better and better.

That would be all.

It seems that you are Chinese, and the following one is the Chinese version.

您好, 我最近收到疑似来自贵方发送的一封邮件.

这封邮件的措辞在我看来类似于推销软件商业用途许可. 我认为贵方可能爬取了 GitHub 上的 Python 开发者的邮箱, 并发送邮件. 我收到的邮件里面有明确的地址指向贵方的项目, 以及相关网页, 发件地址与贵方项目的名称高度重合. 语言表达类似于推销自己的软件商业许可, 并鼓励收件者试用相关软件.

由于我的操作失误, 导致关键证据 (该邮件)被删除, 所以现在我没有有效证据证明贵方的行为. 如果此行为确实是贵方所为 ,我对此表示谴责, 并且我个人认为这种行为违反了贵方作为开发者的道德, *扰了开发者, 干扰了开发者的开发活动, 希望贵方可以对发送了该类邮件的用户发送道歉信.

如果不是贵方所为, 我在此提出道歉, 对干扰了贵方的开发行为以及项目表示道歉.

希望您可以坦诚相待, 以便塑造更良好的互联网和开发者社区环境. 同时祝愿您所开发的项目可以越来越好.

以上.

Segmentation faults

On:
PyArmor 3.9.9 and PyArmor 4.3.3
Ubuntu 16.04
x86 architecture

What happens:

  • We obfuscate our entire codebase
  • When we run integration (end-to-end) tests against it, we get a segmentation fault (not often that I have seen this in Python !)
  • When a simple log line (or a print statement) is added in the right module, the segmentation fault is gone
  • Removing the log line, results in a segmentation fault again
  • Without code obfuscation, no log lines need to be added: the integration tests run smoothly

This has happened before multiple times. Actually, when code changes over time in the specific modules, the log lines can be removed again.

I cannot reproduce this behaviour on example modules, unfortunately. I have the impression that the generation of some specific byte codes, results in segfaults. Changing or adding an arbitrary line in the module seems to fix the issue, but I fear that this way we need to have very (almost over-the-top) testing.

Sorry that this ticket is a bit vague and I cannot provide example files, but I just wonder if other people have seen this behaviour as well ?

Build dynamic library for FreeBSD amd64

Build _pytransform.so for the following platform in May:

FreeBSD  9.3-RELEASE FreeBSD 9.3-RELEASE #0 r268512: 
Thu Jul 10 23:44:39 UTC 2014     [email protected]:/usr/obj/usr/src/sys/GENERIC  amd64 

FreeBSD trueos-1820.joonis.de 12.0-CURRENT FreeBSD 12.0-CURRENT #10 d26791952(trueos-stable-17.12): 
Sat Dec  9 18:10:09 UTC 2017     root@chimera:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64 

Is it possible to set a password for a license?

I want to protect code on a VM, so datetime and hardware information can be altered by customer. I think password with licence can solve this problem - customer still will be able to restore a VM state with my app running, but can not get or modify its source code. Its an acceptable result for me.
So is it possible to set a password for a license? I suggest, it should be requested only once and kept in some salted hash to reuse on each obfuscation
Other idea is to remove licence file from disc and pass it after start, it`s quite the same in usage.

Support for 64bit embedded platform

Pyarmor now only support 32bit embedded platform include Raspberry Pi and Banana Pi.
I'd like to use it on a 64bit Orange Pi Zero Plus 2. Could you please compile the aarch64 _pytransform.so lib? I believe It will also work on 64bit RaspPi & BananaPi

How to pack with my_module

I have a py script named a.py, it has import anothor script named b.py
in a.py: from b import xxx
when I use cmd: pyarmor pack a.py, it can pack sucessfully
but when I run excutable script in a/a, it throw me a bug like
Traceback (most recent call last):
File "projects/pyinstaller/dist/a.py", line 1, in
File "", line 1, in
ImportError: No module named 'b'

how do I handle this situation?

Access to raw code objects

I obfuscated the following Python script.

examples/test/mymod.py:

from __future__ import division, absolute_import, print_function, unicode_literals

def func2():
    print('func2')

def func3():
    print(err)

Build pyarmor:

python pyarmor.py init --src=examples/test --entry=mymod.py projects/test

python pyarmor.py config --disable-restrict-mode=1 projects/test

cd projects/test
./pyarmor build

In Python shell:

>>> import mymod, dis
>>> dis.dis(mymod)
Disassembly of func2:
  4     >>    0 LOAD_GLOBAL              0 (print)
              3 LOAD_CONST               1 (u'func2')
              6 CALL_FUNCTION            1
              9 POP_TOP             
             10 LOAD_CONST               0 (None)
             13 RETURN_VALUE        
             14 NOP                 
             15 NOP                 
             16 NOP                 
             17 NOP                 
             18 NOP                 
             19 NOP                 
             20 NOP                 
             21 NOP                 
             22 NOP                 
             23 NOP                 
             24 JUMP_ABSOLUTE            0

Disassembly of func3:
  7     >>    0 LOAD_GLOBAL              0 (print)
              3 LOAD_GLOBAL              1 (err)
              6 CALL_FUNCTION            1
              9 POP_TOP             
             10 LOAD_CONST               0 (None)
             13 RETURN_VALUE        
             14 NOP                 
             15 NOP                 
             16 NOP                 
             17 NOP                 
             18 NOP                 
             19 NOP                 
             20 NOP                 
             21 NOP                 
             22 NOP                 
             23 NOP                 
             24 JUMP_ABSOLUTE            0

Is it the correct behaviour that you have access to the raw code objects of a module?
So, what is the advantage of using pyarmor? Thanks.

How do we use the system to bind the code to mac id of different users?

For now, you can bind the obfuscated script to the serial number of harddisk, or mac address of network card. Bind to mac id isn't supported, I'll add this feature later.

First get hardware information in target machine,

    python pyarmor.py hdinfo

This command will print hardware information supported by Pyarmor.

Then in your build machine, run the following command to generate licenses

    cd project/your_project_name

    # Generate a new license.lic
    ./pyarmor licenses --bind-disk '100304PBN2081SF3NJ5T' --bind-mac '20:c1:d2:2f:a0:96' "Machine-001"

    # New license saved in "licenses/Machine-001/license.lic"
    # Readable text saved in "licenses/Machine-001/license.lic.txt"
    # "Machine-001" can be any text
    cat licenses/Machine-001/license.lic.txt
    
    # Copy this license.lic to dist/, repalce the default one
    cp licenses/Machine-001/license.lic dist/
    
    # Then copy all the obfuscated scripts and runtime files to target machine

You need generate different license.lic for different machine as above.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.