Welcome to my series of writeups for n00bzunit3d 2024 capture-the-flag competition. In this post, we look at the crypto/vinegar and crypto/vinegar2 challenges.

Let’s start with crypto/vinegar.

The challenge provides us with the encrypted flag and a key.

Encrypted flag: nmivrxbiaatjvvbcjsf
Key: secretkey

Assuming the encryption algorithm is Vigenère (sounds like vinegar), we pass the information to any online Vigenère decyptor such as cryptii and it gives us the flag.

Now to Vinegar 2, we are given the Vigenère encryption code and the encrypted flag.

encryption code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
alphanumerical = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(){}_?'
matrix = []
for i in alphanumerical:
	matrix.append([i])

idx=0
for i in alphanumerical:
	matrix[idx][0] = (alphanumerical[idx:len(alphanumerical)]+alphanumerical[0:idx])
	idx += 1

flag=open('../src/flag.txt').read().strip()
key='5up3r_s3cr3t_k3y_f0r_1337h4x0rs_r1gh7?'
assert len(key)==len(flag)
flag_arr = []
key_arr = []
enc_arr=[]
for y in flag:
	for i in range(len(alphanumerical)):
		if matrix[i][0][0]==y:
			flag_arr.append(i)

for y in key:
	for i in range(len(alphanumerical)):
		if matrix[i][0][0]==y:
			key_arr.append(i)

for i in range(len(flag)):
	enc_arr.append(matrix[flag_arr[i]][0][key_arr[i]])
encrypted=''.join(enc_arr)
f = open('enc.txt','w')
f.write(encrypted)

encrypted flag

*fa4Q(}$ryHGswGPYhOC{C{1)&_vOpHpc2r0({

Getting a flag was as simple as doing the reverse of the encryption and we have the flag.