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)
def input_terminal(self, text): """ This method checks if the dynamic analysis thread is running if it's being run it passes the text as an input pipe.Otherwise passes the text as a command for Radare. :param text: text for argument :return: none """ if self.run == 0: if Singleton.get_project() != "BEAT": try: r2 = model.analysis.StaticAnalysis.static_all(Singleton.get_path()) self.terminal(text + ' >\n') self.terminal(r2.cmd(text)) except Exception as e: x = ErrorDialog(self.analysis_tab, str(e), "Error") x.exec_() self.analysis_tab.terminal_window_lineEdit.setText("") else: x = ErrorDialog(self.analysis_tab, "First select a project", "Error") x.exec_() elif self.run == 1: thread.input(text) self.analysis_tab.terminal_window_lineEdit.clear()
def static(self): """ This method listens to the click of the static analysis button and connects with the model to preform static analysis.This method also saves into the database depending on the type. :return: none """ s = Singleton.get_project() if s == "BEAT": x = ErrorDialog(self.analysis_tab, "Please select a project", "Static analysis Error") x.exec_() return if self.analysis_tab.plugin_comboBox.count() == 0: x = ErrorDialog(self.analysis_tab, "Please install a plugin", "Static analysis Error") x.exec_() return QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor) self.analysis_tab.poi_listWidget.clear() print(Singleton.get_path()) rlocal = model.analysis.StaticAnalysis.static_all(Singleton.get_path()) try: if self.analysis_tab.poi_comboBox.currentText() == "All": strings = model.analysis.StaticAnalysis.static_strings(rlocal, self.analysis_tab.plugin_comboBox.currentText()) for st in strings: item = self.set_item(st, "Strings") item = self.change_font(item) self.analysis_tab.poi_listWidget.addItem(item) functions = model.analysis.StaticAnalysis.static_functions(rlocal, self.analysis_tab.plugin_comboBox.currentText()) for fc in functions: item = self.set_item(fc, "Functions") item = self.change_font(item) self.analysis_tab.poi_listWidget.addItem(item) elif self.analysis_tab.poi_comboBox.currentText() == "Functions": functions = model.analysis.StaticAnalysis.static_functions(rlocal, self.analysis_tab.plugin_comboBox.currentText()) for fc in functions: item = self.set_item(fc, "Functions") item = self.change_font(item) self.analysis_tab.poi_listWidget.addItem(item) elif self.analysis_tab.poi_comboBox.currentText() == "Strings": strings = model.analysis.StaticAnalysis.static_strings(rlocal, self.analysis_tab.plugin_comboBox.currentText()) for st in strings: item = self.set_item(st, "Strings") item = self.change_font(item) self.analysis_tab.poi_listWidget.addItem(item) except Exception as e: x = ErrorDialog(self.analysis_tab, str(e), "Static analysis Error") x.exec_() rlocal.quit() QtWidgets.QApplication.restoreOverrideCursor()