@@ -190,21 +190,22 @@ def getCArchiveInfo(self):
190190 self .fPtr .seek (self .cookiePos , os .SEEK_SET )
191191
192192 # Read CArchive cookie
193- (magic , lengthofPackage , toc , tocLen , self . pyver ) = \
193+ (magic , lengthofPackage , toc , tocLen , pyver ) = \
194194 struct .unpack ('!8siiii' , self .fPtr .read (self .PYINST20_COOKIE_SIZE ))
195195
196196 elif self .pyinstVer == 21 :
197197 self .fPtr .seek (self .cookiePos , os .SEEK_SET )
198198
199199 # Read CArchive cookie
200- (magic , lengthofPackage , toc , tocLen , self . pyver , pylibname ) = \
200+ (magic , lengthofPackage , toc , tocLen , pyver , pylibname ) = \
201201 struct .unpack ('!8siiii64s' , self .fPtr .read (self .PYINST21_COOKIE_SIZE ))
202202
203203 except :
204204 print ('[!] Error : The file is not a pyinstaller archive' )
205205 return False
206206
207- print ('[+] Python version: {0}' .format (self .pyver ))
207+ self .pymaj , self .pymin = (pyver // 100 , pyver % 100 ) if pyver >= 100 else (pyver // 10 , pyver % 10 )
208+ print ('[+] Python version: {0}.{1}' .format (self .pymaj , self .pymin ))
208209
209210 # Additional data after the cookie
210211 tailBytes = self .fileSize - self .cookiePos - (self .PYINST20_COOKIE_SIZE if self .pyinstVer == 20 else self .PYINST21_COOKIE_SIZE )
@@ -319,13 +320,13 @@ def _writePyc(self, filename, data):
319320 with open (filename , 'wb' ) as pycFile :
320321 pycFile .write (pyc_magic ) # pyc magic
321322
322- if self .pyver >= 37 : # PEP 552 -- Deterministic pycs
323+ if self .pymaj >= 3 and self . pymin >= 7 : # PEP 552 -- Deterministic pycs
323324 pycFile .write (b'\0 ' * 4 ) # Bitfield
324325 pycFile .write (b'\0 ' * 8 ) # (Timestamp + size) || hash
325326
326327 else :
327328 pycFile .write (b'\0 ' * 4 ) # Timestamp
328- if self .pyver >= 33 :
329+ if self .pymaj >= 3 and self . pymin >= 3 :
329330 pycFile .write (b'\0 ' * 4 ) # Size parameter added in Python 3.3
330331
331332 pycFile .write (data )
@@ -346,7 +347,7 @@ def _extractPyz(self, name):
346347 # Skip PYZ extraction if not running under the same python version
347348 if pyc_magic != pycHeader :
348349 print ('[!] Warning: This script is running in a different Python version than the one used to build the executable.' )
349- print ('[!] Please run this script in Python{0} to prevent extraction errors during unmarshalling' .format (self .pyver ))
350+ print ('[!] Please run this script in Python {0}.{1} to prevent extraction errors during unmarshalling' .format (self .pymaj , self . pymin ))
350351 print ('[!] Skipping pyz extraction' )
351352 return
352353
0 commit comments