Advertisement
Guest User

Untitled

a guest
Apr 13th, 2014
106
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import struct
  2.  
  3. def print_mos(f, offset, idx):
  4.     offset += 0x28
  5.     offset += idx * 0x10
  6.     f.seek(offset)
  7.     asize = f.read(4)
  8.     vdev = f.read(4)
  9.     offset = f.read(8)
  10.  
  11.     asize = (struct.unpack("<L", asize)[0] & 0xFFFFFF) << 9
  12.     vdev = struct.unpack("<L", vdev)[0]
  13.     offset = struct.unpack("<Q", offset)[0]
  14.     gang = (offset & 0x8000000000000000) != 0
  15.     offset = ((offset & 0x7FFFFFFFFFFFFFFF) << 9) + 0x400000
  16.     print "block %d @%d:%x, size %d, gang %d" % (idx, vdev, offset, asize, gang)
  17.  
  18. f = open('disk', 'rb')
  19.  
  20. pos = 0
  21. while True:
  22.     f.seek(pos)
  23.     magic = f.read(4)
  24.     if len(magic) == 0:
  25.         break
  26.     if (struct.unpack("<L", magic)[0] == 0x00BAB10C):
  27.         f.seek(pos+0x10)
  28.         print "Uberblock found at %x, tgx %d" % (pos, struct.unpack("<Q", f.read(8))[0])
  29.         print_mos(f, pos, 0)
  30.         print_mos(f, pos, 1)
  31.         print_mos(f, pos, 2)
  32.     if (struct.unpack("<L", magic)[0] == 0x010E0A00):
  33.         print "block at %x -- %x" % (pos, (pos - 0x400000) >> 9)
  34.     pos += 0x200
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement