Featured image of post Write-Up ItAlsoExistsOnAudioFIles HeroCTF v4

Write-Up ItAlsoExistsOnAudioFIles HeroCTF v4

Write-up of a steganography challenge that I created for the HeroCTF v4.

Description

Did you know that wave files are composed of frames?? It opens the field of possibilities!

Format : Hero{} Author : Thib File : Song

Write-Up

Looking at the title, one can guess that a steganography method normally used for images must be used. Moreover the statement of the challenge speaks to us about frames. We can easily make the link between the pixels of an image and the frames of a .wav file! So let’s use our dear LSB.

  1. By doing some research, we realize that wave files can be decomposed into “frames” which can be decomposed into a sequence of bits. So we can modify the LSB of each frame to hide an image!

  2. Python has a perfect library for what we want to do.

 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
def decodeLSBInWave(song):

    song = wave.open(song, mode='rb')

    # Convert audio to byte array
    frame_bytes = bytearray(list(song.readframes(song.getnframes())))

    # Extract the LSB of each byte
    extracted = [frame_bytes[i] & 1 for i in range(len(frame_bytes))]
    #print("Extracted bits: "+str(extracted))

    # Convert byte array back to string
    for i in range(0, len(extracted), 8):
    
        ascii_binary = extracted[i:i+8]
    
        decimal = int("".join(map(str, ascii_binary)), 2)
    
        ascii_char = chr(decimal)
        
        string += ascii_char
    
    # Cut off at the filler characters
    decoded = string.split("###")[0]

    # Print the extracted text
    print("Sucessfully decoded: "+decoded)
    song.close()

Flag

Hero{L5B_0N_4UD10}

Built with Hugo
Theme Stack designed by Jimmy