PicoCTF: The Numbers

The attached file is a picture of a series of numbers in the same format as our flag.

We know that every flag follows the format picCTF{} . C is the third letter of the alphabet and appears twice in the opening so I believe that these numbers correspond to letters in the alphabet, For example a=1 b=2 and so on. Let’s write a python script to translate these numbers according to that rule.

First we define an empty dictionary where we will make our key for transcribing the numbers. Next we use a loop to automatically fill out the list with the keys and values we need . To generate a the numbers from 1 to 26 we use ” for i in range(1, 27)”. Then we assign the i variable to be a our key in our dictionary. We also turn it from an integer to a string using str(); this will make matching the flag easier. Then we generate the letters by using the ord() function to convert the letter to it’s unicode point ( an integer that represents the letter, for example, a= 97 and b=98 and so on). Then we add the value of i and subtract one. This is because if we just added the value of i we would skip “a”. Then the code “num_alpha[key] = value ” matches the number and the letter together in our previously defined dictionary.

After that we define our flag value. I removed the curly braces to make things easier, we will have to re add them afterwards in order to submit the flag. Then we take the flag variable and turn it into a list using .split(). After that I wrote a another loop that iterates through flag_list and uses each item on a list as a key for our dictionary we defined and then prints the result.

Now we have the flag!