Skip to content

Instantly share code, notes, and snippets.

@Nicholaz99
Created August 23, 2019 14:11
Show Gist options
  • Save Nicholaz99/e418250f0ac3841577801ecc1ea76a91 to your computer and use it in GitHub Desktop.
Save Nicholaz99/e418250f0ac3841577801ecc1ea76a91 to your computer and use it in GitHub Desktop.
import string
def xor(msg, key):
o = ''
for i in range(len(msg)):
o += chr(ord(msg[i]) ^ ord(key[i % len(key)]))
return o
msg="\x05F\x17\x12\x14\x18\x01\x0c\x0b4"
msg2=">\x1f\x00\x14\n\x08\x07Q\n\x0e"
# Phase 1 - Find part of key
part_of_msg = 'd4rk{'
p2 = '}c0de'
for i in range(len(msg)):
candidate = xor(msg[i:i+len(part_of_msg)], part_of_msg)
if candidate.isalnum():
print "front:", candidate
for i in range(len(msg2)):
candidate2 = xor(msg2[i:i+len(p2)], p2)
if candidate2.isalnum():
print "back:", candidate2
# key = "areyoudank"
# print "Flag:", xor(msg + msg2, key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment