Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] ERROR /usr/local/lib/python3.11/dist-packages/pyarmor/cli/core/pytransform3.so: invalid ELF header #969

Closed
SamComber opened this issue Mar 13, 2023 · 17 comments
Assignees
Labels

Comments

@SamComber
Copy link
Contributor

SamComber commented Mar 13, 2023

I've installed pyarmor 8.0.1 inside a container, I haven't yet supplied a license (we have a license for 5.6.0 pyarmor and not sure if this will work with pyarmor 8.0.1).

I'm running a very simple obfuscation to do a quick test with the new version inside my hardware, and in accordance to trial version rules The maximum size of code object is 35728 bytes in trial version

root@7e7e3fde4ede:/# cat test.py
print(1)

root@7e7e3fde4ede:/# pyarmor gen test.py
INFO     Python 3.11.2
INFO     Pyarmor 8.0 (trial), 000000, non-profits
INFO     search inputs ...
INFO     find script test.py
INFO     find 1 top resources
CRITICAL unknown error, please check pyarmor.error.log
ERROR    /usr/local/lib/python3.11/dist-packages/pyarmor/cli/core/pytransform3.so: invalid ELF header

What is going on here?

@SamComber
Copy link
Contributor Author

uname -a

Linux 7e7e3fde4ede 5.15.78-0-virt #1-Alpine SMP Fri, 11 Nov 2022 10:19:45 +0000 x86_64 x86_64 x86_64 GNU/Linux

@jondy
Copy link
Contributor

jondy commented Mar 15, 2023

Pyarmor 8.0.x only works x86_64 platforms, other platforms will be supported later.

@jondy jondy closed this as completed Mar 15, 2023
@SamComber
Copy link
Contributor Author

@jondy, but I’m running this inside container with virtual “x86_64”, will this only work on actual x86_64 and not in container ?

@jondy
Copy link
Contributor

jondy commented Mar 16, 2023

This is Alpine, it use musl-c, not glib-c.

It will be supported later.

@fO-000
Copy link

fO-000 commented Mar 16, 2023

@jondy I also encountered this issue on the following system, is it caused by musl-c too?

Linux x 6.1.0-kali5-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.12-1kali2 (2023-02-23) x86_64 GNU/Linux
$ pyarmor reg --upgrade -p "non-profits" assets/pyarmor-regcode-xxxx.txt
INFO     Python 3.11.2
INFO     Pyarmor 8.0 (trial), 000000, non-profits
INFO     prepare "assets/pyarmor-regcode-xxxx.txt"
INFO     query key file from server

You are about to upgrade old Pyarmor license to Pyarmor Basic
License for Pyarmor 8.0+

The original license no: pyarmor-vax-00xxxx

The upgraded license information will be

License Type    : pyarmor-old
License Owner   : xxx
Bind Product    : non-profits

This license is about to be ussd for non-profits

Are you sure to continue? (yes/no) yes
INFO     process upgrading file "assets/pyarmor-regcode-xxxx.txt"
INFO     old license no: pyarmor-vax-00xxxx
INFO     send upgrade request to server
INFO     update license token
CRITICAL unknown error, please check pyarmor.error.log
ERROR    /home/x/.local/lib/python3.11/site-packages/pyarmor/cli/core/pytransform3.so: invalid ELF header

@jondy
Copy link
Contributor

jondy commented Mar 16, 2023

This python script could check which c lib is used, now only glib-c is supported:

import platform
print(platform.libc_ver())

@fO-000
Copy link

fO-000 commented Mar 16, 2023

Confirmed, my system is using glib-c 2.36, but also encountered this issue:

Python 3.11.2 (main, Feb 12 2023, 00:48:52) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> import platform
>>> print(platform.libc_ver())
('glibc', '2.36')

@SamComber
Copy link
Contributor Author

My system also...

Python 3.11.2 (main, Feb  8 2023, 14:49:25) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.libc_ver()
('glibc', '2.35')

@jondy
Copy link
Contributor

jondy commented Mar 16, 2023

@fO-000 @SamComber
If arch and libc are ok, another possible cause: endianness mismatch
now only little is supported

@SamComber
Copy link
Contributor Author

Seems the system is little endian, what else could be causing this?

Python 3.11.2 (main, Feb  8 2023, 14:49:25) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.byteorder
'little'

@jondy
Copy link
Contributor

jondy commented Mar 16, 2023

Check it by ldd

ldd /path/to/pyarmor/cli/core/pytransform3.so

@SamComber
Copy link
Contributor Author

@jondy , my guess is the below would work on little endian system? Thanks for your work on pyarmor 8+ release btw :)

root@aa456d15085d:/# ldd /usr/local/lib/python3.11/dist-packages/pyarmor/cli/core/pytransform3.so
	not a dynamic executable

@fO-000
Copy link

fO-000 commented Mar 17, 2023

@jondy Would you reopen this issue?

@SamComber My output is exactly the same as yours.

But another way of checking pytransform3.so dependencies outputs the following:

$ env LD_TRACE_LOADED_OBJECTS=1 /home/x/.local/lib/python3.11/site-packages/pyarmor/cli/core/pytransform3.so
	linux-vdso.so.1 (0x00007ffe8c132000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5346e3e000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f534704a000)

@fO-000
Copy link

fO-000 commented Mar 17, 2023

@jondy Found that the pytransform3.so file is in Mac format instead of Linux format:

$ file ~/.local/lib/python3.11/site-packages/pyarmor/cli/core/pytransform3.so
/home/x/.local/lib/python3.11/site-packages/pyarmor/cli/core/pytransform3.so: Mach-O 64-bit x86_64 dynamically linked shared library, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|NO_REEXPORTED_DYLIBS>

@jondy
Copy link
Contributor

jondy commented Mar 17, 2023

@fO-000 Thanks.

I'll check it.

@jondy
Copy link
Contributor

jondy commented Mar 17, 2023

@fO-000 please upgrade pyarmor.cli.core to 1.0.1, I just check this wheel

$ unzip pyarmor.cli.core-1.0.1-cp311-none-manylinux1_x86_64.whl
$ file pyarmor/cli/core/pyarmor_runtime.so 
pyarmor/cli/core/pyarmor_runtime.so: ELF 64-bit LSB pie executable x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=f2a3921afb9eb55d2ff615840e8e400926d8f103, stripped

@fO-000
Copy link

fO-000 commented Mar 17, 2023

Great, the issue is solved with pyarmor.cli.core version 1.0.1. But a new error appeared, like #983.

$ pyarmor reg --upgrade assets/pyarmor-regcode-xxxx.txt
INFO     Python 3.11.2
INFO     Pyarmor 8.0 (trial), 000000, non-profits
INFO     prepare "assets/pyarmor-regcode-xxxx.txt"
INFO     query key file from server

You are about to upgrade old Pyarmor license to Pyarmor Basic
License for Pyarmor 8.0+

The original license no: pyarmor-vax-00xxxx

The upgraded license information will be

License Type    : pyarmor-old
License Owner   : xxx
Bind Product    : non-profits

This license is about to be ussd for non-profits

Are you sure to continue? (yes/no) yes
INFO     process upgrading file "assets/pyarmor-regcode-xxxx.txt"
INFO     old license no: pyarmor-vax-00xxxx
INFO     send upgrade request to server
INFO     update license token
CRITICAL unknown error, please check pyarmor.error.log
ERROR    request license token faild (1)

The corresponding pyarmor.error.log file is as follows:

51838 MainProcess 2023-03-17 17:20:52,813
Traceback (most recent call last):
  File "/home/x/.local/lib/python3.11/site-packages/pyarmor/cli/__main__.py", line 559, in main
    main_entry(sys.argv[1:])
  File "/home/x/.local/lib/python3.11/site-packages/pyarmor/cli/__main__.py", line 547, in main_entry
    args.func(ctx, args)
  File "/home/x/.local/lib/python3.11/site-packages/pyarmor/cli/__main__.py", line 184, in cmd_reg
    getattr(regsvr, meth)(regfile, args.product)
  File "/home/x/.local/lib/python3.11/site-packages/pyarmor/cli/register.py", line 290, in upgrade
    self.update_token()
  File "/home/x/.local/lib/python3.11/site-packages/pyarmor/cli/register.py", line 110, in update_token
    Pytransform3._update_token(self.ctx)
  File "/home/x/.local/lib/python3.11/site-packages/pyarmor/cli/core/__init__.py", line 72, in _update_token
    m = Pytransform3.init(ctx)
        ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/x/.local/lib/python3.11/site-packages/pyarmor/cli/core/__init__.py", line 42, in init
    m.init_ctx(ctx)
RuntimeError: request license token faild (1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants