def _bbTableDoubleClicked(self, row, col): """ This overrides the callback for table's double click set in the CustomWidget object. Apparently if there is an exception it falls back to the original callback... Not sure why this behaviour. NOTE: This is kind of nasty. :return: None """ it = self.table.item(row, col).text() try: idx = int(it) # decimal bb_path = self.ba.cache.bb_paths[idx] col = QtGui.QColorDialog.getColor() if col.isValid(): # IDA works with BGR (annoying) ida_color = misc.pyside_to_ida_color(col.name()) misc.paint_basic_blocks(bb_path, ida_color) else: print '[x] Invalid QColor' return except IndexError: # Address value (does not contain [A-F]) is interpreted as index return except ValueError: # Address value (containing [A-F]) f***s up int() return
def _showImportTrace(self, restrict=True): """ This is the GUI part of the PIN trace import functionality """ self._console_output("Importing PIN trace information from file...") # Color for the basic blocks hit during the trace col = QtGui.QColorDialog.getColor() if col.isValid(): # IDA works with BGR (annoying) ida_color = misc.pyside_to_ida_color(col.name()) else: # Probably closed the QColorDialog self._console_output( "[!] Problem getting color for trace. Aborting.") return try: imported_info_dict = self.ie.ti.import_data(ida_color) except: self._console_output("[!] Problem importing from file", err=True) self._console_output(traceback.format_exc(), err=True) return self.table.setColumnCount(5) self.table.setHorizontalHeaderLabels( ('Thread ID', 'From', 'To', 'From (name)', 'To (name)')) self.table_label.setText("Imported information from PIN trace") self.table.clearContents() self.table.setRowCount(0) # Fill with contents # TODO: This could be better in a QTree or maybe adding # a dropdown to select the thread id... idx = 0 for tid, call_list in imported_info_dict.iteritems(): self._console_output("Processing Thread ID %d" % tid) for u_ea, v_ea in call_list: self.table.insertRow(idx) tid_item = QTableWidgetItem("%d" % tid) u_item = QTableWidgetItem("%x" % u_ea) u_item.setFlags(u_item.flags() ^ QtCore.Qt.ItemIsEditable) v_item = QTableWidgetItem("%x" % v_ea) v_item.setFlags(v_item.flags() ^ QtCore.Qt.ItemIsEditable) from_item = QTableWidgetItem(misc.get_function_name(u_ea)) to_item = QTableWidgetItem(misc.get_function_name(v_ea)) self.table.setItem(idx, 0, tid_item) self.table.setItem(idx, 1, u_item) self.table.setItem(idx, 2, v_item) self.table.setItem(idx, 3, from_item) self.table.setItem(idx, 4, to_item) idx += 1
def _showImportTrace(self): """ This is the GUI part of the PIN trace import functionality """ self._console_output("Importing PIN trace information from file...") # Color for the basic blocks hit during the trace col = QtGui.QColorDialog.getColor() if col.isValid(): # IDA works with BGR (annoying) ida_color = misc.pyside_to_ida_color(col.name()) else: # Probably closed the QColorDialog self._console_output("[!] Problem getting color for trace. Aborting.") return try: imported_info_dict = self.ie.ti.import_data(ida_color) except: self._console_output("[!] Problem importing from file", err = True) self._console_output(traceback.format_exc(), err = True) return self.table.setColumnCount(5) self.table.setHorizontalHeaderLabels( ('Thread ID', 'From', 'To', 'From (name)', 'To (name)')) self.table_label.setText("Imported information from PIN trace") self.table.clearContents() self.table.setRowCount(0) # Fill with contents # TODO: This could be better in a QTree or maybe adding # a dropdown to select the thread id... idx = 0 for tid, call_list in imported_info_dict.iteritems(): self._console_output("Processing Thread ID %d" % tid) for u_ea, v_ea in call_list: self.table.insertRow(idx) tid_item = QTableWidgetItem("%d" % tid) u_item = QTableWidgetItem("%x" % u_ea) u_item.setFlags(u_item.flags() ^ QtCore.Qt.ItemIsEditable) v_item = QTableWidgetItem("%x" % v_ea) v_item.setFlags(v_item.flags() ^ QtCore.Qt.ItemIsEditable) from_item = QTableWidgetItem(misc.get_function_name(u_ea)) to_item = QTableWidgetItem(misc.get_function_name(v_ea)) self.table.setItem(idx, 0, tid_item) self.table.setItem(idx, 1, u_item) self.table.setItem(idx, 2, v_item) self.table.setItem(idx, 3, from_item) self.table.setItem(idx, 4, to_item) idx += 1