예제 #1
0
    def __init__(self, parent):
        """
            parent: the tkinter parent view to use for this window construction.
        """
        self.parent = parent
        self.app = tk.Toplevel(parent)
        self.app.title("Scripts Manager")
        self.app.resizable(True, True)
        self.rvalue = None
        appFrame = ttk.Frame(self.app)
         #PANED PART
        self.paned = tk.PanedWindow(appFrame, height=300)
        #RIGHT PANE : TAble
        self.viewframe = ttk.Frame(self.paned)
        self.file_tree = CheckboxTreeview(self.viewframe)
        self.file_tree['columns'] = ('name', 'category')
        self.file_tree.heading('#0', text='Name')
        self.file_tree.column("#0", stretch=tk.YES, minwidth=300, width=300)
        self.file_tree.heading('#1', text='Category')
        self.file_tree.column("#1", stretch=tk.YES, minwidth=300, width=300)
        self.file_tree.pack(fill=tk.BOTH, expand=True)
        btn_pane = ttk.Frame(self.viewframe)
        self.execute_icone = tk.PhotoImage(file = Utils.getIcon("execute.png"))
        btn_execute = ttk.Button(btn_pane, text="Execute", image=self.execute_icone, command=self.executedSelectedScripts, tooltip="Execute all selected scripts", style="Toolbutton")        
        btn_execute.pack(side=tk.RIGHT, padx=3, pady=5)
        self.open_folder_icone = tk.PhotoImage(file = Utils.getIcon("folder.png"))
        btn_openPathForUser = ttk.Button(btn_pane, text="Execute", image=self.open_folder_icone, command=self.openPathForUser, tooltip="Open scripts folder", style="Toolbutton")        
        btn_openPathForUser.pack(side=tk.RIGHT, padx=3, pady=5)
        
        btn_pane.pack(fill=tk.X, side=tk.BOTTOM, anchor=tk.E)
        #LEFT PANE : Treeview
        self.frameTw = ttk.Frame(self.paned)
        self.treevw = ttk.Treeview(self.frameTw)
        self.treevw.pack()
        scbVSel = ttk.Scrollbar(self.frameTw,
                                orient=tk.VERTICAL,
                                command=self.treevw.yview)
        self.treevw.configure(yscrollcommand=scbVSel.set)
        self.treevw.grid(row=0, column=0, sticky=tk.NSEW)
        scbVSel.grid(row=0, column=1, sticky=tk.NS)
        self.treevw.grid(row=0, column=0, sticky=tk.NSEW)
        scbVSel.grid(row=0, column=1, sticky=tk.NS)
        self.paned.add(self.frameTw)
        self.paned.add(self.viewframe)
        self.paned.pack(fill=tk.BOTH, expand=1)
        self.frameTw.rowconfigure(0, weight=1) # Weight 1 sur un layout grid, sans ça le composant ne changera pas de taille en cas de resize
        self.frameTw.columnconfigure(0, weight=1) # Weight 1 sur un layout grid, sans ça le composant ne changera pas de taille en cas de resize

        appFrame.pack(fill=tk.BOTH, ipady=10, ipadx=10, expand=True)

        self.treevw.bind("<<TreeviewSelect>>", self.onTreeviewSelect)
        try:
            self.app.wait_visibility()
            self.app.focus_force()
            self.app.lift()
        except tk.TclError:
            pass
        self.refreshUI()
예제 #2
0
 def __init__(self, parent, settings):
     self.proc = None
     self.s = None
     self.__class__.settings = settings
     self.img = ImageTk.PhotoImage(Image.open(Utils.getIcon("help.png")))
     manager = Manager()
     self.exiting = manager.Value('i', 0)
예제 #3
0
 def refreshUI(self):
     for widget in self.treevw.winfo_children():
         widget.destroy()
     script_dir = self.getScriptsDir()
     if self.__class__.folder_icon is None:
         self.__class__.folder_icon = ImageTk.PhotoImage(Image.open(Utils.getIcon("folder.png")))
     parent = self.treevw.insert("", "end", " ", text="Scripts", image=self.__class__.folder_icon, open=True)
     self.treevw.focus(parent)
     self.treevw.selection_set(parent)
     for root, subFolders, files in os.walk(script_dir):
         root_name = root.replace(script_dir, "")
         for folder in subFolders:
             if folder.startswith("__") or folder.endswith("__"):
                 continue
             folder_iid = os.path.join(root_name, folder)
             parent_node = parent if root_name == "" else root_name
             self.treevw.insert(parent_node, "end", folder_iid, text=folder, image=self.__class__.folder_icon)
     self.openScriptFolderView()
예제 #4
0
    def initUI(self, parent):
        """Create widgets and initialize them
        Args:
            parent: the parent tkinter widget container."""
        if self.workerTv is not None:
            self.refreshUI()
            return
        apiclient = APIClient.getInstance()
        self.parent = parent
        self.parent.configure(onfiledrop=self.dropFile)
        ### WORKER TREEVIEW : Which worker knows which commands
        lblworker = ttk.Label(self.parent, text="Workers:")
        lblworker.pack(side=tk.TOP, padx=10, pady=5, fill=tk.X)
        self.workerTv = ttk.Treeview(self.parent)
        self.workerTv['columns'] = ('workers')
        self.workerTv.heading("#0", text='Workers', anchor=tk.W)
        self.workerTv.column("#0", anchor=tk.W)
        self.workerTv.pack(side=tk.TOP, padx=10, pady=10, fill=tk.X)
        self.workerTv.bind("<Double-Button-1>", self.OnWorkerDoubleClick)
        self.workerTv.bind("<Delete>", self.OnWorkerDelete)
        btn_pane = ttk.Frame(self.parent)
        self.btn_setInclusion = ttk.Button(
            btn_pane,
            text="Include/exclude selected worker",
            command=self.setWorkerInclusion)
        self.btn_setInclusion.pack(padx=5, side=tk.RIGHT)
        self.docker_image = tk.PhotoImage(file=Utils.getIcon("baleine.png"))
        self.docker_download_image = tk.PhotoImage(
            file=Utils.getIcon("baleine_download.png"))
        self.btn_ServerWorker = ttk.Button(btn_pane,
                                           command=self.runWorkerOnServer,
                                           text="Start remote worker")
        self.btn_ServerWorker.pack(padx=5, side=tk.RIGHT)

        if git_available:
            self.btn_docker_worker = ttk.Button(
                btn_pane,
                command=self.launchDockerWorker,
                image=self.docker_image,
                style="Toolbutton")
            self.btn_docker_worker.pack(padx=5, side=tk.RIGHT)
            self.btn_docker_worker = ttk.Button(
                btn_pane,
                command=self.installDockerWorker,
                image=self.docker_download_image,
                style="Toolbutton")
            self.btn_docker_worker.pack(padx=5, side=tk.RIGHT)
        self.btn_ServerWorker = ttk.Button(btn_pane,
                                           command=self.registerAsWorker,
                                           text="Register as worker")
        self.btn_ServerWorker.pack(padx=5, side=tk.RIGHT)
        btn_pane.pack(side=tk.TOP, padx=10, pady=5)
        workers = apiclient.getWorkers()
        total_registered_commands = 0
        registeredCommands = set()
        for worker in workers:
            workername = worker["name"]
            try:
                if apiclient.getCurrentPentest() == worker.get("pentest", ""):
                    worker_node = self.workerTv.insert('',
                                                       'end',
                                                       workername,
                                                       text=workername,
                                                       image=self.ok_icon)
                else:
                    worker_node = self.workerTv.insert('',
                                                       'end',
                                                       workername,
                                                       text=workername,
                                                       image=self.nok_icon)
            except tk.TclError:
                pass
        #### TREEVIEW SCANS : overview of ongoing auto scan####
        lblscan = ttk.Label(self.parent, text="Scan overview:")
        lblscan.pack(side=tk.TOP, padx=10, pady=5, fill=tk.X)
        self.scanTv = ttk.Treeview(self.parent)
        self.scanTv['columns'] = ('Started at')
        self.scanTv.heading("#0", text='Scans', anchor=tk.W)
        self.scanTv.column("#0", anchor=tk.W)
        self.scanTv.pack(side=tk.TOP, padx=10, pady=10, fill=tk.X)
        self.scanTv.bind("<Double-Button-1>", self.OnDoubleClick)
        running_scans = Tool.fetchObjects({"status": "running"})
        for running_scan in running_scans:
            self.scanTv.insert('',
                               'end',
                               running_scan.getId(),
                               text=running_scan.name,
                               values=(running_scan.dated),
                               image=self.running_icon)
        #### BUTTONS FOR AUTO SCANNING ####
        if apiclient.getAutoScanStatus():
            self.btn_autoscan = ttk.Button(self.parent,
                                           text="Stop Scanning",
                                           command=self.stopAutoscan)
            self.btn_autoscan.pack()
        else:
            self.btn_autoscan = ttk.Button(self.parent,
                                           text="Start Scanning",
                                           command=self.startAutoscan)
            self.btn_autoscan.pack()
        btn_parse_scans = ttk.Button(self.parent,
                                     text="Parse existing files",
                                     command=self.parseFiles)
        btn_parse_scans.pack(side="top", pady=10)
        info = ttk.Label(self.parent,
                         text="You can also drop your files / folder here")
        info.pack()
예제 #5
0
    def initUI(self, parent):
        """Create widgets and initialize them
        Args:
            parent: the parent tkinter widget container."""
        if self.userTv is not None:
            self.refreshUI()
            return
        self.parent = parent
        ### WORKER TREEVIEW : Which worker knows which commands
        self.userTv = ttk.Treeview(self.parent)
        self.headings = [
            "Username", "Password", "Admin", "Name", "Surname", "Email"
        ]
        self.userTv['columns'] = self.headings
        self.userTv.heading("#0", text='Username', anchor="nw")
        self.userTv.column("#0", anchor="nw")
        self.userTv.heading("#1", text='Password', anchor="nw")
        self.userTv.column("#1", anchor="nw", width=20)
        self.userTv.heading("#2", text='Admin', anchor="nw")
        self.userTv.column("#2", anchor="nw", width=20)
        self.userTv.heading("#3", text='Name', anchor="nw")
        self.userTv.column("#3", anchor="nw", width=20)
        self.userTv.heading("#4", text='Surname', anchor="nw")
        self.userTv.column("#4", anchor="nw", width=20)
        self.userTv.heading("#5", text='Email', anchor="nw")
        self.userTv.column("#5", anchor="nw", width=100)
        self.userTv.pack(side=tk.TOP, padx=10, pady=10, fill=tk.X)
        self.userTv.bind("<Double-Button-1>", self.OnUserDoubleClick)
        self.userTv.bind("<Delete>", self.OnUserDelete)

        #### BUTTONS FOR AUTO SCANNING ####
        lblAddUsername = ttk.LabelFrame(parent, text="Add user")
        addUserFrame = ttk.Frame(lblAddUsername)
        lblAddUser = ttk.Label(addUserFrame, text="Username:"******"Password:"******"*",
                                textvariable=self.password)
        entryAddPwd.grid(row=1, column=1, sticky=tk.W)
        lblAddConfirmPwd = ttk.Label(addUserFrame, text="Confirm:")
        lblAddConfirmPwd.grid(row=2, column=0, sticky=tk.E)
        self.confirmpassword = tk.StringVar()
        entryAddConfirmPwd = ttk.Entry(addUserFrame,
                                       width=20,
                                       show="*",
                                       textvariable=self.confirmpassword)
        entryAddConfirmPwd.grid(row=2, column=1, sticky=tk.W)
        lblName = ttk.Label(addUserFrame, text="Name:")
        lblName.grid(row=3, column=0, sticky=tk.E)
        self.name = ttk.Entry(addUserFrame, width=20)
        self.name.grid(row=3, column=1, sticky=tk.W)
        lblSurname = ttk.Label(addUserFrame, text="Surname:")
        lblSurname.grid(row=4, column=0, sticky=tk.E)
        self.surname = ttk.Entry(addUserFrame, width=20)
        self.surname.grid(row=4, column=1, sticky=tk.W)
        lblEmail = ttk.Label(addUserFrame, text="Email:")
        lblEmail.grid(row=5, column=0, sticky=tk.E)
        self.email = ttk.Entry(addUserFrame, width=30)
        self.email.grid(row=5, column=1, sticky=tk.W)
        self.add_user_icon = tk.PhotoImage(file=Utils.getIcon("add_user.png"))
        btn_addUser = ttk.Button(addUserFrame,
                                 image=self.add_user_icon,
                                 command=self.addUser,
                                 style='Toolbutton')
        btn_addUser.grid(row=6, column=2, sticky=tk.W)
        addUserFrame.pack()
        lblAddUsername.pack()
        self.refreshUI()