PicoCTF Writeup – First Grep
# Information:
CTF Name: PicoCTF
CTF Challenge: First Grep
Challenge Category: General Skills
Challenge Points: 100
PicoCTF 2019.
# Challenge Description:
Can you find the flag in file? This would be really tedious to look through manually, something tells me there is a better way.
Hint: grep tutorial
# Writeup
This is a challenge to help learn the cat, grep and pipe commands on the Linux terminal. I am used to working on Linux terminal and I even use it as one of my main operating systems.
Upon reading the description I decided to download the file. After downloading the file I opened my Linux terminal and did a simple cat command of the file. The cat command displays to the terminal (standard output) the contents of the file, as such:
The output of the command was an enormous amount of strings and it is unnecessary hard to find the picoCTF flag this way. Knowing this I decided to use the grep command to help me. Well, this command searches the plain-text of the file for lines that match the given regular expression.
The command I used is a combination of three different commands, the cat, the pipe, and the grep. The cat command, as explained prints to the terminal the file contents, the pipe command (|) gives the output of the first command to the second, syntax is as such:
mregra on Cyber ~$ first_command | second_command
Finally, the grep command, as explained previously, searches the given data set for lines that match a certain regular expression. Knowing this, the command I used was:
mregra on Cyber ~$ cat file | grep picoCTF
You could use a different regular expression like “pico”, “picoCTF{“, etc.
And the output was:
Thank you very much for reading!
Cheers,
MRegra