forked from fagci/qs-uvk5-firmware-modder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fw.py
executable file
·49 lines (35 loc) · 979 Bytes
/
fw.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
#!/usr/bin/env python3
from uvk5 import UVK5, argv, eprint, Firmware
def main(cmd):
argc = len(argv)
fw = Firmware.load(argv[2])
eprint('Version:', fw.version)
if argc < 3:
return
if cmd == 'mod':
if argc == 3:
print('Mods:', ','.join(list(fw.get_available_mods())))
return
eprint('mods:', argv[3])
fw.apply_mods(argv[3].split(','))
fw.write()
if argc == 5:
with UVK5(argv[4]) as uvk5:
uvk5.get_version()
uvk5.send_firmware(fw)
if cmd == 'cmp':
fw2 = Firmware.load(argv[3])
fw.compare(fw2)
if cmd == 'enc':
fw.write()
if cmd == 'dec':
fw.write_raw()
if cmd == 'search':
fw.search(argv[3].encode())
def usage():
eprint('Usage:', argv[0], '<cmd>', '<fw.bin>', '[args...]')
exit(255)
if __name__ == '__main__':
if len(argv) == 1:
usage()
main(argv[1])