예제 #1
0
 def open_comment(self):
     """
     This method opens the comment pop-up to add a comment/ or edit an exiting comment.Afterwards it updates
     the information to the detailed point of interest in the database.
     :return: none
     """
     item = self.analysis_tab.poi_listWidget.currentItem()
     value = DBConnection.search_by_item(item)
     project_db = DBConnection.get_collection(Singleton.get_project())
     if item.toolTip() == "Functions":
         db_info = project_db["functions"]
     elif item.toolTip() == "Strings":
         db_info = project_db["string"]
     if value is not None:
         id = value["_id"]
         cmt = value["comment"]
         if cmt is None:
             cmt = ""
         pop_up = CommentDialog(self.analysis_tab, cmt)
         comm = pop_up.exec_()
         index = {"_id": id}
         new_value = {"$set": {"comment": comm}}
         db_info.update_one(index, new_value)
         self.detailed_poi(item)
         new_font = QtGui.QFont()
         new_font.setBold(True)
         item.setFont(new_font)
예제 #2
0
    def open_output(self):
        """
        Grabs the output file from the plugin and gets the selcted pois and runs the file with the pois as arguments.
        :return: none
        """
        try:
            plugin = Plugin.get_file(self.analysis_tab.plugin_comboBox.currentText())
            cmd = ["python3", plugin]
            pois = []
            for i in range(self.analysis_tab.poi_listWidget.count()):
                item = self.analysis_tab.poi_listWidget.item(i)
                if item.checkState() == QtCore.Qt.Checked:
                    value = DBConnection.search_by_item(item)
                    out = Plugin.get_output(item.text(), self.analysis_tab.plugin_comboBox.currentText())
                    poi = {"name": item.text(), "from": value["from"], "out": out}
                    pois.append(poi)
            sort = sorted(pois, key=lambda i: i["from"])
            for s in sort:
                cmd.append(str(s))
            subprocess.check_call(cmd)
            x = ErrorDialog(self.analysis_tab, "Finished creating output", "Output")
            x.exec_()
        except subprocess.CalledProcessError as e:
            text = ""
            if e.returncode == 1:
                text = f"Error executing {plugin} file"
            elif e.returncode == 2:
                text = f"{plugin} file not found"

            x = ErrorDialog(self.analysis_tab, text, "Error in Output")
            x.exec_()
        except Exception as e:
            x = ErrorDialog(self.analysis_tab, str(e), "Error in Output")
            x.exec_()
예제 #3
0
 def detailed_poi(self, item):
     """
     This method gets the information of an existing poi in the database and displays it top the detail point of
     interest edit box.
      :param item: current selected poi
      :return: none
     """
     value = DBConnection.search_by_item(item)
     if value is not None:
         del value["_id"]
         y = value
         self.analysis_tab.poi_content_area_textEdit.setText(format_poi(y))
예제 #4
0
    def dynamic(self):
        """
        This method asks the user for parameters, creates a list with the selected pois and  stats dynamic analysis
        thread with the list of pois and parameters as arguments.
         :return:
        """
        if self.analysis_tab.poi_listWidget.count() == 0:
            x = ErrorDialog(self.analysis_tab, "Please run Static analysis first", "Error in DYnamic analysis")
            x.exec_()
            return
        global input
        input, ok_pressed = QtWidgets.QInputDialog.getText(self.analysis_tab, "Dynamic analysis", "Args to pass:"******"")

        if ok_pressed:
            self.run += 1
            pois_checked = []

            r2 = model.analysis.StaticAnalysis.static_all(Singleton.get_path())
            self.terminal('r2 > \n')
            self.terminal(r2.cmd("doo %s" % input))

            for i in range(self.analysis_tab.poi_listWidget.count()):
                item = self.analysis_tab.poi_listWidget.item(i)
                if item.checkState() == QtCore.Qt.Checked:
                    if item.toolTip() == "Functions":
                        value = DBConnection.search_by_item(item)
                        poi = {"name": item.text(), "from": value["from"], "type": item.toolTip(), "rtnPara": [],
                               "rtnFnc": ""}
                        pois_checked.append(poi)

            sort = sorted(pois_checked, key=lambda i: i["from"])

            global thread
            try:
                self.run = 1
                self.dynamic_started.emit()
                thread = model.analysis.DynamicThread.DynamicThread(rlocal=r2, pois=sort)
                thread.textSignal.connect(lambda x: self.terminal(x))
                thread.listSignal.connect(lambda x: self.return_funcitions(x))
                thread.errorSignal.connect(lambda x: self.error_thread(x))
                thread.start()
            except Exception as e:
                print(e)