# New Vignere

## Problem

Another slight twist on a classic, see if you can recover the flag. (Wrap with picoCTF{})

`epdfglkfnbjbhbpicohidjgkhfnejeecmjfnejddgmhpndmchbmifnepdhdmhbah`

new_vignere.py

## Solution

This challenge is similar to New Caesar (the code is nearly identical) except its a Vignere cipher.

The hint for this challenge points to The Cryptanalysis section of Vigenère Cipher Wikipedia Page, which explains the "Kasiski examination". We can use an online Kasiski test tool to automatically find the key length to be

`9`

. DCode shows that the key length could be`3`

,`9`

, or`6`

.The Wikipedia page recommends using Kerckhoffs' method to discover the key letter (Caesar shift) for each column of the vignere cipher. However, that does not work in this case because the Vigenère table has been scrambled by the

`b16_encode`

function.According to Wikipedia: "Once the length of the key is known, the ciphertext can be rewritten into that many columns, with each column corresponding to a single letter of the key. Each column consists of plaintext that has been encrypted by a single Caesar cipher. The Caesar key (shift) is just the letter of the Vigenère key that was used for that column. Using methods similar to those used to break the Caesar cipher, the letters in the ciphertext can be discovered."

I sort of implement the above method. The problem is the

`b16_encode`

function, which splits the letters of the flag in two. Because of this function, we cannot simply bruteforce each column of the Vignere matrix as described above the output is transformed by the`b16_decode`

function. The letters are merged together and the output might not fit within the alphabet even if the key is correct.However, we can still use the above method to make educated guesses about the key since if the

`b16_decode`

function produces valid ascii output with a certain caesar key then it is likely to be the correct key. This bruteforce takes place on lines 53-77 of the solve script.Next, we bruteforce the letters of the key that we could not make educated guesses for using

`itertools.permutations`

. We test every possible key (keeping the guessed letters constant) and display the output when it satisfying the assert statement on line 20 of new_vignere.py.solve script output:

### Flag

`picoCTF{94bf01ad4b8a63425c32c02ba4c9632f}`

Last updated