Created
July 10, 2026 16:08
-
-
Save uyjulian/df6a03cb9718337ff6b431b75d906eb6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # SPDX-License-Identifier: MIT | |
| import sys | |
| import struct | |
| import os | |
| cramfs_known = [] | |
| with open(sys.argv[1], "rb") as f: | |
| f.seek(0x440000) | |
| cramfs_known.append(f.read(0x8000)) | |
| f.seek(0xD28000) | |
| cramfs_known.append(f.read(0x8000)) | |
| f.seek(0x3028000) | |
| cramfs_known.append(f.read(0x8000)) | |
| f.seek(0x6740000) | |
| cramfs_known.append(f.read(0x8000)) | |
| for blk in cramfs_known: | |
| super_magic = int.from_bytes(blk[0:4], byteorder="big") | |
| super_size = int.from_bytes(blk[4:8], byteorder="big") | |
| super_flags = int.from_bytes(blk[8:12], byteorder="big") | |
| super_future = int.from_bytes(blk[12:16], byteorder="big") | |
| super_signature = blk[16:32] | |
| super_fsid_crc = int.from_bytes(blk[32:36], byteorder="big") | |
| super_fsid_edition = int.from_bytes(blk[36:40], byteorder="big") | |
| super_fsid_blocks = int.from_bytes(blk[40:44], byteorder="big") | |
| super_fsid_files = int.from_bytes(blk[44:48], byteorder="big") | |
| super_name = blk[48:64] | |
| print("super_magic: %08x" % (super_magic)) | |
| print("super_size: %08x" % (super_size)) | |
| print("super_flags: %08x" % (super_flags)) | |
| print("super_future: %08x" % (super_future)) | |
| print("super_signature: ", super_signature) | |
| print("super_fsid_crc: %08x" % (super_fsid_crc)) | |
| print("super_fsid_edition: %08x" % (super_fsid_edition)) | |
| print("super_fsid_blocks: %08x" % (super_fsid_blocks)) | |
| print("super_fsid_files: %08x" % (super_fsid_files)) | |
| print("super_name: ", super_name) | |
| offs = 64 | |
| for i in range(super_fsid_files): | |
| inode_mode_uid = int.from_bytes(blk[offs + 0:offs + 4], byteorder="big") | |
| inode_mode = (inode_mode_uid & 0xFFFF0000) >> 16 | |
| inode_uid = inode_mode_uid & 0xFFFF | |
| inode_size_gid = int.from_bytes(blk[offs + 4:offs + 8], byteorder="big") | |
| inode_size = (inode_size_gid & 0xFFFFFF00) >> 8 | |
| inode_gid = inode_size_gid & 0xFF | |
| inode_namelen_offset = int.from_bytes(blk[offs + 8:offs + 12], byteorder="big") | |
| inode_namelen = (inode_namelen_offset & 0xFC000000) >> 26 | |
| inode_offset = inode_namelen_offset & 0x3FFFFFF | |
| offs += 12 | |
| print("inode: ", hex(inode_mode), hex(inode_uid), hex(inode_size), hex(inode_gid), hex(inode_namelen), hex(inode_offset)) | |
| print("inode name: ", blk[offs:offs + (inode_namelen * 4)].rstrip(b"\x00")) | |
| offs += inode_namelen * 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment