Created
August 23, 2019 14:11
-
-
Save Nicholaz99/e418250f0ac3841577801ecc1ea76a91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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