Skip to content

code2319/decompilation-process-of-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

0. Create venv and download dependencies

  1. python -m pip install uncompyle6
  2. download pyinstallerextractor

1. Convert exe file to pyc file

Using pyinstxtrator.py, enter the command in cmd (from venv): python pyinstxtractor.py xxx.exe изображение изображение

After successful decompression, a [XXX. Exe] extracted folder will appear in the same path, which contains the main program without any suffix. What we need to decompile is this file, and others are dependent libraries, such as pyz extracted folder. At this point, we may wonder why this file is not a. pyc file? This may be one of the shortcomings of the pyinstxtrator. The main program converted is not in the right format. We need to fix it manually.

2. Repair .pyc file

If you directly change the suffix of the main file to main.pyc for decompilation, an error will occur. изображение

The reason is that the file header magic number is not aligned, so you need to add magic number. Different python versions of magic number are different.

Python 3.6.0's:
изображение

Python 3.7.2's:
изображение

3. How to get magic number

Compile one by yourself to see how many pyinstaller is required for compiling py files, and modules can be installed with pip.
изображение

Hexadecimal view its magic number (C:\Users\Maksim\desktop\1\__pycache__)
изображение

4. Add magic number

Add magic number at the top.
Source:
изображение

Add bytes:
изображение

After adding:
изображение

Save .pyc file.

5. Decompile pyc files

изображение

Done, the source code is displayed in the terminal (a part of the source code is visible in the screenshot).

Releases

No releases published

Packages

No packages published

Languages