diff options
-rwxr-xr-x | tools/find_bootsect.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/find_bootsect.py b/tools/find_bootsect.py new file mode 100755 index 0000000..f52e910 --- /dev/null +++ b/tools/find_bootsect.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +import os, logging, binascii + +disk_count = 15 +disk_order = [ 0,1,2,4,5,6,7,8,9,10,11,12,13,14,15 ] +disk_paths = [ 'disk%02i.img'%d for d in disk_order ] +disks = [ None for d in range(disk_count) ] +disks_size = [ 0 for d in range(disk_count) ] + +for d in range(disk_count): + path = disk_paths[d] + logging.debug("Try to open disk #%2d"%d) + try: + disks[d] = open(path, "r") + disks_size[d] = os.lstat(path).st_size + logging.debug("Opened disk #%2d"%d) + except IOError as e: + logging.error("Can't open disk #%2d ('%s') : %s"%(d, path, e.strerror)) + disks_size[d] = 0 + except: + logging.error("Can't open disk #%2d ('%s') : unhandled exception"%(d, path)) + disks_size[d] = 0 +logging.debug("Exit. open_disks()") + +ref_sig = binascii.unhexlify('55AA') + +for offset in range(0, min(disks_size), 512): + for disk_no in range(disk_count): + disks[disk_no].seek(offset) + data = disks[disk_no].read(512) + sig = data[510:] + if sig == ref_sig: + print "%s@%x:%s"%(disk_paths[disk_no],offset,binascii.hexlify(sig)) + + |