Tags: crypto python 

Rating: 3.0

<span># seccon2016-vigenere-writeup
Seccon 2016 Vigenere Writeup

The question was like following:

Vigenere


k: ????????????

p: SECCON{???????????????????????????????????}

c: LMIG}RPEDOEEWKJIQIWKJWMNDTSR}TFVUFWYOCBAJBQ



k=key, p=plain, c=cipher, md5(p)=f528a6ab914c1ecf856a1d93103948fe



|ABCDEFGHIJKLMNOPQRSTUVWXYZ{}

-+----------------------------

A|ABCDEFGHIJKLMNOPQRSTUVWXYZ{}

B|BCDEFGHIJKLMNOPQRSTUVWXYZ{}A

C|CDEFGHIJKLMNOPQRSTUVWXYZ{}AB

D|DEFGHIJKLMNOPQRSTUVWXYZ{}ABC

E|EFGHIJKLMNOPQRSTUVWXYZ{}ABCD

F|FGHIJKLMNOPQRSTUVWXYZ{}ABCDE

G|GHIJKLMNOPQRSTUVWXYZ{}ABCDEF

H|HIJKLMNOPQRSTUVWXYZ{}ABCDEFG

I|IJKLMNOPQRSTUVWXYZ{}ABCDEFGH

J|JKLMNOPQRSTUVWXYZ{}ABCDEFGHI

K|KLMNOPQRSTUVWXYZ{}ABCDEFGHIJ

L|LMNOPQRSTUVWXYZ{}ABCDEFGHIJK

M|MNOPQRSTUVWXYZ{}ABCDEFGHIJKL

N|NOPQRSTUVWXYZ{}ABCDEFGHIJKLM

O|OPQRSTUVWXYZ{}ABCDEFGHIJKLMN

P|PQRSTUVWXYZ{}ABCDEFGHIJKLMNO

Q|QRSTUVWXYZ{}ABCDEFGHIJKLMNOP

R|RSTUVWXYZ{}ABCDEFGHIJKLMNOPQ

S|STUVWXYZ{}ABCDEFGHIJKLMNOPQR

T|TUVWXYZ{}ABCDEFGHIJKLMNOPQRS

U|UVWXYZ{}ABCDEFGHIJKLMNOPQRST

V|VWXYZ{}ABCDEFGHIJKLMNOPQRSTU

W|WXYZ{}ABCDEFGHIJKLMNOPQRSTUV

X|XYZ{}ABCDEFGHIJKLMNOPQRSTUVW

Y|YZ{}ABCDEFGHIJKLMNOPQRSTUVWX

Z|Z{}ABCDEFGHIJKLMNOPQRSTUVWXY

{|{}ABCDEFGHIJKLMNOPQRSTUVWXYZ

}|}ABCDEFGHIJKLMNOPQRSTUVWXYZ{



Vigenere cipher

https://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher


First, we have to derive key to decrypt the ciphertext.

As given some of the plaintext is : SECCON{ and }

So we derived the key from first 7 characters of ciphertext: LMIG}RP

The derived key is: VIGENERxxxxx

Since the algorithm is Vigenere, we guessed that the 8th character is E and the current key value is:
VIGENERExxxx

 In Vigenere algorithm the key is repeated by the length of plaintext.

So we divided plaintext by 12 which is keys length.


key:      VIGENERExxxxVIGENERExxxxVIGENERExxxxVIGENER

cipher:  LMIG}RPEDOEEWKJIQIWKJWMNDTSR}TFVUFWYOCBAJBQ

plain: SECCON{AxxxxBCDEDEFGxxxxKLMNOPQRxxxxVWXYYZ}

We saw that the missing parts of plain text are relevant to neighbor characters.

* In the first chunk the characters will be some sequence of A,B,C

* In the second chunk the characters will be some sequence of F,G,H,I,J,K,L

* In the third chunk the characters will be some sequence of Q,R,S,T,U,V,W


 Since we have md5 of plaintext, we write a code that tries the md5 of following sequences to derive the key.




 Flag is: SECCON{ABABABCDEDEFGHIJJKLMNOPQRSTTUVWXYYZ}</span>

Original writeup (https://github.com/rustempasha/seccon2016-vigenere-writeup).