Last active
December 11, 2016 12:23
-
-
Save nknskn/94f78c4976dcf926babbca427022b7cc to your computer and use it in GitHub Desktop.
SECCON 2016 Vegenere(Crypt 100)
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
# encoding: utf-8 | |
import hashlib | |
table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ{}' | |
tableNum = len(table) | |
ansHash = 'f528a6ab914c1ecf856a1d93103948fe' | |
p1 = 'SECCON{A' | |
c2 = 'DOEE' | |
p3 = 'BCDEDEFG' | |
c4 = 'JWMN' | |
p5 = 'KLMNOPQR' | |
c6 = 'UFWY' | |
p7 = 'VWXYYZ}' | |
flag = False | |
def p_search(c, k): | |
k_num = table.find(k) | |
for i in xrange(tableNum): | |
if c == table[(i+k_num) % tableNum]: | |
p = table[i] | |
break | |
return p | |
for j in xrange(tableNum): | |
p2_1 = p_search(c2[0], table[j]) | |
p4_1 = p_search(c4[0], table[j]) | |
p6_1 = p_search(c6[0], table[j]) | |
for k in xrange(tableNum): | |
p2_2 = p_search(c2[1], table[k]) | |
p4_2 = p_search(c4[1], table[k]) | |
p6_2 = p_search(c6[1], table[k]) | |
for l in xrange(tableNum): | |
p2_3 = p_search(c2[2], table[l]) | |
p4_3 = p_search(c4[2], table[l]) | |
p6_3 = p_search(c6[2], table[l]) | |
for m in xrange(tableNum): | |
p2 = p2_1 + p2_2 + p2_3 + p_search(c2[3], table[m]) | |
p4 = p4_1 + p4_2 + p4_3 + p_search(c4[3], table[m]) | |
p6 = p6_1 + p6_2 + p6_3 + p_search(c6[3], table[m]) | |
flag = p1 + p2 + p3 + p4 + p5 + p6 + p7 | |
flagMD5 = hashlib.md5(flag).hexdigest() | |
if flagMD5 == ansHash: | |
print flag | |
exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment