Post

Hackfest 2022: File Type Detective 2.0

Writeup for the “File Type Detective 2.0” challenge created by @dax for the Hackfest CTF 2022.

Undercover

For this challenge, only one file named unknown is provided.

1
2
3
4
5
6
7
8
9
$ file unknown
unknown: data

$ hexdump unknown -C
00000000  3d 3d 20 65 64 32 35 35  31 39 76 31 2d 70 75 62  |== ed25519v1-pub|
00000010  6c 69 63 3a 20 74 79 70  65 30 20 3d 3d 00 00 00  |lic: type0 ==...|
00000020  18 2e 72 89 e1 11 7d 1b  5f 0c f3 5b 61 82 af 8c  |..r...}._..[a...|
00000030  cf 81 1f 5e 71 2b 97 dc  13 f2 a6 b6 8e a7 56 8a  |...^q+........V.|
00000040

By searching for the string == ed25519v1-public: type0 ==, we came across a GitHub repository containing a Python library used to generate Onion addresses for the Tor network. We observe that the header of the file indicates that it is a public key, probably used to generate an Onion address.

The following script is based on the specs to generate the Onion address. The PUBKEY variable contains the bytes found in the unknown file after the header and the three null bytes (\x00).

1
2
3
4
5
6
7
8
9
10
from hashlib import sha3_256
from base64 import b32encode

PUBKEY = b"\x18\x2e\x72\x89\xe1\x11\x7d\x1b\x5f\x0c\xf3\x5b\x61\x82\xaf\x8c\xcf\x81\x1f\x5e\x71\x2b\x97\xdc\x13\xf2\xa6\xb6\x8e\xa7\x56\x8a"
VERSION = b"\x03"

checksum = sha3_256(b".onion checksum" + PUBKEY + VERSION).digest()[:2]
onion_address = b32encode(PUBKEY + checksum + VERSION).decode().lower() + ".onion"

print(onion_address)
1
daxhfcpbcf6rwxym6nnwdavprthych26oevzpxat6ktlndvhk2flpbqd.onion

By navigating with the Tor Browser to the obtained address, the flag is displayed.

This post is licensed under CC BY 4.0 by the author.