Challenge Description
This is, once again, a challenge involving substitution ciphers.
We begin by downloading the given file and seeing its contents.
Contents of the file
After downloading the file using wget <link>
, we realise that it is a zip
file.
We proceed to unzip this file (public.zip)
, creating another directory called public
, with 3 files in it, namely encrypt.py
, study-guide.txt
and flag.txt
.
The encrypted flag and the script used to encrypt it
Running cat
on both the flag.txt
and encrypt.py
files provides us with more information on how we should continue.
The contents of the flag.txt
file is:
brcfxba_vfr_mid_hosbrm_iprc_exa_hoav_vwcrm
For the encrypt.py
file, we realise that this script is used to encrypt the contents of all .txt
files in the current directory as well as its subdirectories.
encrypt.py
(with added comments)Key for this substitution cipher
Since the key(dictionary) for this substitution cipher is produced randomly, we are unable to reverse-engineer to find the key.
Contents of study-guide.txt
Running cat study-guide.txt
displays the 272543 encrypted lines in this file.
Number of lines
To display the number of lines in a file, we can run this command:
This will print the number of lines in a file, followed by the name of the file
Since we are unable to reverse-engineer the key, we can do frequency analysis based on the contents in this file instead. After all, this should be the reason this file was provided.
Getting the Flag
For this challenge, I used this tool from Boxentriq to retrieve the flag. I was able to get the flag by feeding this tool the first 50 lines of the study-guide.txt
file, and adding the encrypted flag at the top.
Flag
picoCTF{perhaps_the_dog_jumped_over_was_just_tired}