Created
April 21, 2020 19:55
-
-
Save mrT4ntr4/d994fb0585d37a113d2937a675264b6c to your computer and use it in GitHub Desktop.
Solution script for Challenge Screams from riceteacatpanda CTF 2020
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Fixing wav and generating an img | |
import soundfile as sf | |
import numpy as np | |
from PIL import Image | |
#im = Image.new() | |
#np.set_printoptions(threshold=np.inf) | |
data, samplerate = sf.read('../aaaaaaaaaaaaaaaaaa.wav') | |
print data,samplerate | |
height = np.size(data) | |
print height | |
pixellist = [] | |
audioarr = np.hsplit(data, data.shape[1])[0] | |
imgarr = np.hsplit(data, data.shape[1])[1] | |
tmplist = [] | |
for r in np.nditer(imgarr): | |
tmp = '{0:.11f}'.format(abs(r)).replace('0.00','') | |
b = int(tmp[:3]) | |
g = int(tmp[3:6]) | |
r = int(tmp[6:9]) | |
tmplist.append((r,g,b)) | |
if(len(tmplist) == 500): | |
pixellist.append(tmplist) | |
tmplist = [] | |
print len(pixellist) | |
array = np.array(pixellist, dtype=np.uint8) | |
# Use PIL to create an image from the new array of pixels | |
new_image = Image.fromarray(array) | |
new_image.save('new22.png') | |
#219215220 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment