Skip to content

Commit 28c492e

Browse files
committed
Fix issue with hardcoded seek offset for decrypted modules
1 parent 37bc67e commit 28c492e

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

analyze_crypted_code.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ def process_code_object(code_obj, filedata: bytes, crypted_regions: list[dict])
118118

119119
def main(filename: str) -> None:
120120
with open(filename, "rb") as fp:
121-
fp.seek(0x20)
121+
skip = int.from_bytes(fp.read(4), 'little') + int.from_bytes(fp.read(4), 'little')
122+
fp.seek(skip)
122123
data = fp.read()
123124

124125
obj = marshal.load(BytesIO(data))

bcc_info.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ def parse_custom_elf(elf: bytes) -> list[tuple[int, str]]:
141141

142142
# Unmarshal Python module containing the calls to BCC.
143143
with open(sys.argv[1], "rb") as fp:
144-
fp.seek(0x20)
144+
skip = int.from_bytes(fp.read(4), 'little') + int.from_bytes(fp.read(4), 'little')
145+
fp.seek(skip)
145146
data = fp.read()
146147

147148
obj = marshal.load(BytesIO(data))

disassemble.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111

1212
with open(sys.argv[1], "rb") as fp:
13-
fp.seek(0x20)
13+
skip = int.from_bytes(fp.read(4), 'little') + int.from_bytes(fp.read(4), 'little')
14+
fp.seek(skip)
1415
data = fp.read()
1516

1617
obj = marshal.load(BytesIO(data))

0 commit comments

Comments
 (0)