-
Notifications
You must be signed in to change notification settings - Fork 0
/
challenge_03.py
68 lines (55 loc) · 2.19 KB
/
challenge_03.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# downloaded Sonic Visualizer - nothing special initially in the spectrum analyzer.
# Its possible that the upper range is actually morse code?
# there is a narrow band where content is repeated...
# small dots of data appear in sequences of blocks of 7. There are 48 blocks. (maybe 48 letters?)
import os
import wave
import collections
import challenge_00
file = os.path.abspath('./Challenge 3/test.wav')
def print_lowest_bits(file):
with wave.open(file, 'rb') as handle:
data = handle.readframes(1024)
# stuff = [format(item, '#010b')[-1] for item in data] # get LSB
stuff = [str(item & 0b00000001) for item in data]
collector = []
for index in range(0, len(stuff), 8):
num = ''.join(stuff[index:index + 8])
collector.append(chr(int(num, 2)))
print(''.join(collector))
print(len(collector))
def wav_example(path):
with wave.open(path, 'rb') as w:
amplitudes = list()
for index in range(w.getnframes()):
frame = w.readframes(index)
for item in range(len(frame)):
amplitudes.append(frame[item])
print(max(amplitudes))
print(min(amplitudes))
count = collections.Counter(amplitudes)
for item in count.items():
print(item)
def decrypt_message(passkey):
infile_ = os.path.abspath('./Challenge 3/solution.txt.enc')
outfile_ = os.path.abspath('./Challenge 3/generated_content/solution.txt')
challenge_00.decrypt_openssl(infile=infile_, outfile=outfile_, passphrase=passkey)
if __name__ == '__main__':
passkey = 'hackfuandallyourtrickshellbearandneverseemtomind'
decrypt_message(passkey.lower())
# print_lowest_bits(file)
# wav_example(file)
# with wave.open(file) as handle:
# for item in dir(handle):
# print(item)
# print(handle.tell())
# print(handle.getcompname())
# print(handle.getcomptype())
# print(handle.getfp())
# print(handle.getframerate())
# print(handle.getparams())
# print(handle.getsampwidth())
# print(handle.getnchannels())
# print(handle.getnframes())
# print(handle.getmarkers())
# print(2534400 / 8)