AudioCrypto SunshineCTF 2021 Writeup

Foreword

Prerequisites

Solution

  1. Open input sound file for reading
  2. Open output sound file for writing
  3. Set output file parameters similar for input file.
frames = inpaudio.readframes(inpaudio.getnframes())
for i in range(0, len(frames), 2):
frame = frames[i: i + 2] # Single frame is two bytes long
# Here is useless print statement
encaudio.writeframes(cryptStream.encryptFrame(frame))
  1. Pick four random values M, A, B and state.
  2. Call next_byte() function 100 times and ensure that it doesn’t return any duplicates. If it does, go back at step 1.
self.state = (self.state * self.a + self.b) % self.m
>>> S = 5
>>> A = 9
>>> B = 7
>>> M = 13
>>> for i in range(20):
... S = (S * A + B) % M
... print(S)
0
7
5
0
7
5
0
7
5
0
7
5
0
7
5
0
7
5
0
7
>>>

--

--

awawa.fun

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store