Skip to content

Commit

Permalink
Fix: edge case blank grabber does not work.
Browse files Browse the repository at this point in the history
  • Loading branch information
remiliacn committed Dec 19, 2024
1 parent b02754c commit b2460ad
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ __pycache__/
*.exe
*_extracted/
.idea/
*.txt
2 changes: 1 addition & 1 deletion amnesia_decompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def _decompile_blank_grabber(pyc_decompiled: str, directory: str):
def _find_blank_grabber_pyc(directory: str) -> str:
for root, _, files in walk(directory):
for file in files:
if file.endswith(".pyc") and fullmatch(r"(\w+-\w+)+.pyc", file):
if file.endswith(".pyc") and fullmatch(r"(.*?).pyc", file) and not file.startswith('pyi') and file != 'struct.pyc':
return path.join(root, file)


Expand Down
21 changes: 19 additions & 2 deletions pyinstxtractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
import marshal
import zlib
import sys
from string import printable
from uuid import uuid4 as uniquename


Expand Down Expand Up @@ -280,6 +281,13 @@ def extractFiles(self):
os.chdir(extractionDir)

for entry in self.tocList:
_filename = entry.name.replace('\x00', '')
for value in entry.name:
if value not in printable:
_filename.replace(value, '')

entry.name = _filename

self.fPtr.seek(entry.position, os.SEEK_SET)
data = self.fPtr.read(entry.cmprsdDataSize)

Expand Down Expand Up @@ -348,13 +356,22 @@ def extractFiles(self):

def _fixBarePycs(self):
for pycFile in self.barePycList:
with open(pycFile, 'r+b') as pycFile:
_filename = pycFile.replace('\x00', '')
for value in pycFile:
if value not in printable:
_filename.replace(value, '')
with open(_filename, 'r+b') as pycFile:
# Overwrite the first four bytes
pycFile.write(self.pycMagic)


def _writePyc(self, filename, data):
with open(filename, 'wb') as pycFile:
_filename = filename.replace('\x00', '')
for value in filename:
if value not in printable:
_filename.replace(value, '')

with open(_filename, 'wb') as pycFile:
pycFile.write(self.pycMagic) # pyc magic

if self.pymaj >= 3 and self.pymin >= 7: # PEP 552 -- Deterministic pycs
Expand Down

0 comments on commit b2460ad

Please sign in to comment.