#!/usr/bin/env python3 # gr_walk2.py - deeper walk: from the window memdesc records, follow the # kernel pointers 2-3 levels and search for page-array records # {vmap_cpu, flags, PA, 0x1000} (2+ consecutive) to recover the page lists. import sys, struct sys.path.insert(0, "/tmp") import guest_pin_stream as gps PAT_SIZE = struct.pack("= 2: out.append((i, run)) i = j else: i += 8 return out def main(): kc = gps.Kcore() if not kc.load(): print("# kcore load failed"); return 1 pov = kc.page_offset_base # find memdesc records (fast direct-map scan) found = [] CH = 1 << 20 pa = 0x100000000 while pa < 0x180000000 and len(found) < 12: d = kc.read(pov + pa, CH) if d: st = 0 while True: i = d.find(PAT_SIZE, st) if i < 0: break st = i + 1 if i + 16 <= len(d) and d[i+8:i+16] == PAT_FLAGS: found.append((pa + i, d[i:i+0x40])) pa += CH print("# memdesc records: %d" % len(found)) for (gpa, rec) in found: size, flags = struct.unpack_from(" 0x%x: page-array at +0x%x: %s" % (kp, p2, arr[0], ["0x%x" % x for x in arr[1][:12]])) return 0 if __name__ == "__main__": sys.exit(main())