Skip to content

Fix the compatibility issue by modifying the way to get the PYC header #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pyinstxtractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,15 @@
import marshal
import zlib
import sys
import imp
import types
from uuid import uuid4 as uniquename

try:
import importlib.util
PYC_MAGIC=importlib.util.MAGIC_NUMBER
except ImportError:
import imp
PYC_MAGIC=imp.get_magic()

class CTOCEntry:
def __init__(self, position, cmprsdDataSize, uncmprsdDataSize, cmprsFlag, typeCmprsData, name):
Expand Down Expand Up @@ -274,7 +279,7 @@ def _extractPyz(self, name):

pycHeader = f.read(4) # Python magic value

if imp.get_magic() != pycHeader:
if PYC_MAGIC != pycHeader:
print('[!] Warning: The script is running in a different python version than the one used to build the executable')
print(' Run this script in Python{0} to prevent extraction errors(if any) during unmarshalling'.format(self.pyver))

Expand Down