Regex101

regex

Regex101 is a very simple CTF challenge. But if you don’t know what is regex or regular expression then it would be very hard for you to solve this challenge.

So the description clearly says we need to find a flag from 2999 flags. And they have given some specific details. The flags first 5 character would be uppercase letters, the second 5 character would be digits and the third 6 character would be again uppercase. With this information let’s find our flag.

Solving Method:-

We need to find our flag from 2999 fake flags. So We need to use regular expression. I used kali linux for this challenge.

I use this command to get the real flag:- cat flags.txt | grep -E ‘SEE{[A-Z]{5}[0-9]{5}[A-Z]{6}’

Let’s devide this command for better understading.

  1. I used the cat command to flags.txt file.
  2. Then I use a pipe command (“|”) to seperate the actuall command.
  3.  Ater that I use grep command to grab the specific text.
  4. -E command stands for expression (regular expression). This command helps us find the specific text combining uppercase letters, digits and again uppercase letters sequence.
  5. And the -E command takes ‘SEE{[A-Z]{5}[0-9]{5}[A-Z]{6}’ arguments to get the real flag.

Let’s break  SEE{[A-Z]{5}[0-9]{5}[A-Z]{6}  this command into small chunks so that you can understand properly.

Explaination:-

First of all let’s divide the command: 

  1. SEE{  
  2. [A-Z]{5} 
  3. [0-9]{5} 
  4. [A-Z]{6}

We know our flag starts with SEE{ so I put the flag format first. We know that our flag’s first 5 characters are uppercase letters. So I provide A-Z inside of the square bracket cause we don’t know which 5 uppercase letters are there in the flag. After that we need to specify how many letters are we looking for. Here’s the command {5}. So the command combination would be [A-Z]{5}. Give the command a try:- cat flags.txt | grep -E ‘[A-Z]{5}’

OMG This is a large result. No worries, follow rest of the method I showed you earlier. The method will be simillar to [A-Z]{5}. Just you need to replace the letters to digits like [0-9]{5}. Do the rest by your self. I know you are smart enough to solve this by your own.

Full command:-  cat flags.txt | grep -E ‘SEE{[A-Z]{5}[0-9]{5}[A-Z]{6}’

Flag:- SEE{RGSXG13841KLWIUO}

See our other ctf  walkthroughs https://secureward.com/walkthroughs/ctf-challenges/

Leave a Comment