def save_profile(self, widget): if self.overwrite: self.profile.remove_profile(self.profile_name) profile_name = self.profile_name_entry.get_text() if profile_name == '': alert = HIGAlertDialog(message_format=_('Unnamed profile'),\ secondary_text=_('You must provide a name \ for this profile.' )) alert.run() alert.destroy() self.profile_name_entry.grab_focus() return None command = self.constructor.get_command('%s') buf = self.profile_description_text.get_buffer() description = buf.get_text(buf.get_start_iter(),\ buf.get_end_iter()) self.profile.add_profile(profile_name,\ command=command,\ description=description,\ options=self.constructor.get_options()) self.scan_interface.toolbar.profile_entry.update() self.scan_interface.refresh_command(None) self.destroy()
def start_search(self): if not self.options["search_db"] and not self.options["directory"]: d = HIGAlertDialog( message_format=_("No search method selected!"), secondary_text=_("%s can search results on directories or \ inside it's own database. Please, select a method by choosing a directory or by checking \ the search data base option at the 'Search options' tab before start the search" % APP_DISPLAY_NAME)) d.run() d.destroy() return self.clear_result_list() matched = 0 total = 0 if self.options["search_db"]: total += len(self.search_db.get_scan_results()) for result in self.search_db.search(**self.search_dict): self.append_result(result) matched += 1 for search_dir in self.search_dirs.itervalues(): total += len(search_dir.get_scan_results()) for result in search_dir.search(**self.search_dict): self.append_result(result) matched += 1 #total += len(self.search_tabs.get_scan_results()) #for result in self.search_tabs.search(**self.search_dict): # self.append_result(result) # matched += 1 self.search_window.set_label_text("Matched <b>%s</b> out of <b>%s</b> scans." % \ (str(matched), str(total)))
def _create_widgets(self): self.vbox = HIGVBox() self.button_box = gtk.HButtonBox() self.email_label = HIGHintSectionLabel(_("Email"), _("\ Optional. We occasionally contact the reporters of crashes in order to get \ more information.")) self.email_entry = gtk.Entry() self.description_label = gtk.Label(_("\ At the top of this form please write what you were doing when the crash \ happened, as well as any other information you think is relevant.")) self.description_scrolled = gtk.ScrolledWindow() self.description_text = gtk.TextView() self.bug_icon = gtk.Image() self.bug_text = gtk.Label(_("""\ This Bug Report dialog allows you to easily tell us about a problem that you \ may have found in %s. Doing so, you help us to help you, by fixing and \ improving %s faster than usual. Submitting the report will open a description \ of the new bug at the bug tracker.\ """ % (APP_DISPLAY_NAME, APP_DISPLAY_NAME))) self.btn_ok = gtk.Button(stock=gtk.STOCK_OK) self.btn_cancel = gtk.Button(stock=gtk.STOCK_CANCEL) self.hbox = HIGHBox() self.table = HIGTable()
def open_file (self, widget): file_chooser = ResultsFileSingleChooserDialog(_("Select Scan Result")) response = file_chooser.run() file_chosen = file_chooser.get_filename() file_chooser.destroy() if response == gtk.RESPONSE_OK: try: parser = NmapParser() parser.parse_file(file_chosen) except xml.sax.SAXParseException, e: alert = HIGAlertDialog( message_format='<b>%s</b>' % _('Error parsing file'), secondary_text=_("The file is not an Nmap XML output file. \ The parsing error that occurred was\n%s" % str(e))) alert.run() alert.destroy() return False except Exception, e: alert = HIGAlertDialog( message_format='<b>%s</b>' % _('Cannot open selected file'), secondary_text=_("This error occurred while trying to open the file:\n%s" % str(e))) alert.run() alert.destroy() return False
def __init__(self): """Initialize Scan Toolbar, including Events, and packing all of the GUI elements in layout""" HIGHBox.__init__(self) self._create_target() self._create_profile() self.scan_button = gtk.Button(_("Scan")) #self.scan_button = HIGButton(_("Scan "), gtk.STOCK_MEDIA_PLAY) self.cancel_button = gtk.Button(_("Cancel")) #self.cancel_button = HIGButton(_("Cancel "), gtk.STOCK_CANCEL) self._pack_noexpand_nofill(self.target_label) self._pack_expand_fill(self.target_entry) self._pack_noexpand_nofill(self.profile_label) self._pack_expand_fill(self.profile_entry) self._pack_noexpand_nofill(self.scan_button) # Removed until I decide what to do with cancelling aggregated scans. # self._pack_noexpand_nofill(self.cancel_button) # Skip over the dropdown arrow so you can tab to the profile entry. self.target_entry.set_focus_chain((self.target_entry.child, )) self.target_entry.child.connect( 'activate', lambda x: self.profile_entry.grab_focus()) self.profile_entry.child.connect('activate', lambda x: self.scan_button.clicked())
def make_scaninfo_display(self, scaninfo): """Return a widget displaying a scan's "scaninfo" information: type, protocol, number of scanned ports, and list of services.""" hbox = HIGHBox() table = HIGTable() table.set_border_width(5) table.set_row_spacings(6) table.set_col_spacings(6) table.attach(HIGEntryLabel(_('Scan type:')), 0, 1, 0, 1) table.attach(HIGEntryLabel(scaninfo['type']), 1, 2, 0, 1) table.attach(HIGEntryLabel(_('Protocol:')), 0, 1, 1, 2) table.attach(HIGEntryLabel(scaninfo['protocol']), 1, 2, 1, 2) table.attach(HIGEntryLabel(_('# scanned ports:')), 0, 1, 2, 3) table.attach(HIGEntryLabel(scaninfo['numservices']), 1, 2, 2, 3) table.attach(HIGEntryLabel(_('Services:')), 0, 1, 3, 4) table.attach(self.make_services_display(scaninfo['services']), 1, 2, 3, 4) hbox._pack_noexpand_nofill(hig_box_space_holder()) hbox._pack_noexpand_nofill(table) return hbox
def run(): if os.name == "posix": signal.signal(signal.SIGHUP, safe_shutdown) signal.signal(signal.SIGTERM, safe_shutdown) signal.signal(signal.SIGINT, safe_shutdown) try: # Create the ~/.zenmap directory by copying from the system-wide # template directory. zenmapCore.Paths.create_user_config_dir(Path.user_config_dir, Path.config_dir) except (IOError, OSError), e: error_dialog = HIGAlertDialog(message_format = _("Error creating the per-user configuration directory"), secondary_text = _("""\ There was an error creating the directory %s or one of the files in it. \ The directory is created by copying the contents of %s. \ The specific error was\n\ \n\ %s\n\ \n\ %s needs to create this directory to store information such as the list of \ scan profiles. Check for access to the directory and try again.\ """) % (Path.user_config_dir, Path.config_dir, str(e), APP_DISPLAY_NAME)) error_dialog.run() error_dialog.destroy() sys.exit(1)
def help(self, widget): d = HIGAlertDialog( parent=self, message_format=_("Help not implemented"), secondary_text=_("Profile editor help is not implemented yet.")) d.run() d.destroy()
def profile_not_found_dialog(self): warn_dialog = HIGAlertDialog(message_format=_("Profile not found"), secondary_text=_("The profile name you \ selected/typed couldn't be found, and probably doesn't exist. Please, check the profile \ name and try again."), type=gtk.MESSAGE_QUESTION) warn_dialog.run() warn_dialog.destroy()
def __create_widgets(self): ### # Vertical box to keep 3 boxes self.main_whole_box = HIGVBox() self.upper_box = HIGVBox() self.middle_box = HIGHBox() self.lower_box = HIGHBox() #self.main_vbox = HIGVBox() self.command_expander = HIGExpander('<b>' + _('Command') + '</b>') self.command_expander.set_expanded(True) self.command_entry = gtk.Entry() self.command_entry.set_editable(False) self.notebook = gtk.Notebook() # Profile info page self.profile_info_vbox = HIGVBox() self.profile_info_label = HIGSectionLabel(_('Profile Information')) self.profile_name_label = HIGEntryLabel(_('Profile name')) self.profile_name_entry = gtk.Entry() self.profile_name_entry.connect('enter-notify-event', self.update_help_name) self.profile_description_label = HIGEntryLabel(_('Description')) self.profile_description_scroll = HIGScrolledWindow() self.profile_description_scroll.set_border_width(0) self.profile_description_text = HIGTextView() self.profile_description_text.connect('motion-notify-event', self.update_help_desc) # Buttons self.buttons_hbox = HIGHBox() self.help_button = HIGButton(stock=gtk.STOCK_HELP) self.help_button.connect('clicked', self.help) self.cancel_button = HIGButton(stock=gtk.STOCK_CANCEL) self.cancel_button.connect('clicked', self.exit) self.delete_button = HIGButton(stock=gtk.STOCK_DELETE) self.delete_button.connect('clicked', self.delete_profile) self.ok_button = HIGButton(stock=gtk.STOCK_OK) self.ok_button.connect('clicked', self.save_profile) ### self.help_vbox = HIGVBox() self.help_label = HIGSectionLabel(_('Help')) self.help_scroll = HIGScrolledWindow() self.help_scroll.set_border_width(0) self.help_field = HIGTextView() self.help_field.set_cursor_visible(False) self.help_field.set_left_margin(5) self.help_field.set_editable(False) self.help_vbox.set_size_request(200, -1)
def add_extraports_diff(self, host_parent, state, extraports1, extraports2): if extraports1 or extraports2: section = _("Extraports") parent = self.append_parent(host_parent, section, state) self.set_parent_status(parent, state) self.diff_it(parent, "", _("Count"), extraports1.get("count"), extraports2.get("count")) self.diff_it(parent, "", _("State"), extraports1.get("state"), extraports2.get("state"))
def __create_widgets(self): self.property_name_label = HIGEntryLabel("") self.example_label = HIGEntryLabel("") self.bold_tg_button = HIGToggleButton("", gtk.STOCK_BOLD) self.italic_tg_button = HIGToggleButton("", gtk.STOCK_ITALIC) self.underline_tg_button = HIGToggleButton("", gtk.STOCK_UNDERLINE) self.text_color_button = HIGButton(_("Text"), stock=gtk.STOCK_SELECT_COLOR) self.highlight_color_button = HIGButton(_("Highlight"), stock=gtk.STOCK_SELECT_COLOR)
def _create_widgets(self): self.lbl_scan = HIGSectionLabel("%s %s"%(_("Scan Result"), str(self.num))) self.hbox = HIGHBox() self.table = HIGTable() self.list_scan = gtk.ListStore(str) self.combo_scan = gtk.ComboBoxEntry(self.list_scan, 0) self.btn_open_scan = gtk.Button(stock=gtk.STOCK_OPEN) self.exp_scan = gtk.Expander(_("Scan Result Visualization")) self.scrolled = gtk.ScrolledWindow() self.txt_scan_result = gtk.TextView() self.txg_tag = gtk.TextTag("scan_style")
def _create_widgets(self): self.diff_box = HIGHBox() self.diff_title = HIGSectionLabel("Comparison") self.diff_scrolled = gtk.ScrolledWindow() self.diff_tree = gtk.TreeStore(str, str, str, str, str, str) self.diff_view = gtk.TreeView(self.diff_tree) self.diff_column1 = gtk.TreeViewColumn("") self.diff_column2 = gtk.TreeViewColumn(_("Section")) self.diff_column3 = gtk.TreeViewColumn(_("Property")) self.diff_column4 = gtk.TreeViewColumn(_("Original value")) self.diff_column5 = gtk.TreeViewColumn(_("Current value")) self.diff_cell = gtk.CellRendererText()
def get_services(self): services = [] for port in self.ports: for p in port.get("port", []): services.append({"service_name":p.get("service_name", _("unknown")), "portid":p.get("portid", ""), "service_version":p.get("service_version", _("Unknown version")), "service_product":p.get("service_product", ""), "service_extrainfo":p.get("service_extrainfo", ""), "port_state":p.get("port_state", _("Unknown")), "protocol":p.get("protocol", "")}) return services
def __init__(self): HIGDialog.__init__(self) self.set_title( _("About %s and %s" % (NMAP_DISPLAY_NAME, APP_DISPLAY_NAME))) self.vbox.set_border_width(12) self.vbox.set_spacing(12) label = gtk.Label() label.set_markup("<span size=\"xx-large\" weight=\"bold\">%s %s</span>" \ % (escape(APP_DISPLAY_NAME), escape(VERSION))) label.set_selectable(True) self.vbox.pack_start(label) label = gtk.Label() label.set_markup("<span size=\"small\">%s</span>" \ % (escape(APP_COPYRIGHT))) self.vbox.pack_start(label) entry = _program_entry( NMAP_DISPLAY_NAME, NMAP_WEB_SITE, """\ %s is a free and open source utility for network exploration and security \ auditing.""" % NMAP_DISPLAY_NAME) self.vbox.pack_start(entry) entry = _program_entry(APP_DISPLAY_NAME, APP_WEB_SITE, """\ %s is a multi-platform graphical %s frontend and results viewer. It was \ originally derived from %s.""" \ % (APP_DISPLAY_NAME, NMAP_DISPLAY_NAME, UMIT_DISPLAY_NAME)) self.vbox.pack_start(entry) entry = _program_entry(UMIT_DISPLAY_NAME, UMIT_WEB_SITE, """\ %s is an %s GUI created as part of the Nmap/Google Summer of Code program.""" \ % (UMIT_DISPLAY_NAME, NMAP_DISPLAY_NAME)) button = gtk.Button(_("%s credits" % UMIT_DISPLAY_NAME)) button.connect("clicked", self._show_umit_credits) entry.hbox.pack_start(button, False) self.vbox.pack_start(entry) self.vbox.show_all() close_button = self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CANCEL) self.set_default_response(gtk.RESPONSE_CANCEL) close_button.grab_focus() self.set_has_separator(False) self.set_resizable(False) self._umit_credits_dialog = None self.connect("response", self._close)
def generate (self): self.html_file = self.make_file (self.result1, self.result2) self.html_file = ' '.join(self.html_file.split(' ')) txt_diff = Diff (self.result1, self.result2, self.junk) self.text_file = '''<br /><br /> <!-- %s --> <center><div class="header" align="center">%s</div></center> <pre align="center">%s</pre> '''% (_("Changes to this file can make %s unable to read it." % APP_DISPLAY_NAME),\ _('Regular Text Diff: '),\ ''.join(txt_diff.generate ())) return self.insert_banner ()
def _create_widgets(self): self.table = HIGTable() self.unchanged_button = gtk.ColorButton(self.colors.unchanged) self.unchanged_label = gtk.Label(_("Property remained <b>U</b>nchanged")) self.added_button = gtk.ColorButton(self.colors.added) self.added_label = gtk.Label(_("Property was <b>A</b>dded")) self.modified_button = gtk.ColorButton(self.colors.modified) self.modified_label = gtk.Label(_("Property was <b>M</b>odified")) self.not_present_button = gtk.ColorButton(self.colors.not_present) self.not_present_label = gtk.Label(_("Property is <b>N</b>ot present"))
def __init__(self, inventory, scans_store): HIGNotebook.__init__(self) self.set_border_width(5) self.__create_widgets(inventory, scans_store) self.__nmap_output_refreshing() self.scans_list.scans_list.connect("row-activated", self._scan_row_activated) self.append_page(self.nmap_output_page, gtk.Label(_('Nmap Output'))) self.append_page(self.open_ports_page, gtk.Label(_('Ports / Hosts'))) self.append_page(self.topology_page, gtk.Label(_('Topology'))) self.append_page(self.host_details_page, gtk.Label(_('Host Details'))) self.append_page(self.scans_list_page, gtk.Label(_('Scans')))
def __init__(self, scans_store): HIGVBox.__init__(self) self.set_spacing(4) scans_store.connect("row-changed", self._row_changed) self.scans_list = gtk.TreeView(scans_store) self.scans_list.get_selection().connect("changed", self._selection_changed) status_col = gtk.TreeViewColumn("Status") cell = gtk.CellRendererText() status_col.pack_start(cell) status_col.set_cell_data_func(cell, status_data_func) self.scans_list.append_column(status_col) command_col = gtk.TreeViewColumn("Command") cell = gtk.CellRendererText() command_col.pack_start(cell) command_col.set_cell_data_func(cell, command_data_func) self.scans_list.append_column(command_col) scrolled_window = HIGScrolledWindow() scrolled_window.set_border_width(0) scrolled_window.add(self.scans_list) self.pack_start(scrolled_window, True, True) hbox = HIGHBox() buttonbox = gtk.HButtonBox() buttonbox.set_layout(gtk.BUTTONBOX_START) buttonbox.set_spacing(4) self.append_button = HIGButton(_("Append Scan"), gtk.STOCK_ADD) buttonbox.pack_start(self.append_button, False) self.remove_button = HIGButton(_("Remove Scan"), gtk.STOCK_REMOVE) buttonbox.pack_start(self.remove_button, False) self.cancel_button = HIGButton(_("Cancel Scan"), gtk.STOCK_CANCEL) buttonbox.pack_start(self.cancel_button, False) hbox.pack_start(buttonbox, padding=4) self.pack_start(hbox, False, padding=4) self._update()
def __init__(self): gtk.FileFilter.__init__(self) patterns = ["*.xml", "*.usr"] for pattern in patterns: self.add_pattern(pattern) self.set_name(_("Nmap XML files (%s)") % ", ".join(patterns))
def _set_from_scan(self, scan): """Initialize the display from a parsed scan.""" # Command info. self.info_command_label.set_text(scan.get_nmap_command()) self.info_nmap_version_label.set_text(scan.get_scanner_version()) self.info_verbose_label.set_text(scan.get_verbose_level()) self.info_debug_label.set_text(scan.get_debugging_level()) # General info. self.info_start_label.set_text(scan.get_formated_date()) self.info_finished_label.set_text(scan.get_formated_finish_date()) self.info_hosts_up_label.set_text(str(scan.get_hosts_up())) self.info_hosts_down_label.set_text(str(scan.get_hosts_down())) self.info_hosts_scanned_label.set_text(str(scan.get_hosts_scanned())) self.info_open_label.set_text(str(scan.get_open_ports())) self.info_filtered_label.set_text(str(scan.get_filtered_ports())) self.info_closed_label.set_text(str(scan.get_closed_ports())) for scaninfo in scan.get_scaninfo(): exp = gtk.Expander('<b>%s - %s</b>' % (_('Scan Info'), scaninfo['type'].capitalize())) exp.set_use_markup(True) display = self.make_scaninfo_display(scaninfo) exp.add(display) self._pack_noexpand_nofill(exp)
def __init__(self, scans): """scans in the format: {"scan_title":parsed_scan} """ gtk.Window.__init__(self) self.set_title(_("Compare Results")) self.scans = scans self.umit_conf = UmitConf() self.colors = Colors() # Diff views self.text_view = DiffText(self.colors, self.umit_conf.colored_diff) self.compare_view = DiffTree(self.colors) self.temp_html_file = None self._create_widgets() self._pack_widgets() self._connect_widgets() # Settings if self.umit_conf.diff_mode == "text": self.text_mode.set_active(True) else: self.compare_mode.set_active(True) self.check_color.set_active(self.umit_conf.colored_diff) # Initial Size Request self.initial_size = self.size_request()
def __init__(self, scans_store): HIGVBox.__init__(self) # This is a cache of details windows we have open. self._details_windows = {} self.set_spacing(0) hbox = HIGHBox() self.scans_list = gtk.ComboBox(scans_store) cell = gtk.CellRendererText() self.scans_list.pack_start(cell, True) self.scans_list.set_cell_data_func(cell, scan_entry_data_func) hbox._pack_expand_fill(self.scans_list) self.scans_list.connect("changed", self._selection_changed) scans_store.connect("row-changed", self._row_changed) scans_store.connect("row-deleted", self._row_deleted) self.details_button = gtk.Button(_("Details")) self.details_button.connect("clicked", self._show_details) hbox._pack_noexpand_nofill(self.details_button) self._pack_noexpand_nofill(hbox) self.nmap_output = NmapOutputViewer() self._pack_expand_fill(self.nmap_output) self._update()
def _create_widgets (self): self.hbox = HIGHBox () self.lbl_diff = HIGSectionLabel ("<b>%s</b>" % _("Diff Result")) self.scrolled = gtk.ScrolledWindow() self.txt_diff_result = gtk.TextView() self.txg_tag = gtk.TextTag ("diff_style") self.txg_added = gtk.TextTag ('added style') self.txg_removed = gtk.TextTag ('removed style')
def __init__(self): gtk.Window.__init__(self) self.set_title(_('How to Report a Bug')) self.set_position(gtk.WIN_POS_CENTER_ALWAYS) self._create_widgets() self._pack_widgets() self._connect_widgets()
def get_scan_name(self): """Get a human-readable string representing this scan.""" scan_name = self.nmap.get("scan_name") if scan_name: return scan_name if self.profile_name and self.target: return _("%s on %s") % (self.profile_name, self.target) return self.get_nmap_command()
def open_browser(self, widget): text1 = self.scan_chooser1.nmap_output text2 = self.scan_chooser2.nmap_output if text1 is None or text2 is None: alert = HIGAlertDialog( message_format='<b>'+_('Select Scan')+'</b>', secondary_text=_("You must select two different scans to \ generate diff.")) alert.run() alert.destroy() return False if text1 == '' and text2 == '': alert = HIGAlertDialog( message_format='<b>'+_('No Text Output')+'</b>', secondary_text=_("Neither of the scans you selected has \ any text output. (Scans loaded from plain Nmap XML output files do not contain \ text output.) The HTML diff shows only differences between text output, so \ there is nothing to show.")) alert.run() alert.destroy() return False # True tells splitlines to keep line endings. text1 = text1.splitlines(True) text2 = text2.splitlines(True) if self.temp_html_file is not None: self.temp_html_file.close() # A NamedTemporaryFile is deleted when it is closed. self.temp_html_file = tempfile.NamedTemporaryFile(suffix = ".html", prefix = "zenmap-diff-") if use_html: diff = DiffHtml(text1, text2) diff = diff.generate() self.temp_html_file.write(''.join(diff)) else: diff = Diff(text1, text2) diff = diff.generate () diff.insert(0, '''<pre>(This diff is been shown in pure text \ because you dont have Python 2.4 or higher.)\n''') diff.append('</pre>') self.temp_html_file.writelines(diff) self.temp_html_file.flush() webbrowser.open("file://" + self.temp_html_file.name, autoraise=1)
def __init__(self): HIGWindow.__init__(self) self.set_title(_("%s credits" % UMIT_DISPLAY_NAME)) self.set_size_request(-1, 250) self.set_position(gtk.WIN_POS_CENTER) self.__create_widgets() self.__packing() self.set_text()
def __init__(self, colors): # Shows colors and chars legend HIGDialog.__init__(self, title=_('Color Descriptions'), buttons=(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) self.colors = colors self._create_widgets() self._pack_widgets() self._connect_widgets()