예제 #1
0
파일: reHooks.py 프로젝트: mfthomps/RESim
        def finish_populating_widget_popup(self, form, popup):
            # Or here, after the popup is done being populated by its owner.

            # We will attach our action to the context menu
            # for the 'Functions window' widget.
            # The action will be be inserted in a submenu of
            # the context menu, named 'Others'.
            if idaversion.get_widget_type(form) == idaapi.BWN_CALL_STACK:
                #line = form.GetCurrentLine()
                pass
            elif idaversion.get_widget_type(form) == idaapi.BWN_DISASM or \
                 idaversion.get_widget_type(form) == idaapi.BWN_DUMP:
                #regs =['eax', 'ebx', 'ecx', 'edx', 'esi', 'edi', 'ebp', 'esp', 'ax', 'bx', 'cx', 'dx', 'ah', 'al', 'bh', 'bl', 'ch', 'cl', 'dh', 'dl']


                regs = idaapi.ph_get_regnames()
                idaapi.attach_action_to_popup(form, popup, "revCursor:action", 'RESim/')
                idaapi.attach_action_to_popup(form, popup, "dis:action", 'RESim/')

                highlighted = idaversion.getHighlight()
                if highlighted is not None:
                    if highlighted in regs:
                        idaapi.attach_action_to_popup(form, popup, "modReg:action", 'RESim/')
                    else:
                        addr = getHex(highlighted)
                        if addr is not None or regFu.isHighlightedEffective():
                            idaapi.attach_action_to_popup(form, popup, "rev:action", 'RESim/')
                            idaapi.attach_action_to_popup(form, popup, "dataWatch:action", 'RESim/')
                            idaapi.attach_action_to_popup(form, popup, "addDataWatch:action", 'RESim/')
                            idaapi.attach_action_to_popup(form, popup, "revData:action", 'RESim/')
                            idaapi.attach_action_to_popup(form, popup, "modMemory:action", 'RESim/')
                            idaapi.attach_action_to_popup(form, popup, "stringMemory:action", 'RESim/')
                opnum = idaapi.get_opnum()
                if opnum >= 0:
                    idaapi.attach_action_to_popup(form, popup, "structField:action", 'RESim/')
예제 #2
0
        def activate(self, ctx):
            if regFu.isHighlightedEffective():
                addr = regFu.getOffset()
                simicsString = gdbProt.Evalx('SendGDBMonitor("@cgc.getMemoryValue(0x%x)");' % addr) 
                print('effective addr 0x%x value %s' % (addr, simicsString))
                value = getHex(simicsString)
            else:
                highlighted = idaapi.get_highlighted_identifier()
                addr = getHex(highlighted)
                if addr is None:
                    print('ModMemoryHandler unable to parse hex from %s' % highlighted)
                    return
                simicsString = gdbProt.Evalx('SendGDBMonitor("@cgc.getMemoryValue(0x%x)");' % addr) 
                print('addr 0x%x value %s' % (addr, simicsString))
                value = getHex(simicsString)

            # Sample form from kernwin.hpp
            s = """Modify memory
            Address: %$
            <~E~nter value:S:32:16::>
            """
            num = Form.NumericArgument('N', value=value)
            ok = idaapi.AskUsingForm(s,
                    Form.NumericArgument('$', addr).arg,
                    num.arg)
            if ok == 1:
                print("You entered: %x" % num.value)
                simicsString = gdbProt.Evalx('SendGDBMonitor("@cgc.writeWord(0x%x, 0x%x)");' % (addr, num.value)) 
                time.sleep(1)
                idc.RefreshDebuggerMemory()
예제 #3
0
파일: idaSIM.py 프로젝트: kingking888/RESim
 def registerMath(self): 
     retval = None
     if regFu.isHighlightedEffective():
         retval = regFu.getOffset()
     else:
         #regs =['eax', 'ebx', 'ecx', 'edx', 'esi', 'edi', 'ebp']
         highlighted = idaversion.getHighlight()
         retval = None
         if highlighted is not None:
             print 'highlighted is %s' % highlighted
             if self.isReg(highlighted):
                 retval = idaversion.get_reg_value(highlighted)
             else:
                 try:
                     retval = int(highlighted, 16)
                 except:
                     pass
                 if retval is None:
                     ''' TBD this is broken, manually manage register list? '''
                     for reg in self.reg_list:
                         if highlighted.startswith(reg):
                             rest = highlighted[len(reg):]
                             value = None
                             try:
                                 value = int(rest[1:])
                             except:
                                 pass
                             if value is not None:
                                 if rest.startswith('+'):
                                     regvalue = idaversion.get_reg_value(reg)
                                     retval = regvalue + value
                                 elif rest.startswith('-'):
                                     regvalue = idaversion.get_reg_value(reg)
                                     retval = regvalue - value
     return retval
예제 #4
0
파일: rev.py 프로젝트: wyu0hop/RESim
def registerMath():
    retval = None
    if regFu.isHighlightedEffective():
        retval = regFu.getOffset()
    else:
        #regs =['eax', 'ebx', 'ecx', 'edx', 'esi', 'edi', 'ebp']
        highlighted = idaapi.get_highlighted_identifier()
        retval = None
        if highlighted is not None:
            print 'highlighted is %s' % highlighted
            if highlighted in reg_list:
                retval = idc.GetRegValue(highlighted)
            else:
                try:
                    retval = int(highlighted, 16)
                except:
                    pass
                if retval is None:
                    for reg in reg_list:
                        if highlighted.startswith(reg):
                            rest = highlighted[len(reg):]
                            value = None
                            try:
                                value = int(rest[1:])
                            except:
                                pass
                            if value is not None:
                                if rest.startswith('+'):
                                    regvalue = idc.GetRegValue(reg)
                                    retval = regvalue + value
                                elif rest.startswith('-'):
                                    regvalue = idc.GetRegValue(reg)
                                    retval = regvalue - value
    return retval
예제 #5
0
    def activate(self, ctx):
        if regFu.isHighlightedEffective():
            addr = regFu.getOffset()
        else:
            highlighted = idaversion.getHighlight()
            addr = getHex(highlighted)
            if addr is None:
                print('ModMemoryHandler unable to parse hex from %s' %
                      highlighted)
                return

        sas = setAddrString.SetAddrString()
        sas.Compile()
        sas.iAddr.value = addr
        val = ''
        for i in range(8):
            c = idaversion.get_wide_byte(addr + i)
            if c >= 0x20 and c <= 0x7e:
                val = val + chr(c)
            else:
                val = val + '.'
        sas.iStr1.value = val
        ok = sas.Execute()
        if ok != 1:
            return
        self.last_data_mem_set = sas.iStr1.value
        #sparm = "'%s'" % sas.iStr1.value
        sparm = "'%s'" % str(sas.iStr1.value).strip()
        dog = 'SendGDBMonitor("@cgc.writeString(0x%x, %s)");' % (
            sas.iAddr.value, sparm)
        print('dog is <%s>' % dog)
        simicsString = gdbProt.Evalx(
            'SendGDBMonitor("@cgc.writeString(0x%x, %s)");' %
            (sas.iAddr.value, sparm))
        time.sleep(2)
        self.isim.updateBookmarkView()
        self.isim.updateDataWatch()
        idaversion.refresh_debugger_memory()
        idaversion.refresh_idaview_anyway()
        idaversion.refresh_choosers()
        print(
            'Bookmarks cleared -- select origin bookmark to return to this cycle'
        )
        print(
            'Note: data watches previous to this point are retained, but associated bookmarks are deleted'
        )
예제 #6
0
파일: reHooks.py 프로젝트: wyu0hop/RESim
    def activate(self, ctx):
        if regFu.isHighlightedEffective():
            addr = regFu.getOffset()
            simicsString = gdbProt.Evalx(
                'SendGDBMonitor("@cgc.getMemoryValue(0x%x)");' % addr)
            print('effective addr 0x%x value %s' % (addr, simicsString))
            value = simicsString
        else:
            highlighted = idaapi.get_highlighted_identifier()
            addr = getHex(highlighted)
            if addr is None:
                print('ModMemoryHandler unable to parse hex from %s' %
                      highlighted)
                return
            simicsString = gdbProt.Evalx(
                'SendGDBMonitor("@cgc.getMemoryValue(0x%x)");' % addr)
            print('addr 0x%x value %s' % (addr, simicsString))
            value = simicsString

        # Sample form from kernwin.hpp
        s = """Modify memory
            Address: %$
            <~E~nter value:t40:80:50::>
            """
        ti = idaapi.textctrl_info_t(value)
        ok = idaapi.AskUsingForm(
            s,
            Form.NumericArgument('$', addr).arg,
            idaapi.pointer(idaapi.c_void_p.from_address(ti.clink_ptr)))
        '''
            string = Form.StringArgument(value)
            ok = idaapi.AskUsingForm(s,
                    Form.NumericArgument('$', addr).arg,
                    string.arg)
            '''
        if ok == 1:
            arg = "'%s'" % ti.text.strip()
            print("You entered: %s <%s>" % (ti.text, arg))
            cmd = "@cgc.writeString(0x%x, %s)" % (addr, arg)
            print cmd
            simicsString = gdbProt.Evalx('SendGDBMonitor("%s");' % (cmd))
            time.sleep(1)
            idc.RefreshDebuggerMemory()