CSE Puzzle Challenge - Puzzle 7 - Solution

Up to now, Walter had been able to decode all of the transmissions sent by his Ham Radio buddies. It was now his turn to come up with something. Having recently visited San Luis Potosi region in Mexico, he had learned about the Pame languages. Would this idea of his be enough to prevent his friends from decoding the secret message? Would he win the secret message contest?

Download HexDump.txt

 

Solution

This month challenge contained 2 parts. The first part was a short text. The second part was an hex dump for a file. The first step in solving the challenge required the participant to rebuild the binary file. This could be done by using an hex editor or by writing a script that would rebuild the file. Once the file was rebuilt, using the “file” command on Linux, one could learn about the nature of the file as show by the following console output:

DemoMachine:~$ file sound.wav
sound.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 44100 Hz

Using an audio player, the participant can confirm that the file is, indeed, a valid audio file. Upon listening, the file appears to be gibberish.

Next, two thing can be done. Either the participant looks closer at the short text accompanying the file or look at the wave form of the audio file. Let’s start by having a closer look at the text.

The text gives a hint that Walter is coming back from a trip to Mexico. A quick search about Pame languages on google will result in finding the “Pame languages” page on wikipedia. A quick read of the text allow the participant to learn that Pame use an octal counting system. This was a hint that the content of the audio file was indeed encoded using base-8.

A quick inspection of the file sound wave (this can be done using Audacity) confirms that only 8 different sound waves are used in creating the file. The first 16 “digits” of the files are simply counting from 0 to 7 twice. This is meant to help the participant in quickly figuring out the octal nature of the sound wave. Further more, the participant should notice that groups of individual sound waves are created and separated by silences. These groups are full base-8 numbers.

The participant then had to extract all the base-8 numbers from the audio file. Multiple techniques can be used to achieve the result. For example, the participant could visually inspect the file and reconstruct the numbers. However, we suggest that the participant automates the process by using a script. Here is an example of such a script:

import re


HEADER = b"RIFF.*data.*\xff\x7f"
LARGE_SPACER = b"(\xff\x7f){10,}"
SMALL_SPACER = b"\xff\x7f"


def get_file_content():
    file = open("sound.wav", "rb")
    file_raw = file.read()
    file.close()
    return file_raw


def remove_header(content):
    return re.sub(HEADER, b"", content)


def extract_octal_digits(data):
    data = split_signals(data)
    return data[:8]


def split_signals(data):
    data = re.compile(LARGE_SPACER).split(data)
    return list(filter(lambda x: should_be_processed(x), data))


def should_be_processed(x):
    return not (x == SMALL_SPACER or x == b"")


def convert_data_to_octal(octal_digits, data):
    data = replace_signals_by_octal_digit(octal_digits, data)
    data = split_signals(data)
    data = data[16:]  # Remove octal digit definition
    return list(map(lambda x: x.replace(SMALL_SPACER, b""), data))


def replace_signals_by_octal_digit(octal_digits, data):
    for i, digit in enumerate(octal_digits):
        data = data.replace(digit, str(i).encode())
    return data


def convert_octal_message_to_text(octal_message):
    message = ""
    for number in octal_message:
        message += chr(int(number.decode(), 8))
    return message


content = get_file_content()
data = remove_header(content)
octal_digits = extract_octal_digits(data)
octal_message = convert_data_to_octal(octal_digits, data)
message = convert_octal_message_to_text(octal_message)
print(message)
 

Once the numbers are extracted, the participant can map the numbers to ASCII code to obtain the final message:

“CSE wishes you a happy new year!/Le CST vous souhaite une bonne année!”

 

Enjoy solving puzzles? Make a career out of it!