Last active
April 18, 2020 20:09
-
-
Save pawlos/11fa9cc08244b0bf125d372afb9a322d to your computer and use it in GitHub Desktop.
Solution for TAMUCtf's leaning_tower!
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
hashes = ["9033bacfd0636139084ea80aa654113f3240f7fc", | |
"97f0f871be356f464bca862487e365d92fc507bb", | |
"11071c464490c8baaa979bf83e098f3318b36003", | |
"45fa0b57640f797ad28709cf7f3b495d61514418", | |
"2540407ace41adaaa279c9a9f8d900bd87a8aa5d", | |
"f4c50cd4475f6a1833180506817b4bbd45dc17f7", | |
"f0e8c88568fcb989f60f09f52b1aad1b7d2454b5", | |
"744dde01735bc3d2b047d7d9fbc5662b97628f01", | |
"2cab6da567fa23426f81d54326ca537e5bd89d7e", | |
"7f0bc15fb2695af18fd1e6c8df386f824cf67af9", | |
"2326181b6f80ba790e6f164190dfdda8106a31ff", | |
"59a7b725369a7d6af671b7ae79e2129e0517b289", | |
"b070a87bd15350073f989853d4f5aa234c563d11", | |
"72c77719d0ae83311c01914cdedcff2ebf06667b", | |
"5b8e4855bdc9d3bea82500fea95d4306d304dccb"] | |
import hashlib | |
import itertools | |
previous = "da39a3ee5e6b4b0d3255bfef95601890afd80709" | |
hexdigits = "0123456789abcdef" | |
def value(c): | |
return int(c,16) | |
def xor(h1,h2): | |
return ''.join([hexdigits[(value(x) ^ value(y))] for (x,y) in zip(h1,h2)]) | |
alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$%&()*+,-./:;<=>?@[\\]^_{}~" | |
result = '' | |
for h in hashes: | |
p = xor(h, previous) | |
for c in alphabet: | |
digest = hashlib.sha1(c).hexdigest() | |
if digest == p: | |
result += c | |
print('Found: '+c) | |
break | |
else: | |
print('Not found for: '+h) | |
previous = h | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment