Created
April 27, 2017 20:00
-
-
Save zorix/31dc21e4e6fb816476840490d2c328d0 to your computer and use it in GitHub Desktop.
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
| data = [ | |
| "1f9111".decode("hex"), | |
| "1799".decode("hex"), | |
| "0790001226d8".decode("hex"), | |
| "0a9e1e5c3ada".decode("hex"), | |
| "1f".decode("hex"), | |
| "099e195e".decode("hex"), | |
| "0a97075a21dac1".decode("hex"), | |
| "0a9710".decode("hex"), | |
| "199e075131d3".decode("hex"), | |
| "1199".decode("hex"), | |
| "12961350".decode("hex"), | |
| ] | |
| # only 6 letter words | |
| data2 = [ | |
| "0790001226d8".decode("hex"), | |
| "0a9e1e5c3ada".decode("hex"), | |
| "199e075131d3".decode("hex"), | |
| ] | |
| l = "0a97075a21dac1".decode("hex") | |
| def xor(c, d): | |
| return ''.join([chr(ord(a) ^ ord(b)) for a,b in zip(c, d[:len(c)])]) | |
| key = '' | |
| ws6 = open('words6.txt', 'rb').read().lower().splitlines() | |
| ws7 = open('words7.txt', 'rb').read().lower().splitlines() | |
| for w in ws7: | |
| k = xor(w, l) | |
| cnt = 0 | |
| for w6 in data2: | |
| de = xor(w6, k) | |
| if de.lower() in ws6: | |
| cnt += 1 | |
| print de, cnt | |
| if cnt > 1: | |
| key = k | |
| break | |
| msg = [] | |
| for x in data: | |
| de = xor(x, key) | |
| msg.append(de) | |
| print ' '.join(msg) | |
| print key.encode('hex') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment