How to Decompile a PyInstaller EXE: Step‑by‑Step Guide
This tutorial explains how to unpack a PyInstaller‑packed executable, restore the missing .pyc header, and decompile the resulting bytecode back to readable Python source using pyinstxtractor, 010Editor, and uncompyle6.
Tools used:
pyinstxtractor.py – extracts the contents of a PyInstaller‑packed exe into a folder.
uncompyle6 – decompiles .pyc files back to Python source.
010Editor (or any binary editor) – view and edit binary data.
Installation
pip install uncompyle6Step 1: Unpack the exe
python3 pyinstxtractor.py ***.exe # replace with your target exeThis creates a folder named filename_extracted containing the unpacked data.
Step 2: Add missing header
PyInstaller removes the first eight bytes of the .pyc file. You must prepend them: the first four bytes are the Python version magic number, the next four are the timestamp. Retrieve the version from the struct information inside the original exe.
1. Locate the file named after the exe (without extension) in the extracted folder.
2. Open it with 010Editor, copy the first eight bytes.
3. Open the target file (e.g., abc_text) and insert the copied bytes at the beginning.
4. Rename the file to add the .pyc extension.
Step 3: Decompile the .pyc
The resulting .pyc can now be decompiled. Use uncompyle6:
uncompyle6 abc_text.pyc > abc_text.pyThe command produces the original Python source file.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
