From ea3381947943b8cd33f8edad41b4f32ea52af49e Mon Sep 17 00:00:00 2001 From: h0t_max Date: Tue, 19 Jul 2022 01:02:21 +0300 Subject: inital commit --- XuUnp.py | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 XuUnp.py (limited to 'XuUnp.py') diff --git a/XuUnp.py b/XuUnp.py new file mode 100644 index 0000000..dc84408 --- /dev/null +++ b/XuUnp.py @@ -0,0 +1,78 @@ +import struct, sys, os, binascii + +class bitsReader(object): + def __init__(self, ab): + self.bits = int(binascii.hexlify(ab[::-1]), 16) + self.o = 0 + def get(self, n=1): + self.bits, v = divmod(self.bits, 1< %d, be patient..." % (len(ab), cbUnp)) + br = bitsReader(ab[4:]) + r = bytearray() + while (br.bits): + flag = br.get(1) + if flag: + ncp = br.get(4) + if ncp < 3: ncp += 16 + offs = br.get(14) + ocp = len(r) - offs + for i in range(ncp): r.append(r[ocp+i]) + else: + r.append(br.get(8)) + if len(r) != cbUnp: print("? Got %d instead of %d..." % (len(r), cbUnp)) + else: print("+ Unpacked OK") + return bytes(r) + +class Elf64_Shdr(object): + fmt = struct.Struct("