top of page

CTF#03 Solution

Hidden Password in Numbers Text File

Number of files: 1

Flag pattern: flag#**********

Flag: flag#asdetwovvk

Solvable on which OS: Windows

This solution’s OS: Windows 11

Software: Text editor, (Python)

Estimated solution time: 8 minutes

Internet access required: For software installation only

Details

Goal

The user needs to find a way to isolate the non-numeric characters to retrieve the flag that’s hidden among all the numbers. This can be done manually by replacing each of the digits with an empty string until only the flag is left out, or by way of a script in Python that will extract only the flag’s characters (the non-numeric characters) one by one.

Implementation

We received a file named FindInText.txt. We’ll open it in a text editor such as Notepad:

At first glance it seems that the file contains only digits.

But a closer inspection reveals that things are different – for example, here’s the letter t:

ctf1.2.png

This raises a suspicion that other letters or special characters may be there too, and maybe they’ll advance us towards the flag.

We can look for the letters and special characters as is called for in the file name, but it’s more efficient to just delete all the numeric characters. For example, in the text editor we can replace all the occurrences of every digit with an empty string – starting from 0 and ending with 9:

Repeating the action for every digit from 0 to 9 leaves us with:

And that’s our flag.

 

Alternatively, this Python script will parse the text character by character and insert the non-numeric characters one by one to a string:

file = open(“FindInText.txt”, ‘r’)

str = file.read()

file.close()

flag = “”

for i in str:

    if not(i.isnumeric()):

        flag+=i

print(“flag: “ + flag)

 

Save the text as a Python file (.py) located in the same folder as the CTF file (FintInText.txt).

It runs like so (see the bottom part of the image):

Here too we see that the program extracts the flag for us.

bottom of page