First Grep | CyLab Security Academy (PicoCTF)
First Grep is a General Skill, easy challenge intending on the use of Grep tool. We are provided with the following details along with a file containing flag.
Can you find the flag in the file? This would be really tedious to look through manually, something tells me there is a better way.
Upon opening the file, there are scrambled alphabets, numbers and special symbols. So we will input the following command in the terminal
file file
It outputs file: ASCII text, with very long lines (14545) meaning our flag is hidden somewhere in the jumbled ASCII characters. The simplest method would be to just use Ctrl + F and enter picoCTF{ to find the flag but as the challenge name suggests using the grep tool. grep is basically superior form of Ctrl + F capable of looking into even sub-folders files and many more. To list grep commands simply enter the following command in terminal:
grep --help
Here, we need to read the string "pico" or "picoCTF{" inside the file and for that after going through grep help section we enter the following command:
grep -oE "picoCTF{.*}" file
This command reveals the exact flag. Here -o(only matching) prints only the specific text matching the pattern and -E (Extended regular expressions) enables modern regex syntax; helps define the format of the file. .* means grab the content inside the brackets.
Hence, this lab simply aims to introduce users to the grep tool.
Fun Fact: grep stands for Global Regular Expression Print and it is recently been added to windows as well.
