Skip to content

Instantly share code, notes, and snippets.

@larsborn
Created November 20, 2022 23:35
Show Gist options
  • Save larsborn/0ec24d7b294248c51de0c3335802cbd4 to your computer and use it in GitHub Desktop.
Save larsborn/0ec24d7b294248c51de0c3335802cbd4 to your computer and use it in GitHub Desktop.
as seen in 96baba74a907890b995f23c7db21568f7bfb5dbf417ed90ca311482b99702b72
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import binascii
def decrypt(buf: bytes, key: int, summand: int) -> str:
ret = bytearray()
for i, c in enumerate(buf):
ret.append(c ^ key)
key += (-1 if i % 2 else 1) + summand
key &= 0xff
return ret.decode('utf-8').rstrip('\0')
if __name__ == '__main__':
assert decrypt(binascii.unhexlify(b'8797286a6da3f032539eb4'), 0xe4, -0x38) == r'c:\Windows'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment