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] `RuntimeError: request license token failed (3): <h1>Server Error (500)</h1>`

smart0313 opened this issue · comments

在全新的设备上加密foo.py脚本全过程

设备信息

  • win7_x86
  • python3.7.4
  • pyarmor-8.5.1
  • pyarmor.cli.core-6.5.0

python版本

C:\Users\bulid>python
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 19:29:22) [MSC v.191
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

step1安装pyarmor

  C:\Users\bulid>pip install pyarmor
   ...
    90% |█████████████████████████████   | 399kB ..
    92% |█████████████████████████████▌  | 409kB .
    94% |██████████████████████████████  | 419kB .
    96% |███████████████████████████████ | 430kB
    99% |████████████████████████████████| 440kB
    100% |████████████████████████████████| 450k
B ...
Installing collected packages: pyarmor.cli.core, pyarmor
Successfully installed pyarmor-8.5.1 pyarmor.cli.core-6.5.0
You are using pip version 19.0.3, however version 24.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' comm
and.


C:\Users\bulid>pyarmor -v
Pyarmor 8.5.1 (trial), 000000, non-profits

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


C:\Users\bulid>

step2生成组设备文件

Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

C:\Users\bulid>pyarmor -v
Pyarmor 8.5.1 (trial), 000000, non-profits

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


C:\Users\bulid>pyarmor reg -g 7
INFO     Python 3.7.4
INFO     Pyarmor 8.5.1 (trial), 000000, non-profits
INFO     Platform windows.x86
INFO     generating device file ".pyarmor\group\pyarmor-group-device.7"
INFO     current machine id is "mbb859339bd24aba0eeaa374b91459549"
INFO     device file has been generated successfully

step3生成离线设备注册文件

C:\Users\bulid>pyarmor reg -g 7 pyarmor-regfile-6219.zip
INFO     Python 3.7.4
INFO     Pyarmor 8.5.1 (trial), 000000, non-profits
INFO     Platform windows.x86
INFO     register device file ".pyarmor\group\pyarmor-group-device.7"
INFO     use group license "pyarmor-regfile-6219.zip"
INFO     send request to server
INFO     write registration file "pyarmor-device-regfile-6219.7.zip"
INFO     please copy deivce regfile to offline device and run
INFO         pyarmor reg pyarmor-device-regfile-6219.7.zip
INFO     The device regfile has been generated successfully

step4离线设备注册

C:\Users\bulid>pyarmor reg pyarmor-device-regfile-6219.7.zip
INFO     Python 3.7.4
INFO     Pyarmor 8.5.1 (trial), 000000, non-profits
INFO     Platform windows.x86
INFO     register "pyarmor-device-regfile-6219.7.zip"
INFO     machine id in group license: mbb859339bd24aba0eeaa374b91459549
INFO     got machine id: mbb859339bd24aba0eeaa374b91459549
INFO     this machine id matchs group license
INFO     This license registration information:

License Type    : pyarmor-group
License No.     : pyarmor-vax-006219
License To      : xxx有限公司
License Product : ---

BCC Mode        : Yes
RFT Mode        : Yes

Notes
* Offline obfuscation


C:\Users\bulid>pyarmor -v
Pyarmor 8.5.1 (group), 006219, ---

License Type    : pyarmor-group
License No.     : pyarmor-vax-006219
License To      : xxx有限公司
License Product : ---

BCC Mode        : Yes
RFT Mode        : Yes

Notes
* Offline obfuscation


C:\Users\bulid>

step5 加密脚本

Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

C:\Users\bulid>cd demo

C:\Users\bulid\demo>python foo.py
hello world

C:\Users\bulid\demo>pyarmor gen foo.py
INFO     Python 3.7.4
INFO     Pyarmor 8.5.1 (group), 006219,---
INFO     Platform windows.x86
INFO     search inputs ...
INFO     find script foo.py
INFO     find 1 top resources
ERROR    request license token failed (3): <h1>Server Error (500)</h1>
ERROR    somthing is wrong
*=============================================================*
*  Please enable debug option `-d` to run it again            *
*    pyarmor -d gen options ...                               *
*                                                             *
*  Then check console log to find more information            *
*                                                             *
*  Please also check                                          *
*    https://pyarmor.readthedocs.io/en/latest/questions.html  *
*  or run `pyarmor man` to find solutions quickly             *
*=============================================================*


C:\Users\bulid\demo>pyarmor -d gen foo.py
INFO     Python 3.7.4
INFO     Pyarmor 8.5.1 (trial), 000000, non-profits
INFO     Platform windows.x86
DEBUG    native platform windows.x86
DEBUG    home path: C:\Users\bulid\.pyarmor
DEBUG    command options: {'no_runtime': False, 'inputs': ['foo.py']}
DEBUG    install plugin: CodesignPlugin
DEBUG    install plugin: DarwinUniversalPlugin
INFO     search inputs ...
INFO     find script foo.py
INFO     find 1 top resources
DEBUG    unknown error, please check pyarmor.error.log
ERROR    request license token failed (3): <h1>Server Error (500)</h1>
ERROR    somthing is wrong
*=============================================================*
*  Please check                                               *
*    https://pyarmor.readthedocs.io/en/latest/questions.html  *
*  or run `pyarmor man` to find solutions quickly             *
*                                                             *
*  It's recommand to report issue by `pyarmor man` in order   *
*  to provide necessary information, and avoid dupcliated     *
*  issues or unclear question.                                *
*=============================================================*

C:\Users\bulid\demo>pyarmor --version
Pyarmor 8.5.1 (trial), 000000, non-profits

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


C:\Users\bulid\demo>

pyarmor.repoer.bug:

[Bug] RuntimeError: request license token failed (3): <h1>Server Error (500)</h1>

### Full command options and console output
C:\Users\bulid\AppData\Local\Programs\Python\Python37-32\Scripts\pyarmor -d gen foo.py

2024-03-19 14:11:39,828 Python 3.7.4
2024-03-19 14:11:39,829 Pyarmor 8.5.1 (trial), 000000, non-profits
2024-03-19 14:11:39,829 Platform windows.x86
2024-03-19 14:11:39,830 native platform windows.x86
2024-03-19 14:11:39,830 home path: C:\Users\bulid\.pyarmor
2024-03-19 14:11:39,830 command options: {'no_runtime': False, 'inputs': ['foo.py']}
2024-03-19 14:11:39,830 install plugin: CodesignPlugin
2024-03-19 14:11:39,830 install plugin: DarwinUniversalPlugin
2024-03-19 14:11:39,830 search inputs ...
2024-03-19 14:11:39,831 find script foo.py
2024-03-19 14:11:39,831 find 1 top resources
2024-03-19 14:11:40,173 unknown error, please check pyarmor.error.log
2024-03-19 14:11:40,176 request license token failed (3): <h1>Server Error (500)</h1>


### Traceback
Traceback (most recent call last):
  File "c:\users\bulid\appdata\local\programs\python\python37-32\lib\site-packages\pyarmor\cli\__main__.py", line 757, in main
    main_entry(sys.argv[1:])
  File "c:\users\bulid\appdata\local\programs\python\python37-32\lib\site-packages\pyarmor\cli\__main__.py", line 745, in main_entry
    return args.func(ctx, args)
  File "c:\users\bulid\appdata\local\programs\python\python37-32\lib\site-packages\pyarmor\cli\__main__.py", line 237, in cmd_gen
    builder.process(options)
  File "c:\users\bulid\appdata\local\programs\python\python37-32\lib\site-packages\pyarmor\cli\generate.py", line 155, in process
    Pytransform3.pre_build(self.ctx)
  File "c:\users\bulid\appdata\local\programs\python\python37-32\lib\site-packages\pyarmor\cli\core\__init__.py", line 120, in pre_build
    m = Pytransform3.init(ctx)
  File "c:\users\bulid\appdata\local\programs\python\python37-32\lib\site-packages\pyarmor\cli\core\__init__.py", line 100, in init
    m.init_ctx(ctx)
RuntimeError: request license token failed (3): <h1>Server Error (500)</h1>

pyarmor.eeror.log:

3528 MainProcess 2024-03-19 14:21:45,899
Traceback (most recent call last):
  File "c:\users\bulid\appdata\local\programs\python\python37-32\lib\site-packages\pyarmor\cli\__main__.py", line 757, in main
    main_entry(sys.argv[1:])
  File "c:\users\bulid\appdata\local\programs\python\python37-32\lib\site-packages\pyarmor\cli\__main__.py", line 745, in main_entry
    return args.func(ctx, args)
  File "c:\users\bulid\appdata\local\programs\python\python37-32\lib\site-packages\pyarmor\cli\__main__.py", line 237, in cmd_gen
    builder.process(options)
  File "c:\users\bulid\appdata\local\programs\python\python37-32\lib\site-packages\pyarmor\cli\generate.py", line 155, in process
    Pytransform3.pre_build(self.ctx)
  File "c:\users\bulid\appdata\local\programs\python\python37-32\lib\site-packages\pyarmor\cli\core\__init__.py", line 120, in pre_build
    m = Pytransform3.init(ctx)
  File "c:\users\bulid\appdata\local\programs\python\python37-32\lib\site-packages\pyarmor\cli\core\__init__.py", line 100, in init
    m.init_ctx(ctx)
RuntimeError: request license token failed (3): <h1>Server Error (500)</h1>

全新系统,还是不行,依旧是**request license token failed (3): Server Error (500)**这个错误。

以下为.pyarmor相关目录文件

Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

C:\Users\bulid\.pyarmor>dir
 驱动器 C 中的卷没有标签。
 卷的序列号是 2CE1-80C3

 C:\Users\bulid\.pyarmor 的目录

2024/03/19  14:09    <DIR>          .
2024/03/19  14:09    <DIR>          ..
2024/03/19  14:10                 0 .license.token
2024/03/19  14:09             2,835 .pyarmor_capsule.zip
2024/03/19  14:08    <DIR>          group
2024/03/19  14:09               197 license.lic
               3 个文件          3,032 字节
               3 个目录 205,155,770,368 可用字节

C:\Users\bulid\.pyarmor>cd group

C:\Users\bulid\.pyarmor\group>dir
 驱动器 C 中的卷没有标签。
 卷的序列号是 2CE1-80C3

 C:\Users\bulid\.pyarmor\group 的目录

2024/03/19  14:08    <DIR>          .
2024/03/19  14:08    <DIR>          ..
2024/03/19  14:08               141 pyarmor-group-device.7
2024/03/19  14:08    <DIR>          tokens
               1 个文件            141 字节
               3 个目录 205,155,770,368 可用字节

C:\Users\bulid\.pyarmor\group>cd tokens

C:\Users\bulid\.pyarmor\group\tokens>dir
 驱动器 C 中的卷没有标签。
 卷的序列号是 2CE1-80C3

 C:\Users\bulid\.pyarmor\group\tokens 的目录

2024/03/19  14:08    <DIR>          .
2024/03/19  14:08    <DIR>          ..
2024/03/19  14:08               549 mbb859339bd24aba0eeaa374b91459549
               1 个文件            549 字节
               2 个目录 205,155,770,368 可用字节

C:\Users\bulid\.pyarmor\group\tokens>

machine id 一直为 mbb859339bd24aba0eeaa374b91459549 并未发生改变

已经测试了1~10台设备(都无法使用了)。均是pyarmor gen xxx.py直接报的500。你们再看看是哪里的问题吧。

你们的 Windows 是物理设备,还是 Qemu,还是 Docker container?

问题已经重现,正在解决中

已经解决,上传了一个快速补丁,需要下载覆盖原来的 /path/to/pyarmor/cli/core/*.pyd

https://pyarmor.dashingsoft.com/downloads/temp/win32.x86/py37/pytransform3.pyd
https://pyarmor.dashingsoft.com/downloads/temp/win32.x86/py37/pyarmor_runtime.pyd

新的扩展模块会在 pyarmor.cli.core 下次发布的时候更新,但是下一次 Pyarmor 版本不一定会更新 pyarmor.cli.core 库,内核库因为比较大,更新时间会在一个月之后.

好的,已解决问题,谢谢帮助

We're also facing this issue. Any progress so far?

The next

A quick walkaroud is downloading pre-release extensions from

https://pyarmor.dashingsoft.com/downloads/temp/win32.x86/py37/pytransform3.pyd
https://pyarmor.dashingsoft.com/downloads/temp/win32.x86/py37/pyarmor_runtime.pyd

Then overwrite same file at /path/to/pyarmor/cli/core/*.pyd

Or waiting for next release of pyarmor.cli.core, it may one month later.

We are using python 3.11 on windows x86_64
I get this error:
image

do you have the links for a compatible version?

@aykutkilic

This solution is not for your case. It's only for Group License in 32-bit Windows.

Please first run pyarmor-man to find the solutions, if not, report new issues with necessary information

Fixed in v8.5.3