Esempio n. 1
0
 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 and len(data) > 1:
             with open(file_path, 'wb') as f:
                 f.write(data[1])
Esempio n. 2
0
 def breakpoint_native(self, 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.dwarf_api('putBreakpoint', ptr)
Esempio n. 3
0
 def breakpoint_objc(self, input_=None, pending_args=None):
     if input_ is None or not isinstance(input_, str):
         accept, input_ = InputDialog.input(
             self._app_window, hint='insert obj class or method',
             placeholder='com.package.class or com.package.class.method') #todo
         if not accept:
             return
     self.objc_pending_args = pending_args
     self.dwarf_api('putBreakpoint', input_)
Esempio n. 4
0
    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
Esempio n. 5
0
 def breakpoint_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('putBreakpoint', input_)
Esempio n. 6
0
    def breakpoint_module_initialization(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.module_initialization_breakpoints:
            return

        self.dwarf_api('putModuleInitializationBreakpoint', input_)
Esempio n. 7
0
 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)
Esempio n. 8
0
File: core.py Progetto: Ghxst/Dwarf
 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)
Esempio n. 9
0
    def breakpoint_java_class_initialization(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.java_class_initialization_breakpoints:
            return

        self.dwarf_api('putJavaClassInitializationBreakpoint', input_)
Esempio n. 10
0
File: core.py Progetto: Ghxst/Dwarf
    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_)
Esempio n. 11
0
 def handle_start(self):
     ph = ''
     if self.until_address > 0:
         ph = hex(self.until_address)
     address, inp = InputDialog.input_pointer(
         self.app, input_content=ph, hint='pointer to last instruction')
     if address > 0:
         self.until_address = address
         self.app.console_panel.show_console_tab('emulator')
         self.emulator.emulate(self.until_address,
                               user_arch=self._uc_user_arch,
                               user_mode=self._uc_user_mode,
                               cs_arch=self._cs_user_arch,
                               cs_mode=self._cs_user_mode)
Esempio n. 12
0
File: core.py Progetto: Ghxst/Dwarf
    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_)
Esempio n. 13
0
 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)
Esempio n. 14
0
    def _on_cm_search(self):
        from dwarf.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)
Esempio n. 15
0
 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)
Esempio n. 16
0
 def add_watchpoint(self, ptr=None):
     if ptr is None:
         ptr, input = InputDialog.input_pointer(self._app_window)
         if ptr == 0:
             return
     return self.dwarf_api('addWatchpoint', ptr)