def activate(self, ctx): addr = getRefAddr() if addr is None: highlighted = idaversion.getHighlight() addr = getHex(highlighted) ''' if regFu.isHighlightedEffective(): addr = regFu.getOffset() else: highlighted = idaversion.getHighlight() addr = getHex(highlighted) ''' sas = setAddrValue.SetAddrValue() sas.Compile() sas.iAddr.value = addr sas.iOffset.value = 0 sas.iRawHex.value = idaversion.get_wide_dword(sas.iAddr.value) ok = sas.Execute() if ok != 1: return val = sas.iRawHex.value addr = sas.iAddr.value offset = sas.iOffset.value new_addr = addr+offset simicsString = gdbProt.Evalx('SendGDBMonitor("@cgc.writeWord(0x%x, 0x%x)");' % (new_addr, val)) 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')
def signalClient(self, norev=False): start_eip = idaversion.get_reg_value(self.PC) #print('signalClient eip was at 0x%x, then after rev 1 0x%x call setAndDisable string is %s' % (start_eip, eip, simicsString)) if norev: idaapi.step_into() idaversion.wait_for_next_event(idc.WFNE_SUSP, -1) simicsString = gdbProt.Evalx('SendGDBMonitor("@cgc.printRegJson()");') try: regs = json.loads(simicsString) except: print('failed to get regs from %s' % simicsString) return for reg in regs: r = str(reg.upper()) if r == 'EFLAGS': r = 'EFL' elif r == 'CPSR': r = 'PSR' #print('set %s to 0x%x' % (r, regs[reg])) idaversion.set_reg_value(regs[reg], r) idaversion.refresh_debugger_memory() new_eip = idaversion.get_reg_value(self.PC) #print('signalClient back from cont new_eip is 0x%x' % new_eip) if new_eip >= self.kernel_base: print('in kernel, run to user') self.updateStackTrace()
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' )
def RESimClient(): #Wait() ida_dbg.wait_for_next_event(idc.WFNE_ANY, -1) print('back from dbg wait') reg_list = idautils.GetRegisterList() kernel_base = 0xc0000000 info = idaapi.get_inf_structure() if info.is_64bit(): print('64-bit') kernel_base = 0xFFFFFFFF00000000 else: print('32-bit') idc.refresh_lists() idc.auto_wait() bookmark_view = bookmarkView.bookmarkView() stack_trace = stackTrace.StackTrace() data_watch = dataWatch.DataWatch() branch_not_taken = branchNotTaken.BranchNotTaken() write_watch = writeWatch.WriteWatch() #print('back from init bookmarkView') keymap_done = False #primePump() #nameSysCalls(True) #print('back from nameSysCalls') #print('now create bookmark_view') isim = idaSIM.IdaSIM(stack_trace, bookmark_view, data_watch, branch_not_taken, write_watch, kernel_base, reg_list) idaversion.grab_focus('Stack view') bm_title = "Bookmarks" bookmark_view.Create(isim, bm_title) idaversion.grab_focus(bm_title) bookmark_view.register() bookmark_list = bookmark_view.updateBookmarkView() if bookmark_list is not None: for bm in bookmark_list: if 'nox' in bm: eip_str = getTagValue(bm, 'nox') eip = int(eip_str, 16) idc.MakeCode(eip) idaversion.grab_focus(bm_title) st_title = 'stack trace' stack_trace.Create(isim, st_title) idaversion.grab_focus(st_title) stack_trace.register() idaversion.grab_focus(st_title) dw_title = 'data watch' data_watch.Create(isim, dw_title) idaversion.grab_focus(dw_title) data_watch.register() bnt_title = 'BNT' idaversion.grab_focus(dw_title) branch_not_taken.Create(isim, bnt_title) idaversion.grab_focus(bnt_title) branch_not_taken.register() #branch_not_taken.updateList() idaversion.grab_focus(bnt_title) ww_title = 'write watch' write_watch.Create(isim, ww_title) idaversion.grab_focus(ww_title) write_watch.register() reHooks.register(isim) re_hooks = reHooks.Hooks() re_hooks.hook() dbg_hooks = dbgHooks.DBGHooks(isim) dbg_hooks.hook() #form=idaversion.find_widget("IDA View-EIP") #idaversion.activate_widget(form, True) #print('IDA View-EIP form is %s' % str(form)) # MakeCode(eip) ''' run_to_connect_desc = idaapi.action_desc_t( 'run_to_connect:action', # The action name. This acts like an ID and must be unique 'Run to connect', # The action text. RunToConnectHandler()) # The action handler. idaapi.register_action(run_to_connect_desc) idaapi.attach_action_to_menu( 'Debugger/O Run to/', # The relative path of where to add the action 'run_to_connect:action', # The action ID (see above) idaapi.SETMENU_APP) # We want to append the action after the 'Manual instruction...' ''' if not keymap_done: doKeyMap(isim) print('dbg %r' % idaapi.dbg_is_loaded()) isim.showSimicsMessage() idaversion.refresh_debugger_memory() #checkHelp() isim.recordText() isim.showSimicsMessage() if not isim.just_debug: # first origin is sometimes off, call twice. #goToOrigin() pass idaversion.batch(0) #isim.resynch() print('IDA SDK VERSION: %d' % idaapi.IDA_SDK_VERSION) print('RESim Ida Client Version 1.2')
run_to_connect_desc = idaapi.action_desc_t( 'run_to_connect:action', # The action name. This acts like an ID and must be unique 'Run to connect', # The action text. RunToConnectHandler()) # The action handler. idaapi.register_action(run_to_connect_desc) idaapi.attach_action_to_menu( 'Debugger/O Run to/', # The relative path of where to add the action 'run_to_connect:action', # The action ID (see above) idaapi.SETMENU_APP) # We want to append the action after the 'Manual instruction...' ''' if not keymap_done: doKeyMap(isim) print('dbg %r' % idaapi.dbg_is_loaded()) isim.showSimicsMessage() idaversion.refresh_debugger_memory() #checkHelp() isim.recordText() isim.showSimicsMessage() if not isim.just_debug: # first origin is sometimes off, call twice. #goToOrigin() pass idaversion.batch(0) #isim.resynch() print('IDA SDK VERSION: %d' % idaapi.IDA_SDK_VERSION)