Information Security 3 min read

How to Decompile a PyInstaller‑Packed Executable Using pyinstxtractor and uncompyle6

This guide explains how to unpack a PyInstaller‑packed executable, restore the stripped .pyc header using a binary editor, and decompile the resulting file with uncompyle6, providing a step‑by‑step workflow for Python reverse‑engineering.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
How to Decompile a PyInstaller‑Packed Executable Using pyinstxtractor and uncompyle6

Tools required: pyinstxtractor.py (to unpack an exe generated by PyInstaller), uncompyle6 (a .pyc decompiler), and a binary editor such as 010 Editor.

Install uncompyle6 with pip install uncompyle6 .

Step 1 – Unpack the executable : run python3 pyinstxtractor.py your_file.exe (replace your_file.exe with the target file). The script creates a folder named your_file_extracted containing the extracted data.

Step 2 – Restore the missing header : PyInstaller removes the first eight bytes of each .pyc file (four‑byte Python version and four‑byte timestamp). Open the original executable in 010 Editor, copy the first eight bytes from the struct section, then prepend them to the extracted .pyc file (e.g., abc_text ) and rename the file with a .pyc extension.

After inserting the header, the file changes from the original state to the modified state:

Finally, rename the file with a .pyc suffix.

Step 3 – Decompile the .pyc file : run uncompyle6 abc_text.pyc > abc_text.py to obtain the original Python source code.

information securityReverse Engineeringpyinstallerdecompilationuncompyle6010editor
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.