📖
CTF Wiki
  • 🚩Arne's CTF Writeups!
  • 2025
    • TUCTF
      • Forensics - Security Rocks
    • San Diego CTF
      • Crypto - RustSA
      • Misc - Triglot
  • 2024
    • Lexington CTF
      • Misc - a little bit of tomcroppery
    • Imaginary CTF
      • Web - Journal
    • Space Heroes CTF
      • Web - Antikythera
    • HTB Cyber Apocalypse
      • Pwn - Sound of Silence
      • Misc - MultiDigilingual
  • 2023
    • NahamConCTF
      • Mobile - Red Light Green Light
    • BucketCTF
      • Rev - Schematic
      • Rev - Random security
    • HTB Cyber Apocalypse
      • Rev - Cave System
      • Rev - Somewhat Linear
      • Pwn - Void
  • 2022
    • DownUnderCTF 2022
      • Cloud - Jimmy Builds a Kite
    • Ã¥ngstromCTF 2022
      • Pwn - really obnoxious problem
      • Pwn - whatsmyname
    • Engineer CTF
      • Misc - Not really random
      • Misc - Broken Pieces
    • KnightCTF 2022
    • HTB CTF: Dirty Money
      • Forensics - Perseverance
  • 2021
    • MetaCTF CyberGames 2021
    • HTB - Cyber Santa
      • RE - Infiltration
    • Securebug CTF Thor 2021
      • Web - Tricks 1
      • Web - Tricks 2
      • RE - Hidden in Plain Sight
    • TFC CTF 2021
      • RE - Crackity
      • Pwn - Jumpy
      • Misc - Weird Friend
    • K3RN3L CTF 2021
      • Crypto - Pascal RSA
    • DamCTF 2021
      • Misc - library-of-babel
      • Pwn - cookie-monster
    • Killer Queen CTF 2021
      • Pwn - Tweety Birb
      • Forensics - Tippy Tappies
      • Pwn - I want to break free
    • BuckeyeCTF 2021
      • Web - pay2win
      • Misc - USB Exfiltration
Powered by GitBook
On this page
  • Description
  • Downloads
  • Solution
  1. 2023
  2. HTB Cyber Apocalypse

Rev - Somewhat Linear

Hard

Last updated 1 year ago

Description

Deep in the alien cave system, you find a strange device. It seems to be some sort of communication cipherer, but only a couple of recordings are still intact. Can you figure out what the aliens were trying to say? The flag is all lower case

Downloads

Solution

For this challenge, we're given a really short python script and 2 '.wav' sound files.

import numpy as np
import soundfile as sf

flag, rate = sf.read('../htb/flag.wav')


# randomly shuffle the frequencies
freqs = np.fft.rfftfreq(len(flag), 1.0/rate)
filter_frequency_response = np.random.uniform(-10, 10, len(freqs))

# get the amplitudes
def filter(sample):
    amplitudes = np.fft.rfft(sample)
    shuffled_amplitudes = amplitudes * filter_frequency_response

    return np.fft.irfft(shuffled_amplitudes)

impulse = np.zeros(len(flag))
impulse[0] = 1

shuffled_signal = filter(impulse)
sf.write('impulse_response.wav', shuffled_signal, rate)

shuffled_flag = filter(flag)
sf.write('shuffled_flag.wav', shuffled_flag, rate)

What this code does is that it first generates a random sound wave and multiplies it with a very simple impulse wave that is generated with the following code:

The result is then multiplied with the amplitude of the flag.wav sound file.

We can add print statements to see the before and after of the multiplication of the impulse.

Since the impulse simply adds a complex component, we can use the real keyword to get back the generated random noise.

After getting back the randomized noise, we simply need to use the shuffled flag sound waves and divide the amplitudes with the random noise. The solve script is as follows:

import numpy as np
import soundfile as sf

impulse, rate = sf.read('impulse_response.wav')
shuffled_flag, rate = sf.read('shuffled_flag.wav')

# Get the randomized filter_frequency_response
impulse_response = np.fft.rfft(impulse).real
print(impulse_response)

# Get the amplitudes of the shuffled flag
flag_amplitudes = np.fft.rfft(shuffled_flag)
print(flag_amplitudes)

# Divide the amplitudes with the random noise
amplitudes = flag_amplitudes / impulse_response
print(amplitudes)

# Inverse fourier transform
flag = np.fft.irfft(amplitudes)
sf.write('flag.wav', flag, rate)

Flag: htb{th1s_w@s_l0w_eff0rt}

4MB
rev_somewhat_linear.zip
archive
Generated impulse
Before and after multiplication
Getting back the random noise