def dump_memory(self, file_path=None, ptr=0, length=0): if ptr == 0: ptr, inp = InputDialog.input_pointer(self._app_window) if ptr > 0: if length == 0: accept, length = InputDialog.input(self._app_window, hint='insert length', placeholder='1024') if not accept: return try: if length.startswith('0x'): length = int(length, 16) else: length = int(length) except: return if file_path is None: r = QFileDialog.getSaveFileName( self._app_window, caption='Save binary dump to file') if len(r) == 0 or len(r[0]) == 0: return file_path = r[0] data = self.read_memory(ptr, length) if data is not None: with open(file_path, 'wb') as f: f.write(data)
def _on_cm_search(self): from ui.dialogs.dialog_input import InputDialog accept, input_ = InputDialog.input( self, hint='Search something in this list', placeholder='search...', input_content=self._current_search) if accept and not input_: # reset search self._current_search = '' for row in range(self.model().rowCount()): self.setRowHidden( row, self.model().invisibleRootItem().index(), False) elif accept and input_: # search for input self._current_search = input_ have_result, search_results = self.contains_text( input_, stop_at_match=False) if not have_result: return # hide non matching for row in range(self.model().rowCount()): item = self.model().item(row, 0) hide = True for sr in search_results: if sr[0] == row: hide = False break self.setRowHidden( row, self.model().invisibleRootItem().index(), hide)
def _create_bookmark(self, index=-1, ptr=''): note = '' if ptr == '': if isinstance(index, int) and index >= 0: ptr = self._bookmarks_model.item(index, 0).text() note = self._bookmarks_model.item(index, 1).text() ptr, _ = InputDialog.input_pointer(parent=self._app_window, input_content=ptr) else: if not isinstance(ptr, int): try: if ptr.startswith('0x'): ptr = int(ptr, 16) else: ptr = int(ptr) except ValueError: ptr = 0 if ptr > 0: ptr = hex(ptr) if self._bookmarks_list.uppercase_hex: ptr = ptr.upper().replace('0X', '0x') index = self._bookmarks_model.findItems(ptr, Qt.MatchExactly) if len(index) > 0: index = index[0].row() note = self._bookmarks_model.item(index, 1).text() else: index = -1 accept, note = InputDialog.input(hint='Insert notes for %s' % ptr, input_content=note) if accept: if index < 0: self.insert_bookmark(ptr, note) else: item = self._bookmarks_model.item(index, 0) item.setText(ptr) item = self._bookmarks_model.item(index, 1) item.setText(note) self.bookmarks[ptr] = note
def hook_java(self, input_=None, pending_args=None): if input_ is None or not isinstance(input_, str): accept, input_ = InputDialog.input( self._app_window, hint='insert java class or method', placeholder='com.package.class or com.package.class.method') if not accept: return self.java_pending_args = pending_args input_ = input_.replace(' ', '') self.dwarf_api('hookJava', input_)
def search(self): accept, input = InputDialog.input(self.app, hint='Search', input_content=self.current_class_search, placeholder='Search something...') if accept: self.current_class_search = input.lower() for i in range(0, self.class_list.count()): try: if self.class_list.item(i).text().lower().index(self.current_class_search.lower()) >= 0: self.class_list.setRowHidden(i, False) except: self.class_list.setRowHidden(i, True)
def hook_native(self, input_=None, pending_args=None, own_input=None): if input_ is None or not isinstance(input_, str): ptr, input_ = InputDialog.input_pointer(self._app_window) else: ptr = utils.parse_ptr( self._app_window.dwarf.dwarf_api('evaluatePtr', input_)) if ptr > 0: self.temporary_input = input_ if own_input is not None: self.temporary_input = own_input self.native_pending_args = pending_args self.dwarf_api('hookNative', ptr)
def hook_native_on_load(self, input_=None): if input_ is None or not isinstance(input_, str): accept, input_ = InputDialog.input(self._app_window, hint='insert module name', placeholder='libtarget.so') if not accept: return if len(input_) == 0: return if input_ in self._app_window.dwarf.native_on_loads: return self.dwarf_api('hookNativeOnLoad', input_)
def hook_java_on_load(self, input_=None): if input_ is None or not isinstance(input_, str): accept, input_ = InputDialog.input( self._app_window, hint='insert class name', placeholder='com.android.mytargetclass') if not accept: return if len(input_) == 0: return if input_ in self._app_window.dwarf.native_on_loads: return self.dwarf_api('hookJavaOnLoad', input_)
def _on_modify_condition(self, num_row): item = self._hooks_model.item(num_row, 4) data = item.data(Qt.UserRole + 2) if data is None: data = '' ptr = self._hooks_model.item(num_row, 0).text() accept, input_ = InputDialog().input( self._app_window, 'Insert condition for %s' % ptr, input_content=data) if accept: what = utils.parse_ptr(ptr) if what == 0: what = self._hooks_model.item(num_row, 2).data(Qt.UserRole + 2) if self._app_window.dwarf.dwarf_api('setHookCondition', [what, input_]): item.setData(input_, Qt.UserRole + 2) if not item.text(): item.setText('ƒ') item.setToolTip(input_) self.onHookChanged.emit(ptr)
def add_watcher(self, ptr=None): if ptr is None: ptr, input = InputDialog.input_pointer(self._app_window) if ptr == 0: return return self.dwarf_api('addWatcher', ptr)
def on_cm_jump_to_address(self, view=DEBUG_VIEW_MEMORY): ptr, _ = InputDialog.input_pointer(self.app) if ptr > 0: self.jump_to_address(ptr, view=view)