def __init__(self, command=None, profile_name=None, deletable=True, overwrite=False): HIGWindow.__init__(self) self.connect("delete_event", self.exit) self.set_title(_('Profile Editor')) self.set_position(gtk.WIN_POS_CENTER) self.deletable = deletable self.profile_name = profile_name self.overwrite = overwrite # Used to block recursive updating of the command entry when the # command entry causes the OptionBuilder widgets to change. self.inhibit_command_update = False self.__create_widgets() self.__pack_widgets() self.profile = CommandProfile() self.ops = NmapOptions() if profile_name: log.debug("Showing profile %s" % profile_name) prof = self.profile.get_profile(profile_name) # Interface settings self.profile_name_entry.set_text(profile_name) self.profile_description_text.get_buffer().set_text( prof['description']) command_string = prof['command'] self.ops.parse_string(command_string) if command: self.ops.parse_string(command) self.option_builder = OptionBuilder( Path.profile_editor, self.ops, self.update_command, self.help_field.get_buffer()) log.debug("Option groups: %s" % str(self.option_builder.groups)) log.debug("Option section names: %s" % str( self.option_builder.section_names)) #log.debug("Option tabs: %s" % str(self.option_builder.tabs)) for tab in self.option_builder.groups: self.__create_tab( _(tab), _(self.option_builder.section_names[tab]), self.option_builder.tabs[tab]) self.update_command()
def __init__(self, profile_name=None, deletable=True, overwrite=False): HIGWindow.__init__(self) self.connect("delete_event", self.exit) self.set_title(_('Profile Editor')) self.set_position(gtk.WIN_POS_CENTER) self.deletable = deletable self.profile_name = profile_name self.overwrite = overwrite self.__create_widgets() self.__pack_widgets() self.profile = CommandProfile() options_used = {} if profile_name: log.debug("Showing profile %s" % profile_name) prof = self.profile.get_profile(profile_name) options_used = prof['options'] # Interface settings self.profile_name_entry.set_text(profile_name) self.profile_description_text.get_buffer().set_text( prof['description']) self.constructor = CommandConstructor(options_used) ### self.profilehelp = ProfileHelp(options_used) ### self.options = OptionBuilder(Path.profile_editor, self.constructor, self.update_command, self.profilehelp) log.debug("Option groups: %s" % str(self.options.groups)) log.debug("Option section names: %s" % str(self.options.section_names)) #log.debug("Option tabs: %s" % str(self.options.tabs)) for tab in self.options.groups: self.__create_tab(tab, self.options.section_names[tab], self.options.tabs[tab]) self.update_command()
def update_target_profile(self, parsed): """Update the "Target" and "Profile" entries based on the contents of a parsed scan.""" target = parsed.get_target() profile_name = parsed.get_profile_name() if target: self.toolbar.target_entry.child.set_text(target) else: self.toolbar.target_entry.child.set_text("") if profile_name: profile = CommandProfile() profile.add_profile(profile_name, command=parsed.profile or "", options=parsed.profile_options or "", description=parsed.profile_description or "") del (profile) self.toolbar.profile_entry.update() self.toolbar.selected_profile = profile_name else: self.toolbar.profile_entry.child.set_text("")
def refresh_command_target(self, widget): """Refreshes the command target only if the selected profile is not empty.""" #log.debug(">>> Refresh Command Target") profile = self.toolbar.selected_profile #log.debug(">>> Profile: %s" % profile) if profile != '': target = self.toolbar.selected_target #log.debug(">>> Target: %s" % target) try: cmd_profile = CommandProfile() command = cmd_profile.get_command(profile) % target del (cmd_profile) self.command_toolbar.command = command except ProfileNotFound: pass # Go without a profile except TypeError: pass # The target is empty...