Siunam's Website

My personal website

Home About Blog Writeups Projects E-Portfolio

Ancient

Overview

Background

Find the flag

In this challenge, we can download a file:

┌[siunam♥earth]-(~/ctf/Incognito-4.0/Crypto/Ancient)-[2023.02.17|23:00:30(HKT)]
└> file challenge.png   
challenge.png: data

Which should be a png image file.

However, when we open it:

It said it’s broken!

Let’s use strings to view all the strings!

┌[siunam♥earth]-(~/ctf/Incognito-4.0/Crypto/Ancient)-[2023.02.17|23:01:38(HKT)]
└> strings challenge.png
IHDR
iCCPICC profile
[...]

iCCPICC profile??

Let’s google that:

Right off the bat, we found another CTF’s writeup:

Wikipedia’s magic headers:

So, the challenge.png is missing the PNG’s magic header?

┌[siunam♥earth]-(~/ctf/Incognito-4.0/Crypto/Ancient)-[2023.02.17|23:03:26(HKT)]
└> xxd challenge.png | head -n 1 
00000000: 0000 0000 aa0a 1a0a 0000 000d 4948 4452  ............IHDR

In our case, it’s missing the first 6 bytes: 89 50 4E 47 0D 0A.

To fix that image, we can use hexeditor to modify the raw bytes:

┌[siunam♥earth]-(~/ctf/Incognito-4.0/Crypto/Ancient)-[2023.02.17|23:05:08(HKT)]
└> file challenge.png
challenge.png: PNG image data, 400 x 170, 8-bit/color RGBA, non-interlaced

It’s an image now!

challenge.png:

Hmm… I’ve no clue what is it…

Let’s upload that image:

Cistercian numerals??

The Cistercian Number System was devised by Cisterican monks in the early 13th century as a compact way to write numbers. Using these numerals any number from 1 to 9,999 can be written in a single glyph by combining the basic elements together on a vertical line.

This website explained how Cistercian Number System looks like:

After that, I watched Numberphile’s video about Cistercian Number System:

Armed with above information, we can find all the Cistercian numbers in decimal:

Hmm… What can we do with those numbers?

Based on my experience, it’s ASCII characters in decimal!

To convert ASCII decimal to text, we can use Python:

#!/usr/bin/env/python3

def main():
    listCistercianNumbers = [
        105,
        99,
        116,
        102,
        123,
        48,
        108,
        100,
        95,
        109,
        48,
        110,
        107,
        95,
        49,
        57,
        48,
        100,
        101,
        49,
        99,
        51,
        125
    ]

    flag = ''
    for number in listCistercianNumbers:
        flag += chr(number)
    else:
        print(flag)

if __name__ == '__main__':
    main()
┌[siunam♥earth]-(~/ctf/Incognito-4.0/Crypto/Ancient)-[2023.02.18|16:02:12(HKT)]
└> python3 solve.py
ictf{0ld_m0nk_190de1c3}

Nice! We got the flag!

Conclusion

What we’ve learned:

  1. Fixing PNG Magic Header & Cistercian Number System