Skip to content

Commit

Permalink
Grammar fixes
Browse files Browse the repository at this point in the history
- remove unused vars in exceptions
- correct whitespace around operators, slices
  • Loading branch information
madeddy committed Apr 4, 2024
1 parent 58bfada commit 4ab7bdc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions deobfuscate.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def extract_slot_rpyc(f, slot):
slots = {}

while position + 12 <= len(data):
slotid, start, length = struct.unpack("<III", data[position : position + 12])
slotid, start, length = struct.unpack("<III", data[position:position + 12])
if (slotid, start, length) == (0, 0, 0):
break

Expand All @@ -90,7 +90,7 @@ def extract_slot_rpyc(f, slot):
raise ValueError("Unknown slot id")

start, length = slots[slot]
return data[start : start + length]
return data[start:start + length]

@extractor
def extract_slot_legacy(f, slot):
Expand Down Expand Up @@ -130,7 +130,7 @@ def extract_slot_headerscan(f, slot):

slots = {}
while position + 12 <= len(data):
slotid, start, length = struct.unpack("<III", data[position : position + 12])
slotid, start, length = struct.unpack("<III", data[position:position + 12])
if (slotid, start, length) == (0, 0, 0):
break

Expand All @@ -146,7 +146,7 @@ def extract_slot_headerscan(f, slot):
raise ValueError("Unknown slot id")

start, length = slots[slot]
return data[start : start + length]
return data[start:start + length]

@extractor
def extract_slot_zlibscan(f, slot):
Expand Down
12 changes: 6 additions & 6 deletions unrpyc.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def read_ast_from_file(in_file):

try:
contents = zlib.decompress(contents)
except Exception as e:
except Exception:
raise Exception(
"Did not find a zlib compressed blob where it was expected. Either the header has been "
"modified or the file structure has been changed.") from None
Expand Down Expand Up @@ -227,7 +227,7 @@ def worker(arg_tup):
comparable=args.comparable, translator=translator,
init_offset=args.init_offset, try_harder=args.try_harder,
sl_custom_names=args.sl_custom_names)
except Exception as e:
except Exception:
with printlock:
print(f'Error while decompiling {filename}:')
print(traceback.format_exc())
Expand Down Expand Up @@ -441,12 +441,12 @@ def traverse(inpath):
bad = results.count(False)

if bad == 0:
print(f'Decompilation of {good} script file{"s" if good>1 else ""} successful')
print(f'Decompilation of {good} script file{"s" if good > 1 else ""} successful')
elif good == 0:
print(f'Decompilation of {bad} file{"s" if bad>1 else ""} failed')
print(f'Decompilation of {bad} file{"s" if bad > 1 else ""} failed')
else:
print(f'Decompilation of {good} file{"s" if good>1 else ""} successful\n'
f'but decompilation of {bad} file{"s" if bad>1 else ""} failed')
print(f'Decompilation of {good} file{"s" if good > 1 else ""} successful\n'
f'but decompilation of {bad} file{"s" if bad > 1 else ""} failed')


if __name__ == '__main__':
Expand Down

0 comments on commit 4ab7bdc

Please sign in to comment.