Skip to main content

Snyk Fetch the Flag CTF 2023 writeup: Honey Baked Messages

Written by
snyk ctf honey baked messages

November 30, 2023

0 mins read

Thanks for playing Fetch with us! Congrats to the thousands of players who joined us for Fetch the Flag CTF. If you were at Snyk’s 2023 Fetch the Flag and are looking for the answer to the Honey Baked Messages challenge, you’ve come to the right place. Let’s walk through the solution together!

This challenge focuses on the idea of Hamming codes. Hamming codes are a type of error-correcting codes. This challenge uses the (7, 4) version of Hamming codes.

The challenge consists of these parts:

  1. Understand that this is Hamming coding.

  2. Read in each line of the file. 

  3. Determine the needed H matrix for the problem.

  4. Error correct the entire file and get the flag.

Here is the solve.py solution script:

import numpy as np

H = np.array(
        [
            [1, 1, 1, 0, 1, 0, 0],
            [0, 1, 1, 1, 0, 1, 0],
            [1, 1, 0, 1, 0, 0, 1]
        ]
    )
errors = {
    "000":None,
    "001": 6,
    "010": 5,
    "011": 3,
    "100": 4,
    "101": 0,
    "110": 2,
    "111": 1
}

def np2usable(nparr):
    return np.array2string(nparr).replace(" ", "" ).replace("[", "").replace(']', "")

def fixErrs(hamming):
    error = (np.matmul(H, hamming)%2)
    err_idx = errors[np2usable(error)]
    if err_idx != None:
        # print(err_idx)
        hamming[err_idx] +=1
        hamming[err_idx] %= 2

    return hamming[:4]

data = []
with open("message_2.txt", "r") as reader:
    for line in reader:
        code = np.fromstring(" ".join(line.strip("\n")), dtype = int, sep=" ")
        data.append(np2usable(fixErrs(code)))
split_chars = (list(zip(*(iter(data),) * 2)))

[print(chr(int(j+k, 2)), end="") for j,k in split_chars ]

Thanks for making Fetch happen!

A huge thank you to all the teams in Fetch the Flag 2023! It was great seeing all of you there and you can always find me on YouTube.

Here are the writeups for the other 2023 challenges. Dig in!

Posted in:

Read more

Blog

Fetch the Flag CTF 2026: Official Challenge Write-Ups & Community Highlights

Explore official write-ups and community highlights from the Fetch the Flag CTF 2026, featuring over 20 challenges in web security, AI, and crypto. Learn from the experts and dive into the technical details of this year's most intricate binary puzzles and web exploits.

Blog

4 Reasons Why CTFs Are One of the Best Ways to Grow in Cybersecurity

Capture The Flag (CTF) competitions are a powerful way to accelerate your cybersecurity career by exposing you to real-world vulnerabilities and diverse technical niches. Discover why CTFs are one of the best methods to grow your expertise and professional network.

Compliance FEATURE cropped
Blog

The Ultimate Guide to Upcoming CTFs: From Beginner to Elite Hacker in 6 Months (October 2025 - April 2026)

Master CTFs from beginner to elite hacker in 6 months with this ultimate guide! Discover top competitions, understand difficulty classifications, and strategize your path to success from October 2025 to April 2026.