Beispiel #1
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_()
Beispiel #2
0
 def save_plugin(self):
     """
     This method after creating a new plugin this method communicates with the model to save the changes to the
     database.
     :return: none
     """
     plugin_db = DBConnection.get_collection("plugin")
     plg_cllc = plugin_db[self.plugin_tab.DPVPluginName.text()]
     info = {
         "name": self.plugin_tab.DPVPluginName.text(),
         "desc": self.plugin_tab.DPVPluginDescription.toPlainText(),
         "poi": {
             "item": []
         },
         "output": self.plugin_tab.DPVDefaultOutputField.text()
     }
     plg = Plugin.get_name(self.plugin_tab.DPVPluginName.text())
     self.delete_save_operations(self.plugin_creation_finished,
                                 [self.plugin_tab.pushButton_7],
                                 [self.plugin_tab.ButtonSavePlugin],
                                 self.plugin_tab.listWidget)
     if not plg:
         plg_cllc.insert(info, check_keys=False)
         x = ErrorDialog(self.plugin_tab, "Plugin Saved", "Save Plugin")
         x.exec_()
         self.plugin_signal.emit()
     else:
         x = ErrorDialog(self, "Plugin already exists", "Error Plugin")
         x.exec_()
         return
Beispiel #3
0
 def item_activated(self):
     """
     This method listens for selecting a plugin to display the plugin
     formation.
     :return: none
     """
     if self.plugin_tab.listWidget.count() != 0:
         plugin_s = self.plugin_tab.listWidget.selectedItems()
         plugin_name = [item.text().encode("ascii") for item in plugin_s]
         if plugin_name:
             try:
                 self.plugin = plugin_name[0].decode()
                 cursor = Plugin.get_name(self.plugin)
                 if cursor:
                     for pl in cursor:
                         self.plugin_tab.DPVPluginName.setText(pl["name"])
                         self.plugin_tab.DPVPluginDescription.setText(
                             pl["desc"])
                         self.plugin_tab.DPVDefaultOutputField.setText(
                             pl["output"])
                         for i in pl["poi"]["item"]:
                             last_text = self.plugin_tab.DVPPointOfInterest.toPlainText(
                             )
                             new = last_text + i["type"] + " " + i[
                                 "name"] + "\n"
                             self.plugin_tab.DVPPointOfInterest.setText(new)
             except Exception as e:
                 x = ErrorDialog(self.plugin_tab, str(e), "Error")
                 x.exec_()
def static_functions(rlocal, cplugin):
    """
    analysis all the functions in the binary and filters with the selected plugin and adds them to the database
    :param rlocal: R2Connection of the binary file
    :param cplugin: string current selected plugin
    :return: List of dict with filtered functions
    """
    items = []
    s = Singleton.get_project()
    project_db = DBConnection.get_collection(s)

    #if project_db["functions"]:
    #    project_db.drop_collection("functions")

    func_db = project_db["functions"]
    func_all = rlocal.cmdj("aflj")
    func_plg = Plugin.plugin_types("Function", cplugin)

    for fc in func_all:

        if fc["name"] in func_plg:
            function = rlocal.cmdj("axtj %s" % fc["name"])
            tmp = fc["name"]
            for f in function:
                fc["name"] = tmp + " " + hex(f["from"])
                items.append(fc["name"])
                fc["comment"] = ""
                fc["runs"] = []
                fc["from"] = hex(f["from"])
                if "_id" in fc:
                    del fc["_id"]
                if func_db.find({"name": fc["name"]}).count() == 0:
                    func_db.insert_one(fc)
    return items
 def set_plugins(self):
     """
     This method adds the installed plugins into a list which will update the list view. "
     :return: none
     """ ""
     self.poi_tab.comboBox.clear()
     for pl in Plugin.get_installed_plugins():
         self.poi_tab.comboBox.addItem(pl)
Beispiel #6
0
 def set_plugins(self):
     """
     This method check which plugins are on the database and add them to the drop down list for changing the plugin.
     :return: none
     """
     self.analysis_tab.plugin_comboBox.clear()
     for pl in Plugin.get_installed_plugins():
         self.analysis_tab.plugin_comboBox.addItem(pl)
 def delete_poi(self):
     """
     This method interacts with the model to delete a point of interest which will be updated into the
             database and will also update the view.
     :return:none
     """
     poi = self.poi_tab.listWidget_2.selectedItems()
     poi_name = [item.text().encode("ascii") for item in poi]
     button_reply = QtWidgets.QMessageBox.question(
         self.poi_tab, 'PyQt5 message',
         "Do you like to erase Poi %s ?" % poi_name[0].decode(),
         QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
         QtWidgets.QMessageBox.No)
     if button_reply == QtWidgets.QMessageBox.Yes and poi_name:
         Plugin.delete_poi(self.poi_tab.comboBox.currentText(),
                           poi_name[0].decode())
         self.filter_poi(self.poi_tab.comboBox.currentText(),
                         self.poi_tab.comboBox_2.currentText())
 def add_poi(self):
     """
     This method interacts with the model to create a new point of interest which will be updated into the
     database and will also update the view."
     :return: none
     """ ""
     add_poi_pop_up = AddPOIDialog(self.poi_tab)
     pois = add_poi_pop_up.exec_()
     doc = Plugin.get_name(self.poi_tab.comboBox.currentText())
     if doc and pois:
         for item in doc:
             new = item["poi"]["item"] + pois["item"]
             dict = {"item": new}
             Plugin.update_poi(dict, item["name"])
             self.fill_poi(self.poi_tab.comboBox_2.currentText())
             self.filter_poi(self.poi_tab.comboBox.currentText(),
                             self.poi_tab.comboBox_2.currentText())
         self.add_poi_signal.emit()
 def item_activated_event(self):
     """
     This method will listen for a change in the current poi where if another is selected it will cange the
     detailed view to that poi.
     :return: none
     """
     if self.poi_tab.listWidget_2.count() != 0:
         poi = self.poi_tab.listWidget_2.selectedItems()
         poi_name = [item.text().encode("ascii") for item in poi]
         if poi_name:
             cursor = Plugin.get_poi(self.poi_tab.comboBox.currentText())
             for i in cursor["item"]:
                 if i["name"] == poi_name[0].decode():
                     self.poi_tab.textEdit.setText(format_poi(i))
                     break
 def filter_poi(self, current, poi_type):
     """
     This method gets all the point fo interest in the database and depending in which plug in we are working
     it filters just the  matched point of interests
     :param current: selected plugin
     :param poi_type: selcted type of poi
     :return: none
     """
     self.poi_tab.listWidget_2.clear()
     doc = Plugin.get_poi(current)
     for i in doc["item"]:
         if poi_type != "All":
             if i["type"] == poi_type:
                 self.poi_tab.listWidget_2.addItem(i["name"])
         else:
             self.poi_tab.listWidget_2.addItem(i["name"])
 def fill_poi(self, current):
     """
     This method gets the current working plugin and gets all the point of interest and adds them into a list
     that will be used in the point of interest view and adds the types of pois into the dropdown.
     :param current: current plugin
     :return: none
     """
     self.poi_tab.listWidget_2.clear()
     doc = Plugin.get_poi(current)
     if doc:
         types = []
         for i in doc["item"]:
             self.poi_tab.listWidget_2.addItem(i["name"])
             if i["type"] not in types:
                 types.append(i["type"])
                 self.poi_tab.comboBox_2.addItem(i["type"])
def static_strings(rlocal, cplugin):
    """
    analysis all the strings in the binary and filters with nthe selected plugin and adds them to the database
    :param rlocal: R2Connection of the binary file
    :param cplugin: string current selected plugin
    :return: List of dict with filtered strings
    """
    items = []
    s = Singleton.get_project()
    project_db = DBConnection.get_collection(s)
    # Strings
    strings = rlocal.cmdj("izj")
    str_plg = Plugin.plugin_types("String", cplugin)

    #if project_db["string"]:
    #    project_db.drop_collection("string")

    str_db = project_db["string"]
    for string in strings:
        text = string["string"]
        text_decoded = base64.b64decode(text)
        for i in str_plg:
            if i.upper() in text_decoded.decode().upper():
                x = rlocal.cmdj("axtj %s" % string["vaddr"])
                tmp = text_decoded.decode()
                for str in x:
                    string["string"] = tmp + " " + hex(str["from"])
                    items.append(string["string"])
                    string["from"] = hex(str["from"])
                    string["comment"] = ""
                    if "_id" in string:
                        del string["_id"]
                    if str_db.find({"string": string["string"]}).count() == 0:
                        str_db.insert_one(string)
                break
    return items
Beispiel #13
0
 def set_plugins(self):
     self.plugin_tab.listWidget.clear()
     for pl in Plugin.get_installed_plugins():
         self.plugin_tab.listWidget.addItem(pl)