""" This module has the functions for the 'kodump' subcommand from the 'crodump' script. """ from .hexdump import unhex, toout, hexdump import io import struct def decode_kod(kod, args, data): """ various methods of hexdumping KOD decoded data. """ if args.nokod: # plain hexdump, no KOD decode hexdump(args.offset, data, args) elif args.shift: # explicitly specified shift. args.shift = int(args.shift, 0) enc = kod.decode(args.shift, data) hexdump(args.offset, enc, args) elif args.increment: def incdata(data, s): """ add 's' to each byte. This is useful for finding the correct shift from an incorrectly shifted chunk. """ return b"".join(struct.pack(" read from stdin. import sys data = sys.stdin.buffer.read() if args.unhex: data = unhex(data) decode_kod(kod, args, data)