-
-
Save AndyNovo/835fe6c090a5c267ed47a7a96adeaee2 to your computer and use it in GitHub Desktop.
XORient Yourself
This file contains hidden or 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
| 1020222c733a203a6c393d3769362d2520353121356907160c1b0a796f06213a306f263f782e722a3b222323293628376937263c262b362a3669272c6f28292c6f2b262663203d253d21262c3763382638306f3a26246317001e78383d3b3830614546102a202c74306f36232d3d722f3f2228756c0c1a111d153817001e077e761605701d16130a6b610f060f101b7c070c001003177f32 |
This file contains hidden or 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
| #!/usr/bin/env python2 | |
| def xor(msg, key): | |
| o = '' | |
| for i in range(len(msg)): | |
| o += chr(ord(msg[i]) ^ ord(key[i % len(key)])) | |
| return o | |
| with open('message', 'r') as f: | |
| msg = ''.join(f.readlines()).rstrip('\n') | |
| with open('key', 'r') as k: | |
| key = ''.join(k.readlines()).rstrip('\n') | |
| assert key.isalnum() and (len(key) == 9) | |
| assert 'TUCTF' in msg | |
| #NOTE: I am sharing the hex digest not the raw as indicated here | |
| with open('encrypted', 'w') as fo: | |
| fo.write(xor(msg, key)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment