summaryrefslogtreecommitdiff
path: root/signsmu.py
blob: 32327b325d0611f6ef44966a4b60efca5f10cc2e (plain)
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
# smutool  Tool for SMU
# Copyright (C) 2015  Damien Zammit <damien@zamaudio.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# See <http://www.gnu.org/licenses/>. 
#

import sys
import struct, hashlib, hmac

args=sys.argv
if len(sys.argv) == 1:
	print "Usage: python signsmu.py <smu firmware>"
	sys.exit()

def reverse(strs):
    return ''.join([strs[i] for i in xrange(len(strs)-1, -1, -1)])

key1 = "\x77\x33\xbf\x25\x5c\x07\x03\x78\x1f\xb7\xc1\x3b\x7f\x4b\x92\xaf"

f = open(args[1], "rb")
firmware = bytearray()
try:
	firmware = bytearray(f.read())
finally:
	f.close()

h = hmac.new(key1, firmware, hashlib.sha1)
mhash = h.digest()
print hex(struct.unpack(">5I", mhash)[0])
print hex(struct.unpack(">5I", mhash)[1])
print hex(struct.unpack(">5I", mhash)[2])
print hex(struct.unpack(">5I", mhash)[3])
print hex(struct.unpack(">5I", mhash)[4])