This commit is contained in:
nitowa
2024-05-04 01:15:15 +02:00
commit e34d53d818
31 changed files with 110 additions and 0 deletions
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+51
View File
@@ -0,0 +1,51 @@
import wave
import sys
alphabet="abcdefghijklmnopqrstuvwxyz "
outfile = "output.wav"
data= []
def usage():
print("Usage:")
print("python3", sys.argv[0], "<text>")
print("<text> may only contain a-z and spaces")
return
if len(sys.argv) < 2 or any(map(lambda char: not char in alphabet,sys.argv[1].lower())):
usage()
exit(1)
if(len(sys.argv[1]) < 250):
print("WARNING: short texts may be much harder to break. You should use at least 250 characters")
input = sys.argv[1].lower()
print("Generating keyboard sounds for \"", input, "\"")
silence = wave.open("./data/silence.wav", 'rb')
data.append([silence.getparams(), silence.readframes(silence.getnframes())])
data.append([silence.getparams(), silence.readframes(silence.getnframes())])
silence.close()
for char in input:
if(char == " "):
char = "spc"
sound_file = "./data/"+char+".wav"
wav_data = wave.open(sound_file, 'rb')
data.append([wav_data.getparams(), wav_data.readframes(wav_data.getnframes())])
wav_data.close()
silence = wave.open("./data/silence.wav", 'rb')
data.append([silence.getparams(), silence.readframes(silence.getnframes())])
silence.close()
silence.close()
output = wave.open(outfile, 'wb')
output.setparams(data[0][0])
for i in range(len(data)):
output.writeframes(data[i][1])
output.close()
print("Your file is at", outfile)
+55
View File
@@ -0,0 +1,55 @@
from scipy.io import wavfile
import sys
samplerate, data = wavfile.read('./output.wav')
if len(sys.argv) < 2:
print("Usage:", "python3", sys.argv[0], "<file.wav>")
exit(1)
i = 0
countsilent = 0
samplefound = 0
avg = []
start = 0
end = 0
avg.append([0])
for sample in data:
i+=1
if(sample[1]<100):
countsilent += 1
if(countsilent > 10000 and sample[1]>100):
countsilent = 0
#print(str(i)+": sample found")
start = i
samplefound = 1
if(countsilent > 8000 and samplefound==1):
samplefound = 0
#print(str(i)+": sample ended")
end = i
avg[len(avg)-1]=avg[len(avg)-1]/(end-start)
avg.append([0])
if (samplefound == 1):
avg[len(avg)-1] += sample[1]
alphabet = "abcdefghijklmnopqr stuvwxyz"
avgs = {}
i=0
res=""
for arr in avg:
value = round(arr[0], 2)
#print(value)
if str(value) not in avgs:
avgs[str(value)]=alphabet[i]
#print(str(value), "is", alphabet[i])
i+=1
res+=avgs[str(value)]
print(res)
print("\n")
print("plug the substitution cipher into https://www.guballa.de/substitution-solver and hope it worked!")
+4
View File
@@ -0,0 +1,4 @@
rm output.wav
python ./generator.py "THE DAY HAD BEGUN ON A BRIGHT NOTE THE SUN FINALLY PEELED THROUGH THE RAIN FOR THE FIRST TIME IN A WEEL AND THE FLAG IS PBCTF OPEN BRACE MECHANICAL LEYBOARDS ARE LOUD CLOSE BRACE AND THE BIRDS WERE SINGING IN ITS WARMTH THERE WAS NO WAY TO ANTICIPATE WHAT WAS ABOUT TO HAPPEN"
python ./solver.py output.wav
read -p "Press enter to continue"