def do_dump(args): nvram = restruct.parse(NVRAM, args.infile) for section in nvram.sections: name = section.header.name.rstrip('\x00') if not name: continue print(name + ':') for val in section.values: v = val.value if all(0x20 <= b <= 0x7E for b in v): v = repr(v.decode('ascii')) print(' ' + val.key + ': ' + restruct.format_value(v, str))
sys.exit(1) if isinstance(img4, IMG4): payload = img4['payload'] manifest = img4['manifest'] elif isinstance(img4, IMG4Manifest): payload = None manifest = img4 elif isinstance(img4, IMG4Payload): payload = img4 manifest = None if payload: p = payload.native if args.raw: print(restruct.format_value(p, str)) else: print('payload:') print(' type:', p['type']) print(' desc:', p['description']) if p['keybags']: print(' keybags:') keybags = payload['keybags'].parse(IMG4KeyBagSequence).native for kb in keybags: print(' id: ', kb['id']) print(' iv: ', restruct.format_value(kb['iv'], str)) print(' key:', restruct.format_value(kb['key'], str)) print() if p['compression']: print(' compression:') print(' algo:', p['compression']['algorithm'])
def dump_value(n, v): return restruct.format_value(v, str)