Skip to content

Instantly share code, notes, and snippets.

@snowyegret23
Created April 18, 2023 12:23
Show Gist options
  • Save snowyegret23/11b56999f5f6fded4b1f3404ce4d9dc2 to your computer and use it in GitHub Desktop.
Save snowyegret23/11b56999f5f6fded4b1f3404ce4d9dc2 to your computer and use it in GitHub Desktop.
파일의 특정 부분까지 주어진 xor 키를 사용하여 xor.
import itertools
file = "testfile.bundle"
xor_key = b"\x43\x73\x6d\x36\x68\x50\x23\x50\x39\x76\x6d\x61"
endpoint = 0x400
with open(file, "rb") as f:
data = f.read()
result = bytes(
itertools.starmap(
lambda x, y: x ^ y, zip(data[:endpoint], itertools.cycle(xor_key))
)
)
with open(f"{file}.dec", "wb") as f:
f.write(result + data[endpoint:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment