From 15099fc4fff9437da9104f67c33e4a92ed15a76f Mon Sep 17 00:00:00 2001 From: itsme Date: Wed, 7 Jul 2021 01:55:05 +0200 Subject: CroStru record structure now seems to be mostly decoded --- crodump.py | 81 ++++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 50 insertions(+), 31 deletions(-) diff --git a/crodump.py b/crodump.py index 1ba7e5e..7a9d9f3 100644 --- a/crodump.py +++ b/crodump.py @@ -9,7 +9,15 @@ python3 crodump.py crodump chechnya_proverki_ul_2012 python3 crodump.py kodump -s 6 -o 0x4cc9 -e 0x5d95 chechnya_proverki_ul_2012/CroStru.dat """ +def toout(args, data): + """ return either ascdump or hexdump """ + if args.ascdump: + return asasc(data) + else: + return tohex(data) + def enumunreferenced(ranges, filesize): + """ from a list of used ranges and the filesize, enumerate the list of unused ranges """ o = 0 for start, end, desc in sorted(ranges): if start > o: @@ -19,6 +27,7 @@ def enumunreferenced(ranges, filesize): yield o, filesize-o class Datafile: + """ Represent a single .dat with it's .tad index file """ def __init__(self, dat, tad): self.dat = dat self.tad = tad @@ -39,7 +48,7 @@ class Datafile: self.dat.seek(ofs) return self.dat.read(size) - def dump(self, args, dokodecode=False, plainbytes=0): + def dump(self, args, nodecode=False): print("tadhdr: %08x %08x" % tuple(self.tadhdr)) ranges = [] for i, (ofs, ln, chk) in enumerate(self.tadidx): @@ -50,30 +59,45 @@ class Datafile: ln &= 0xFFFFFFF dat = self.readdata(ofs, ln) + ranges.append((ofs, ofs+ln, "item #%d" % i)) plain = b'' - decrypted = ' ' - if dokodecode and not args.nokod: - pb = plainbytes if flags else 8 - plain = dat[:pb] - dat = kodecode(i+1, dat[pb:]) - decrypted = '*' if flags else '+' - if args.ascdump: - print("%5d: %08x-%08x: (%02x:%08x) %s %s%s" % (i, ofs, ofs+ln, flags, chk, tohex(plain), decrypted, asasc(dat))) + decflag = ' ' + infostr = "" + tail = b'' + if not nodecode and not flags: + extofs, extlen = struct.unpack("