Skip to content

Instantly share code, notes, and snippets.

@Yepoleb
Created September 1, 2016 03:23
Show Gist options
  • Save Yepoleb/78b532516ca9f43aa19455142ad5e4e2 to your computer and use it in GitHub Desktop.
Save Yepoleb/78b532516ca9f43aa19455142ad5e4e2 to your computer and use it in GitHub Desktop.
import struct
import os
from collections import namedtuple
HEADER_FMT = "<4s7L"
HeaderTuple = namedtuple("Header", ["magic", "unknown1", "size1", "offset1",
"size3", "names_ofs", "names_len", "offset3"])
binary = open("data.up", "rb")
header_bytes = binary.read(32)
header = HeaderTuple(*struct.unpack(HEADER_FMT, header_bytes))
print(header)
print(hex(header[3]), hex(header[5]), hex(header[7]),
hex(os.path.getsize("data.up")))
if not header.magic == b"UDSP":
print("File not UpPackage")
binary.seek(header.names_ofs)
names_bytes = binary.read(header.names_len)
names = names_bytes.split(b"\0")
print("names len", len(names))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment