Skip to content

Commit 6c8dcd4

Browse files
committed
PEExtractor: Add Inno Setup (used by NEC) extraction
1 parent a128edb commit 6c8dcd4

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ FROM debian:bullseye
4747
# Install runtime dependencies.
4848
RUN sed -i -e 's/main/main contrib non-free/' /etc/apt/sources.list && \
4949
apt-get update && \
50-
DEBIAN_FRONTEND=noninteractive apt-get install -y python3 python3-pip p7zip-full p7zip-rar unshield qemu-system-x86 && \
50+
DEBIAN_FRONTEND=noninteractive apt-get install -y python3 python3-pip p7zip-full p7zip-rar innoextract unshield qemu-system-x86 && \
5151
apt-get clean && \
5252
rm -rf /var/lib/apt/lists
5353

biostools/extractors.py

+33
Original file line numberDiff line numberDiff line change
@@ -2300,6 +2300,13 @@ def extract(self, file_path, file_header, dest_dir, dest_dir_0):
23002300
if ret:
23012301
return ret
23022302

2303+
# Cover Inno Setup installers.
2304+
if file_header[48:52] == b'Inno':
2305+
# Determine if this executable can be extracted with innoextract.
2306+
ret = self._extract_inno(file_path, file_header, dest_dir)
2307+
if ret:
2308+
return ret
2309+
23032310
# Read up to 16 MB as a safety net.
23042311
file_header += util.read_complement(file_path, file_header)
23052312

@@ -2455,6 +2462,32 @@ def _extract_flashtool(self, file_path, file_header, dest_dir, match):
24552462
# Return destination directory path.
24562463
return dest_dir
24572464

2465+
def _extract_inno(self, file_path, file_header, dest_dir):
2466+
# Create destination directory and stop if it couldn't be created.
2467+
if not util.try_makedirs(dest_dir):
2468+
return True
2469+
2470+
# Run innoextract command.
2471+
try:
2472+
subprocess.run(['innoextract', '-e', os.path.abspath(file_path)], stdout=self._devnull, stderr=subprocess.STDOUT, cwd=dest_dir)
2473+
except:
2474+
pass
2475+
2476+
# Assume failure if nothing was extracted.
2477+
files_extracted = os.listdir(dest_dir)
2478+
if len(files_extracted) < 1:
2479+
self.debug_print('Extraction produced no files:', file_path)
2480+
return False
2481+
2482+
# Remove file.
2483+
try:
2484+
os.remove(file_path)
2485+
except:
2486+
pass
2487+
2488+
# Return destination directory path.
2489+
return dest_dir
2490+
24582491

24592492
class TarExtractor(ArchiveExtractor):
24602493
"""Extract tar archives."""

0 commit comments

Comments
 (0)