Skip to content

Commit c1bf702

Browse files
committed
Bugfixes
1 parent 28c492e commit c1bf702

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

analyze_crypted_code.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,13 @@ def process_code_object(code_obj, filedata: bytes, crypted_regions: list[dict])
106106
filedata: Entire contents of the Python module
107107
crypted_regions: List that is appended to
108108
"""
109+
if info := get_crypto_info(filedata, code_obj):
110+
crypted_regions.append(info)
111+
109112
for const in code_obj.co_consts:
110113
if isinstance(const, type((lambda: None).__code__)):
111114
print("Found nested code object: " + str(const))
112115
display_code(const)
113-
if info := get_crypto_info(filedata, const):
114-
crypted_regions.append(info)
115116

116117
process_code_object(const, filedata, crypted_regions)
117118

@@ -127,7 +128,6 @@ def main(filename: str) -> None:
127128

128129
crypted_regions: list[dict] = []
129130
process_code_object(obj, data, crypted_regions)
130-
crypted_regions.append(get_crypto_info(data, obj))
131131

132132
json.dump(crypted_regions, open(filename + ".json", "w"))
133133

decrypt_gcm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ def decrypt_gcm_without_tag(key: bytes, nonce: bytes, ciphertext: bytes) -> byte
113113
crypted_regions = json.load(open(filename + ".json"))
114114

115115
for region in crypted_regions:
116-
start = region["ciphertext_offset"] + 0x20 # account for pyarmor module header
116+
skip = int.from_bytes(module[0:4], 'little') + int.from_bytes(module[4:8], 'little')
117+
start = region["ciphertext_offset"] + skip
117118
size = region["ciphertext_size"]
118119
ciphertext = module[start:start+size]
119120
nonce = bytes.fromhex(region["nonce"])

0 commit comments

Comments
 (0)