Exemplo n.º 1
0
class AutoREView(idaapi.PluginForm):
    ADDR_ROLE = QtCore.Qt.UserRole + 1

    def __init__(self, data):
        super(AutoREView, self).__init__()
        self._data = data

    def Show(self):
        return idaapi.PluginForm.Show(self, 'AutoRE', options=idaapi.PluginForm.FORM_PERSIST)

    def OnCreate(self, form):
        # if HAS_PYSIDE:
        #     self.parent = self.FormToPySideWidget(form)
        # else:
        self.parent = self.FormToPyQtWidget(form)

        self.tv = QTreeView()
        self.tv.setExpandsOnDoubleClick(False)

        root_layout = QVBoxLayout(self.parent)
        # self.le_filter = QLineEdit(self.parent)

        # root_layout.addWidget(self.le_filter)
        root_layout.addWidget(self.tv)

        self.parent.setLayout(root_layout)

        self._model = QtGui.QStandardItemModel()
        self._init_model()
        self.tv.setModel(self._model)

        self.tv.setColumnWidth(0, 200)
        self.tv.setColumnWidth(1, 300)
        self.tv.header().setStretchLastSection(True)

        self.tv.expandAll()

        self.tv.doubleClicked.connect(self.on_navigate_to_method_requested)
        # self.le_filter.textChanged.connect(self.on_filter_text_changed)

    def OnClose(self, form):
        # print 'TODO: OnClose(): clear the pointer to form in the plugin'
        pass

    def _tv_init_header(self, model):
        item_header = QtGui.QStandardItem("EA")
        item_header.setToolTip("Address")
        model.setHorizontalHeaderItem(0, item_header)

        item_header = QtGui.QStandardItem("Function name")
        model.setHorizontalHeaderItem(1, item_header)

        item_header = QtGui.QStandardItem("API called")
        model.setHorizontalHeaderItem(2, item_header)

    def _tv_make_tag_item(self, name):
        rv = QtGui.QStandardItem(name)

        rv.setEditable(False)
        return [rv, QtGui.QStandardItem(), QtGui.QStandardItem()]

    def _tv_make_ref_item(self, tag, ref):
        ea_item = QtGui.QStandardItem(('%0' + get_addr_width() + 'X') % ref['ea'])
        ea_item.setEditable(False)
        ea_item.setData(ref['ea'], self.ADDR_ROLE)

        name_item = QtGui.QStandardItem(ref['name'])
        name_item.setEditable(False)
        name_item.setData(ref['ea'], self.ADDR_ROLE)

        apis = ', '.join(ref['tags'][tag])
        api_name = QtGui.QStandardItem(apis)
        api_name.setEditable(False)
        api_name.setData(ref['ea'], self.ADDR_ROLE)
        api_name.setToolTip(apis)

        return [ea_item, name_item, api_name]

    def _init_model(self):
        self._model.clear()

        root_node = self._model.invisibleRootItem()
        self._tv_init_header(self._model)

        for tag, refs in self._data.items():
            item_tag_list = self._tv_make_tag_item(tag)
            item_tag = item_tag_list[0]

            root_node.appendRow(item_tag_list)

            for ref in refs:
                ref_item_list = self._tv_make_ref_item(tag, ref)

                item_tag.appendRow(ref_item_list)

    def on_navigate_to_method_requested(self, index):
        addr = index.data(role=self.ADDR_ROLE)
        if addr is not None:
            idaapi.jumpto(addr)
Exemplo n.º 2
0
class Ui_MainWindow(object):
    def setupUi(self, MainWindow, model):
        # self.initDirectory(DEFAULT_DIR_PATH)
        MainWindow.setObjectName("MainWindow")
        MainWindow.setWindowTitle("Exploit")

        self.centralWidget = QtWidgets.QWidget(MainWindow)
        self.centralWidget.setObjectName("centralWidget")

        self.hLayout = QtWidgets.QHBoxLayout(self.centralWidget)
        self.hLayout.setContentsMargins(11, 11, 11, 11)
        self.hLayout.setObjectName("hLayout")

        self.comboBox_Devices = QtWidgets.QComboBox()
        self.comboBox_Devices.setStyleSheet(
            "max-width:250;\n"
            "selection-color: rgb(11, 181, 255);\n"
            "selection-background-color: rgb(255, 255, 255);")
        self.comboBox_Devices.setObjectName("comboBox_Devices")
        devices = next(os.walk(DEFAULT_DIR_PATH))[1]

        self.comboBox_Devices.addItem("Devices")
        for device in devices:
            self.comboBox_Devices.addItem(device)

        self.comboBox_Devices.activated[str].connect(self.setTreeviewItem)
        self.listLabel = QtWidgets.QLabel("DEVICES")
        self.dialog = QDialog()
        self.layout = QVBoxLayout(self.dialog)

        self.treeView = QTreeView(self.dialog)
        # QTreeView use QStandardItemModel as data source
        self.treeView.setModel(model)
        # model.setRootPath(DEFAULT_DIR_PATH)
        # self.treeView.setRootIndex(model.index(DEFAULT_DIR_PATH))
        self.treeView.setHeaderHidden(True)
        self.treeView.hideColumn(1)
        self.treeView.hideColumn(2)
        self.treeView.hideColumn(3)
        self.treeView.setExpandsOnDoubleClick(True)
        # self.treeView.doubleClicked.connect(self.printUrl)
        self.layout.addWidget(self.treeView)

        self.listLabel1 = QtWidgets.QLabel("DATA")
        self.listLabel1.setStyleSheet("font: 14pt \"Sans Serif\";")
        self.listLabel1.setAlignment(QtCore.Qt.AlignCenter)

        self.details_dialog = QDialog()
        self.layout_details = QVBoxLayout(self.details_dialog)

        self.treeView_Details = QTreeView(self.details_dialog)
        # QTreeView use QStandardItemModel as data source

        # self.details_model = QFileSystemModel()
        # self.details_model.setRootPath(DEFAULT_DIR_PATH)
        # self.treeView_Details.setModel( self.details_model)
        # self.treeView_Details.setRootIndex(self.details_model.index(DEFAULT_DIR_PATH))
        self.layout_details.addWidget(self.treeView_Details)
        # self.tableView = QTableView()
        # self.tableView.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
        # self.tableView.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
        # self.tableView.verticalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Fixed)
        # self.tableView.verticalHeader().setDefaultSectionSize(80)
        # self.tableView.horizontalHeader().setDefaultAlignment(Qt.AlignLeft)

        splitter_label = QtWidgets.QSplitter(Qt.Horizontal)
        splitter_label.addWidget(self.comboBox_Devices)
        splitter_label.addWidget(self.listLabel1)
        splitter_label.setSizes([30, 157])

        splitter_data = QtWidgets.QSplitter(Qt.Horizontal)
        splitter_data.addWidget(self.treeView)
        splitter_data.addWidget(self.treeView_Details)
        splitter_data.setSizes([30, 157])

        splitter_all = QtWidgets.QSplitter(Qt.Vertical)
        splitter_all.addWidget(splitter_label)
        splitter_all.addWidget(splitter_data)
        splitter_all.setSizes([1, 500])

        self.hLayout.addWidget(splitter_all)

        MainWindow.setCentralWidget(self.centralWidget)

    def initDirectory(self, path):
        new_item = self.newItem(path)
        self.readDirectory(path, new_item)
        model.appendRow(new_item)

    def readDirectory(self, path, parent_item):
        directory = os.listdir(path)
        for file_name in directory:
            self.file_path = path + '/' + file_name
            new_item = self.newItem(self.file_path)
            parent_item.appendRow(new_item)
            if os.path.isdir(self.file_path):
                self.readDirectory(self.file_path, new_item)

    def newItem(self, path):
        title = os.path.basename(path)
        item = QStandardItem()
        if os.path.isdir(path):
            icon_path = DIR_ICON_PATH
        else:
            if path.endswith('PNG') or path.endswith('png') or path.endswith(
                    'JPG') or path.endswith('jpg') or path.endswith(
                        'JPEG') or path.endswith('jpeg') or path.endswith(
                            'GIF') or path.endswith('gif'):
                icon_path = IMAGE_ICON_PATH
            elif path.endswith('.mp4'):
                icon_path = VIDEO_ICON_PATH
            else:
                icon_path = FILE_ICON_PATH
        icon = QIcon(icon_path)
        item.setText(title)
        item.setIcon(icon)
        return item

    def setTreeviewItem(self, device):
        if device != "Devices":
            self.initDirectory(DEFAULT_DIR_PATH + "/" + device + "/")
        else:
            pass

    def printUrl(self, signal):
        file_path = model.filePath(signal)
        if "Toshiba Laptop" in file_path:
            print(file_path.replace("/home/.exploits/Toshiba Laptop", ""))
        else:
            print(file_path.replace("/home/.exploits/Hp Desktop", ""))
Exemplo n.º 3
0
class YuToolsNoteViewer(QWidget):

    def __init__(self):
        super(YuToolsNoteViewer, self).__init__()

        self.tv_notes = QTreeView(self)
        self.tv_notes.setGeometry(10, 40, 311, 630)
        self.tv_notes.setExpandsOnDoubleClick(False)
        self.tv_notes.clicked.connect(self.click_tv_item)
        self.tv_notes.doubleClicked.connect(self.doubleclick_tv_item)

        self.te_note = QTextEdit(self)
        font_default = QFont()
        font_default.setPointSize(12)
        self.te_note.setFont(font_default)
        self.te_note.setGeometry(330, 40, 451, 630)

        self.btn_add_root = QPushButton(self)
        self.btn_add_root.setText('Add Root')
        self.btn_add_root.setGeometry(10, 10, 75, 23)
        self.btn_add_root.clicked.connect(self.btn_click)

        self.btn_add_sub = QPushButton(self)
        self.btn_add_sub.setText('Add Sub')
        self.btn_add_sub.setDisabled(True)
        self.btn_add_sub.setGeometry(100, 10, 75, 23)
        self.btn_add_sub.clicked.connect(self.btn_click)

        self.btn_add_note = QPushButton(self)
        self.btn_add_note.setText('Add Note')
        self.btn_add_note.setDisabled(True)
        self.btn_add_note.setGeometry(190, 10, 75, 23)
        self.btn_add_note.clicked.connect(self.btn_click)

        self.rb_fonts_small = QRadioButton(self)
        self.rb_fonts_small.setText('Small')
        self.rb_fonts_small.setGeometry(350, 10, 60, 23)
        self.rb_fonts_small.clicked.connect(self.change_font_size)
        self.rb_fonts_normal = QRadioButton(self)
        self.rb_fonts_normal.setText('Normal')
        self.rb_fonts_normal.setGeometry(420, 10, 60, 23)
        self.rb_fonts_normal.clicked.connect(self.change_font_size)
        self.rb_fonts_normal.setChecked(True)
        self.rb_fonts_big = QRadioButton(self)
        self.rb_fonts_big.setText('Big')
        self.rb_fonts_big.setGeometry(490, 10, 60, 23)
        self.rb_fonts_big.clicked.connect(self.change_font_size)
        self.rb_fonts_bigger = QRadioButton(self)
        self.rb_fonts_bigger.setText('Bigger')
        self.rb_fonts_bigger.setGeometry(560, 10, 60, 23)
        self.rb_fonts_bigger.clicked.connect(self.change_font_size)
        self.rb_fonts_biggest = QRadioButton(self)
        self.rb_fonts_biggest.setText('Biggest')
        self.rb_fonts_biggest.setGeometry(630, 10, 60, 23)
        self.rb_fonts_biggest.clicked.connect(self.change_font_size)

        self.btn_save_note = QPushButton(self)
        self.btn_save_note.setText('Save')
        self.btn_save_note.setDisabled(True)
        self.btn_save_note.setGeometry(710, 10, 75, 23)
        self.btn_save_note.clicked.connect(self.btn_click)

        self.select_path = None

        self.init_tree()

    def init_tree(self):
        model = QFileSystemModel()
        path = os.path.dirname(os.path.realpath(__file__)) + os.path.sep + 'notes'
        model.setRootPath(path)
        self.tv_notes.setModel(model)
        self.tv_notes.setRootIndex(model.index(path))
        self.tv_notes.setHeaderHidden(True)
        self.tv_notes.resizeColumnToContents(0)
        self.tv_notes.setColumnHidden(1, True)
        self.tv_notes.setColumnHidden(2, True)
        self.tv_notes.setColumnHidden(3, True)

    def click_tv_item(self, index):
        is_dir = index.model().isDir(index)
        self.select_path = index.model().filePath(index)
        if is_dir:
            self.btn_add_sub.setDisabled(False)
            self.btn_add_note.setDisabled(False)
            self.btn_save_note.setDisabled(True)
            self.te_note.clear()
            self.te_note.setDisabled(True)
        else:
            self.te_note.clear()
            self.btn_add_sub.setDisabled(True)
            self.btn_add_note.setDisabled(True)
            self.btn_save_note.setDisabled(False)
            self.te_note.setDisabled(False)
            file = open(self.select_path, mode='r', encoding='utf-8')
            for line in file.readlines():
                self.te_note.append(line.strip('\n'))
            file.close()

    def doubleclick_tv_item(self, index):
        is_dir = index.model().isDir(index)
        self.select_path = index.model().filePath(index)
        path, ordinary_filename = os.path.split(self.select_path)
        file_name, success = QInputDialog.getText(self, "Title", "File Name:", QLineEdit.Normal,
                                                  ordinary_filename.split('.')[0])
        if success:
            if file_name.strip(' ') == '':
                return
            if is_dir:
                os.rename(self.select_path, path + os.path.sep + file_name.strip(' '))
            else:
                os.rename(self.select_path, path + os.path.sep + file_name.strip(' ') + '.txt')

    def btn_click(self):
        btn = self.sender()
        if btn == self.btn_save_note:
            content = self.te_note.toPlainText()
            lines = content.split('\n')
            file = open(self.select_path, mode='w+', encoding='utf-8')
            for line in lines:
                file.write(line + '\n')
            file.close()
        else:
            file_name, success = QInputDialog.getText(self, "Title", "File Name:", QLineEdit.Normal, '')
            if success:
                if file_name.strip(' ') == '':
                    return
                if btn == self.btn_add_root:
                    path = os.path.dirname(
                        os.path.realpath(__file__)) + os.path.sep + 'notes' + os.path.sep + file_name.strip(' ')
                    if not os.path.exists(path):
                        os.mkdir(path)
                elif btn == self.btn_add_sub:
                    path = self.select_path + os.path.sep + file_name.strip(' ')
                    if not os.path.exists(path):
                        os.mkdir(path)
                elif btn == self.btn_add_note:
                    path = self.select_path + os.path.sep + file_name.strip(' ') + '.txt'
                    if not os.path.exists(path):
                        open(path, mode='w', encoding='utf-8')

    def change_font_size(self):
        rb = self.sender()
        font = QFont()
        if rb == self.rb_fonts_small:
            font.setPointSize(10)
        elif rb == self.rb_fonts_normal:
            font.setPointSize(12)
        elif rb == self.rb_fonts_big:
            font.setPointSize(14)
        elif rb == self.rb_fonts_bigger:
            font.setPointSize(18)
        elif rb == self.rb_fonts_biggest:
            font.setPointSize(20)
        self.te_note.setFont(font)