def _addTool(self, _event=None): """Callback for add tool action Add a tool without any check to port. Args: _event: not used but mandatory """ toolname_values = self.tool_panel.getValue() toolname = ViewElement.list_tuple_to_dict(toolname_values)[ "Tool to add"] self.controller.addAllTool(toolname, 'Custom tools', '', False)
def addAProof(self, _event, obj): """Callback when add proof is clicked. Add proof and update window Args _event: mandatory but not used obj: the clicked index proof """ values = self.form.getValue() formValues = ViewElement.list_tuple_to_dict(values) self.controller.addAProof(formValues, obj) self.form.clear() for widget in self.appliViewFrame.winfo_children(): widget.destroy() self.openModifyWindow()
def onOk(self, _event): """ Called when the user clicked the validation button. Set the rvalue attributes to the value selected and close the window. """ # send the data to the parent res, msg = self.form.checkForm() if not res: tk.messagebox.showwarning("Form not validated", msg, parent=self.app) return form_values = self.form.getValue() form_values_as_dicts = ViewElement.list_tuple_to_dict(form_values) self.rvalue = (form_values_as_dicts["bin"], form_values_as_dicts["plugin"]) self.app.destroy()
def onOk(self, _event=None): """Called the the Export button is pressed. return a list of strings corresponding to the selected fields. Args: _event: not used but mandatory""" res, msg = self.form.checkForm() if res: form_values = self.form.getValue() form_values_as_dicts = ViewElement.list_tuple_to_dict(form_values) mfields = form_values_as_dicts["Fields"] fields = [k for k, v in mfields.items() if v == 1] self.rvalue = fields self.app.destroy() else: tk.messagebox.showwarning("Form not validated", msg, parent=self.app)
def onOk(self, _event): """ Called when the user clicked the validation button. Set the rvalue attributes to the value selected and close the window. Args: _event: not used but mandatory """ # send the data to the parent res, msg = self.form.checkForm() if res: form_values = self.form.getValue() form_values_as_dicts = ViewElement.list_tuple_to_dict(form_values) self.rvalue = {"name": form_values_as_dicts["Database name"], "type": form_values_as_dicts.get("Pentest type", ""), "start": form_values_as_dicts["startd"], "end": form_values_as_dicts["endd"], "settings": form_values_as_dicts["Settings"], "scope": form_values_as_dicts["Scope"], "pentesters": form_values_as_dicts["Pentester names"]} self.app.destroy() else: tk.messagebox.showwarning( "Form not validated", msg, parent=self.app)
def onOk(self, _event=None): """ Called when the user clicked the validation button. launch parsing with selected parser on selected file/directory. Close the window. Args: _event: not used but mandatory """ res, msg = self.form.checkForm() if not res: tk.messagebox.showwarning("Form not validated", msg, parent=self.app) return notes = None tags = None form_values = self.form.getValue() form_values_as_dicts = ViewElement.list_tuple_to_dict(form_values) file_path = form_values_as_dicts["File"] plugin = form_values_as_dicts["Plugin"] wave = form_values_as_dicts["Wave"] files = [] if os.path.isdir(file_path): # r=root, d=directories, f = files for r, _d, f in os.walk(file_path): for fil in f: files.append(os.path.join(r, fil)) else: files.append(file_path) results = {} dialog = ChildDialogProgress( self.parent, "Importing files", "Importing " + str(len(files)) + " files. Please wait for a few seconds.", 200, "determinate") dialog.show(len(files)) # LOOP ON FOLDER FILES for f_i, file_path in enumerate(files): md5File = md5(file_path) toolName = os.path.splitext( os.path.basename(file_path))[0] + md5File[:6] dialog.update(f_i) if plugin == "auto-detect": # AUTO DETECT foundPlugin = "Ignored" for pluginName in listPlugin(): if foundPlugin != "Ignored": break mod = loadPlugin(pluginName) if mod.autoDetectEnabled(): with io.open(file_path, 'r', encoding="utf-8") as f: notes, tags, lvl, targets = mod.Parse(f) if notes is not None and tags is not None: foundPlugin = pluginName results[foundPlugin] = results.get(foundPlugin, []) + [file_path] else: # SET PLUGIN mod = loadPlugin(plugin) with io.open(file_path, 'r', encoding="utf-8") as f: notes, tags, lvl, targets = mod.Parse(f) results[plugin] = results.get(plugin, []) + [file_path] # IF PLUGIN FOUND SOMETHING if notes is not None and tags is not None: # ADD THE RESULTING TOOL TO AFFECTED for target in targets.values(): date = datetime.fromtimestamp(os.path.getmtime( file_path)).strftime("%d/%m/%Y %H:%M:%S") if target is None: scope = None ip = None port = None proto = None else: scope = target.get("scope", None) ip = target.get("ip", None) port = target.get("port", None) proto = target.get("proto", None) Wave().initialize(wave, []).addInDb() tool_m = Tool().initialize(toolName, wave, scope=scope, ip=ip, port=port, proto=proto, lvl=lvl, text="", dated=date, datef=date, scanner_ip="Imported file", status="done", notes=notes, tags=tags) tool_m.addInDb() mongoInstance = MongoCalendar.getInstance() outputRelDir = tool_m.getOutputDir( mongoInstance.calendarName) abs_path = os.path.dirname(os.path.abspath(__file__)) outputDir = os.path.join(abs_path, "../../../results", outputRelDir) mod.centralizeFile(file_path, outputDir) tool_m.update({ "resultfile": os.path.join(outputRelDir, os.path.basename(file_path)) }) dialog.destroy() # DISPLAY RESULTS presResults = "" filesIgnored = 0 for key, value in results.items(): presResults += str(len(value)) + " " + str(key) + ".\n" if key == "Ignored": filesIgnored += 1 if plugin == "auto-detect": if filesIgnored > 0: tk.messagebox.showwarning("Auto-detect ended", presResults, parent=self.app) else: tk.messagebox.showinfo("Auto-detect ended", presResults, parent=self.app) else: if filesIgnored > 0: tk.messagebox.showwarning("Parsing ended", presResults, parent=self.app) else: tk.messagebox.showinfo("Parsing ended", presResults, parent=self.app) self.rvalue = None self.app.destroy()