[문제]
Vigenere
k: ????????????
p: SECCON{???????????????????????????????????}
c: LMIG}RPEDOEEWKJIQIWKJWMNDTSR}TFVUFWYOCBAJBQ
k=key, p=plain, c=cipher, md5(p)=f528a6ab914c1ecf856a1d93103948fe
[풀이]
import md5
p = "SECCON{???????????????????????????????????}"
c = 'LMIG}RPEDOEEWKJIQIWKJWMNDTSR}TFVUFWYOCBAJBQ'
m = "ABCDEFGHIJKLMNOPQRSTUVWXYZ{}"
a = []
for i in range(len(p[:7])):
for j in range(len(m)):
if m[j] == p[i]:
a.append( j )
b = []
for i in range(len(p[:7])):
for j in range(len(m)):
if m[j] == c[i]:
b.append( j )
_k = ''
for i in range(len(b)):
_k += m[b[i]-a[i]]
print "[+] key:", _k+("?"*(12-len(_k)))
##############
a = []
for i in c:
for j in range(len(m)):
if m[j] == i:
a.append( j )
b = []
for i in _k:
for j in range(len(m)):
if m[j] == i:
b.append( j )
## b/f
print "[!] b/f ..."
q = b
for z in m:
for y in m:
for x in m:
for u in m:
for o in m:
k = z+y+x+u+o
d = []
for i in k:
for j in range(len(m)):
if m[j] == i:
d.append( j )
o = b+d
flag = ''
for i in range( len(a) ):
flag += m[(a[i]-o[i%len(o)])%len(m)]
_md = md5.new( flag ).hexdigest()
if _md == "f528a6ab914c1ecf856a1d93103948fe":
print "[+] key:", _k+k
print "[+] flag:", flag
exit()
'''
blackcon@bk{~/seccon/crypto}:python vigenere.py
[+] key: VIGENER?????
[!] b/f ...
[+] key: VIGENERECODE
[+] flag: SECCON{ABABABCDEDEFGHIJJKLMNOPQRSTTUVWXYYZ}
'''
'Security > [게임] CTF 풀이' 카테고리의 다른 글
[Kinght CTF] Fix It Felix! writeup (0) | 2022.01.23 |
---|---|
[exploit] 2016 33c3 CTF - babyfengshui (0) | 2016.12.30 |
[exploit] 2016 SecconCTF - jmper writeups (exploit only) (0) | 2016.12.11 |
[exploit] 2016 SecconCTF - cheer_msg writeups (exploit only) (0) | 2016.12.11 |
[exploit] 2016 SecconCTF - checker writeups (exploit only) (0) | 2016.12.11 |