Exemplo n.º 1
0
 def eval(self, item):
     if isinstance(item, (int, long)):
         return item
     return constants.eval(item)
Exemplo n.º 2
0
 def eval(self, item):
     if isinstance(item, (int,long)):
         return item
     return constants.eval(item)
Exemplo n.º 3
0
def render_body(context, reg_context, stack_allowed=True, **pageargs):
    __M_caller = context.caller_stack._push_frame()
    try:
        __M_locals = __M_dict_builtin(reg_context=reg_context,
                                      pageargs=pageargs,
                                      stack_allowed=stack_allowed)
        int = context.get('int', UNDEFINED)
        NameError = context.get('NameError', UNDEFINED)
        isinstance = context.get('isinstance', UNDEFINED)
        str = context.get('str', UNDEFINED)
        __M_writer = context.writer()

        from pwnlib.regsort import regsort
        from pwnlib.constants import Constant, eval
        from pwnlib.shellcraft import registers
        from pwnlib.shellcraft.i386 import mov

        __M_locals_builtin_stored = __M_locals_builtin()
        __M_locals.update(
            __M_dict_builtin([
                (__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in
                ['regsort', 'registers', 'Constant', 'mov', 'eval']
                if __M_key in __M_locals_builtin_stored
            ]))
        __M_writer(u'\n')
        __M_writer(u'\n')
        __M_writer(u'\n')

        reg_context = {k: v for k, v in reg_context.items() if v is not None}

        eax = reg_context.get('eax', None)
        edx = reg_context.get('edx', None)
        cdq = False

        if isinstance(eax, str):
            try:
                eax = eval(eax)
            except NameError:
                pass

        if isinstance(edx, str):
            try:
                edx = eval(edx)
            except NameError:
                pass

        if isinstance(eax, int) and isinstance(edx, int) and eax >> 31 == edx:
            cdq = True
            reg_context.pop('edx')

        sorted_regs = regsort(reg_context, registers.i386)

        __M_locals_builtin_stored = __M_locals_builtin()
        __M_locals.update(
            __M_dict_builtin([
                (__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in
                ['reg_context', 'k', 'eax', 'cdq', 'v', 'edx', 'sorted_regs']
                if __M_key in __M_locals_builtin_stored
            ]))
        __M_writer(u'\n')
        if not sorted_regs:
            __M_writer(u'  /* setregs noop */\n')
        else:
            for how, src, dst in regsort(reg_context, registers.i386):
                if how == 'xchg':
                    __M_writer(u'    xchg ')
                    __M_writer(unicode(src))
                    __M_writer(u', ')
                    __M_writer(unicode(dst))
                    __M_writer(u'\n')
                else:
                    __M_writer(u'    ')
                    __M_writer(unicode(mov(src, dst)))
                    __M_writer(u'\n')
            if cdq:
                __M_writer(u'    cdq /* edx=0 */\n')
        return ''
    finally:
        context.caller_stack._pop_frame()
Exemplo n.º 4
0
 def eval(self, item):
     if isinstance(item, six.integer_types):
         return item
     return constants.eval(item)