Esempio n. 1
0
    def _profile_entry_changed(self, widget):
        """Update the command based on the contents of the target and profile
        entries. If the command corresponding to the current profile is not
        blank, use it. Otherwise use the current contents of the command
        entry."""
        profile_name = self.toolbar.get_selected_profile()
        target_string = self.toolbar.get_selected_target()

        cmd_profile = CommandProfile()
        command_string = cmd_profile.get_command(profile_name)
        del(cmd_profile)
        if command_string == "":
            command_string = self.command_toolbar.get_command()

        ops = NmapOptions()
        ops.parse_string(command_string)

        # Use the targets from the command entry, if there are any, otherwise
        # use any targets from the profile.
        targets = split_quoted(target_string)
        if len(targets) > 0:
            ops.target_specs = targets
        else:
            self.toolbar.set_selected_target(join_quoted(ops.target_specs))

        self.set_command_quiet(ops.render_string())
Esempio n. 2
0
    def update(self, search):
        """Updates the search dictionary by parsing the input string."""

        # Kill leftover keys and parse again. SLOW? Not really.
        self.search_dict.clear()

        for word in split_quoted(search):
            if word.find(":") != -1:
                # We have an operator in our word, so we make the part left of
                # the semicolon a key, and the part on the right a value
                op, arg = word.split(":", 1)
                if op in self.ops2keys:
                    key = self.ops2keys[op]
                    if key in self.search_dict:
                        self.search_dict[key].append(arg)
                    else:
                        self.search_dict[key] = [arg]
            else:
                # Just a simple keyword
                if "keyword" in self.search_dict:
                    self.search_dict["keyword"].append(word)
                else:
                    self.search_dict["keyword"] = [word]

        # Check if we have any dir: operators in our map, and if so, add them
        # to the search_gui object and remove them from the map. The dir:
        # operator isn't a real operator, in a sense that it doesn't need to be
        # processed by the SearchResult.search() function. It is needed only to
        # create a new SearchDir object, which is then used to perform the
        # actual search().
        self.search_gui.init_search_dirs(self.search_dict.pop("dir", []))
Esempio n. 3
0
    def _target_entry_changed(self, editable):
        target_string = self.toolbar.get_selected_target()
        targets = split_quoted(target_string)

        ops = NmapOptions()
        ops.parse_string(self.command_toolbar.get_command())
        ops.target_specs = targets
        self.set_command_quiet(ops.render_string())
Esempio n. 4
0
 def get_targets(self):
     return split_quoted(self.get_text().decode("UTF-8"))
Esempio n. 5
0
 def get_targets(self):
     return split_quoted(self.get_text().decode("UTF-8"))