morse-code picoCTF 2022 Solution

Published: July 20, 2023

Description

A short WAV file encodes the flag in Morse. Decode the audio, replace spaces with underscores, and wrap it in picoCTF{...}.

Download morse_chal.wav and have a Morse audio decoder ready (e.g., morsecode.world → Audio Decoder, or our Morse Decoder tool for dot-dash text).

Solution

Want to try it yourself first?

The guided walkthrough reveals hints one step at a time.

Walk me through it
  1. Step 1
    Run the audio through a decoder
    Observation
    I noticed the challenge provided a WAV file named morse_chal.wav and the description explicitly mentioned Morse code, which suggested feeding the audio directly into an online Morse audio decoder to extract the encoded letters.
    The file is only ~30 seconds long; most online Morse decoders output the letters immediately.
    What didn't work first

    Tried: Trying to listen to the audio and manually transcribe dots and dashes by ear.

    Manually transcribing Morse audio is extremely error-prone, especially for digits mixed with letters. A beginner will mishear short tones as long ones and lose track of word boundaries. Online audio decoders like morsecode.world handle the entire conversion automatically in seconds.

    Tried: Using a text-based Morse decoder tool before decoding the audio first.

    Text-based Morse decoders expect dot-dash input like .-. --. not a WAV file. The first step is to feed the WAV to an audio-specific decoder to get the dot-dash (or letter) text, and only then use a text decoder if you have the raw symbols.

    Learn more

    Morse code represents letters and digits as sequences of short signals (dots) and long signals (dashes), separated by pauses. It was developed in the 1830s for telegraph communication and is still used in amateur radio. Each character has a unique dot-dash pattern: A is .-, B is -..., and so on.

    In audio Morse, the dots and dashes are tones of different durations. Automated decoders work by analyzing the waveform: they measure the duration of each tone and silence, classify them as dots, dashes, or separators based on timing ratios, and map the resulting patterns to characters. Online tools like morsecode.world or morse.withgoogle.com can decode audio files without any local software. Once you have the dot-dash text, you can also use our Morse Code Decoder to convert it to plain text instantly.

    For those who prefer command-line tools, fldigi is a popular open-source amateur radio application that includes a Morse decoder. More programmatically, Python libraries like pyaudio combined with signal processing can detect tone frequencies and timings from WAV files.

  2. Step 2
    Apply the required formatting
    Observation
    I noticed the problem statement explicitly said to replace spaces with underscores before wrapping in picoCTF{...}, and the decoder output was uppercase with word boundaries, which meant two transformations (lowercase conversion and space-to-underscore substitution) were needed before the flag would pass the submission check.
    The decoded message reads WH47 H47H 90D W20U9H7 - that's letter-and-digit Morse, where 4, 7, 9, 0, 2 are real digits in the Morse alphabet (....-, --..., ----., -----, ..---), not garbled letters. Spaces become underscores per the prompt. Wrap with picoCTF{ and } to assemble the final flag, e.g. picoCTF{wh47_h47h_90d_w20u9h7} ending in a closing brace so the format check passes.
    What didn't work first

    Tried: Treating the digits in the decoded output as garbled letters and re-decoding them.

    Morse code has a full numeral set (0-9) so digits like 4, 7, 9 in the output are correct and intentional, not a decoding error. Re-interpreting them as letters produces nonsense. Trust the decoder output and keep the digits as-is.

    Tried: Leaving spaces between words instead of replacing them with underscores.

    The challenge prompt explicitly says to replace spaces with underscores before wrapping in picoCTF{}. Submitting with spaces (e.g. picoCTF{wh47 h47h ...}) will fail the flag check. Use tr or a simple find-and-replace to swap every space for an underscore.

    Learn more

    The pipeline demonstrates several useful shell text-transformation tools in sequence. tr ' ' '_' translates (replaces) every space with an underscore - the tr (translate) utility maps individual characters one-to-one, making it ideal for single-character substitutions. tr '[:upper:]' '[:lower:]' then lowercases the entire string using character classes, which handles the full alphabet without listing each letter.

    The final two sed substitutions prepend the flag prefix and append the closing brace. sed 's/^/picoCTF{/' replaces the start-of-line anchor with the prefix text, and sed 's/$/}/' appends to the end of the line. Chaining these transformations is idiomatic Unix shell scripting.

    In CTF flag formatting, word separators commonly use underscores rather than spaces because spaces can cause issues in URLs and command-line arguments. Recognizing this convention helps when you decode a phrase and need to decide how to format it for submission.

Interactive tools
  • Morse Code DecoderDecode Morse code to plain text or encode text to Morse code. Supports all letters, digits, and common punctuation.
  • Cipher Identifier & Auto-DecoderPaste any ciphertext and the tool auto-runs every common decoder (base64, hex, Morse, ROT, Atbash, Bacon, binary, decimal, URL) and ranks the results by English-likeness.
Alternate Solution

If you already have the decoded dot-dash text (from morsecode.world or another audio decoder), paste it straight into the Morse Code Decoder on this site to convert dots and dashes to letters instantly. No audio processing needed for that last step.

Flag

Reveal flag

picoCTF{...}

Simple signal-processing exercise, so there's no need for heavy tooling.

Key takeaway

Morse code is a substitution encoding that maps each character to a fixed dot-dash pattern, and audio Morse simply renders those patterns as tones of different durations. Any message encoded this way is trivially recovered with off-the-shelf decoders because the codebook is public. In CTF contexts, recognizing the characteristic rhythmic beeping or the dot-dash text representation is enough to pick the right tool and decode in seconds.

Related reading

Want more picoCTF 2022 writeups?

Tools used in this challenge

What to try next