-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdump.py
34 lines (27 loc) · 923 Bytes
/
dump.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
import click
import time
from Shine6 import commands as cmd
from Shine6.keyboard import open_keyboard
@click.command()
@click.option('--output-file', '-o', help='Output file for flash dump.')
def main(output_file):
"""Dumps all memory from keyboard."""
is_capturing = False
dump = []
def capture_bytes(data):
if is_capturing:
dump.extend(data[5:5+0x3c])
with open_keyboard(callback=capture_bytes) as keyboard:
keyboard.send_packets(cmd.lock_settings())
packets = []
for address in range(0x00, 0xa428, 0x3c):
packets += cmd.read_address(address)
is_capturing = True
keyboard.send_packets(packets)
is_capturing = False
keyboard.send_packets(cmd.unlock_settings())
time.sleep(1)
with open(output_file, 'wb') as file:
file.write(bytearray(dump[:0xa428]))
if __name__ == '__main__':
main()