"""
soo... this script dumps and unxor some little endian bytes
"""
ADDRS = 0x00000000  # start address
ADDRE = 0x00000000  # end address (exclusive)

KEY = 0x73  # uint8

mem = currentProgram.getMemory()

length = ADDRE - ADDRS
if length <= 0:
    raise Exception("invalid address range")

data = mem.getBytes(toAddr(ADDRS), length)
if data is None:
    raise Exception("memory read failed")

dec = bytes((b ^ KEY) & 0xff for b in data)

with open("/tmp/dec.bin", "wb") as f:
    f.write(dec)

print("[+] unxor: wrote %d bytes" % len(dec))
