Skip to content

Instantly share code, notes, and snippets.

@0awawa0
Created April 8, 2021 04:29
Show Gist options
  • Save 0awawa0/c49778eb76932434e98820cf394dfd48 to your computer and use it in GitHub Desktop.
Save 0awawa0/c49778eb76932434e98820cf394dfd48 to your computer and use it in GitHub Desktop.
def xorBytes(b1, b2):
 res = b""
 for i in range(max(len(b1), len(b2))):
 res += bytes([b1[i % len(b1)] ^ b2[i % len(b2)]])
 return res
crib = b"actf{"
ctext = bytes.fromhex("ae27eb3a148c3cf031079921ea3315cd27eb7d02882bf724169921eb3a469920e07d0b883bf63c018869a5090e8868e331078a68ec2e468c2bf13b1d9a20ea0208882de12e398c2df60211852deb021f823dda35079b2dda25099f35ab7d218227e17d0a982bee7d098368f13503cd27f135039f68e62f1f9d3cea7c")
for i in range(len(ctext) - 5):
 offset = ctext[i: i + 5]
 key = xorBytes(offset, crib)
 try:
 print(xorBytes(key, ctext[i:]).decode())
 except:
 continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment