Example #1
0
    def open(self):
        mainDir = os.path.normpath(Utils.getMainDir())
        mongoInstance = MongoCalendar.getInstance()
        with open(os.path.join(mainDir, "setupTerminalForPentest.sh"), "r") as f:
            data = f.read()
            lines = data.split("\n")
            lines[0] = "POLLENISATOR_CURRENT_DB="+str(mongoInstance.calendarName)
            data = "\n".join(lines)
            with open(os.path.join(mainDir, "setupTerminalForPentest.sh"), "w") as f:
                f.write(data)
        favorite = self.settings.getFavoriteTerm()
        if favorite is None:
            tkinter.messagebox.showerror("Terminal settings invalid", "None of the terminals given in the settings are installed on this computer.")
            return False

        if which(favorite) is not None:
            terms = self.settings.getTerms()
            terms_dict = {}
            for term in terms:
                terms_dict[term.split(" ")[0]] = term
            command_term = terms_dict.get(favorite, None)
            if command_term is not None:
                Utils.execute(terms_dict[favorite])
                return True
            else:
                tkinter.messagebox.showerror("Terminal settings invalid", "Check your terminal settings")
        else:
            tkinter.messagebox.showerror("Terminal settings invalid", "The selected favorite terminal is not available on this computer.")
        return False
Example #2
0
 def prepareCalendar(self, dbName, pentest_type, start_date, end_date, scope, settings, pentesters):
     """
     Initiate a pentest database with wizard info
     Args:
         dbName: the database name
         pentest_type: a pentest type choosen from settings pentest_types. Used to select commands that will be launched by default
         start_date: a begining date and time for the pentest
         end_date: ending date and time for the pentest
         scope: a list of scope valid string (IP, network IP or host name)
         settings: a dict of settings with keys:
             * "Add domains whose IP are in scope": if 1, will do a dns lookup on new domains and check if found IP is in scope
             * "Add domains who have a parent domain in scope": if 1, will add a new domain if a parent domain is in scope
             * "Add all domains found":  Unsafe. if 1, all new domains found by tools will be considered in scope.
     """
     commands = Command.getList({"$or":[{"types":{"$elemMatch":{"$eq":pentest_type}}}, {"types":{"$elemMatch":{"$eq":"Commun"}}}]})
     if not commands:
         commandslist = Command.getList()
         if not commandslist:
             dialog = ChildDialogQuestion(self.parent, "No command found", "There is no registered command in the database. Would you like to import the default set?")
             self.parent.wait_window(dialog.app)
             if dialog.rvalue != "Yes":
                 return
             default = os.path.join(Utils.getMainDir(), "exports/pollenisator_commands.gzip")
             res = self.importCommands(default)
             if res:
                 default = os.path.join(Utils.getMainDir(), "exports/pollenisator_group_commands.gzip")
                 res = self.importCommands(default)
         commands = Command.getList({"$or":[{"types":{"$elemMatch":{"$eq":pentest_type}}}, {"types":{"$elemMatch":{"$eq":"Commun"}}}]})
     #Duplicate commands in local database
     allcommands = Command.fetchObjects({})
     for command in allcommands:
         command.indb = MongoCalendar.getInstance().calendarName
         command.addInDb()
     Wave().initialize(dbName, commands).addInDb()
     Interval().initialize(dbName, start_date, end_date).addInDb()
     values = {"wave":dbName, "Scopes":scope, "Settings":False}
     ScopeController(Scope()).doInsert(values)
     self.settings.reloadSettings()
     self.settings.db_settings["pentest_type"] = pentest_type
     self.settings.db_settings["include_domains_with_ip_in_scope"] = settings['Add domains whose IP are in scope'] == 1
     self.settings.db_settings["include_domains_with_topdomain_in_scope"] = settings["Add domains who have a parent domain in scope"] == 1
     self.settings.db_settings["include_all_domains"] = settings["Add all domains found"] == 1
     self.settings.db_settings["pentesters"] = list(map(lambda x: x.strip(), pentesters.split("\n")))
     self.settings.save()