Skip to content

Commit 5c3d6ba

Browse files
[1.0.1] Fix: Section without EntropyEncoding && Infinite ressources
1 parent 886de6b commit 5c3d6ba

File tree

6 files changed

+33
-19
lines changed

6 files changed

+33
-19
lines changed

PKG-INFO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 2.1
22
Name: ProgramExecutableAnalyzer
3-
Version: 1.0.0
3+
Version: 1.0.1
44
Summary: This script analyzes MZ-PE (MS-DOS) executable.
55
Home-page: https://github.com/mauricelambert/ProgramExecutableAnalyzer
66
Author: Maurice Lambert

ProgramExecutableAnalyzer.egg-info/PKG-INFO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 2.1
22
Name: ProgramExecutableAnalyzer
3-
Version: 1.0.0
3+
Version: 1.0.1
44
Summary: This script analyzes MZ-PE (MS-DOS) executable.
55
Home-page: https://github.com/mauricelambert/ProgramExecutableAnalyzer
66
Author: Maurice Lambert

ProgramExecutableAnalyzer.egg-info/SOURCES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ LICENSE.txt
22
MANIFEST.in
33
ProgramExecutableAnalyzer.py
44
README.md
5+
rich_ids.txt
56
setup.cfg
67
setup.py
78
ProgramExecutableAnalyzer.egg-info/PKG-INFO

ProgramExecutableAnalyzer.py

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
This script analyzes MZ-PE (MS-DOS) executable file.
2424
"""
2525

26-
__version__ = "1.0.0"
26+
__version__ = "1.0.1"
2727
__author__ = "Maurice Lambert"
2828
__author_email__ = "mauricelambert434@gmail.com"
2929
__maintainer__ = "Maurice Lambert"
@@ -47,9 +47,10 @@
4747

4848
from sys import argv, stderr, stdin, exit, executable
4949
from string import printable as printable_
50+
from os.path import basename, isfile
5051
from urllib.request import urlopen
52+
from dataclasses import dataclass
5153
from shutil import copyfileobj
52-
from os.path import basename
5354
from binascii import hexlify
5455
from os.path import getsize
5556
from random import randint
@@ -58,6 +59,12 @@
5859
from time import ctime
5960
from os import name
6061

62+
@dataclass
63+
class Section:
64+
label: str
65+
start_position: int
66+
size: int
67+
6168
try:
6269
from EntropyAnalysis import charts_chunks_file_entropy, Section
6370
from matplotlib import pyplot
@@ -1173,13 +1180,14 @@ class SYSTEMTIME(Structure):
11731180
if calcul_checksum == checksum_value
11741181
else "Invalid checksum",
11751182
)
1176-
with open("rich_ids.txt", "wb") as rich_headers:
1177-
copyfileobj(
1178-
urlopen(
1179-
"https://raw.githubusercontent.com/dishather/richprint/master/comp_id.txt"
1180-
),
1181-
rich_headers,
1182-
)
1183+
if not isfile("rich_ids.txt"):
1184+
with open("rich_ids.txt", "wb") as rich_headers:
1185+
copyfileobj(
1186+
urlopen(
1187+
"https://raw.githubusercontent.com/dishather/richprint/master/comp_id.txt"
1188+
),
1189+
rich_headers,
1190+
)
11831191
with open("rich_ids.txt") as rich_headers:
11841192
for id_, value in sorted(ids.items(), key=lambda x: x[1]):
11851193
for line in rich_headers:
@@ -3831,14 +3839,17 @@ def read_StringFileInfo():
38313839
def read_resources_headers(main=False):
38323840
global position, last_object
38333841
data = file.read(4)
3834-
vprint(
3842+
time_ = file.read(4)
3843+
if any(time_):
3844+
return
3845+
print(
38353846
"Characteristics".ljust(25),
38363847
f"{position:0>8x}-{position+4:0>8x}".ljust(20),
38373848
hexlify(data).decode().ljust(40),
38383849
"".join(chr(x) if x in printable else "." for x in data).ljust(20),
38393850
int.from_bytes(data, "little"),
38403851
)
3841-
data = file.read(4)
3852+
data = time_
38423853
print(
38433854
"Timestamp".ljust(25),
38443855
f"{position+4:0>8x}-{position+8:0>8x}".ljust(20),
@@ -4265,11 +4276,13 @@ def read_resources_headers(main=False):
42654276

42664277
overlay_position = max([x.start_position + x.size for x in sections])
42674278
file.seek(overlay_position)
4268-
try:
4269-
with open("overlay_" + basename(argv[1]), "wb") as overlay:
4270-
copyfileobj(file, overlay)
4271-
except PermissionError:
4272-
print("Permission Denied to extract overlay.", file=stderr)
4279+
if file.read(1):
4280+
file.seek(overlay_position)
4281+
try:
4282+
with open("overlay_" + basename(argv[1]), "wb") as overlay:
4283+
copyfileobj(file, overlay)
4284+
except PermissionError:
4285+
print("Permission Denied to extract overlay.", file=stderr)
42734286
if entropy_charts_import:
42744287
axes = pyplot.gca()
42754288
axes.invert_yaxis()

rich_ids.txt

Whitespace-only changes.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="ProgramExecutableAnalyzer",
5-
version="1.0.0",
5+
version="1.0.1",
66
py_modules=["ProgramExecutableAnalyzer"],
77
install_requires=[],
88
author="Maurice Lambert",

0 commit comments

Comments
 (0)