-
Notifications
You must be signed in to change notification settings - Fork 1
/
extract.py
executable file
·41 lines (34 loc) · 1.06 KB
/
extract.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
import os
import struct
FIRMWARE = "TX-6610_V4_150922.bin"
st = os.stat(FIRMWARE)
mem = open(FIRMWARE, "rb")
magic_bytes, header_size, file_size, crc, version, customer_version, kernel_size, rootfs_size, ctrom_size, model = struct.unpack(">4sIII32s32sIII32s", mem.read(124))
print("Magic bytes: {0}".format(magic_bytes))
print("Header size: {0} bytes".format(header_size))
print("File size: {0} bytes".format(file_size))
print("CRC32: {:08X}".format(crc))
print("Version: {0}".format(version))
print("Customer version: {0}".format(customer_version))
print("Kernel size: {0} bytes".format(kernel_size))
print("Rootfs size: {0} bytes".format(rootfs_size))
print("ctrom size: {0} bytes".format(ctrom_size))
print("Model: {0}".format(model))
#dump lzma
mem.seek(0x100)
lzma = mem.read(kernel_size)
f = open("tclinux", "wb")
f.write(lzma)
f.close()
#dump squashfs
mem.seek(0x150000)
squashfs = mem.read(rootfs_size)
f = open("rootfs.squashfs", "wb")
f.write(squashfs)
f.close()
#last 232 bytes
mem.seek(0x350000)
ending = mem.read(232)
f = open("sign", "wb")
f.write(ending)
f.close()