2023-06-11 13:35:12 -04:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
from struct import unpack
|
|
|
|
|
2023-12-29 16:12:09 -05:00
|
|
|
|
2023-06-11 13:35:12 -04:00
|
|
|
def main():
|
|
|
|
if not os.path.exists("out"):
|
|
|
|
os.makedirs("out")
|
|
|
|
|
2023-12-29 16:12:09 -05:00
|
|
|
with open(sys.argv[1], "rb") as rf:
|
|
|
|
count = unpack("<I", rf.read(4))[0]
|
2023-06-11 13:35:12 -04:00
|
|
|
for pos in range(count):
|
2023-12-29 16:12:09 -05:00
|
|
|
rf.seek(4 + pos * 0x40)
|
|
|
|
start = unpack("<I", rf.read(4))[0] + (count * 0x40) + 4
|
|
|
|
length = unpack("<I", rf.read(4))[0]
|
|
|
|
# flag1 =
|
|
|
|
unpack("<I", rf.read(4))[0]
|
|
|
|
# flag2 =
|
|
|
|
unpack("<I", rf.read(4))[0]
|
|
|
|
filename = rf.read(0x30).rstrip(b"\x00").decode('utf-8')
|
2023-06-11 13:35:12 -04:00
|
|
|
print(f"Start: {hex(start)} Length: {hex(length)} Filename: {filename}")
|
2023-12-29 16:12:09 -05:00
|
|
|
with open(os.path.join("out", filename), "wb") as wf:
|
2023-06-11 13:35:12 -04:00
|
|
|
rf.seek(start)
|
2023-12-29 16:12:09 -05:00
|
|
|
while length > 0:
|
|
|
|
size = min(length, 0x200000)
|
|
|
|
data = rf.read(size)
|
2023-06-11 13:35:12 -04:00
|
|
|
wf.write(data)
|
2023-12-29 16:12:09 -05:00
|
|
|
length -= size
|
2023-06-11 13:35:12 -04:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-12-29 16:12:09 -05:00
|
|
|
main()
|