enc.txt farm.sage farm_solve.sage
For this task, we are given two file: the code and the encrypted flag.
#!/usr/bin/env sage
= +
=
=
= # Optimization the key length :D
return
assert in
return
=
= , **5 + **3 + **2 + 1
,
+=
return
# KEEP IT SECRET
= # I think 64**14 > 2**64 is not brute-forcible :P
=
enc = 805c9GMYuD5RefTmabUNfS9N9YrkwbAbdZE0df91uCEytcoy9FDSbZ8Ay8jj
We can see that the alphabet is mapped to polynomial in GF(64). The encryption is a simple linear substitution of each character of the flag in base64 and can be easily reversed.
Encrypted Char = key * Char
Which can be reversed to
Char = (Encrypted Char) / key
We just need to find the key and for this we can use the fact the flag must begin by CCTF{
(Q0NURns=
in base 64) to find it because
key = (Encrypted Char) / Char
= +
=
=
assert in
return
=
= 0
=
+=1
=
= 0
=
+=1
= / # Key used to compute value
=
+=
and the flag is CCTF{EnCrYp7I0n_4nD_5u8STitUtIn9_iN_Fi3Ld!}