def bytes2value(self, typename, databytes): if databytes is None: return None if typename in TYPENAMES_G2STRUCT: return struct.unpack(TYPENAMES_G2STRUCT[typename], databytes)[0] elif typename == 'string': return str(u(databytes)) elif typename == 'bytearray': databytes = u(databytes) return ' '.join(['%02x'%ord(i) for i in databytes]) else: return databytes
def bytes2value(self, typename, databytes): if databytes is None: return None if typename in TYPENAMES_G2STRUCT: return struct.unpack(TYPENAMES_G2STRUCT[typename], databytes)[0] elif typename == 'string': return str(u(databytes)) elif typename == 'bytearray': databytes = u(databytes) return ' '.join(['%02x' % ord(i) for i in databytes]) else: return databytes
def update_scan_result(self): match_count = self.backend.get_match_count() self.found_count_label.set_text(_('Found: %d') % (match_count, )) if (match_count > SCAN_RESULT_LIST_LIMIT): self.scanresult_liststore.clear() else: self.command_lock.acquire() lines = self.backend.send_command('list', get_output=True) self.command_lock.release() self.scanresult_tv.set_model(None) # temporarily disable model for scanresult_liststore for the sake of performance self.scanresult_liststore.clear() for line in lines: line = str(u(line)) (mid, line) = line.split(']', 1) mid = int(mid.strip(' []')) (addr, off, rt, val, t) = list(map(str.strip, line.split(',')[:5])) addr = int(addr, 16) off = int(off.split('+')[1], 16) t = t.strip(' []') if t == 'unknown': continue self.scanresult_liststore.append( [addr, val, t, True, off, rt, mid]) self.scanresult_tv.set_model(self.scanresult_liststore)
def browse_memory(self, addr=None): # select a region contains addr try: self.read_maps() except: self.show_error( _('Cannot retieve memory maps of that process, maybe it has exited (crashed), or you don\'t have enough privilege' )) return selected_region = None if addr: for m in self.maps: if m['start_addr'] <= addr and addr < m['end_addr']: selected_region = m break if selected_region: if selected_region['flags'][0] != 'r': # not readable self.show_error(_('Address %x is not readable') % (addr, )) return else: self.show_error(_('Address %x is not valid') % (addr, )) return else: # just select the first readable region for m in self.maps: if m['flags'][0] == 'r': selected_region = m break if selected_region is None: self.show_error(_('Cannot find a readable region')) return addr = selected_region['start_addr'] # read region if necessary start_addr = max(addr - 1024, selected_region['start_addr']) end_addr = min(addr + 1024, selected_region['end_addr']) if self.last_hexedit_address[0] != start_addr or \ self.last_hexedit_address[1] != end_addr: data = self.read_memory(start_addr, end_addr - start_addr) if data is None: self.show_error(_('Cannot read memory')) return self.last_hexedit_address = (start_addr, end_addr) self.memoryeditor_hexview.payload = u(data) self.memoryeditor_hexview.base_addr = start_addr # set editable flag self.memoryeditor_hexview.editable = ( selected_region['flags'][1] == 'w') if addr: self.memoryeditor_hexview.show_addr(addr) self.memoryeditor_window.show()
def browse_memory(self, addr=None): # select a region contains addr try: self.read_maps() except: self.show_error(_('Cannot retrieve memory maps of that process, maybe it has ' 'exited (crashed), or you don\'t have enough privileges')) return selected_region = None if addr: for m in self.maps: if m['start_addr'] <= addr and addr < m['end_addr']: selected_region = m break if selected_region: if selected_region['flags'][0] != 'r': # not readable self.show_error(_('Address %x is not readable') % (addr,)) return else: self.show_error(_('Address %x is not valid') % (addr,)) return else: # just select the first readable region for m in self.maps: if m['flags'][0] == 'r': selected_region = m break if selected_region is None: self.show_error(_('Cannot find a readable region')) return addr = selected_region['start_addr'] # read region if necessary start_addr = max(addr - 1024, selected_region['start_addr']) end_addr = min(addr + 1024, selected_region['end_addr']) if self.last_hexedit_address[0] != start_addr or \ self.last_hexedit_address[1] != end_addr: data = self.read_memory(start_addr, end_addr - start_addr) if data is None: self.show_error(_('Cannot read memory')) return self.last_hexedit_address = (start_addr, end_addr) self.memoryeditor_hexview.payload = u(data) self.memoryeditor_hexview.base_addr = start_addr # set editable flag self.memoryeditor_hexview.editable = (selected_region['flags'][1] == 'w') if addr: self.memoryeditor_hexview.show_addr(addr) self.memoryeditor_window.show()
def update_scan_result(self): match_count = self.backend.get_match_count() self.found_count_label.set_text(_('Found: %d') % (match_count, )) if (match_count > SCAN_RESULT_LIST_LIMIT): self.scanresult_liststore.clear() else: self.command_lock.acquire() lines = self.backend.send_command('list', get_output=True) self.command_lock.release() self.scanresult_tv.set_model(None) # temporarily disable model for scanresult_liststore for the sake of performance self.scanresult_liststore.clear() for line in lines: line = str(u(line)) line = line[line.find(']') + 1:] (a, o, rt, v, t) = list(map(str.strip, line.split(',')[:5])) a = '%x' % (int(a, 16), ) o = '%x' % (int(o.split('+')[1], 16), ) t = t[1:-1] if t == 'unknown': continue self.scanresult_liststore.append([a, v, t, True, o, rt]) self.scanresult_tv.set_model(self.scanresult_liststore)
def update_scan_result(self): match_count = self.backend.get_match_count() self.found_count_label.set_text(_('Found: %d') % (match_count,)) if (match_count > SCAN_RESULT_LIST_LIMIT): self.scanresult_liststore.clear() else: self.command_lock.acquire() lines = self.backend.send_command('list', get_output = True) self.command_lock.release() self.scanresult_tv.set_model(None) # temporarily disable model for scanresult_liststore for the sake of performance self.scanresult_liststore.clear() for line in lines: line = str(u(line)) line = line[line.find(']')+1:] (a, o, rt, v, t) = list(map(str.strip, line.split(',')[:5])) a = '%x'%(int(a,16),) o = '%x'%(int(o.split('+')[1],16),) t = t[1:-1] if t == 'unknown': continue self.scanresult_liststore.append([a, v, t, True, o, rt]) self.scanresult_tv.set_model(self.scanresult_liststore)
def get_version(self): return u(self.lib.get_version())