Exemple #1
0
    def run(self, args):

        regs = gxf.Registers()
        memory = gxf.Memory()

        tomark = args.mark[:]

        if args.mark_used:
            try:
                dis = gxf.disassemble_lines(regs.get('pc')).lines[:1]
            except gxf.GdbError:
                dis = ()
            for line in dis:
                for _, t in line.tokens[line.instidx:]:
                    tomark.append(t)
                    tomark.extend(regs.impact.get(t, ()))

        for reg, val in regs.regs.items():
            if reg == "eflags" or (len(reg) == 2 and reg[1] == "s"):
                continue

            if reg in tomark:
                ttype = Token.Name.Builtin
            elif reg in ("rdi", "rsi", "rdx", "rcx", "r8", "r9"):
                ttype = Token.Text
            elif reg in ("rip", "eip", "rbp", "esp", "rsp", "rax", "eax"):
                ttype = Token.Generic.Heading
            else:
                ttype = Token.Comment

            print("%s%s" % (Formattable(
                ((ttype, "%-4s" % reg),
                 (Token.Comment, ": "))), memory.refchain(val)))
Exemple #2
0
    def run(self, args):

        memory = gxf.Memory()

        refchain = memory.refchain(args.what)

        refchain.output()
        mmap = refchain[0][1]
        mmap.output()
Exemple #3
0
    def run(self, args):

        size = int(args.size or gxf.cpu.get_addrsz())
        start = int(args.what - args.before * size)
        end = int(args.until or args.what + args.count * size)

        memory = gxf.Memory()

        for addr in range(start, end, size):
            offset = addr - int(args.what)
            refchain = memory.refchain(addr)

            print("%2.d " % (offset, ), end="")
            refchain.output()
Exemple #4
0
    def run(self, args):

        size = args.size or gxf.cpu.get_addrsz()
        start = args.what - args.before * size
        end = args.until or args.what + args.count * size

        memory = gxf.Memory()

        # FIXME: WTF. need to find a gdb solution or a gxf hack.
        def posint(x):
            return int(x) & 0xffffffffffffffff

        for addr in range(posint(start), posint(end), posint(size)):
            offset = addr - posint(args.what)
            refchain = memory.refchain(addr)

            print("%2.d " % (offset, ), end="")
            refchain.output()
Exemple #5
0
    def run(self, args):

        try:
            trunk, branch, future, stop = gxf.disassemble_heading(
                args.what, count=args.count + args.before, offset=-args.before)
        except gxf.MemoryError as e:
            if e.address == args.what:
                memory = gxf.Memory()
                print("Invalid address %s." %
                      memory.refchain(e.address).format())
                return
            else:
                # This is probably a bug :S
                raise

        trunk.output(stop=branch)

        if future:
            print("future:")
            future.output(stop=stop)

            print("alternative:")
            trunk.output(start=branch)
Exemple #6
0
    def run(self, args):

        memory = gxf.Memory()

        memory.output(args.what)