import struct import sys def carve_ramdrive(dump_file): with open(dump_file, 'rb') as f: data = f.read() print("Searching for FAT Boot Sectors...") # FAT filesystem identifiers in the boot sector for fs_type in [b'FAT12 ', b'FAT16 ']: idx = 0 while True: idx = data.find(fs_type, idx) if idx == -1: break # The fs_type string is at offset 0x36 in the boot sector boot_start = idx - 0x36 # Check for the jump instruction that starts all FAT boot sectors (EB xx 90 or E9 xx xx) if boot_start >= 0 and data[boot_start] in [0xEB, 0xE9]: try: # Parse the exact size of the drive from the boot sector header bps = struct.unpack('") else: carve_ramdrive(sys.argv[1])