def shareCommand(self, command_option):
     selected = self.tvShares.selection()[0]
     parent_iid = self.tvShares.parent(selected)
     if not parent_iid:  # file in share
         return
     ip = self.tvShares.item(parent_iid)["text"]
     item_values = self.tvShares.item(selected)["values"]
     domain = item_values[-2] if item_values[-2] != "" else None
     user = item_values[-1]
     share_name = item_values[0]
     apiclient = APIClient.getInstance()
     apiclient.getCurrentPentest()
     user_o = apiclient.findInDb(apiclient.getCurrentPentest(),
                                 ActiveDirectory.collName, {
                                     "type": "user",
                                     "domain": domain,
                                     "username": user
                                 }, False)
     if user_o is None:
         tk.messagebox.showerror(
             "user not found",
             "User " + str(domain) + "\\" + str(user) + " was not found")
         return
     user = "" if user is None else user
     domain = "" if domain is None else domain
     command_option = command_option.replace("|username|", user)
     command_option = command_option.replace("|domain|", domain)
     command_option = command_option.replace("|password|",
                                             user_o["password"])
     command_option = command_option.replace(
         "|share|", share_name.replace("\\\\", "\\"))
     command_option = command_option.replace("|ip|", ip)
     Utils.executeInExternalTerm(command_option)
Example #2
0
 def openTerminal(cls, default_target=""):
     if cls.settings.isTrapCommand():
         comm = "bash --rcfile " + os.path.join(
             Utils.getMainDir(), "setupTerminalForPentest.sh")
     else:
         comm = "bash"
     env = {
         "POLLENISATOR_DEFAULT_TARGET": default_target,
     }
     res = Utils.executeInExternalTerm(comm, with_bash=False, env=env)
 def computerCommand(self, command_option, ips=None, user=None):
     if ips is None:
         ips = []
         selection = self.tvComputers.selection()
         for selected in selection:
             item = self.tvComputers.item(selected)
             ip = item["text"]
             ips.append(ip)
     if user is None:
         selection_users = self.tvUsers.selection()
         if len(selection_users) >= 1:
             item = self.tvUsers.item(selection_users[0])
             user = (item["values"][1], item["text"], item["values"][0])
         else:
             user = None
     for ip in ips:
         searching = [
             "wordlist", r"ask_text:([^:\|]+)", "users_as_file", "ip"
         ]
         for keyword in searching:
             s = re.search(r"\|" + keyword + r"\|", command_option)
             if s is not None:
                 if keyword == "wordlist":
                     dialog = ChildDialogAskFile(self.tkApp,
                                                 f"Choose a wordlist file")
                     command_option = command_option.replace(
                         s.group(0), dialog.rvalue)
                 elif keyword == "ip":
                     command_option = command_option.replace(s.group(0), ip)
                 elif keyword == "users_as_file":
                     filepath = self.exportAllUsersAsFile()
                     command_option = command_option.replace(
                         s.group(0), filepath)
                 elif "|ask_text:" in s.group(0):
                     what = s.group(1)
                     dialog = ChildDialogAskText(self.tkApp, what)
                     self.tkApp.wait_window(dialog.app)
                     fp = tempfile.mkdtemp()
                     filepath = os.path.join(fp, what + ".txt")
                     with open(filepath, "w") as f:
                         f.write(dialog.rvalue)
                     command_option = command_option.replace(
                         s.group(0), filepath)
         user_searching = {
             "domain": None,
             "username": None,
             "password": None
         }
         if any(
                 map(
                     lambda user_keyword: f"|{user_keyword}|" in
                     command_option, user_searching)):
             if user is not None and len(user) == 3:
                 command_option = command_option.replace(
                     "|domain|", user[0])
                 command_option = command_option.replace(
                     "|username|", user[1])
                 command_option = command_option.replace(
                     "|password|", user[2])
             else:
                 for user_keyword in user_searching:
                     if f"|{user_keyword}|" in command_option:
                         dialog = ChildDialogAskText(self.parent,
                                                     "Enter " +
                                                     str(user_keyword),
                                                     multiline=False)
                         self.parent.wait_window(dialog.app)
                         if dialog.rvalue is None:
                             return
                         command_option = command_option.replace(
                             f"|{user_keyword}|", dialog.rvalue)
         Utils.executeInExternalTerm(command_option)