Post

FetchTheFlag CTF 2023-Warmup-Beep64

Beep64

Description

Author: @soups71
Every CTF needs a base64 challenge… right?

Download the file(s) below. Attachments:  chall.zip

Solution

1. unzip chall.zip

1
2
3
$ unzip chall.zip 
Archive:  chall.zip
  inflating: sine.wav 

2. I listen to sine.wav, It makes me think about the sound when I push the number on the old telephone.
It’s called DTMF (dual tone multi-frequency).
There is a tool to decode DTMF. dtmf-decoder

1
2
3
$ ./dtmf.py sine.wav > numbers.txt
$ cat numbers.txt 
8*44*33*333*555*2*4*444*7777*9999*33*777*666*7777*7*2*222*33*666*66*33*7777*7*2*222*33*9999*33*777*666*7777*7*2*222*33*666*66*33*7777*7*2*222*33*666*66*33*7777*7*2*222*33*9999*33*777*666*7777*7*2*222*33*6.....

3. The script to decode T9 (Text input on 9 Keys):

1
2
3
4
5
6
7
8
9
T9_Mapping = {2: "abc", 3: "def", 4: "ghi", 5: "jkl", 6: "mno", 7: "pqrs", 8: "tuv", 9: "wxyz", 0: " "}

f = open("numbers.txt", "r")
numbers = filter(None, ''.join(f.read().splitlines()).split("*"))
plain_text = ""
for i in numbers:
    offset = len(i) - 1
    plain_text += T9_Mapping[int(i[0])][offset]
print(plain_text)

after I ran this script. I got theflagiszerospaceonespacezerospaceonespaceonespacezerospaceonespacezerozerospaceonespaceonespace.....

4. Almost get the flag. Just write a bit more script to decode the message.
Binary in alphabet form > Binary > Base64 > Text

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
T9_Mapping = {2: "abc", 3: "def", 4: "ghi", 5: "jkl", 6: "mno", 7: "pqrs", 8: "tuv", 9: "wxyz", 0: " "}

f = open("numbers.txt", "r")
numbers = filter(None, ''.join(f.read().splitlines()).split("*"))
plain_text = ""
for i in numbers:
    offset = len(i) - 1
    plain_text += T9_Mapping[int(i[0])][offset]

#Translate binary in alphabet form to actual binary numbers '1' and '0'.
binary_text = plain_text[9:].split("space")
binary_result = ''
for j in range(len(binary_text)):
    if len(binary_text[j]) > 4:
        if 'zeroone' in binary_text[j]: binary_result += '0 1'
        if 'oneone ' in binary_text[j]: binary_result += '1 1'
        if 'zerozero' in binary_text[j]: binary_result += '0 0'
        if 'onezero' in binary_text[j]: binary_result += '1 0'
    else:
        if 'zero' in binary_text[j]: binary_result += '0'
        if 'one' in binary_text[j]: binary_result += '1'

#Translate binary to base64.
base64_text = ''.join([chr(int(binary, 2)) for binary in binary_result.split(' ')])

#Translate base64 to text.
import base64
flag = base64.b64decode(base64_text)
print(flag.decode())

Flag: flag{0421a964add97ff041431e2418e64508}

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