pyarmor icon indicating copy to clipboard operation
pyarmor copied to clipboard

urllib.error.HTTPError: HTTP Error 401: Unauthorized when setting .pyarmor_config file to advanced_mode: 5

Open ddi98 opened this issue 3 years ago • 8 comments

hi, I'm trying to obfuscate my flask app but when in advanced_mode I set a parameter other than 0 I get the following error: urllib.error.HTTPError: HTTP Error 401: Unauthorized I bought the pro license! please help me i have to deliver this software and i can't deliver it without obfuscating the code

ddi98 avatar Mar 30 '23 16:03 ddi98

Could you provide the full traceback to give more context?

I suggest making a very simple "Hello World" Flask application and trying to obfuscate that. If that works, go through the application you're having problems with and comment out possible culprits.

AlecHaring avatar Mar 30 '23 17:03 AlecHaring

(venv) PS C:\Users\Giuseppe\Dropbox\PROGETTI_PYCHARM\FormulariTools> pyarmor-7 build INFO PyArmor Version 8.0.21 INFO Python 3.7.0 INFO Build project ... INFO Check project INFO Use capsule: C:\Users\Giuseppe.pyarmor.pyarmor_capsule.zip INFO Output path is: C:\Users\Giuseppe\Dropbox\PROGETTI_PYCHARM\FormulariTools\dist INFO Taget platforms: [] INFO Getting remote file: https://pyarmor.dashingsoft.com/files/r52.6/index.json Traceback (most recent call last): File "C:\Users\Giuseppe\Dropbox\PROGETTI_PYCHARM\FormulariTools\venv\lib\site-packages\pyarmor\utils.py", line 1685, in _urlopen return urlopen(*args, **kwargs) File "C:\Python37\lib\urllib\request.py", line 222, in urlopen return opener.open(url, data, timeout) File "C:\Python37\lib\urllib\request.py", line 531, in open response = meth(req, response) File "C:\Python37\lib\urllib\request.py", line 641, in http_response 'http', request, response, code, msg, hdrs) File "C:\Python37\lib\urllib\request.py", line 569, in error return self._call_chain(*args) File "C:\Python37\lib\urllib\request.py", line 503, in _call_chain result = func(*args) File "C:\Python37\lib\urllib\request.py", line 649, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 401: Unauthorized

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Python37\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "C:\Python37\lib\runpy.py", line 85, in run_code exec(code, run_globals) File "C:\Users\Giuseppe\Dropbox\PROGETTI_PYCHARM\FormulariTools\venv\Scripts\pyarmor-7.exe_main.py", line 7, in File "C:\Users\Giuseppe\Dropbox\PROGETTI_PYCHARM\FormulariTools\venv\lib\site-packages\pyarmor\pyarmor.py", line 1612, in main_entry main(sys.argv[1:]) File "C:\Users\Giuseppe\Dropbox\PROGETTI_PYCHARM\FormulariTools\venv\lib\site-packages\pyarmor\pyarmor.py", line 1604, in main args.func(args) File "C:\Users\Giuseppe\Dropbox\PROGETTI_PYCHARM\FormulariTools\venv\lib\site-packages\pyarmor\pyarmor.py", line 257, in _build platforms = check_cross_platform(platforms, supermode, vmenabled) File "C:\Users\Giuseppe\Dropbox\PROGETTI_PYCHARM\FormulariTools\venv\lib\site-packages\pyarmor\utils.py", line 1221, in check_cross_platform platid = _get_preferred_platid(name, features=features) File "C:\Users\Giuseppe\Dropbox\PROGETTI_PYCHARM\FormulariTools\venv\lib\site-packages\pyarmor\utils.py", line 1186, in _get_preferred_platid plist = [x['id'] for x in _get_platform_list() if x['name'] == name] File "C:\Users\Giuseppe\Dropbox\PROGETTI_PYCHARM\FormulariTools\venv\lib\site-packages\pyarmor\utils.py", line 239, in _get_platform_list res = _get_remote_file(platform_config, timeout=PYARMOR_TIMEOUT) File "C:\Users\Giuseppe\Dropbox\PROGETTI_PYCHARM\FormulariTools\venv\lib\site-packages\pyarmor\utils.py", line 230, in _get_remote_file return _urlopen(req, None, timeout) File "C:\Users\Giuseppe\Dropbox\PROGETTI_PYCHARM\FormulariTools\venv\lib\site-packages\pyarmor\utils.py", line 1689, in _urlopen return urlopen(*args, **kwargs) File "C:\Python37\lib\urllib\request.py", line 222, in urlopen return opener.open(url, data, timeout) File "C:\Python37\lib\urllib\request.py", line 531, in open response = meth(req, response) File "C:\Python37\lib\urllib\request.py", line 641, in http_response 'http', request, response, code, msg, hdrs) File "C:\Python37\lib\urllib\request.py", line 569, in error return self._call_chain(*args) File "C:\Python37\lib\urllib\request.py", line 503, in _call_chain result = func(*args) File "C:\Python37\lib\urllib\request.py", line 649, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 401: Unauthorized (venv) PS C:\Users\Giuseppe\Dropbox\PROGETTI_PYCHARM\FormulariTools>

ddi98 avatar Mar 30 '23 17:03 ddi98

@ddi98 which platform you used? pyarmor-7 is old pyarmor, the new license could not work with it.

Please check Pyarmor 8 documentation and use command gen to obfuscate the scripts.

jondy avatar Mar 30 '23 22:03 jondy

I would like to use version 8 but with the documentation found I can only obfuscate a single file.

what are the analogous commands of pyarmor8 to perform these two operations: pyarmor-7 init --entry:app.py pyarmor-7 build Thanks in advance

ddi98 avatar Mar 31 '23 09:03 ddi98

I kindly await your reply as I explained to you before I have to deliver this program and I can't without obfuscating the code.. but would it be possible to enable the advanced_mode functions on version 7 given that today version 8 is unusable?

if I can do the same things with version 8 all the better, but at least put us in a position to work. Thank you @jondy help me please

ddi98 avatar Mar 31 '23 17:03 ddi98

I would like to use version 8 but with the documentation found I can only obfuscate a single file.

List all the scripts and packages in the command line, gen command is designed to obfuscate package and list scripts.

For example

    pyarmor gen foo.py
    pyarmor gen src/mypkg
    pyarmor gen -r src/mypkg
    pyarmor gen -r src/pkg1 src/pkg2 libs/dbpkg
    pyarmor gen -r main.py src/*.py libs/utils.py libs/dbpkg

Also check man page of command gen in Pyarmor documentation 8.0

jondy avatar Apr 01 '23 01:04 jondy

hi @jondy , i tried with the following command: pyarmor gen -r C:/Users/Giuseppe/Dropbox/PROGETTI_PYCHARM/FormulariTools/app.py C:/Users/Giuseppe/Dropbox/PROGETTI_PYCHARM/FormulariTools

but the following error is returned in the pyarmor.error.log file: 18088 MainProcess 2023-04-01 11:26:50,522 Traceback (most recent call last): File "C:\Users\Giuseppe\Dropbox\PROGETTI_PYCHARM\FormulariTools\venv\lib\site-packages\pyarmor\cli\__main__.py", line 629, in main main_entry(sys.argv[1:]) File "C:\Users\Giuseppe\Dropbox\PROGETTI_PYCHARM\FormulariTools\venv\lib\site-packages\pyarmor\cli\__main__.py", line 617, in main_entry args.func(ctx, args) File "C:\Users\Giuseppe\Dropbox\PROGETTI_PYCHARM\FormulariTools\venv\lib\site-packages\pyarmor\cli\__main__.py", line 179, in cmd_gen builder.process(options, pack=args.pack) File "C:\Users\Giuseppe\Dropbox\PROGETTI_PYCHARM\FormulariTools\venv\lib\site-packages\pyarmor\cli\generate.py", line 153, in process self._obfuscate_scripts() File "C:\Users\Giuseppe\Dropbox\PROGETTI_PYCHARM\FormulariTools\venv\lib\site-packages\pyarmor\cli\generate.py", line 118, in _obfuscate_scripts code = Pytransform3.generate_obfuscated_script(self.ctx, r) File "C:\Users\Giuseppe\Dropbox\PROGETTI_PYCHARM\FormulariTools\venv\lib\site-packages\pyarmor\cli\core\__init__.py", line 48, in generate_obfuscated_script return m.generate_obfuscated_script(ctx, res) File "<maker>", line 719, in generate_obfuscated_script File "<maker>", line 522, in process File "<maker>", line 522, in <listcomp> File "<maker>", line 1812, in handle File "<maker>", line 1807, in visit File "<maker>", line 1804, in visit File "<maker>", line 1771, in patch_co_object File "<maker>", line 1756, in _check_co_info RuntimeError: co_info inner error

ddi98 avatar Apr 01 '23 09:04 ddi98

Please report new issue if it's a new bug.

jondy avatar Apr 01 '23 11:04 jondy