Skip to content

Instantly share code, notes, and snippets.

@tjkendev
Created December 11, 2016 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjkendev/f006f6630686a36753e765c5908541ce to your computer and use it in GitHub Desktop.
Save tjkendev/f006f6630686a36753e765c5908541ce to your computer and use it in GitHub Desktop.
# encoding: utf-8
K="ABCDEFGHIJKLMNOPQRSTUVWXYZ{}"
index=K.index
lk = len(K)
k="????????????"
key_l = len(k)
p="SECCON{???????????????????????????????????}"
c="LMIG}RPEDOEEWKJIQIWKJWMNDTSR}TFVUFWYOCBAJBQ"
p_md5="f528a6ab914c1ecf856a1d93103948fe"
l = len(c)
# 復号化
for i in xrange(l):
if p[i]=="?": continue
v = K[(index(c[i]) - index(p[i]) + lk) % lk]
ks[i%key_l] = v
print ks
# encoding: utf-8
K="ABCDEFGHIJKLMNOPQRSTUVWXYZ{}"
index=K.index
lk = len(K)
k="????????????"
key_l = len(k)
p="SECCON{???????????????????????????????????}"
c="LMIG}RPEDOEEWKJIQIWKJWMNDTSR}TFVUFWYOCBAJBQ"
p_md5="f528a6ab914c1ecf856a1d93103948fe"
l = len(c)
ks = list("VIGENERE????")
import itertools, md5
for el in itertools.product(K, repeat=4):
ks[-4:] = el
p_tmp = list(p)
for i in xrange(l):
p_tmp[i] = K[(index(c[i]) - index(ks[i%key_l]) + lk) % lk]
digest = md5.new("".join(p_tmp)).hexdigest()
print digest
if digest == p_md5:
print "".join(p_tmp)
exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment