while True:
file.seek(block)
buffer = file.read(ISO9660_BLKSZ)
if len(buffer) < ISO9660_BLKSZ:
break
if buffer[1:6] == "CD001":
type = ord(buffer[0])
print("Volume Offset: %08x" % block)
print("Volume Version: %02x" % ord(buffer[6]))
print("Standard ID: %s" % buffer[1:6])
if type == ISO9660_VOLDESC_BOOT:
print("Volume Type: ISO9660(%02x) Boot Record" % type)
print("Boot System Identifier: %s" % buffer[7:39])
print("Boot Identifier: %s" % buffer[40:71])
print
elif type == ISO9660_VOLDESC_PRIMARY or type == ISO9660_VOLDESC_SUPP:
if type == ISO9660_VOLDESC_PRIMARY:
print("Volume Type: ISO9660(%02x) Primary Volume Descriptor" % type)
else:
print("Volume Type: ISO9660(%02x) Supplementary Volume Descriptor" % type)
print("System ID: %s" % buffer[8:39])
print("Volume ID: %s" % buffer[39:71])
print("Volume Space Size: %d" % struct.unpack("<L", buffer[80:84]))
print("Volume Set Size: %d" % struct.unpack("<H", buffer[120:122]))
print("Volume Sequence Number: %d" % struct.unpack("<H", buffer[124:126]))
print("Logical Block Size: %d" % struct.unpack("<H", buffer[128:130]))
print("Path Table Size: %d" % struct.unpack("<L", buffer[132:136]))
print("Location of Occurrence of Type L Path Table: %d" % struct.unpack("<L", buffer[140:144]))
print("Location of Optional Occurrence of Type L Path Table: %d" % struct.unpack("<L", buffer[144:148]))
print("Location of Occurrence of Type M Path Table: %d" % struct.unpack(">L", buffer[148:152]))
print("Location of Optional Occurrence of Type L Path Table: %d" % struct.unpack(">L", buffer[152:156]))
# 156 - 190
print("FDD - LEN-DR: %d" % struct.unpack("<b", buffer[156:157]))
print("FDD - Extended Attribute Record Length: %d" % struct.unpack("<b", buffer[157:158]))
print("FDD - Location of Extent: %d" % struct.unpack("<L", buffer[158:162]))
print("FDD - Data Length: %d" % struct.unpack("<L", buffer[166:170]))
print("FDD - Recording Date and Time: %d-%d-%d %d:%d:%d" % (ord(buffer[174]) + 1900,ord(buffer[175]),ord(buffer[176]),ord(buffer[177]),ord(buffer[178]),ord(buffer[179])))
print("FDD - File Flags: %d" % ord(buffer[181]))
print("FDD - File Unit Size: %d" % ord(buffer[182]))
print("FDD - Interleave Gap Size: %d" % ord(buffer[183]))
print("FDD - Volume Sequence Number: %d" % struct.unpack("<H", buffer[184:186]))
x = ord(buffer[188])
print("FDD - Length of File Identifier: %d" % x)
print("FDD - File Identifier: %s" % buffer[189:188 + x])
print("FDD - Padding Field:")
print("FDD - System Use:")
print("Volume Set ID: %s" % buffer[190:318].strip())
print("Publisher ID: %s" % buffer[318:446].strip())
print("Data Preparer ID: %s" % buffer[446:574].strip())
print("Application ID: %s" % buffer[574:702].strip())
print("Copyright File ID: %s" % buffer[702:739].strip())
print("Abstract File ID: %s" % buffer[739:776].strip())
print("Bibliographic File ID: %s" % buffer[776:813].strip())
elif type == ISO9660_VOLDESC_PART:
print("Volume Type: ISO9660(%02x) Volume Partition Descriptor" % type)
print
elif type == ISO9660_VOLDESC_END:
print("Volume Type: ISO9660(%02x) Volume Descriptor Set Terminator" % type)
print
break
else:
print("Volume Type: ISO9660(%02x) Reserved Volume Descriptor" % type)
print
block = block + 0x800
file.close()
文件格式解析:ISO9660 (ISO文件) -- Python
最新推荐文章于 2024-07-28 23:33:12 发布