Skip to content

Instantly share code, notes, and snippets.

@faidamine
Created September 10, 2017 19:34
Show Gist options
  • Save faidamine/ee26a2d24ae48844822d4f7745c1a197 to your computer and use it in GitHub Desktop.
Save faidamine/ee26a2d24ae48844822d4f7745c1a197 to your computer and use it in GitHub Desktop.
#usr/bin/python
#Faid Mohammed Amine
#Fb : piratuer
### [Crypto] ASIS Finals 2017 - Simple Crypto
def xor_str(x, y):
if len(x) > len(y):
return ''.join([chr(ord(z) ^ ord(p)) for (z, p) in zip(x[:len(y)], y)])
else:
return ''.join([chr(ord(z) ^ ord(p)) for (z, p) in zip(x, y[:len(x)])])
KEY = 'musZTXmxV58UdwiKt8Tp'.encode("hex")
encrypted = open("flag.enc", "r")
cnt = encrypted.read()
encrypted.close()
decrypted = xor_str(KEY * (len(cnt) // len(KEY) + 1), cnt).decode("hex")
output = open("flag", "w")
output.write(decrypted)
output.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment