Last active
August 29, 2015 14:08
-
-
Save axot/be958d654fd182e77c26 to your computer and use it in GitHub Desktop.
tkbctf4 "Simple Serial Code"
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
import random | |
import string | |
import md5 | |
flag = md5.new() | |
flag.update("this_is_not_flag!!") | |
flag_md5 = flag.hexdigest() | |
print "flag_md5:", flag_md5 | |
flag_md5 = [flag_md5[i:i+4] for i in range(0, len(flag_md5), 4)] | |
i = 0 | |
res = [] | |
while True: | |
serial = ''.join(random.choice(string.ascii_lowercase + \ | |
string.ascii_uppercase) for _ in range(4)) | |
m = md5.new() | |
m.update(serial) | |
md = m.hexdigest() | |
if i < len(flag_md5) and md[0:4] == flag_md5[i]: | |
res.append(serial) | |
i += 1 | |
if i == len(flag_md5): | |
print "found serial: ",''.join(res) | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment