Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the executable file produced by decompiling pyinstaller

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Today, I will talk to you about what the executable file generated by decompiling pyinstaller is, many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

In a calculation, when using a binary program written by python and then compiled and packaged by someone else, it always reports an error "missing chain ID", but check that chain ID has been added to the pdb file.

In order to find out the cause of the error, the binary executable file is decompiled. The following is a record of the operation:

Python is an interpreted language, so executable files compiled and packaged by python are easy to be decompiled, while executable files obtained by compiled languages such as Cdinger + are more difficult to decompile.

The executable file produced by decompiling pyinstaller can be divided into two steps: one is to obtain the pyc (pyo) file from the executable file, and the other is to get the py file from the pyc (pyo) file.

Get the pyc file

When running the pyintaller-packaged executable on Linux, it unzips the packaged file to the _ MEIxxxxxx path in the temporary folder (/ tmp) and temporarily stores it, and then deletes it after execution, so there will be time to extract. However, this _ MEIxxxxxx path is mainly .so files and does not contain source code.

However, pyinstaller comes with the script archive_viewer.py, which can be extracted from the executable file to get the pyc file:

1python archive_viewer.py exefilename

There are four commands available:

1234U: go Up one levelO: open embedded archive nameX: extract nameQ: quit

There are two sections in the list to watch, one is out00-PYZ.pyz, which contains all the libraries referenced by the main program, and the other is the file name of the main program, which will contain the main program.

For example, a program that displays the weather, whose main program name is show.py, calls calc.py, which requires

12x show extracts to show.pyc o out00-PYZ.pyz and then looks at the called library, and then x calc extracts to calc.pyc

So we get show.pyc and calc.pyc.

The method of getting py file from pyc

There are many methods, such as

Online programs, such as python decompilation, online pyc decompilation, etc.

Uncompyle6 is a python script, so it can be run in batches, using uncompyle6 file.pyc.

Easypythondecompiler et al.

Be careful

When pyinstaller is compiled into pyc, the magic value of pyc is removed, and if you use easypythondecompiler, you need to add magic value (using 010 Editor editor). Magic value has a total of 8 bytes, the first four correspond to the version of python used at compile time, and the last four correspond to the compilation time, such as python2.7 03f30d 0a 01 23 4567 ee 0c 0d 0a 01 23 45 67 in python 3.4. If you don't know the python version used at compile time, you can find it through a trick: the first four bytes already exist in the pyc file (such as pyimod01_os_path) that the first few files contained in the executable file.

This way, files such as show.py and calc.py can be decompiled.

After reading the above, do you have any further understanding of what the executable files produced by decompiling pyinstaller are? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report