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 _create_widgets(self): self.button_box = gtk.HButtonBox() self.button_box_ok = gtk.HButtonBox() self.description_scrolled = gtk.ScrolledWindow() self.description_text = gtk.TextView() self.description_text.set_editable(False) self.bug_text = gtk.Label() self.bug_text.set_markup( _('An unexpected error has crashed ' '%(app_name)s. Please copy the stack trace below and send it to ' 'the <a href="mailto:[email protected]">[email protected]</a> mailing list. ' '(<a href="http://seclists.org/nmap-dev/">More about the list.</a>' ') The developers will see your report and try to fix the problem.' ) % {"app_name": escape(APP_DISPLAY_NAME)}) self.email_frame = gtk.Frame() self.email_label = gtk.Label() self.email_label.set_markup( _('<b>Copy and email to ' '<a href="mailto:[email protected]">[email protected]</a>:</b>')) self.btn_copy = gtk.Button(stock=gtk.STOCK_COPY) self.btn_ok = gtk.Button(stock=gtk.STOCK_OK) self.hbox = HIGHBox()
def delete_profile(self, widget=None, extra=None): if self.deletable: dialog = HIGDialog(buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) alert = HIGEntryLabel('<b>'+_("Deleting Profile")+'</b>') text = HIGEntryLabel(_('Your profile is going to be deleted! Click\ Ok to continue, or Cancel to go back to Profile Editor.')) hbox = HIGHBox() hbox.set_border_width(5) hbox.set_spacing(12) vbox = HIGVBox() vbox.set_border_width(5) vbox.set_spacing(12) image = gtk.Image() image.set_from_stock(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG) vbox.pack_start(alert) vbox.pack_start(text) hbox.pack_start(image) hbox.pack_start(vbox) dialog.vbox.pack_start(hbox) dialog.vbox.show_all() response = dialog.run() dialog.destroy() if response == gtk.RESPONSE_CANCEL: return True self.profile.remove_profile(self.profile_name) self.update_profile_entry() self.destroy()
def __init__(self, scans): gtk.Window.__init__(self) self.set_title(_("Compare Results")) self.ndiff_process = None # We allow the user to start a new diff before the old one has # finished. We have to keep references to old processes until they # finish to avoid problems when tearing down the Python interpreter at # program exit. self.old_processes = [] self.timer_id = None self.main_vbox = HIGVBox() self.diff_view = DiffView() self.diff_view.set_size_request(-1, 100) self.hbox_buttons = HIGHBox() self.progress = gtk.ProgressBar() self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE) self.hbox_selection = HIGHBox() self.scan_chooser_a = ScanChooser(scans, _(u"A Scan")) self.scan_chooser_b = ScanChooser(scans, _(u"B Scan")) self._pack_widgets() self._connect_widgets() self.set_default_size(-1, 500) # Initial Size Request self.initial_size = self.get_size()
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) 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 __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) 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 _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 _create_widgets(self): # Search box and buttons self.search_top_hbox = HIGHBox() self.search_label = HIGSectionLabel(_("Search:")) self.search_entry = gtk.Entry() self.expressions_btn = HIGToggleButton(_("Expressions "), gtk.STOCK_EDIT) # The quick reference tooltip button self.search_tooltip_btn = HIGButton(" ", gtk.STOCK_INFO) # The expression VBox. This is only visible once the user clicks on # "Expressions" self.expr_vbox = gtk.VBox() # Results section self.result_list = gtk.ListStore(str, str, int) # title, date, id self.result_view = gtk.TreeView(self.result_list) self.result_scrolled = gtk.ScrolledWindow() self.result_title_column = gtk.TreeViewColumn(_("Scan")) self.result_date_column = gtk.TreeViewColumn(_("Date")) self.no_db_warning = gtk.Label() self.no_db_warning.set_line_wrap(True) self.no_db_warning.set_no_show_all(True) self.expr_window = None
def create_table_hbox(self): table = HIGTable() hbox = HIGHBox() hbox._pack_noexpand_nofill(hig_box_space_holder()) hbox._pack_noexpand_nofill(table) return table, hbox
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): """Initialize command toolbar""" HIGHBox.__init__(self) self.command_label = HIGEntryLabel(_("Command:")) self.command_entry = gtk.Entry() self._pack_noexpand_nofill(self.command_label) self._pack_expand_fill(self.command_entry)
def __create_widgets(self): ### # Vertical box to keep 3 boxes self.main_whole_box = HIGVBox() self.upper_box = HIGHBox() self.middle_box = HIGHBox() self.lower_box = HIGHBox() #self.main_vbox = HIGVBox() self.command_entry = gtk.Entry() self.command_entry_changed_cb_id = self.command_entry.connect( "changed", self.command_entry_changed_cb) self.scan_button = HIGButton(_("Scan")) self.scan_button.connect("clicked", self.run_scan) 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.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.save_button = HIGButton(_("Save Changes"), stock=gtk.STOCK_SAVE) self.save_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 _create_widgets(self): self.main_vbox = HIGVBox() self.diff_view = DiffView() self.diff_view.set_size_request(-1, 100) self.hbox_buttons = HIGHBox() self.progress = gtk.ProgressBar() self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE) self.hbox_selection = HIGHBox() self.scan_chooser_a = ScanChooser(self.scans, _(u"A Scan")) self.scan_chooser_b = ScanChooser(self.scans, _(u"B Scan"))
def __init__(self, param=""): HIGHBox.__init__(self) self.entry = OptionEntry() self.button = HIGButton(stock=gtk.STOCK_OPEN) self._pack_expand_fill(self.entry) self._pack_noexpand_nofill(self.button) self.entry.set_text(param) self.button.connect('clicked', self.open_dialog_cb)
def _create_widgets(self): self.lbl_scan = HIGSectionLabel(self.title) 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 Output")) 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 __init__(self, root_tabs, ops, update_command, help_buf): self.hmainbox = HIGHBox(False, 0) self.notscripttab = False # show profile editor it is a script tab self.nmap_process = None self.script_list_timeout_id = None self.nmap_timeout_id = None self.chk_nmap_timeout_id = None self.script_file_chooser = None self.ops = ops self.update_command = update_command self.help_buf = help_buf self.arg_values = {} self.current_arguments = [] self.set_help_texts() self.prev_script_spec = None self.focusedentry = None self.liststore = gtk.ListStore(str, "gboolean", object) self.file_liststore = gtk.ListStore(str, "gboolean") # Arg name, arg value, (name, desc) tuple. self.arg_liststore = gtk.ListStore(str, str, object) # This is what is shown initially. After the initial Nmap run to get # the list of script is finished, this will be replaced with a TreeView # showing the scripts or an error message. self.script_list_container = gtk.VBox() self.script_list_container.pack_start(self.make_please_wait_widget()) self.hmainbox.pack_start(self.script_list_container, False, False, 0) self.nmap_error_widget = gtk.Label( _("There was an error getting the list of scripts from Nmap. " "Try upgrading Nmap.")) self.nmap_error_widget.set_line_wrap(True) self.nmap_error_widget.show_all() self.script_list_widget = self.make_script_list_widget() self.script_list_widget.show_all() vbox = HIGVBox(False, 5) vbox.pack_start(self.make_description_widget(), True, True, 0) vbox.pack_start(self.make_arguments_widget(), True, True, 0) self.hmainbox.pack_end(vbox, True, True, 0) self.update_argument_values(self.ops["--script-args"]) # Start the initial backgrounded Nmap run to get the list of all # available scripts. self.get_script_list("all", self.initial_script_list_cb)
def _create_widgets(self): # The second toolbar: command entry field + buttons self.second_toolbar = HIGHBox() self.rn_hbox = gtk.HBox() self.rn_hbox.set_spacing(4) self.rn_vbox = gtk.VBox() # RadialNet's widgets self.radialnet = RadialNet(LAYOUT_WEIGHTED) self.control = ControlWidget(self.radialnet) self.fisheye = ControlFisheye(self.radialnet) self.rn_toolbar = Toolbar(self.radialnet, self, self.control, self.fisheye)
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.throbber = Throbber() hbox._pack_noexpand_nofill(self.throbber) 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()
class TopologyPage(HIGVBox): def __init__(self, inventory): HIGVBox.__init__(self) self.set_border_width(6) self.set_spacing(4) self.network_inventory = inventory self._create_widgets() self._pack_widgets() def _create_widgets(self): # The second toolbar: command entry field + buttons self.second_toolbar = HIGHBox() self.rn_hbox = gtk.HBox() self.rn_hbox.set_spacing(4) self.rn_vbox = gtk.VBox() # RadialNet's widgets self.radialnet = RadialNet(LAYOUT_WEIGHTED) self.control = ControlWidget(self.radialnet) self.fisheye = ControlFisheye(self.radialnet) self.rn_toolbar = Toolbar(self.radialnet, self, self.control, self.fisheye) def _pack_widgets(self): self.second_toolbar.pack_start(self.rn_toolbar, False) self.rn_hbox.pack_start(self.radialnet, True, True) self.rn_hbox.pack_start(self.control, False) self.rn_vbox.pack_start(self.rn_hbox, True, True) self.rn_vbox.pack_start(self.fisheye, False) self.pack_start(self.second_toolbar, False, False) self.pack_start(self.rn_vbox, True, True) def add_scan(self, scan): """Parses a given XML file and adds the parsed result to the network inventory.""" self.network_inventory.add_scan(scan) self.update_radialnet() def update_radialnet(self): """Creates a graph from network inventory's host list and displays it.""" graph = make_graph_from_hosts(self.network_inventory.get_hosts()) self.radialnet.set_empty() self.radialnet.set_graph(graph) self.radialnet.show()
def __init__(self): """ """ super(SaveDialog, self).__init__(title=_("Save Topology"), action=gtk.FILE_CHOOSER_ACTION_SAVE, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK)) types_store = gtk.ListStore(str, object, str) for type in TYPES: types_store.append(type) self.__combo = gtk.ComboBox(types_store) cell = gtk.CellRendererText() self.__combo.pack_start(cell, True) self.__combo.add_attribute(cell, "text", 0) self.__combo.connect("changed", self.__combo_changed_cb) self.__combo.set_active(0) self.connect("response", self.__response_cb) hbox = HIGHBox() label = gtk.Label(_("Select File Type:")) hbox.pack_end(self.__combo, False) hbox.pack_end(label, False) self.set_extra_widget(hbox) self.set_do_overwrite_confirmation(True) hbox.show_all()
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, 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 _create_widgets(self): self.button_box = gtk.HButtonBox() self.button_box_ok = gtk.HButtonBox() self.description_scrolled = gtk.ScrolledWindow() self.description_text = gtk.TextView() self.description_text.set_editable(False) self.bug_text = gtk.Label() self.bug_text.set_markup( _( "An unexpected error has crashed " "%(app_name)s. Please copy the stack trace below and send it to " 'the <a href="mailto:[email protected]">[email protected]</a> mailing list. ' '(<a href="http://seclists.org/nmap-dev/">More about the list.</a>' ") The developers will see your report and try to fix the problem." ) % {"app_name": escape(APP_DISPLAY_NAME)} ) self.email_frame = gtk.Frame() self.email_label = gtk.Label() self.email_label.set_markup(_("<b>Copy and email to " '<a href="mailto:[email protected]">[email protected]</a>:</b>')) self.btn_copy = gtk.Button(stock=gtk.STOCK_COPY) self.btn_ok = gtk.Button(stock=gtk.STOCK_OK) self.hbox = HIGHBox()
def _create_widgets(self): self.vbox = HIGVBox() self.button_box = gtk.HButtonBox() self.email_label = gtk.Label(_("""\ An email address is optional. Sometimes we use it to get more information. If \ you provide an email address your report will be marked private so only \ project developers can read it.\ """)) self.email_entry = gtk.Entry() self.summary_entry = gtk.Entry() self.description_label = gtk.Label(_("\ What were you doing when the crash happened?\ ")) self.description_scrolled = gtk.ScrolledWindow() self.description_text = gtk.TextView() self.bug_text = gtk.Label(_("""\ An unhandled exception has crashed Zenmap. This dialog allows you to tell us \ what you did to cause the crash and help us to fix it. Submitting the report \ will open a description of the new bug at the bug tracker. Feel free to edit \ the report to remove any identifying information such as your home directory.\ """)) 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 __create_widgets(self): ### # Vertical box to keep 3 boxes self.main_whole_box = HIGVBox() self.upper_box = HIGHBox() self.middle_box = HIGHBox() self.lower_box = HIGHBox() #self.main_vbox = HIGVBox() self.command_entry = gtk.Entry() self.command_entry_changed_cb_id = self.command_entry.connect( "changed", self.command_entry_changed_cb) self.scan_button = HIGButton(_("Scan")) self.scan_button.connect("clicked", self.run_scan) 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.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.save_button = HIGButton(_("Save Changes"), stock=gtk.STOCK_SAVE) self.save_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 set_comment(self, comment=""): self.comment_expander.set_use_markup(True) if comment: self.comment_expander.set_expanded(True) hbox = HIGHBox() self.comment_scrolled = gtk.ScrolledWindow() self.comment_scrolled.set_border_width(5) self.comment_scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.comment_txt_vw = gtk.TextView() self.comment_txt_vw.set_wrap_mode(gtk.WRAP_WORD) self.comment_txt_vw.get_buffer().set_text(comment) self.comment_scrolled.add(self.comment_txt_vw) hbox._pack_expand_fill(self.comment_scrolled) self.comment_expander.add(hbox) self._pack_noexpand_nofill(self.comment_expander)
def set_comment(self, comment=''): self.comment_expander.set_use_markup(True) if comment: self.comment_expander.set_expanded(True) hbox = HIGHBox() self.comment_scrolled = gtk.ScrolledWindow() self.comment_scrolled.set_border_width(5) self.comment_scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.comment_txt_vw = gtk.TextView() self.comment_txt_vw.set_wrap_mode(gtk.WRAP_WORD) self.comment_txt_vw.get_buffer().set_text(comment) self.comment_scrolled.add(self.comment_txt_vw) hbox._pack_expand_fill(self.comment_scrolled) self.comment_expander.add(hbox) self._pack_noexpand_nofill(self.comment_expander)
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 __create_widgets(self): self.vbox = HIGVBox() self.hbox = HIGHBox() self.notebook = HIGNotebook() self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE) self.written_by_scroll = HIGScrolledWindow() self.written_by_text = HIGTextView() self.design_scroll = HIGScrolledWindow() self.design_text = HIGTextView() self.soc2007_scroll = HIGScrolledWindow() self.soc2007_text = HIGTextView() self.contributors_scroll = HIGScrolledWindow() self.contributors_text = HIGTextView() self.translation_scroll = HIGScrolledWindow() self.translation_text = HIGTextView() self.nokia_scroll = HIGScrolledWindow() self.nokia_text = HIGTextView()
def __init__(self): HIGHBox.__init__(self) self.information_label = gtk.Label() self.entry = gtk.Entry() self.pack_start(self.information_label, False) self.information_label.show() label = gtk.Label(_("Host Filter:")) self.pack_start(label, False) label.show() self.pack_start(self.entry, True, True) self.entry.show() help_button = gtk.Button() icon = gtk.Image() icon.set_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_BUTTON) help_button.add(icon) help_button.connect("clicked", self._help_button_clicked) self.pack_start(help_button, False) help_button.show_all() self.entry.connect("changed", lambda x: self.emit("changed"))
def _create_widgets(self): # Ports view self.port_columns = {} self.port_list = gtk.ListStore(str, str, int, str, str, str, str) self.port_tree = gtk.TreeStore(str, str, int, str, str, str, str) self.port_view = gtk.TreeView(self.port_list) self.cell_icon = gtk.CellRendererPixbuf() self.cell_port = gtk.CellRendererText() self.port_columns['hostname'] = gtk.TreeViewColumn(_('Host')) self.port_columns['icon'] = gtk.TreeViewColumn('') self.port_columns['port_number'] = gtk.TreeViewColumn(_('Port')) self.port_columns['protocol'] = gtk.TreeViewColumn(_('Protocol')) self.port_columns['state'] = gtk.TreeViewColumn(_('State')) self.port_columns['service'] = gtk.TreeViewColumn(_('Service')) self.port_columns['version'] = gtk.TreeViewColumn(_('Version')) # Host services view self.host_columns = {} self.host_list = gtk.ListStore(str, str, str, int, str, str, str) self.host_tree = gtk.TreeStore(str, str, str, int, str, str, str) self.host_view = gtk.TreeView(self.host_list) self.cell_host_icon = gtk.CellRendererPixbuf() self.cell_host = gtk.CellRendererText() self.host_columns['service'] = gtk.TreeViewColumn(_('Service')) self.host_columns['hostname'] = gtk.TreeViewColumn(_('Hostname')) self.host_columns['icon'] = gtk.TreeViewColumn('') self.host_columns['protocol'] = gtk.TreeViewColumn(_('Protocol')) self.host_columns['port_number'] = gtk.TreeViewColumn(_('Port')) self.host_columns['state'] = gtk.TreeViewColumn(_('State')) self.host_columns['version'] = gtk.TreeViewColumn(_('Version')) self.scroll_ports_hosts = gtk.ScrolledWindow() self.expander_sorting = gtk.Expander(_('Display Order / Grouping')) self.hbox_sort_group = HIGHBox() self.frame_sort = gtk.Frame() self.frame_group = gtk.Frame() self.table_sort = HIGTable() self.table_group = HIGTable() self.radio_sort_port = gtk.RadioButton(None, _('Sort by port number')) self.radio_sort_service = gtk.RadioButton(self.radio_sort_port,\ _('Sort by service name'))
def _create_widgets(self): self.main_vbox = HIGVBox() self.hbox_mode = HIGHBox() self.hbox_settings = HIGHBox() self.hbox_buttons = HIGHBox() self.hbox_result = HIGHBox() self.btn_open_browser = HIGButton(_("Open in Browser"), stock=gtk.STOCK_EXECUTE) self.btn_help = HIGButton(stock=gtk.STOCK_HELP) self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE) self.check_color = gtk.CheckButton(_("Enable colored diffies")) self.btn_legend = HIGButton(_("Color Descriptions"), stock=gtk.STOCK_SELECT_COLOR) self.text_mode = gtk.ToggleButton(_("Text Mode")) self.compare_mode = gtk.ToggleButton(_("Compare Mode")) self.vpaned = gtk.VPaned() self.hpaned = gtk.HPaned() self.scan_chooser1 = ScanChooser(self.scans, "1") self.scan_chooser2 = ScanChooser(self.scans, "2") self.scan_buffer1 = self.scan_chooser1.get_buffer() self.scan_buffer2 = self.scan_chooser2.get_buffer()
class CrashReport(HIGDialog): def __init__(self, type, value, tb): HIGDialog.__init__(self) gtk.Window.__init__(self) self.set_title(_('Crash Report')) self.set_position(gtk.WIN_POS_CENTER_ALWAYS) self._create_widgets() self._pack_widgets() self._connect_widgets() trace = "".join(traceback.format_exception(type, value, tb)) text = "Version: " + VERSION + "\n" + trace self.description_text.get_buffer().set_text(text) def _create_widgets(self): self.button_box = gtk.HButtonBox() self.button_box_ok = gtk.HButtonBox() self.description_scrolled = gtk.ScrolledWindow() self.description_text = gtk.TextView() self.description_text.set_editable(False) self.bug_text = gtk.Label() self.bug_text.set_markup(_("""\ An unexpected error has crashed %(app_name)s. Please copy the stack trace below and \ send it to the <a href="mailto:[email protected]">[email protected]</a> \ mailing list. (<a href="http://seclists.org/nmap-dev/">More about the list.</a>) \ The developers will see your report and try to fix the problem.""") % \ { "app_name": escape(APP_DISPLAY_NAME) }) self.email_frame = gtk.Frame() self.email_label = gtk.Label() self.email_label.set_markup(_("""\ <b>Copy and email to <a href="mailto:[email protected]">[email protected]</a>:</b>\ """)) self.btn_copy = gtk.Button(stock=gtk.STOCK_COPY) self.btn_ok = gtk.Button(stock=gtk.STOCK_OK) self.hbox = HIGHBox() def _pack_widgets(self): self.description_scrolled.add(self.description_text) self.description_scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.description_scrolled.set_size_request(400, 150) self.description_text.set_wrap_mode(gtk.WRAP_WORD) self.bug_text.set_line_wrap(True) self.email_label.set_line_wrap(True) self.email_frame.set_label_widget(self.email_label) self.email_frame.set_shadow_type(gtk.SHADOW_NONE) self.hbox.set_border_width(6) self.vbox.set_border_width(6) self.hbox._pack_expand_fill(self.bug_text) self.button_box.set_layout(gtk.BUTTONBOX_START) self.button_box_ok.set_layout(gtk.BUTTONBOX_END) self.button_box.pack_start(self.btn_copy) self.button_box_ok.pack_start(self.btn_ok) self.vbox.pack_start(self.hbox) self.vbox.pack_start(self.email_frame) self.vbox.pack_start(self.description_scrolled) self.vbox.pack_start(self.button_box) self.action_area.pack_start(self.button_box_ok) def _connect_widgets(self): self.btn_ok.connect("clicked", self.close) self.btn_copy.connect("clicked", self.copy) self.connect("delete-event", self.close) def get_description(self): buff = self.description_text.get_buffer() return buff.get_text(buff.get_start_iter(), buff.get_end_iter()) def copy(self, widget=None, event=None): clipboard = gtk.clipboard_get() clipboard.set_text(self.get_description()) clipboard.store() def close(self, widget=None, event=None): self.destroy() gtk.main_quit() sys.exit(0)
class DiffWindow(gtk.Window): def __init__(self, scans): gtk.Window.__init__(self) self.set_title(_("Compare Results")) self.ndiff_process = None # We allow the user to start a new diff before the old one has # finished. We have to keep references to old processes until they # finish to avoid problems when tearing down the Python interpreter at # program exit. self.old_processes = [] self.timer_id = None self.main_vbox = HIGVBox() self.diff_view = DiffView() self.diff_view.set_size_request(-1, 100) self.hbox_buttons = HIGHBox() self.progress = gtk.ProgressBar() self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE) self.hbox_selection = HIGHBox() self.scan_chooser_a = ScanChooser(scans, _(u"A Scan")) self.scan_chooser_b = ScanChooser(scans, _(u"B Scan")) self._pack_widgets() self._connect_widgets() self.set_default_size(-1, 500) # Initial Size Request self.initial_size = self.get_size() def _pack_widgets(self): self.main_vbox.set_border_width(6) self.hbox_selection.pack_start(self.scan_chooser_a, True, True) self.hbox_selection.pack_start(self.scan_chooser_b, True, True) self.main_vbox.pack_start(self.hbox_selection, False) scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scroll.add(self.diff_view) self.main_vbox.pack_start(scroll, True, True) self.progress.hide() self.progress.set_no_show_all(True) self.hbox_buttons.pack_start(self.progress, False) self.hbox_buttons.pack_end(self.btn_close, False) self.main_vbox._pack_noexpand_nofill(self.hbox_buttons) self.add(self.main_vbox) def _connect_widgets(self): self.connect("delete-event", self.close) self.btn_close.connect("clicked", self.close) self.scan_chooser_a.connect('changed', self.refresh_diff) self.scan_chooser_b.connect('changed', self.refresh_diff) def refresh_diff(self, widget): """This method is called whenever the diff output might have changed, such as when a different scan was selected in one of the choosers.""" log.debug("Refresh diff.") if (self.ndiff_process is not None and self.ndiff_process.poll() is None): # Put this in the list of old processes we keep track of. self.old_processes.append(self.ndiff_process) self.ndiff_process = None scan_a = self.scan_chooser_a.parsed_scan scan_b = self.scan_chooser_b.parsed_scan if scan_a is None or scan_b is None: self.diff_view.clear() else: try: self.ndiff_process = zenmapCore.Diff.ndiff(scan_a, scan_b) except OSError, e: alert = HIGAlertDialog( message_format=_("Error running ndiff"), secondary_text=_( "There was an error running the ndiff program.\n\n" ) + str(e).decode(sys.getdefaultencoding(), "replace")) alert.run() alert.destroy() else:
class ScanRunDetailsPage(HIGVBox): def __init__(self, scan): HIGVBox.__init__(self) na = _('Not available') # Command info self.command_label = HIGEntryLabel(_('Command:')) self.info_command_label = HIGEntryLabel(na) self.nmap_version_label = HIGEntryLabel(_('Nmap Version:')) self.info_nmap_version_label = HIGEntryLabel(na) self.verbose_label = HIGEntryLabel(_('Verbosity level:')) self.info_verbose_label = HIGEntryLabel(na) self.debug_label = HIGEntryLabel(_('Debug level:')) self.info_debug_label = HIGEntryLabel(na) self.command_expander = gtk.Expander( "<b>" + _("Command Info") + "</b>") self.command_expander.set_use_markup(True) self.command_table = HIGTable() self.command_table.set_border_width(5) self.command_table.set_row_spacings(6) self.command_table.set_col_spacings(6) self.command_hbox = HIGHBox() self.command_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.command_hbox._pack_noexpand_nofill(self.command_table) self.command_table.attach(self.command_label, 0, 1, 0, 1) self.command_table.attach(self.info_command_label, 1, 2, 0, 1) self.command_table.attach(self.nmap_version_label, 0, 1, 1, 2) self.command_table.attach(self.info_nmap_version_label, 1, 2, 1, 2) self.command_table.attach(self.verbose_label, 0, 1, 2, 3) self.command_table.attach(self.info_verbose_label, 1, 2, 2, 3) self.command_table.attach(self.debug_label, 0, 1, 3, 4) self.command_table.attach(self.info_debug_label, 1, 2, 3, 4) self.command_expander.add(self.command_hbox) self._pack_noexpand_nofill(self.command_expander) self.command_expander.set_expanded(True) # General info: self.start_label = HIGEntryLabel(_('Started on:')) self.info_start_label = HIGEntryLabel(na) self.finished_label = HIGEntryLabel(_('Finished on:')) self.info_finished_label = HIGEntryLabel(na) self.host_up_label = HIGEntryLabel(_('Hosts up:')) self.info_hosts_up_label = HIGEntryLabel(na) self.host_down_label = HIGEntryLabel(_('Hosts down:')) self.info_hosts_down_label = HIGEntryLabel(na) self.host_scanned_label = HIGEntryLabel(_('Hosts scanned:')) self.info_hosts_scanned_label = HIGEntryLabel(na) self.open_label = HIGEntryLabel(_('Open ports:')) self.info_open_label = HIGEntryLabel(na) self.filtered_label = HIGEntryLabel(_('Filtered ports:')) self.info_filtered_label = HIGEntryLabel(na) self.closed_label = HIGEntryLabel(_('Closed ports:')) self.info_closed_label = HIGEntryLabel(na) self.general_expander = gtk.Expander( "<b>" + _("General Info") + "</b>") self.general_expander.set_use_markup(True) self.general_table = HIGTable() self.general_table.set_border_width(5) self.general_table.set_row_spacings(6) self.general_table.set_col_spacings(6) self.general_hbox = HIGHBox() self.general_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.general_hbox._pack_noexpand_nofill(self.general_table) self.general_table.attach(self.start_label, 0, 1, 0, 1) self.general_table.attach(self.info_start_label, 1, 2, 0, 1) self.general_table.attach(self.finished_label, 0, 1, 1, 2) self.general_table.attach(self.info_finished_label, 1, 2, 1, 2) self.general_table.attach(self.host_up_label, 0, 1, 2, 3) self.general_table.attach(self.info_hosts_up_label, 1, 2, 2, 3) self.general_table.attach(self.host_down_label, 0, 1, 3, 4) self.general_table.attach(self.info_hosts_down_label, 1, 2, 3, 4) self.general_table.attach(self.host_scanned_label, 0, 1, 4, 5) self.general_table.attach(self.info_hosts_scanned_label, 1, 2, 4, 5) self.general_table.attach(self.open_label, 0, 1, 5, 6) self.general_table.attach(self.info_open_label, 1, 2, 5, 6) self.general_table.attach(self.filtered_label, 0, 1, 6, 7) self.general_table.attach(self.info_filtered_label, 1, 2, 6, 7) self.general_table.attach(self.closed_label, 0, 1, 7, 8) self.general_table.attach(self.info_closed_label, 1, 2, 7, 8) self.general_expander.add(self.general_hbox) self._pack_noexpand_nofill(self.general_expander) self.general_expander.set_expanded(True) self._set_from_scan(scan) 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_formatted_date()) self.info_finished_label.set_text(scan.get_formatted_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 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 make_services_display(self, services): """Return a widget displaying a list of services like 1-1027,1029-1033,1040,1043,1050,1058-1059,1067-1068,1076,1080""" combo = gtk.combo_box_new_text() for i in services.split(","): combo.append_text(i) return combo
class ScanChooser(HIGVBox): """This class allows the selection of scan results from the list of open tabs or from a file. It emits the "changed" signal when the scan selection has changed.""" __gsignals__ = { "changed": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ()) } def __init__(self, scans, title): self.__gobject_init__() self.title = title self.scan_dict = {} # Setting HIGVBox self.set_border_width(5) self.set_spacing(6) self._create_widgets() self._pack_hbox() self._attaching_widgets() self._set_scrolled() self._set_text_view() self._set_open_button() for scan in scans: self.add_scan(scan.scan_name or scan.get_nmap_command(), scan) self.combo_scan.connect('changed', self.show_scan) self.combo_scan.connect('changed', lambda x: self.emit('changed')) self._pack_noexpand_nofill(self.lbl_scan) self._pack_expand_fill(self.hbox) def _create_widgets(self): self.lbl_scan = HIGSectionLabel(self.title) 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 Output")) self.scrolled = gtk.ScrolledWindow() self.txt_scan_result = gtk.TextView() self.txg_tag = gtk.TextTag("scan_style") def get_buffer(self): return self.txt_scan_result.get_buffer() def show_scan(self, widget): nmap_output = self.get_nmap_output() if nmap_output: self.txt_scan_result.get_buffer().set_text(nmap_output) def normalize_output(self, output): return "\n".join(output.split("\\n")) def _pack_hbox(self): self.hbox._pack_noexpand_nofill(hig_box_space_holder()) self.hbox._pack_expand_fill(self.table) def _attaching_widgets(self): self.table.attach(self.combo_scan, 0, 1, 0, 1, yoptions=0) self.table.attach( self.btn_open_scan, 1, 2, 0, 1, yoptions=0, xoptions=0) self.table.attach(self.exp_scan, 0, 2, 1, 2) def _set_scrolled(self): self.scrolled.set_border_width(5) self.scrolled.set_size_request(-1, 130) # Packing scrolled window into expander self.exp_scan.add(self.scrolled) # Packing text view into scrolled window self.scrolled.add_with_viewport(self.txt_scan_result) # Setting scrolled window self.scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) def _set_text_view(self): self.txg_table = self.txt_scan_result.get_buffer().get_tag_table() self.txg_table.add(self.txg_tag) self.txg_tag.set_property("family", "Monospace") self.txt_scan_result.set_wrap_mode(gtk.WRAP_WORD) self.txt_scan_result.set_editable(False) self.txt_scan_result.get_buffer().connect( "changed", self._text_changed_cb) def _set_open_button(self): self.btn_open_scan.connect('clicked', self.open_file) 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: %s""") % str(e)) alert.run() alert.destroy() return False scan_name = os.path.split(file_chosen)[-1] self.add_scan(scan_name, parser) self.combo_scan.set_active(len(self.list_scan) - 1)
def __init__(self, scan): HIGVBox.__init__(self) na = _('Not available') # Command info self.command_label = HIGEntryLabel(_('Command:')) self.info_command_label = HIGEntryLabel(na) self.nmap_version_label = HIGEntryLabel(_('Nmap Version:')) self.info_nmap_version_label = HIGEntryLabel(na) self.verbose_label = HIGEntryLabel(_('Verbosity level:')) self.info_verbose_label = HIGEntryLabel(na) self.debug_label = HIGEntryLabel(_('Debug level:')) self.info_debug_label = HIGEntryLabel(na) self.command_expander = gtk.Expander( "<b>" + _("Command Info") + "</b>") self.command_expander.set_use_markup(True) self.command_table = HIGTable() self.command_table.set_border_width(5) self.command_table.set_row_spacings(6) self.command_table.set_col_spacings(6) self.command_hbox = HIGHBox() self.command_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.command_hbox._pack_noexpand_nofill(self.command_table) self.command_table.attach(self.command_label, 0, 1, 0, 1) self.command_table.attach(self.info_command_label, 1, 2, 0, 1) self.command_table.attach(self.nmap_version_label, 0, 1, 1, 2) self.command_table.attach(self.info_nmap_version_label, 1, 2, 1, 2) self.command_table.attach(self.verbose_label, 0, 1, 2, 3) self.command_table.attach(self.info_verbose_label, 1, 2, 2, 3) self.command_table.attach(self.debug_label, 0, 1, 3, 4) self.command_table.attach(self.info_debug_label, 1, 2, 3, 4) self.command_expander.add(self.command_hbox) self._pack_noexpand_nofill(self.command_expander) self.command_expander.set_expanded(True) # General info: self.start_label = HIGEntryLabel(_('Started on:')) self.info_start_label = HIGEntryLabel(na) self.finished_label = HIGEntryLabel(_('Finished on:')) self.info_finished_label = HIGEntryLabel(na) self.host_up_label = HIGEntryLabel(_('Hosts up:')) self.info_hosts_up_label = HIGEntryLabel(na) self.host_down_label = HIGEntryLabel(_('Hosts down:')) self.info_hosts_down_label = HIGEntryLabel(na) self.host_scanned_label = HIGEntryLabel(_('Hosts scanned:')) self.info_hosts_scanned_label = HIGEntryLabel(na) self.open_label = HIGEntryLabel(_('Open ports:')) self.info_open_label = HIGEntryLabel(na) self.filtered_label = HIGEntryLabel(_('Filtered ports:')) self.info_filtered_label = HIGEntryLabel(na) self.closed_label = HIGEntryLabel(_('Closed ports:')) self.info_closed_label = HIGEntryLabel(na) self.general_expander = gtk.Expander( "<b>" + _("General Info") + "</b>") self.general_expander.set_use_markup(True) self.general_table = HIGTable() self.general_table.set_border_width(5) self.general_table.set_row_spacings(6) self.general_table.set_col_spacings(6) self.general_hbox = HIGHBox() self.general_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.general_hbox._pack_noexpand_nofill(self.general_table) self.general_table.attach(self.start_label, 0, 1, 0, 1) self.general_table.attach(self.info_start_label, 1, 2, 0, 1) self.general_table.attach(self.finished_label, 0, 1, 1, 2) self.general_table.attach(self.info_finished_label, 1, 2, 1, 2) self.general_table.attach(self.host_up_label, 0, 1, 2, 3) self.general_table.attach(self.info_hosts_up_label, 1, 2, 2, 3) self.general_table.attach(self.host_down_label, 0, 1, 3, 4) self.general_table.attach(self.info_hosts_down_label, 1, 2, 3, 4) self.general_table.attach(self.host_scanned_label, 0, 1, 4, 5) self.general_table.attach(self.info_hosts_scanned_label, 1, 2, 4, 5) self.general_table.attach(self.open_label, 0, 1, 5, 6) self.general_table.attach(self.info_open_label, 1, 2, 5, 6) self.general_table.attach(self.filtered_label, 0, 1, 6, 7) self.general_table.attach(self.info_filtered_label, 1, 2, 6, 7) self.general_table.attach(self.closed_label, 0, 1, 7, 8) self.general_table.attach(self.info_closed_label, 1, 2, 7, 8) self.general_expander.add(self.general_hbox) self._pack_noexpand_nofill(self.general_expander) self.general_expander.set_expanded(True) self._set_from_scan(scan)
class ProfileEditor(HIGWindow): 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 command_entry_changed_cb(self, widget): command_string = self.command_entry.get_text().decode("UTF-8") self.ops.parse_string(command_string) self.inhibit_command_update = True self.option_builder.update() self.inhibit_command_update = False def update_command(self): """Regenerate and display the command.""" if not self.inhibit_command_update: # Block recursive updating of the OptionBuilder widgets when they # cause a change in the command entry. self.command_entry.handler_block(self.command_entry_changed_cb_id) self.command_entry.set_text(self.ops.render_string()) self.command_entry.handler_unblock(self.command_entry_changed_cb_id) def update_help_name(self, widget, extra): self.help_field.get_buffer().set_text("Profile name\n\nThis is how the" +" profile will be identified in the drop-down combo box in the" +" scan tab.") def update_help_desc(self, widget, extra): self.help_field.get_buffer().set_text("Description\n\nThe description is a" + " full description of what the scan does, which may be long.") def __create_widgets(self): ### # Vertical box to keep 3 boxes self.main_whole_box = HIGVBox() self.upper_box = HIGHBox() self.middle_box = HIGHBox() self.lower_box = HIGHBox() #self.main_vbox = HIGVBox() self.command_entry = gtk.Entry() self.command_entry_changed_cb_id = \ self.command_entry.connect("changed", self.command_entry_changed_cb) self.scan_button = HIGButton(_("Scan")) self.scan_button.connect("clicked", self.run_scan) 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.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.save_button = HIGButton(_("Save Changes"), stock=gtk.STOCK_SAVE) self.save_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 __pack_widgets(self): ### self.add(self.main_whole_box) # Packing command entry to upper box self.upper_box._pack_expand_fill(self.command_entry) self.upper_box._pack_noexpand_nofill(self.scan_button) # Packing notebook (left) and help box (right) to middle box self.middle_box._pack_expand_fill(self.notebook) self.middle_box._pack_expand_fill(self.help_vbox) # Packing buttons to lower box self.lower_box.pack_end(self.buttons_hbox) # Packing the three vertical boxes to the main box self.main_whole_box._pack_noexpand_nofill(self.upper_box) self.main_whole_box._pack_expand_fill(self.middle_box) self.main_whole_box._pack_noexpand_nofill(self.lower_box) ### # Packing profile information tab on notebook self.notebook.append_page(self.profile_info_vbox, gtk.Label(_('Profile'))) self.profile_info_vbox.set_border_width(5) table = HIGTable() self.profile_info_vbox._pack_noexpand_nofill(self.profile_info_label) self.profile_info_vbox._pack_expand_fill(HIGSpacer(table)) self.profile_description_scroll.add(self.profile_description_text) vbox_desc = HIGVBox() vbox_desc._pack_noexpand_nofill(self.profile_description_label) vbox_desc._pack_expand_fill(hig_box_space_holder()) vbox_ann = HIGVBox() vbox_ann._pack_expand_fill(hig_box_space_holder()) table.attach(self.profile_name_label,0,1,0,1,xoptions=0,yoptions=0) table.attach(self.profile_name_entry,1,2,0,1,yoptions=0) table.attach(vbox_desc,0,1,1,2,xoptions=0) table.attach(self.profile_description_scroll,1,2,1,2) # Packing buttons on button_hbox self.buttons_hbox._pack_expand_fill(hig_box_space_holder()) if self.deletable: self.buttons_hbox._pack_noexpand_nofill(self.delete_button) self.buttons_hbox._pack_noexpand_nofill(self.cancel_button) self.buttons_hbox._pack_noexpand_nofill(self.save_button) self.buttons_hbox.set_border_width(5) self.buttons_hbox.set_spacing(6) ### self.help_vbox._pack_noexpand_nofill(self.help_label) self.help_vbox._pack_expand_fill(self.help_scroll) self.help_scroll.add(self.help_field) self.help_vbox.set_border_width(1) self.help_vbox.set_spacing(1) ### def __create_tab(self, tab_name, section_name, tab): log.debug(">>> Tab name: %s" % tab_name) log.debug(">>>Creating profile editor section: %s" % section_name) vbox = HIGVBox() if tab.notscripttab: # if notscripttab is set table = HIGTable() table.set_row_spacings(2) section = HIGSectionLabel(section_name) vbox._pack_noexpand_nofill(section) vbox._pack_noexpand_nofill(HIGSpacer(table)) vbox.set_border_width(5) tab.fill_table(table, True) else: hbox = tab.get_hmain_box() vbox.pack_start(hbox,True,True,0) self.notebook.append_page(vbox, gtk.Label(tab_name)) 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.ops.render_string() buf = self.profile_description_text.get_buffer() description = buf.get_text(buf.get_start_iter(),\ buf.get_end_iter()) try: self.profile.add_profile(profile_name,\ command=command,\ description=description) except ValueError: alert = HIGAlertDialog(message_format=_('Disallowed profile name'),\ secondary_text=_('Sorry, the name "%s" \ is not allowed due to technical limitations. (The underlying ConfigParser \ used to store profiles does not allow it.) Choose a different \ name.' % profile_name)) alert.run() alert.destroy() return self.scan_interface.toolbar.profile_entry.update() self.destroy() def clean_profile_info(self): self.profile_name_entry.set_text('') self.profile_description_text.get_buffer().set_text('') def set_scan_interface(self, interface): self.scan_interface = interface def exit(self, *args): self.destroy() def delete_profile(self, widget=None, extra=None): if self.deletable: dialog = HIGDialog(buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) alert = HIGEntryLabel('<b>'+_("Deleting Profile")+'</b>') text = HIGEntryLabel(_('Your profile is going to be deleted! Click\ Ok to continue, or Cancel to go back to Profile Editor.')) hbox = HIGHBox() hbox.set_border_width(5) hbox.set_spacing(12) vbox = HIGVBox() vbox.set_border_width(5) vbox.set_spacing(12) image = gtk.Image() image.set_from_stock(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG) vbox.pack_start(alert) vbox.pack_start(text) hbox.pack_start(image) hbox.pack_start(vbox) dialog.vbox.pack_start(hbox) dialog.vbox.show_all() response = dialog.run() dialog.destroy() if response == gtk.RESPONSE_CANCEL: return True self.profile.remove_profile(self.profile_name) self.update_profile_entry() self.destroy() def run_scan(self, widget=None): command_string = self.command_entry.get_text().decode("UTF-8") self.scan_interface.command_toolbar.command = command_string self.scan_interface.start_scan_cb() self.exit() def update_profile_entry(self, widget=None, extra=None): self.scan_interface.toolbar.profile_entry.update() list = self.scan_interface.toolbar.profile_entry.get_model() length = len(list) if length >0 : self.scan_interface.toolbar.profile_entry.set_active(0)
class DiffWindow(gtk.Window): def __init__(self, scans): gtk.Window.__init__(self) self.set_title(_("Compare Results")) self.ndiff_process = None # We allow the user to start a new diff before the old one has # finished. We have to keep references to old processes until they # finish to avoid problems when tearing down the Python interpreter at # program exit. self.old_processes = [] self.timer_id = None self.main_vbox = HIGVBox() self.diff_view = DiffView() self.diff_view.set_size_request(-1, 100) self.hbox_buttons = HIGHBox() self.progress = gtk.ProgressBar() self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE) self.hbox_selection = HIGHBox() self.scan_chooser_a = ScanChooser(scans, _(u"A Scan")) self.scan_chooser_b = ScanChooser(scans, _(u"B Scan")) self._pack_widgets() self._connect_widgets() self.set_default_size(-1, 500) # Initial Size Request self.initial_size = self.get_size() def _pack_widgets(self): self.main_vbox.set_border_width(6) self.hbox_selection.pack_start(self.scan_chooser_a, True, True) self.hbox_selection.pack_start(self.scan_chooser_b, True, True) self.main_vbox.pack_start(self.hbox_selection, False) scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scroll.add(self.diff_view) self.main_vbox.pack_start(scroll, True, True) self.progress.hide() self.progress.set_no_show_all(True) self.hbox_buttons.pack_start(self.progress, False) self.hbox_buttons.pack_end(self.btn_close, False) self.main_vbox._pack_noexpand_nofill(self.hbox_buttons) self.add(self.main_vbox) def _connect_widgets(self): self.connect("delete-event", self.close) self.btn_close.connect("clicked", self.close) self.scan_chooser_a.connect('changed', self.refresh_diff) self.scan_chooser_b.connect('changed', self.refresh_diff) def refresh_diff(self, widget): """This method is called whenever the diff output might have changed, such as when a different scan was selected in one of the choosers.""" log.debug("Refresh diff.") if (self.ndiff_process is not None and self.ndiff_process.poll() is None): # Put this in the list of old processes we keep track of. self.old_processes.append(self.ndiff_process) self.ndiff_process = None scan_a = self.scan_chooser_a.parsed_scan scan_b = self.scan_chooser_b.parsed_scan if scan_a is None or scan_b is None: self.diff_view.clear() else: try: self.ndiff_process = zenmapCore.Diff.ndiff(scan_a, scan_b) except OSError as e: alert = HIGAlertDialog( message_format=_("Error running ndiff"), secondary_text=_( "There was an error running the ndiff program.\n\n") + str(e).decode(sys.getdefaultencoding(), "replace")) alert.run() alert.destroy() else: self.progress.show() if self.timer_id is None: self.timer_id = gobject.timeout_add( NDIFF_CHECK_TIMEOUT, self.check_ndiff_process) def check_ndiff_process(self): """Check if the ndiff subprocess is done and show the diff if it is. Also remove any finished processes from the old process list.""" # Check if any old background processes have finished. for p in self.old_processes[:]: if p.poll() is not None: p.close() self.old_processes.remove(p) if self.ndiff_process is not None: # We're running the most recent scan. Check if it's done. status = self.ndiff_process.poll() if status is None: # Keep calling this function on a timer until the process # finishes. self.progress.pulse() return True if status == 0 or status == 1: # Successful completion. try: diff = self.ndiff_process.get_scan_diff() except zenmapCore.Diff.NdiffParseException as e: alert = HIGAlertDialog( message_format=_("Error parsing ndiff output"), secondary_text=str(e)) alert.run() alert.destroy() else: self.diff_view.show_diff(diff) else: # Unsuccessful completion. error_text = _( "The ndiff process terminated with status code %d." ) % status stderr = self.ndiff_process.stderr.read() if len(stderr) > 0: error_text += "\n\n" + stderr alert = HIGAlertDialog(message_format=_("Error running ndiff"), secondary_text=error_text) alert.run() alert.destroy() self.progress.hide() self.ndiff_process.close() self.ndiff_process = None if len(self.old_processes) > 0: # Keep calling this callback. return True else: # All done. self.timer_id = None return False def close(self, widget=None, extra=None): self.destroy()
def __init__(self, scan): HIGVBox.__init__(self) na = _('Not available') # Command info self.command_label = HIGEntryLabel(_('Command:')) self.info_command_label = HIGEntryLabel(na) self.nmap_version_label = HIGEntryLabel(_('Nmap Version:')) self.info_nmap_version_label = HIGEntryLabel(na) self.verbose_label = HIGEntryLabel(_('Verbosity level:')) self.info_verbose_label = HIGEntryLabel(na) self.debug_label = HIGEntryLabel(_('Debug level:')) self.info_debug_label = HIGEntryLabel(na) self.command_expander = gtk.Expander("<b>" + _("Command Info") + "</b>") self.command_expander.set_use_markup(True) self.command_table = HIGTable() self.command_table.set_border_width(5) self.command_table.set_row_spacings(6) self.command_table.set_col_spacings(6) self.command_hbox = HIGHBox() self.command_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.command_hbox._pack_noexpand_nofill(self.command_table) self.command_table.attach(self.command_label, 0, 1, 0, 1) self.command_table.attach(self.info_command_label, 1, 2, 0, 1) self.command_table.attach(self.nmap_version_label, 0, 1, 1, 2) self.command_table.attach(self.info_nmap_version_label, 1, 2, 1, 2) self.command_table.attach(self.verbose_label, 0, 1, 2, 3) self.command_table.attach(self.info_verbose_label, 1, 2, 2, 3) self.command_table.attach(self.debug_label, 0, 1, 3, 4) self.command_table.attach(self.info_debug_label, 1, 2, 3, 4) self.command_expander.add(self.command_hbox) self._pack_noexpand_nofill(self.command_expander) self.command_expander.set_expanded(True) # General info: self.start_label = HIGEntryLabel(_('Started on:')) self.info_start_label = HIGEntryLabel(na) self.finished_label = HIGEntryLabel(_('Finished on:')) self.info_finished_label = HIGEntryLabel(na) self.host_up_label = HIGEntryLabel(_('Hosts up:')) self.info_hosts_up_label = HIGEntryLabel(na) self.host_down_label = HIGEntryLabel(_('Hosts down:')) self.info_hosts_down_label = HIGEntryLabel(na) self.host_scanned_label = HIGEntryLabel(_('Hosts scanned:')) self.info_hosts_scanned_label = HIGEntryLabel(na) self.open_label = HIGEntryLabel(_('Open ports:')) self.info_open_label = HIGEntryLabel(na) self.filtered_label = HIGEntryLabel(_('Filtered ports:')) self.info_filtered_label = HIGEntryLabel(na) self.closed_label = HIGEntryLabel(_('Closed ports:')) self.info_closed_label = HIGEntryLabel(na) self.general_expander = gtk.Expander("<b>" + _("General Info") + "</b>") self.general_expander.set_use_markup(True) self.general_table = HIGTable() self.general_table.set_border_width(5) self.general_table.set_row_spacings(6) self.general_table.set_col_spacings(6) self.general_hbox = HIGHBox() self.general_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.general_hbox._pack_noexpand_nofill(self.general_table) self.general_table.attach(self.start_label, 0, 1, 0, 1) self.general_table.attach(self.info_start_label, 1, 2, 0, 1) self.general_table.attach(self.finished_label, 0, 1, 1, 2) self.general_table.attach(self.info_finished_label, 1, 2, 1, 2) self.general_table.attach(self.host_up_label, 0, 1, 2, 3) self.general_table.attach(self.info_hosts_up_label, 1, 2, 2, 3) self.general_table.attach(self.host_down_label, 0, 1, 3, 4) self.general_table.attach(self.info_hosts_down_label, 1, 2, 3, 4) self.general_table.attach(self.host_scanned_label, 0, 1, 4, 5) self.general_table.attach(self.info_hosts_scanned_label, 1, 2, 4, 5) self.general_table.attach(self.open_label, 0, 1, 5, 6) self.general_table.attach(self.info_open_label, 1, 2, 5, 6) self.general_table.attach(self.filtered_label, 0, 1, 6, 7) self.general_table.attach(self.info_filtered_label, 1, 2, 6, 7) self.general_table.attach(self.closed_label, 0, 1, 7, 8) self.general_table.attach(self.info_closed_label, 1, 2, 7, 8) self.general_expander.add(self.general_hbox) self._pack_noexpand_nofill(self.general_expander) self.general_expander.set_expanded(True) self._set_from_scan(scan)
class ScanRunDetailsPage(HIGVBox): def __init__(self, scan): HIGVBox.__init__(self) na = _('Not available') # Command info self.command_label = HIGEntryLabel(_('Command:')) self.info_command_label = HIGEntryLabel(na) self.nmap_version_label = HIGEntryLabel(_('Nmap Version:')) self.info_nmap_version_label = HIGEntryLabel(na) self.verbose_label = HIGEntryLabel(_('Verbosity level:')) self.info_verbose_label = HIGEntryLabel(na) self.debug_label = HIGEntryLabel(_('Debug level:')) self.info_debug_label = HIGEntryLabel(na) self.command_expander = gtk.Expander("<b>" + _("Command Info") + "</b>") self.command_expander.set_use_markup(True) self.command_table = HIGTable() self.command_table.set_border_width(5) self.command_table.set_row_spacings(6) self.command_table.set_col_spacings(6) self.command_hbox = HIGHBox() self.command_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.command_hbox._pack_noexpand_nofill(self.command_table) self.command_table.attach(self.command_label, 0, 1, 0, 1) self.command_table.attach(self.info_command_label, 1, 2, 0, 1) self.command_table.attach(self.nmap_version_label, 0, 1, 1, 2) self.command_table.attach(self.info_nmap_version_label, 1, 2, 1, 2) self.command_table.attach(self.verbose_label, 0, 1, 2, 3) self.command_table.attach(self.info_verbose_label, 1, 2, 2, 3) self.command_table.attach(self.debug_label, 0, 1, 3, 4) self.command_table.attach(self.info_debug_label, 1, 2, 3, 4) self.command_expander.add(self.command_hbox) self._pack_noexpand_nofill(self.command_expander) self.command_expander.set_expanded(True) # General info: self.start_label = HIGEntryLabel(_('Started on:')) self.info_start_label = HIGEntryLabel(na) self.finished_label = HIGEntryLabel(_('Finished on:')) self.info_finished_label = HIGEntryLabel(na) self.host_up_label = HIGEntryLabel(_('Hosts up:')) self.info_hosts_up_label = HIGEntryLabel(na) self.host_down_label = HIGEntryLabel(_('Hosts down:')) self.info_hosts_down_label = HIGEntryLabel(na) self.host_scanned_label = HIGEntryLabel(_('Hosts scanned:')) self.info_hosts_scanned_label = HIGEntryLabel(na) self.open_label = HIGEntryLabel(_('Open ports:')) self.info_open_label = HIGEntryLabel(na) self.filtered_label = HIGEntryLabel(_('Filtered ports:')) self.info_filtered_label = HIGEntryLabel(na) self.closed_label = HIGEntryLabel(_('Closed ports:')) self.info_closed_label = HIGEntryLabel(na) self.general_expander = gtk.Expander("<b>" + _("General Info") + "</b>") self.general_expander.set_use_markup(True) self.general_table = HIGTable() self.general_table.set_border_width(5) self.general_table.set_row_spacings(6) self.general_table.set_col_spacings(6) self.general_hbox = HIGHBox() self.general_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.general_hbox._pack_noexpand_nofill(self.general_table) self.general_table.attach(self.start_label, 0, 1, 0, 1) self.general_table.attach(self.info_start_label, 1, 2, 0, 1) self.general_table.attach(self.finished_label, 0, 1, 1, 2) self.general_table.attach(self.info_finished_label, 1, 2, 1, 2) self.general_table.attach(self.host_up_label, 0, 1, 2, 3) self.general_table.attach(self.info_hosts_up_label, 1, 2, 2, 3) self.general_table.attach(self.host_down_label, 0, 1, 3, 4) self.general_table.attach(self.info_hosts_down_label, 1, 2, 3, 4) self.general_table.attach(self.host_scanned_label, 0, 1, 4, 5) self.general_table.attach(self.info_hosts_scanned_label, 1, 2, 4, 5) self.general_table.attach(self.open_label, 0, 1, 5, 6) self.general_table.attach(self.info_open_label, 1, 2, 5, 6) self.general_table.attach(self.filtered_label, 0, 1, 6, 7) self.general_table.attach(self.info_filtered_label, 1, 2, 6, 7) self.general_table.attach(self.closed_label, 0, 1, 7, 8) self.general_table.attach(self.info_closed_label, 1, 2, 7, 8) self.general_expander.add(self.general_hbox) self._pack_noexpand_nofill(self.general_expander) self.general_expander.set_expanded(True) self._set_from_scan(scan) 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_formatted_date()) self.info_finished_label.set_text(scan.get_formatted_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 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 make_services_display(self, services): """Return a widget displaying a list of services like 1-1027,1029-1033,1040,1043,1050,1058-1059,1067-1068,1076,1080""" combo = gtk.combo_box_new_text() for i in services.split(","): combo.append_text(i) return combo
class UmitCredits(HIGWindow): 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 __create_widgets(self): self.vbox = HIGVBox() self.hbox = HIGHBox() self.notebook = HIGNotebook() self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE) self.written_by_scroll = HIGScrolledWindow() self.written_by_text = HIGTextView() self.design_scroll = HIGScrolledWindow() self.design_text = HIGTextView() self.soc2007_scroll = HIGScrolledWindow() self.soc2007_text = HIGTextView() self.contributors_scroll = HIGScrolledWindow() self.contributors_text = HIGTextView() self.translation_scroll = HIGScrolledWindow() self.translation_text = HIGTextView() self.nokia_scroll = HIGScrolledWindow() self.nokia_text = HIGTextView() def __packing(self): self.add(self.vbox) self.vbox.set_spacing(12) self.vbox._pack_expand_fill(self.notebook) self.vbox._pack_noexpand_nofill(self.hbox) self.hbox._pack_expand_fill(hig_box_space_holder()) self.hbox._pack_noexpand_nofill(self.btn_close) self.notebook.append_page( self.written_by_scroll, gtk.Label(_("Written by"))) self.notebook.append_page( self.design_scroll, gtk.Label(_("Design"))) self.notebook.append_page( self.soc2007_scroll, gtk.Label(_("SoC 2007"))) self.notebook.append_page( self.contributors_scroll, gtk.Label(_("Contributors"))) self.notebook.append_page( self.translation_scroll, gtk.Label(_("Translation"))) self.notebook.append_page( self.nokia_scroll, gtk.Label(_("Maemo"))) self.written_by_scroll.add(self.written_by_text) self.written_by_text.set_wrap_mode(gtk.WRAP_NONE) self.design_scroll.add(self.design_text) self.design_text.set_wrap_mode(gtk.WRAP_NONE) self.soc2007_scroll.add(self.soc2007_text) self.soc2007_text.set_wrap_mode(gtk.WRAP_NONE) self.contributors_scroll.add(self.contributors_text) self.contributors_text.set_wrap_mode(gtk.WRAP_NONE) self.translation_scroll.add(self.translation_text) self.translation_text.set_wrap_mode(gtk.WRAP_NONE) self.nokia_scroll.add(self.nokia_text) self.nokia_text.set_wrap_mode(gtk.WRAP_NONE) self.btn_close.connect('clicked', lambda x, y=None: self.destroy()) def set_text(self): b = self.written_by_text.get_buffer() b.set_text("""Adriano Monteiro Marques <*****@*****.**>""") b = self.design_text.get_buffer() b.set_text("""Operating System and Vulnerability Icons: Takeshi Alexandre Gondo <*****@*****.**> Logo, Application Icons and Splash screen: Virgílio Carlo de Menezes Vasconcelos <*****@*****.**> The Umit Project Web Site Design: Joao Paulo Pacheco <*****@*****.**>""") b = self.soc2007_text.get_buffer() b.set_text("""Independent Features: Adriano Monteiro Marques <*****@*****.**> Frederico Silva Ribeiro <*****@*****.**> Network Inventory: Guilherme Henrique Polo Gonçalves <*****@*****.**> Umit Radial Mapper: João Paulo de Souza Medeiros <*****@*****.**> Profile/Wizard interface editor: Luis Antonio Bastião Silva <*****@*****.**> NSE Facilitator: Maxim I. Gavrilov <*****@*****.**> Umit Web: Rodolfo da Silva Carvalho <*****@*****.**>""") b = self.contributors_text.get_buffer() b.set_text("""Sponsored by (SoC 2005, 2006 and 2007): Google <*****@*****.**> Mentor of Umit for Google SoC 2005 and 2006: Fyodor <*****@*****.**> Mentor of Umit for Google SoC 2007 Projects: Adriano Monteiro Marques <*****@*****.**> Initial development: Adriano Monteiro Marques <*****@*****.**> Cleber Rodrigues Rosa Junior <*****@*****.**> Nmap students from Google SoC 2007 that helped Umit: Eddie Bell <*****@*****.**> David Fifield <*****@*****.**> Kris Katterjohn <*****@*****.**> The Umit Project WebSite: AbraoBarbosa dos Santos Neto <*****@*****.**> Adriano Monteiro Marques <*****@*****.**> Heitor de Lima Matos <*****@*****.**> Joao Paulo Pacheco <*****@*****.**> João Paulo de Souza Medeiros <*****@*****.**> Luis Antonio Bastião Silva <*****@*****.**> Rodolfo da Silva Carvalho <*****@*****.**> Beta testers for 0.9.5RC1: Drew Miller <*****@*****.**> Igor Feghali <*****@*****.**> Joao Paulo Pacheco <*****@*****.**> Luis Antonio Bastião Silva <*****@*****.**> <*****@*****.**> <*****@*****.**> <*****@*****.**> Initial attempt on Maemo port: Adriano Monteiro Marques <*****@*****.**> Osvaldo Santana Neto <*****@*****.**>""") b = self.translation_text.get_buffer() b.set_text("""Brazilian Portuguese: Adriano Monteiro Marques <*****@*****.**>""") b = self.nokia_text.get_buffer() b.set_text("""Adriano Monteiro Marques <*****@*****.**>""")
class ProfileEditor(HIGWindow): 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 command_entry_changed_cb(self, widget): command_string = self.command_entry.get_text().decode("UTF-8") self.ops.parse_string(command_string) self.inhibit_command_update = True self.option_builder.update() self.inhibit_command_update = False def update_command(self): """Regenerate and display the command.""" if not self.inhibit_command_update: # Block recursive updating of the OptionBuilder widgets when they # cause a change in the command entry. self.command_entry.handler_block(self.command_entry_changed_cb_id) self.command_entry.set_text(self.ops.render_string()) self.command_entry.handler_unblock( self.command_entry_changed_cb_id) def update_help_name(self, widget, extra): self.help_field.get_buffer().set_text( "Profile name\n\nThis is how the profile will be identified " "in the drop-down combo box in the scan tab.") def update_help_desc(self, widget, extra): self.help_field.get_buffer().set_text( "Description\n\nThe description is a full description of what " "the scan does, which may be long.") def __create_widgets(self): ### # Vertical box to keep 3 boxes self.main_whole_box = HIGVBox() self.upper_box = HIGHBox() self.middle_box = HIGHBox() self.lower_box = HIGHBox() #self.main_vbox = HIGVBox() self.command_entry = gtk.Entry() self.command_entry_changed_cb_id = self.command_entry.connect( "changed", self.command_entry_changed_cb) self.scan_button = HIGButton(_("Scan")) self.scan_button.connect("clicked", self.run_scan) 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.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.save_button = HIGButton(_("Save Changes"), stock=gtk.STOCK_SAVE) self.save_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 __pack_widgets(self): ### self.add(self.main_whole_box) # Packing command entry to upper box self.upper_box._pack_expand_fill(self.command_entry) self.upper_box._pack_noexpand_nofill(self.scan_button) # Packing notebook (left) and help box (right) to middle box self.middle_box._pack_expand_fill(self.notebook) self.middle_box._pack_expand_fill(self.help_vbox) # Packing buttons to lower box self.lower_box.pack_end(self.buttons_hbox) # Packing the three vertical boxes to the main box self.main_whole_box._pack_noexpand_nofill(self.upper_box) self.main_whole_box._pack_expand_fill(self.middle_box) self.main_whole_box._pack_noexpand_nofill(self.lower_box) ### # Packing profile information tab on notebook self.notebook.append_page( self.profile_info_vbox, gtk.Label(_('Profile'))) self.profile_info_vbox.set_border_width(5) table = HIGTable() self.profile_info_vbox._pack_noexpand_nofill(self.profile_info_label) self.profile_info_vbox._pack_expand_fill(HIGSpacer(table)) self.profile_description_scroll.add(self.profile_description_text) vbox_desc = HIGVBox() vbox_desc._pack_noexpand_nofill(self.profile_description_label) vbox_desc._pack_expand_fill(hig_box_space_holder()) vbox_ann = HIGVBox() vbox_ann._pack_expand_fill(hig_box_space_holder()) table.attach( self.profile_name_label, 0, 1, 0, 1, xoptions=0, yoptions=0) table.attach(self.profile_name_entry, 1, 2, 0, 1, yoptions=0) table.attach(vbox_desc, 0, 1, 1, 2, xoptions=0) table.attach(self.profile_description_scroll, 1, 2, 1, 2) # Packing buttons on button_hbox self.buttons_hbox._pack_expand_fill(hig_box_space_holder()) if self.deletable: self.buttons_hbox._pack_noexpand_nofill(self.delete_button) self.buttons_hbox._pack_noexpand_nofill(self.cancel_button) self.buttons_hbox._pack_noexpand_nofill(self.save_button) self.buttons_hbox.set_border_width(5) self.buttons_hbox.set_spacing(6) ### self.help_vbox._pack_noexpand_nofill(self.help_label) self.help_vbox._pack_expand_fill(self.help_scroll) self.help_scroll.add(self.help_field) self.help_vbox.set_border_width(1) self.help_vbox.set_spacing(1) ### def __create_tab(self, tab_name, section_name, tab): log.debug(">>> Tab name: %s" % tab_name) log.debug(">>>Creating profile editor section: %s" % section_name) vbox = HIGVBox() if tab.notscripttab: # if notscripttab is set table = HIGTable() table.set_row_spacings(2) section = HIGSectionLabel(section_name) vbox._pack_noexpand_nofill(section) vbox._pack_noexpand_nofill(HIGSpacer(table)) vbox.set_border_width(5) tab.fill_table(table, True) else: hbox = tab.get_hmain_box() vbox.pack_start(hbox, True, True, 0) self.notebook.append_page(vbox, gtk.Label(tab_name)) 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.ops.render_string() buf = self.profile_description_text.get_buffer() description = buf.get_text( buf.get_start_iter(), buf.get_end_iter()) try: self.profile.add_profile( profile_name, command=command, description=description) except ValueError: alert = HIGAlertDialog( message_format=_('Disallowed profile name'), secondary_text=_('Sorry, the name "%s" is not allowed due ' 'to technical limitations. (The underlying ' 'ConfigParser used to store profiles does not allow ' 'it.) Choose a different name.' % profile_name)) alert.run() alert.destroy() return self.scan_interface.toolbar.profile_entry.update() self.destroy() def clean_profile_info(self): self.profile_name_entry.set_text('') self.profile_description_text.get_buffer().set_text('') def set_scan_interface(self, interface): self.scan_interface = interface def exit(self, *args): self.destroy() def delete_profile(self, widget=None, extra=None): if self.deletable: dialog = HIGDialog(buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) alert = HIGEntryLabel('<b>' + _("Deleting Profile") + '</b>') text = HIGEntryLabel(_( 'Your profile is going to be deleted! ClickOk to continue, ' 'or Cancel to go back to Profile Editor.')) hbox = HIGHBox() hbox.set_border_width(5) hbox.set_spacing(12) vbox = HIGVBox() vbox.set_border_width(5) vbox.set_spacing(12) image = gtk.Image() image.set_from_stock( gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG) vbox.pack_start(alert) vbox.pack_start(text) hbox.pack_start(image) hbox.pack_start(vbox) dialog.vbox.pack_start(hbox) dialog.vbox.show_all() response = dialog.run() dialog.destroy() if response == gtk.RESPONSE_CANCEL: return True self.profile.remove_profile(self.profile_name) self.update_profile_entry() self.destroy() def run_scan(self, widget=None): command_string = self.command_entry.get_text().decode("UTF-8") self.scan_interface.command_toolbar.command = command_string self.scan_interface.start_scan_cb() self.exit() def update_profile_entry(self, widget=None, extra=None): self.scan_interface.toolbar.profile_entry.update() list = self.scan_interface.toolbar.profile_entry.get_model() length = len(list) if length > 0: self.scan_interface.toolbar.profile_entry.set_active(0)
class CrashReport(HIGWindow): def __init__(self, summary, description): HIGWindow.__init__(self) gtk.Window.__init__(self) self.set_title(_('Crash Report')) self.set_position(gtk.WIN_POS_CENTER_ALWAYS) self.response_id = False self._create_widgets() self._pack_widgets() self._connect_widgets() self.summary = summary self.description = "\n----\n" + description def _create_widgets(self): self.vbox = HIGVBox() self.button_box = gtk.HButtonBox() self.email_label = gtk.Label(_("""\ An email address is optional. Sometimes we use it to get more information. If \ you provide an email address your report will be marked private so only \ project developers can read it.\ """)) self.email_entry = gtk.Entry() self.summary_entry = gtk.Entry() self.description_label = gtk.Label(_("\ What were you doing when the crash happened?\ ")) self.description_scrolled = gtk.ScrolledWindow() self.description_text = gtk.TextView() self.bug_text = gtk.Label(_("""\ An unhandled exception has crashed Zenmap. This dialog allows you to tell us \ what you did to cause the crash and help us to fix it. Submitting the report \ will open a description of the new bug at the bug tracker. Feel free to edit \ the report to remove any identifying information such as your home directory.\ """)) 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 _pack_widgets(self): self.description_label.set_line_wrap(True) self.description_label.set_alignment(0.0, 0.5) self.description_scrolled.add(self.description_text) self.description_scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.description_scrolled.set_size_request(400, 150) self.description_text.set_wrap_mode(gtk.WRAP_WORD) self.email_label.set_line_wrap(True) self.email_label.set_alignment(0.0, 0.5) self.bug_text.set_line_wrap(True) self.hbox.set_border_width(12) self.vbox.set_border_width(6) self.table.attach_label(gtk.Label(_("Summary")), 0, 1, 0, 1) self.table.attach_entry(self.summary_entry, 1, 2, 0, 1) self.table.attach_entry(self.description_label, 0, 2, 1, 2) self.table.attach_entry(self.description_scrolled, 0, 2, 2, 3) self.table.attach(self.email_label, 0, 2, 3, 4) self.table.attach_label(gtk.Label(_("Email")), 0, 1, 4, 5) self.table.attach_entry(self.email_entry, 1, 2, 4, 5) self.hbox._pack_expand_fill(self.bug_text) self.button_box.set_layout(gtk.BUTTONBOX_END) self.button_box.pack_start(self.btn_ok) self.button_box.pack_start(self.btn_cancel) self.vbox._pack_noexpand_nofill(self.hbox) self.vbox._pack_expand_fill(self.table) self.vbox._pack_noexpand_nofill(self.button_box) self.add(self.vbox) def _connect_widgets(self): self.btn_ok.connect("clicked", self.send_report) self.btn_cancel.connect("clicked", self.close) self.connect("delete-event", self.close) def send_report(self, widget): bug_register = BugRegister() description_text = self.description private = False if self.email != "": description_text += "\n\n" + self.email private = True report_url = bug_register.get_report_url(self.summary, description_text, private = private) # First we try reporting the bug with a web browser because that gives # better feedback on what happened. If that doesn't work try with # urllib2. try: webbrowser.open(report_url) except webbrowser.Error: try: urllib2.urlopen(report_url) ok_dialog = HIGAlertDialog(type=gtk.MESSAGE_INFO, message_format=_("Bug reported"), secondary_text=_("The bug was successfully reported.")) ok_dialog.run() ok_dialog.destroy() except urllib2.URLError, e: cancel_dialog = HIGAlertDialog(type=gtk.MESSAGE_ERROR, message_format=_("Bug not reported"), secondary_text=_("This error occurred while trying to report the bug:\n\n" + str(e))) cancel_dialog.run() cancel_dialog.destroy() self.close()
class DiffWindow(gtk.Window): def __init__(self, scans): gtk.Window.__init__(self) self.set_title(_("Compare Results")) self.ndiff_process = None # We allow the user to start a new diff before the old one has # finished. We have to keep references to old processes until they # finish to avoid problems when tearing down the Python interpreter at # program exit. self.old_processes = [] self.timer_id = None self.main_vbox = HIGVBox() self.diff_view = DiffView() self.diff_view.set_size_request(-1, 100) self.hbox_buttons = HIGHBox() self.progress = gtk.ProgressBar() self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE) self.hbox_selection = HIGHBox() self.scan_chooser_a = ScanChooser(scans, _(u"A Scan")) self.scan_chooser_b = ScanChooser(scans, _(u"B Scan")) self._pack_widgets() self._connect_widgets() self.set_default_size(-1, 500) # Initial Size Request self.initial_size = self.get_size() def _pack_widgets(self): self.main_vbox.set_border_width(6) self.hbox_selection.pack_start(self.scan_chooser_a, True, True) self.hbox_selection.pack_start(self.scan_chooser_b, True, True) self.main_vbox.pack_start(self.hbox_selection, False) scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scroll.add(self.diff_view) self.main_vbox.pack_start(scroll, True, True) self.progress.hide() self.progress.set_no_show_all(True) self.hbox_buttons.pack_start(self.progress, False) self.hbox_buttons.pack_end(self.btn_close, False) self.main_vbox._pack_noexpand_nofill(self.hbox_buttons) self.add(self.main_vbox) def _connect_widgets(self): self.connect("delete-event", self.close) self.btn_close.connect("clicked", self.close) self.scan_chooser_a.connect('changed', self.refresh_diff) self.scan_chooser_b.connect('changed', self.refresh_diff) def refresh_diff(self, widget): """This method is called whenever the diff output might have changed, such as when a different scan was selected in one of the choosers.""" log.debug("Refresh diff.") if (self.ndiff_process is not None and self.ndiff_process.poll() is None): # Put this in the list of old processes we keep track of. self.old_processes.append(self.ndiff_process) self.ndiff_process = None scan_a = self.scan_chooser_a.parsed_scan scan_b = self.scan_chooser_b.parsed_scan if scan_a is None or scan_b is None: self.diff_view.clear() else: try: self.ndiff_process = zenmapCore.Diff.ndiff(scan_a, scan_b) except OSError as e: alert = HIGAlertDialog( message_format=_("Error running ndiff"), secondary_text=_( "There was an error running the ndiff program.\n\n" ) + str(e).decode(sys.getdefaultencoding(), "replace")) alert.run() alert.destroy() else: self.progress.show() if self.timer_id is None: self.timer_id = gobject.timeout_add( NDIFF_CHECK_TIMEOUT, self.check_ndiff_process) def check_ndiff_process(self): """Check if the ndiff subprocess is done and show the diff if it is. Also remove any finished processes from the old process list.""" # Check if any old background processes have finished. for p in self.old_processes[:]: if p.poll() is not None: p.close() self.old_processes.remove(p) if self.ndiff_process is not None: # We're running the most recent scan. Check if it's done. status = self.ndiff_process.poll() if status is None: # Keep calling this function on a timer until the process # finishes. self.progress.pulse() return True if status == 0 or status == 1: # Successful completion. try: diff = self.ndiff_process.get_scan_diff() except zenmapCore.Diff.NdiffParseException as e: alert = HIGAlertDialog( message_format=_("Error parsing ndiff output"), secondary_text=str(e)) alert.run() alert.destroy() else: self.diff_view.show_diff(diff) else: # Unsuccessful completion. error_text = _( "The ndiff process terminated with status code %d." ) % status stderr = self.ndiff_process.stderr.read() if len(stderr) > 0: error_text += "\n\n" + stderr alert = HIGAlertDialog( message_format=_("Error running ndiff"), secondary_text=error_text) alert.run() alert.destroy() self.progress.hide() self.ndiff_process.close() self.ndiff_process = None if len(self.old_processes) > 0: # Keep calling this callback. return True else: # All done. self.timer_id = None return False def close(self, widget=None, extra=None): self.destroy()
class UmitCredits(HIGWindow): 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 __create_widgets(self): self.vbox = HIGVBox() self.hbox = HIGHBox() self.notebook = HIGNotebook() self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE) self.written_by_scroll = HIGScrolledWindow() self.written_by_text = HIGTextView() self.design_scroll = HIGScrolledWindow() self.design_text = HIGTextView() self.soc2007_scroll = HIGScrolledWindow() self.soc2007_text = HIGTextView() self.contributors_scroll = HIGScrolledWindow() self.contributors_text = HIGTextView() self.translation_scroll = HIGScrolledWindow() self.translation_text = HIGTextView() self.nokia_scroll = HIGScrolledWindow() self.nokia_text = HIGTextView() def __packing(self): self.add(self.vbox) self.vbox.set_spacing(12) self.vbox._pack_expand_fill(self.notebook) self.vbox._pack_noexpand_nofill(self.hbox) self.hbox._pack_expand_fill(hig_box_space_holder()) self.hbox._pack_noexpand_nofill(self.btn_close) self.notebook.append_page(self.written_by_scroll, gtk.Label(_("Written by"))) self.notebook.append_page(self.design_scroll, gtk.Label(_("Design"))) self.notebook.append_page(self.soc2007_scroll, gtk.Label(_("SoC 2007"))) self.notebook.append_page(self.contributors_scroll, gtk.Label(_("Contributors"))) self.notebook.append_page(self.translation_scroll, gtk.Label(_("Translation"))) self.notebook.append_page(self.nokia_scroll, gtk.Label(_("Maemo"))) self.written_by_scroll.add(self.written_by_text) self.written_by_text.set_wrap_mode(gtk.WRAP_NONE) self.design_scroll.add(self.design_text) self.design_text.set_wrap_mode(gtk.WRAP_NONE) self.soc2007_scroll.add(self.soc2007_text) self.soc2007_text.set_wrap_mode(gtk.WRAP_NONE) self.contributors_scroll.add(self.contributors_text) self.contributors_text.set_wrap_mode(gtk.WRAP_NONE) self.translation_scroll.add(self.translation_text) self.translation_text.set_wrap_mode(gtk.WRAP_NONE) self.nokia_scroll.add(self.nokia_text) self.nokia_text.set_wrap_mode(gtk.WRAP_NONE) self.btn_close.connect('clicked', lambda x, y=None: self.destroy()) def set_text(self): b = self.written_by_text.get_buffer() b.set_text("""Adriano Monteiro Marques <*****@*****.**>""") b = self.design_text.get_buffer() b.set_text("""Operating System and Vulnerability Icons: Takeshi Alexandre Gondo <*****@*****.**> Logo, Application Icons and Splash screen: Virgílio Carlo de Menezes Vasconcelos <*****@*****.**> The Umit Project Web Site Design: Joao Paulo Pacheco <*****@*****.**>""") b = self.soc2007_text.get_buffer() b.set_text("""Independent Features: Adriano Monteiro Marques <*****@*****.**> Frederico Silva Ribeiro <*****@*****.**> Network Inventory: Guilherme Henrique Polo Gonçalves <*****@*****.**> Umit Radial Mapper: João Paulo de Souza Medeiros <*****@*****.**> Profile/Wizard interface editor: Luis Antonio Bastião Silva <*****@*****.**> NSE Facilitator: Maxim I. Gavrilov <*****@*****.**> Umit Web: Rodolfo da Silva Carvalho <*****@*****.**>""") b = self.contributors_text.get_buffer() b.set_text("""Sponsored by (SoC 2005, 2006 and 2007): Google <*****@*****.**> Mentor of Umit for Google SoC 2005 and 2006: Fyodor <*****@*****.**> Mentor of Umit for Google SoC 2007 Projects: Adriano Monteiro Marques <*****@*****.**> Initial development: Adriano Monteiro Marques <*****@*****.**> Cleber Rodrigues Rosa Junior <*****@*****.**> Nmap students from Google SoC 2007 that helped Umit: Eddie Bell <*****@*****.**> David Fifield <*****@*****.**> Kris Katterjohn <*****@*****.**> The Umit Project WebSite: AbraoBarbosa dos Santos Neto <*****@*****.**> Adriano Monteiro Marques <*****@*****.**> Heitor de Lima Matos <*****@*****.**> Joao Paulo Pacheco <*****@*****.**> João Paulo de Souza Medeiros <*****@*****.**> Luis Antonio Bastião Silva <*****@*****.**> Rodolfo da Silva Carvalho <*****@*****.**> Beta testers for 0.9.5RC1: Drew Miller <*****@*****.**> Igor Feghali <*****@*****.**> Joao Paulo Pacheco <*****@*****.**> Luis Antonio Bastião Silva <*****@*****.**> <*****@*****.**> <*****@*****.**> <*****@*****.**> Initial attempt on Maemo port: Adriano Monteiro Marques <*****@*****.**> Osvaldo Santana Neto <*****@*****.**>""") b = self.translation_text.get_buffer() b.set_text("""Brazilian Portuguese: Adriano Monteiro Marques <*****@*****.**>""") b = self.nokia_text.get_buffer() b.set_text("""Adriano Monteiro Marques <*****@*****.**>""")