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] Bug while packing with --mix-str #908

Closed
kr1tx opened this issue Dec 31, 2022 · 16 comments
Closed

[BUG] Bug while packing with --mix-str #908

kr1tx opened this issue Dec 31, 2022 · 16 comments
Assignees
Labels

Comments

@kr1tx
Copy link

kr1tx commented Dec 31, 2022

After packing with the following command

pyarmor pack --with-license licenses\new\license.lic -x " --mix-str --advanced 1 --plugin check_ntp_time" -e " --onefile --icon icon.ico" Script.py

After packing successfully. I encounter the following error when running the obfuscated script
Note The problem will stay the same even if I waited for the script to be packed using pyinstaller.

File "Script.py", line 4, in <module>
  File "<frozen Script>", line 202, in <module>
  File "<frozen Script>", line -1, in NTPException
NameError: name 'utf' is not defined

Note that: If I removed the --mix-str option the code will run with no problems at all after packing.

I have implemented these lines at the beginning of my code

# -*- coding: utf-8 -*-
# {PyArmor Plugins}
# PyArmor Plugin: check_ntp_time()

Any help?

@kr1tx kr1tx added the bug label Dec 31, 2022
@jondy
Copy link
Contributor

jondy commented Jan 2, 2023

What's line 202 of "Script.py"?

@kr1tx
Copy link
Author

kr1tx commented Jan 3, 2023

Line 202 is in the "check_ntp_time" plugin I guess.

199. class NTPStats(NTPPacket):
200.     """NTP statistics.
201. 
202.     Wrapper for NTPPacket, offering additional statistics like offset and
203.     delay, and timestamps converted to system time.
204.     """

So even If I removed the option --plugin check_ntp_time" and the comments for the plugin from Script.py. The error will still persist:

Traceback (most recent call last):
  File "Script.py>", line 3, in <module>
  File "<frozen Script>", line 1, in <module>
NameError: name 'utf' is not define 

And the line 3 in Script.py is try: And line 1 is # -*- coding: utf-8 -*-

@kr1tx
Copy link
Author

kr1tx commented Jan 3, 2023

The problem is not in my code. Even with the following command the same error still persist pyarmor obfuscate Script.py --mix-str
I ran this command on a very simple script:

1. # -*- coding: utf-8 -*-
2. 
3. print("ok")

And still. I get the same error Whenever I run the script after a successful Obfuscation:

Traceback (most recent call last):
  File "<Script.py>", line 3, in <module>
  File "<frozen Script>", line -1, in <module>
NameError: name 'utf' is not defined

@jondy
Copy link
Contributor

jondy commented Jan 4, 2023

Which pyarmor version is used? I can't reproduce it in the latest version 7.7.4

@kr1tx
Copy link
Author

kr1tx commented Jan 4, 2023

I am using PyArmor Version 7.7.4

@kr1tx
Copy link
Author

kr1tx commented Jan 5, 2023

Python version used is Python 3.10.8

@jondy
Copy link
Contributor

jondy commented Jan 5, 2023

Reproduced, it will be fixed with next major version 8.0

jondy added a commit that referenced this issue Jan 5, 2023
@jondy
Copy link
Contributor

jondy commented Jan 5, 2023

This patch e9b10f0 is a quick workaroud:

@jondy
Copy link
Contributor

jondy commented Jan 6, 2023

Here it's a simple release plan
https://github.com/dashingsoft/pyarmor#release-plan

Here it's how pyarmor to find c compiler, check it to find the solution
https://github.com/dashingsoft/pyarmor/blob/master/src/sppmode.py#L85

@kr1tx
Copy link
Author

kr1tx commented Jan 6, 2023

Thanks! You were truly helpful.
Sadly I am facing a new issue.. So If I tried to obfuscate a script using the following command: pyarmor obfuscate --with-license licenses\new\license.lic --mix-str --advanced 5 --plugin check_ntp_time hello.py the script will be obfuscated successfully but it would close after I run it. Without showing any error or so.

The script used:

# -*- coding: utf-8 -*-
# {PyArmor Plugins}
# PyArmor Plugin: check_ntp_time()


print("ok")

I tried removing --plugin check_ntp_time and the script worked after a successful obfuscation.
The problem is I need my software to be time-limited. I apologize for the oversight If there's something I have missed.

@kr1tx
Copy link
Author

kr1tx commented Jan 6, 2023

Removing **--mix-str** and keeping --plugin check_ntp_time Fixes the issue..: pyarmor obfuscate --with-license licenses\new\license.lic --advanced 5 --plugin check_ntp_time hello.py

@jondy jondy closed this as completed Mar 23, 2023
@kr1tx
Copy link
Author

kr1tx commented Mar 28, 2023

Hey @jondy this problem still persists. Such script would not work
The commands used: pyarmor-7 pack --with-license licenses\new\license.lic -x " --mix-str --advanced 5 --plugin check_ntp_time" -e " --onefile --icon fuse.ico" Script.py

# -*- coding: utf-8 -*-
# {PyArmor Plugins}
# PyArmor Plugin: check_ntp_time()
"""it all done, you can rest now 1:48 PM"""
print("hello friend.")

@jondy
Copy link
Contributor

jondy commented Mar 28, 2023

What's the error message?

@kr1tx
Copy link
Author

kr1tx commented Mar 29, 2023

I get no errors, the script just exits.

Edit: If I removed --mix-str and kept --plugin check_ntp_time or removed --plugin check_ntp_time and kept --mix-strthe script would work fine but both are required

@kr1tx
Copy link
Author

kr1tx commented Mar 30, 2023

@jondy hello?

@jondy
Copy link
Contributor

jondy commented Mar 30, 2023

I'll fix 7.x bug later. This will be fixed in 8.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

2 participants