Пример #1
0
 def build_modules_list(self, list, modules):
     list.setMinimumWidth(int(self.app_window.get_app_instance().width() / 3))
     for m in sorted(modules, key=lambda x: x['name']):
         q = NotEditableListWidgetItem('%s (%s)' % (m['name'], str(m['base'])))
         q.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
         q.setCheckState(Qt.Checked)
         q.set_data(m)
         list.addItem(q)
Пример #2
0
    def on_enumeration_match(self, java_class):
        try:
            if PREFIXED_CLASS.index(java_class) >= 0:
                try:
                    if self.trace_classes.index(java_class) >= 0:
                        return
                except:
                    pass
                q = NotEditableListWidgetItem(java_class)
                self.trace_list.addItem(q)
                self.trace_classes.append(java_class)
        except:
            pass

        q = NotEditableListWidgetItem(java_class)
        self.class_list.addItem(q)
Пример #3
0
    def log(self, what, clear=False):
        if clear:
            self.clear()

        if isinstance(what, QListWidgetItem):
            self.list.addItem(what)
        else:
            self.list.addItem(NotEditableListWidgetItem(what))
Пример #4
0
    def update_dwarf(self, item):
        self.commit_list.clear()
        q = NotEditableListWidgetItem('Updating dwarf...')
        q.setFlags(Qt.NoItemFlags)
        self.commit_list.addItem(q)

        utils.do_shell_command('git fetch -q https://github.com/iGio90/Dwarf.git', stdout=subprocess.DEVNULL)
        utils.do_shell_command('git checkout -f -q master', stdout=subprocess.DEVNULL)
        utils.do_shell_command('git reset --hard FETCH_HEAD', stdout=subprocess.DEVNULL)
        sha = utils.do_shell_command('git log -1 master --pretty=format:%H')

        print('')
        print('')
        print('Dwarf updated to commit := ' + sha)
        print('')
        print('')

        sys.exit(0)
Пример #5
0
 def class_list_double_click(self, item):
     try:
         if self.trace_classes.index(item.text()) >= 0:
             return
     except:
         pass
     self.trace_classes.append(item.text())
     q = NotEditableListWidgetItem(item.text())
     self.trace_list.addItem(q)
     self.trace_list.sortItems()
Пример #6
0
    def add_to_main_content_content(self, what, clear=False, scroll=False):
        if clear:
            self.list.clear()

        if isinstance(what, QListWidgetItem):
            self.list.addItem(what)
        else:
            item = NotEditableListWidgetItem(what)
            self.list.addItem(item)

        if scroll:
            self.list.scrollToBottom()
Пример #7
0
 def update_spawn_list(self, device):
     self.spawn_list.clear()
     try:
         apps = device.enumerate_applications()
     except:
         return
     last_letter = ''
     for app in sorted(apps, key=lambda x: x.name):
         app_name = app.name
         l = app.name[0].upper()
         if last_letter != l:
             if last_letter != '':
                 q = NotEditableListWidgetItem('')
                 q.setFlags(Qt.NoItemFlags)
                 self.spawn_list.addItem(q)
             last_letter = l
             q = NotEditableListWidgetItem(last_letter)
             q.setFlags(Qt.NoItemFlags)
             self.spawn_list.addItem(q)
         q = AndroidPackageWidget(app_name, app.identifier, 0)
         self.spawn_list.addItem(q)
Пример #8
0
    def run(self):

        self.clear_spawns.emit()

        if self.device is not None:
            try:
                apps = self.device.enumerate_applications()

                last_letter = ''

                for app in sorted(apps, key=lambda x: x.name):
                    app_name = app.name
                    letter = app.name[0].upper()

                    if last_letter != letter:
                        if last_letter != '':
                            item = NotEditableListWidgetItem('')
                            item.setFlags(Qt.NoItemFlags)
                            self.add_spawn.emit(item)

                        last_letter = letter
                        item = NotEditableListWidgetItem(last_letter)
                        item.setFlags(Qt.NoItemFlags)
                        self.add_spawn.emit(item)

                    item = AndroidPackageWidget(app_name, app.identifier, 0)
                    self.add_spawn.emit(item)
            except frida.ServerNotRunningError:
                self.is_error.emit('unable to connect to remote frida server: not started')
            except frida.TransportError:
                self.is_error.emit('unable to connect to remote frida server: closed')
            except frida.TimedOutError:
                self.is_error.emit('unable to connect to remote frida server: timedout')
            except Exception:
                self.is_error.emit('something was wrong...')

        self.device = None
Пример #9
0
    def on_event(self, event, clazz, data):
        if event == 'leave':
            indicator = '<------'
            if self.trace_depth > 0:
                self.trace_depth -= 1
        else:
            indicator = '------>'

        if self.trace_depth == 0 and self.events_list.count(
        ) > 0 and event == 'enter':
            q = NotEditableListWidgetItem('')
            q.setFlags(Qt.NoItemFlags)
            self.events_list.addItem(q)

        q = NotEditableListWidgetItem(
            '%s%s\t%s\t\t%s' %
            (' ' * (4 * self.trace_depth), indicator, clazz, data))
        self.events_list.addItem(q)

        if event == 'enter':
            self.trace_depth += 1
Пример #10
0
 def on_dwarf_commit(self, com_text, color=False):
     q = NotEditableListWidgetItem(com_text)
     q.setFlags(Qt.NoItemFlags)
     if color:
         q.setForeground(QColor('#ef5350'))
     self.commit_list.addItem(q)
Пример #11
0
 def append(self, data):
     data = data.replace('\n', '')
     self.list.addItem(NotEditableListWidgetItem(data))
Пример #12
0
    def setup_options_view(self):
        self.options.setOrientation(Qt.Horizontal)

        filter_functions_layout = QVBoxLayout()
        filter_functions_layout.addWidget(QLabel("Filter functions"))

        bar = QScrollBar()
        bar.setFixedHeight(0)
        bar.setFixedWidth(0)

        self.filter_functions.setHorizontalScrollBar(bar)
        self.filter_functions.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.filter_functions.setPlainText(self.ftrace.get_current_filters())
        self.filter_functions.setPlaceholderText("*SyS_open*")
        filter_functions_layout.addWidget(self.filter_functions)

        filter_events_layout = QVBoxLayout()
        filter_events_layout.addWidget(QLabel("Filter events"))

        bar = QScrollBar()
        bar.setFixedHeight(0)
        bar.setFixedWidth(0)

        self.filter_events.setHorizontalScrollBar(bar)
        self.filter_events.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.filter_events.setPlainText(self.ftrace.get_current_events())
        self.filter_events.setPlaceholderText(
            'raw_syscalls:sys_exit\nraw_syscalls:sys_enter')
        filter_events_layout.addWidget(self.filter_events)

        filter_functions_widget = QWidget()
        filter_functions_widget.setLayout(filter_functions_layout)
        filter_events_widget = QWidget()
        filter_events_widget.setLayout(filter_events_layout)

        options_list_layout = QVBoxLayout()
        options_list_layout.addWidget(QLabel("Options"))

        for option in self.ftrace.get_options():
            if len(option) < 1:
                continue

            q = NotEditableListWidgetItem()
            q.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)

            if not option.startswith('no'):
                q.setCheckState(Qt.Checked)
                q.setText(option)
            else:
                q.setCheckState(Qt.Unchecked)
                q.setText(option[2:])
            self.options_list.addItem(q)

        options_list_layout.addWidget(self.options_list)

        options_list_widget = QWidget()
        options_list_widget.setLayout(options_list_layout)

        self.options.addWidget(filter_functions_widget)
        self.options.addWidget(filter_events_widget)
        self.options.addWidget(options_list_widget)
Пример #13
0
    def update_commits(self):
        data = self.app.get_dwarf().get_git().get_dwarf_commits()
        if data is None:
            q = NotEditableListWidgetItem('Failed to fetch commit list. Try later.')
            q.setFlags(Qt.NoItemFlags)
            self.commit_list.addItem(q)
            return

        most_recent_remote_commit = ''
        most_recent_local_commit = utils.do_shell_command('git log -1 master --pretty=format:%H')
        most_recent_date = ''
        for commit in data:
            if most_recent_remote_commit == '':
                most_recent_remote_commit = commit['sha']
                if most_recent_remote_commit != most_recent_local_commit:
                    self.dwarf_update_button.setVisible(True)

                    q = NotEditableListWidgetItem('')
                    q.setFlags(Qt.NoItemFlags)
                    self.commit_list.addItem(q)
            commit = commit['commit']
            date = commit['committer']['date'].split('T')
            if most_recent_date != date[0]:
                if most_recent_date != '':
                    q = NotEditableListWidgetItem('')
                    q.setFlags(Qt.NoItemFlags)
                    self.commit_list.addItem(q)
                q = NotEditableListWidgetItem(date[0])
                q.setFlags(Qt.NoItemFlags)
                self.commit_list.addItem(q)
                most_recent_date = date[0]

            q = NotEditableListWidgetItem('%s - %s (%s)' % (date[1][:-1], commit['message'],
                                                            commit['author']['name']))
            q.setFlags(Qt.NoItemFlags)
            q.setForeground(Qt.white)
            self.commit_list.addItem(q)
Пример #14
0
    def update_commits(self):
        r = None
        try:
            r = requests.get('https://api.github.com/repos/iGio90/dwarf/commits')
        except:
            pass
        if r is None or r.status_code != 200:
            q = NotEditableListWidgetItem('Failed to fetch commit list. Try later.')
            q.setFlags(Qt.NoItemFlags)
            self.commit_list.addItem(q)
            return

        most_recent_remote_commit = ''
        most_recent_local_commit = utils.do_shell_command('git log -1 master --pretty=format:%H')
        most_recent_date = ''
        for commit in r.json():
            if most_recent_remote_commit == '':
                most_recent_remote_commit = commit['sha']
                if most_recent_remote_commit != most_recent_local_commit:
                    self.dwarf_update_button.setVisible(True)

                    q = NotEditableListWidgetItem('')
                    q.setFlags(Qt.NoItemFlags)
                    self.commit_list.addItem(q)
            commit = commit['commit']
            date = commit['committer']['date'].split('T')
            if most_recent_date != date[0]:
                if most_recent_date != '':
                    q = NotEditableListWidgetItem('')
                    q.setFlags(Qt.NoItemFlags)
                    self.commit_list.addItem(q)
                q = NotEditableListWidgetItem(date[0])
                q.setFlags(Qt.NoItemFlags)
                self.commit_list.addItem(q)
                most_recent_date = date[0]

            q = NotEditableListWidgetItem('%s - %s (%s)' % (date[1][:-1], commit['message'],
                                                            commit['author']['name']))
            q.setFlags(Qt.NoItemFlags)
            q.setForeground(Qt.white)
            self.commit_list.addItem(q)
Пример #15
0
 def on_emulator_memory_range_mapped(self, address, size):
     q = NotEditableListWidgetItem(hex(address))
     q.setForeground(Qt.red)
     self.ranges_list.addItem(q)
     self.ranges_list.sortItems()
Пример #16
0
 def append_data(self, key, text_data):
     if key not in self.data:
         self.key_lists.addItem(NotEditableListWidgetItem(key))
     self.data[key] = text_data
Пример #17
0
 def on_dwarf_status(self, text):
     q = NotEditableListWidgetItem(text)
     q.setFlags(Qt.NoItemFlags)
     self.commit_list.addItem(q)