-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecoder.py
62 lines (49 loc) · 1.39 KB
/
decoder.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
# Korg Monotribe wave -> firmware binary decoding application
# by th0mas aka gravitronic
# http://gravitronic.blogspot.com
# hit me up on twitter http://twitter.com/gravitronic
from struct import pack
def encode(short, long, skip, little, output):
f = open("bits", "r")
finished = ""
i = 0
f.seek(0)
str=""
print "%s: short %s, long %s, skip %d, little %d" % (output, short, long, skip, little)
for i in range(skip):
print "skipping a line"
f.readline();
for b in f.readlines():
if b[0] == "0":
if little == True:
str = short + str
else:
str = str + short
elif b[0] == "1":
if little == True:
str = long + str
else:
str = str + long
i+=1
if i == 8:
finished += pack("B", int(str, 2))
i = 0
str = ""
f = open(output, "w")
f.write(finished)
f.close()
#j = 0
#for i in range(8):
# encode("0", "1", i, True, str(j)+".bin")
# j+=1
# encode("1", "0", i, True, str(j)+".bin")
# j+=1
# encode("0", "1", i, False, str(j)+".bin")
# j+=1
# encode("1", "0", i, False, str(j)+".bin")
# this works:
# 1.bin: short 1, long 0, skip 0, little 1
print "Monotribe firmware decoder by th0mas aka gravitronic"
print "http://twitter.com/gravitronic"
print "use at your own risk!"
encode("1", "0", 0, True, "firmware.bin")