def openInsertWindow(self): """ Creates a tkinter form using Forms classes. This form aims to insert a new Command """ self._initContextualMenu() panel_top = self.form.addFormPanel(grid=True) panel_top.addFormLabel("Name") panel_top.addFormStr("Name", r"\S+", "", None, column=1) panel_top.addFormLabel("Level", row=1) panel_top.addFormCombo("Level", ["network", "domain", "ip", "port", "wave"], "network", row=1, column=1) panel_top.addFormHelper( "lvl wave: will run on each wave once\nlvl network: will run on each NetworkIP once\nlvl domain: will run on each scope domain once\nlvl ip: will run on each ip/hostname once\nlvl port: will run on each port once", row=1, column=2) panel_types = self.form.addFormPanel(grid=True) panel_types.addFormChecklist("Types", Settings.getPentestTypes(), [], row=2, column=1) panel_types.addFormHelper( "This command will be added by default on pentest having a type checked in this list.\nThis list can be modified on settings.", column=2) panel_safe = self.form.addFormPanel(grid=True) panel_safe.addFormLabel("Safe") panel_safe.addFormCheckbox("Safe", "Safe", "False", column=1) panel_safe.addFormHelper( "If checked, this command can be run by an auto scan.", column=2) panel_text = self.form.addFormPanel() panel_text.addFormLabel("Command line options", side="top") panel_text.addFormHelper( """Do not include binary name/path\nDo not include Output file option\nUse variables |wave|, |scope|, |ip|, |port|, |parent_domain|, |outputDir|, |port.service|, |port.product|, |ip.infos.*| |port.infos.*|""", side="right") panel_text.addFormText("Command line options", r"", "", self.menuContextuel, side="top", height=5) panel_bottom = self.form.addFormPanel(grid=True) panel_bottom.addFormLabel("Ports/Services") panel_bottom.addFormStr( "Ports/Services", r"^((.{0})|(\d{1,5}|[^\, ]+)(?:, (\d{1,5}|[^\, ]+))*)$", "", width=50, column=1) panel_bottom.addFormHelper( "Services, ports or port ranges.\nthis list must be separated by a comma, if no protocol is specified, tcp/ will be used.\n Example: ssl/http,https,http/ssl,0-65535,443...", column=2) self._commonWindowForms() self.completeInsertWindow()
def openModifyWindow(self): """ Creates a tkinter form using Forms classes. This form aims to update or delete an existing Command """ modelData = self.controller.getData() self._initContextualMenu() settings = self.mainApp.settings settings.reloadSettings() panel_top = self.form.addFormPanel(grid=True) panel_top.addFormLabel("Name", modelData["name"], sticky=tk.NW) panel_top.addFormLabel("Level", modelData["lvl"], row=1, sticky=tk.NW) panel_top_bis = self.form.addFormPanel(grid=True) panel_top_bis.addFormChecklist("Types", Settings.getPentestTypes().keys(), modelData["types"], column=1) panel_safe = self.form.addFormPanel(grid=True) panel_safe.addFormLabel("Safe") panel_safe.addFormCheckbox("Safe", "Safe", modelData["safe"] == "True", column=1) panel_safe.addFormHelper( "If checked, this command can be run by an auto scan.", column=2) panel_text = self.form.addFormPanel() panel_text.addFormLabel("Command line options", side="top") panel_text.addFormHelper( """Do not include binary name/path\nDo not include Output file option\nUse variables |wave|, |scope|, |ip|, |port|, |parent_domain|, |outputDir|, |port.service|, |port.product|, |ip.infos.*| |port.infos.*|""", side="right") panel_text.addFormText("Command line options", r"", modelData["text"], self.menuContextuel, side="left", height=5) panel_bottom = self.form.addFormPanel(grid=True) if modelData["lvl"] == "port": panel_bottom.addFormLabel("Ports/Services", column=0) panel_bottom.addFormStr( "Ports/Services", r"^(\d{1,5}|[^\,]+)(?:,(\d{1,5}|[^\,]+))*$", modelData["ports"], self.popup, width=50, column=1) panel_bottom.addFormHelper( "Services, ports or port ranges.\nthis list must be separated by a comma, if no protocol is specified, tcp/ will be used.\n Example: ssl/http,https,http/ssl,0-65535,443...", column=2) self._commonWindowForms(modelData) self.completeModifyWindow()
def __init__(self, parent, default): """ Open a child dialog of a tkinter application to ask details about the new pentest. Args: parent: the tkinter parent view to use for this window construction. """ self.app = tk.Toplevel(parent) self.app.resizable(False, False) self.rvalue = None self.parent = parent mainFrame = ttk.Frame(self.app) self.form = FormPanel() form1 = self.form.addFormPanel(grid=True, side=tk.TOP, fill=tk.X) form1.addFormLabel("Database name") form1.addFormStr("Database name", r"^\S+$", default=default.get("name", ""), width=50, column=1) types = list(Settings.getPentestTypes().keys()) if types: form1.addFormLabel("Pentest type", row=1) form1.addFormCombo( "Pentest type", types, default=default.get("type", types[0]), row=1, column=1) form1.addFormLabel("Starting", row=2) form1.addFormDate("startd", parent, default.get("start", datetime.strftime(datetime.now(), "%d/%m/%Y %H:%M:%S")), "%d/%m/%Y %H:%M:%S", row=2, column=1) form1.addFormLabel("Ending", row=3) form1.addFormDate("endd", parent, default.get("end", "31/12/2099 00:00:00"), "%d/%m/%Y %H:%M:%S", row=3, column=1) form2 = self.form.addFormPanel(grid=True, side=tk.TOP, fill=tk.X, pady=5) form2.addFormLabel("Scope", pady=5) form2.addFormText( "Scope", "", default.get("scope", ""), height=5, column=1, sticky=tk.E, pady=5) form2.addFormHelper( "You can declare network ip as IP/MASKSIZE, ips or domains", column=2, sticky=tk.W) form2.addFormLabel("Pentester names", row=1, sticky=tk.E) form2.addFormText( "Pentester names", "", default.get("pentesters", ""), row=1, column=1, sticky=tk.W, height=3, pady=5) form3 = self.form.addFormPanel(side=tk.TOP, fill=tk.X, pady=5) default_settings = [] for key, val in default.get("settings", {}).items(): if val == 1: default_settings.append(key) form3.addFormChecklist("Settings", ["Add domains whose IP are in scope", "Add domains who have a parent domain in scope", "Add all domains found"], default_settings, side=tk.TOP, fill=tk.X, pady=5) form3.addFormButton("Create", self.onOk, side=tk.BOTTOM) self.form.constructView(mainFrame) self.form.setFocusOn("Database name") mainFrame.pack(fill=tk.BOTH, ipadx=10, ipady=10) self.app.transient(parent) self.app.wait_visibility() self.app.grab_set()