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() table = HIGTable() section = HIGSectionLabel(section_name) vbox._pack_noexpand_nofill(section) vbox._pack_noexpand_nofill(HIGSpacer(table)) vbox.set_border_width(6) tab.fill_table(table, True) self.scrollwindow = HIGScrolledWindow() self.scrollwindow.set_size_request(600, 300) vp = gtk.Viewport() vp.add(vbox) vp.set_shadow_type(gtk.SHADOW_NONE) self.scrollwindow.add(vp) vbox_tmp = HIGVBox() vbox_tmp.set_border_width(6) vbox_tmp.set_spacing(12) vbox_tmp.pack_start(self.scrollwindow) self.notebook.append_page(vbox_tmp, gtk.Label(tab_name))
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() table = HIGTable() section = HIGSectionLabel(section_name) vbox._pack_noexpand_nofill(section) vbox._pack_noexpand_nofill(HIGSpacer(table)) vbox.set_border_width(6) tab.fill_table(table, True) self.scrollwindow = HIGScrolledWindow() self.scrollwindow.set_size_request(600,300) vp = gtk.Viewport() vp.add(vbox) vp.set_shadow_type(gtk.SHADOW_NONE) self.scrollwindow.add(vp) vbox_tmp = HIGVBox() vbox_tmp.set_border_width(6) vbox_tmp.set_spacing(12) vbox_tmp.pack_start(self.scrollwindow) self.notebook.append_page(vbox_tmp, gtk.Label(tab_name))
class LogsWindow(HIGWindow): """ Logs Window """ def __init__(self): HIGWindow.__init__(self, type=gtk.WINDOW_TOPLEVEL) self.set_title(_('Logs')) self.set_position(gtk.WIN_POS_CENTER_ALWAYS) self.set_size_request(720,480) self.set_border_width(10) self.__create_widgets() self.__pack_widgets() self.__connect_widgets() #test #from umit.icm.agent.gui.Notifications import * #t = NotificationUpdate(mode=new_release_mode,text="test",timeout=10000) def __create_widgets(self): """""" #box self.main_vbox = HIGVBox() self.btn_box = gtk.HButtonBox() self.LogsGUI_vbox = HIGHBox() self.main_vbox.set_border_width(2) #close button self.close_button = gtk.Button(stock=gtk.STOCK_CLOSE) #log information box self.LogsGUI_hbox1 = HIGHBox() self.LogsGUI_hbox2 = HIGHBox() self.LogsGUI_subbox = LogsGUI() def __pack_widgets(self): self.main_vbox._pack_expand_fill(self.LogsGUI_vbox) self.main_vbox._pack_noexpand_nofill(self.btn_box) self.LogsGUI_vbox._pack_expand_fill(self.LogsGUI_hbox1) self.LogsGUI_vbox._pack_noexpand_nofill(self.LogsGUI_hbox2) self.LogsGUI_hbox1._pack_expand_fill(self.LogsGUI_subbox) self.btn_box.set_layout(gtk.BUTTONBOX_END) self.btn_box.set_spacing(8) self.btn_box.pack_start(self.close_button) self.add(self.main_vbox) def __connect_widgets(self): """""" self.close_button.connect('clicked', lambda x: self.destroy())
def __do_layout(self): """ Layout window widgets. """ main_vbox = HIGVBox() main_vbox.set_border_width(5) main_vbox.set_spacing(12) header_hbox = HIGHBox() schedp_hbox = HIGHBox() cron_box = HIGVBox() cron_table = HIGTable(5, 2) btns_hbox = HIGHBox() header_hbox._pack_expand_fill(self.ttitle) header_hbox._pack_noexpand_nofill(self.umit_logo) schedp_hbox._pack_noexpand_nofill(self.schedp_name_lbl) schedp_hbox._pack_expand_fill(self.schedp_name) # cron format settings_align = gtk.Alignment(0.5, 0.5, 1, 1) settings_align.set_padding(6, 0, 12, 0) cron_table.attach(self.cron_minute_lbl, 0, 1, 0, 1) cron_table.attach(self.cron_minute, 1, 2, 0, 1) cron_table.attach(self.cron_hour_lbl, 0, 1, 1, 2) cron_table.attach(self.cron_hour, 1, 2, 1, 2) cron_table.attach(self.cron_day_lbl, 0, 1, 2, 3) cron_table.attach(self.cron_day, 1, 2, 2, 3) cron_table.attach(self.cron_month_lbl, 0, 1, 3, 4) cron_table.attach(self.cron_month, 1, 2, 3, 4) cron_table.attach(self.cron_weekday_lbl, 0, 1, 4, 5) cron_table.attach(self.cron_weekday, 1, 2, 4, 5) cron_box._pack_noexpand_nofill(cron_table) settings_align.add(cron_box) self.cron_frame.add(settings_align) # bottom buttons btns_hbox.set_homogeneous(True) btns_hbox._pack_expand_fill(self.help) btns_hbox._pack_expand_fill(hig_box_space_holder()) btns_hbox._pack_expand_fill(self.apply) btns_hbox._pack_expand_fill(self.cancel) btns_hbox._pack_expand_fill(self.ok) main_vbox._pack_noexpand_nofill(header_hbox) main_vbox._pack_noexpand_nofill(gtk.HSeparator()) main_vbox._pack_noexpand_nofill(schedp_hbox) main_vbox._pack_noexpand_nofill(self.cron_frame) main_vbox.pack_end(btns_hbox, False, False, 0) self.add(main_vbox)
def __layout(self): self.set_position(gtk.WIN_POS_CENTER) main_vbox = HIGVBox() top_hbox = HIGHBox() top_hbox._pack_noexpand_nofill(self.iimg) top_hbox._pack_noexpand_nofill(self.topic) main_vbox._pack_noexpand_nofill(top_hbox) main_vbox._pack_noexpand_nofill(self.message) self.add(main_vbox)
def __pack_widgets(self): self.add(self.main_vbox) # Packing widgets to main_vbox self.main_vbox._pack_noexpand_nofill(self.command_expander) self.main_vbox._pack_expand_fill(self.notebook) self.main_vbox._pack_noexpand_nofill(self.buttons_hbox) # Packing command_entry on command_expander self.command_expander.hbox.pack_start(self.command_entry) # 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_noexpand_nofill(HIGSpacer(table)) self.profile_annotation_scroll.add(self.profile_annotation_text) 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_noexpand_nofill(self.profile_annotation_label) vbox_ann._pack_expand_fill(hig_box_space_holder()) table.attach(self.profile_name_label, 0, 1, 0, 1) table.attach(self.profile_name_entry, 1, 2, 0, 1) #table.attach(self.profile_hint_label,0,1,1,2,xoptions=0) table.attach(self.profile_hint_label, 0, 1, 1, 2) table.attach(self.profile_hint_entry, 1, 2, 1, 2) table.attach(vbox_desc, 0, 1, 2, 3) table.attach(self.profile_description_scroll, 1, 2, 2, 3) table.attach(vbox_ann, 0, 1, 3, 4) table.attach(self.profile_annotation_scroll, 1, 2, 3, 4) # Packing buttons on button_hbox self.buttons_hbox.pack_start(self.help_button) #self.buttons_hbox.pack_start(self.delete_button) self.buttons_hbox.pack_start(self.cancel_button) self.buttons_hbox.pack_start(self.ok_button) self.buttons_hbox.set_border_width(5) self.buttons_hbox.set_spacing(6)
def __pack_widgets(self): self.add(self.main_vbox) # Packing widgets to main_vbox self.main_vbox._pack_noexpand_nofill(self.command_expander) self.main_vbox._pack_expand_fill(self.notebook) self.main_vbox._pack_noexpand_nofill(self.buttons_hbox) # Packing command_entry on command_expander self.command_expander.hbox.pack_start(self.command_entry) # 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_noexpand_nofill(HIGSpacer(table)) self.profile_annotation_scroll.add(self.profile_annotation_text) 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_noexpand_nofill(self.profile_annotation_label) vbox_ann._pack_expand_fill(hig_box_space_holder()) table.attach(self.profile_name_label,0,1,0,1) table.attach(self.profile_name_entry,1,2,0,1) #table.attach(self.profile_hint_label,0,1,1,2,xoptions=0) table.attach(self.profile_hint_label,0,1,1,2) table.attach(self.profile_hint_entry,1,2,1,2) table.attach(vbox_desc,0,1,2,3) table.attach(self.profile_description_scroll,1,2,2,3) table.attach(vbox_ann,0,1,3,4) table.attach(self.profile_annotation_scroll,1,2,3,4) # Packing buttons on button_hbox self.buttons_hbox.pack_start(self.help_button) #self.buttons_hbox.pack_start(self.delete_button) self.buttons_hbox.pack_start(self.cancel_button) self.buttons_hbox.pack_start(self.ok_button) self.buttons_hbox.set_border_width(5) self.buttons_hbox.set_spacing(6)
def __do_layout(self): """ Layout window widgets. """ main_vbox = HIGVBox() btns_box = HIGHBox() main_vbox.pack_start(self.logo_img) main_vbox.pack_start(self.lbl_program_version) main_vbox.pack_start(self.lbl_program_description) btns_box.pack_end(self.btn_close) main_vbox._pack_noexpand_nofill(btns_box) self.btn_close.grab_focus() self.add(main_vbox)
def __init__(self): HIGVBox.__init__(self) self.set_spacing(12) sec_vbox = HIGVBox() self.description = HIGEntryLabel(_("""Umit allow user to construct \ powerful commands in two distinct ways:""")) self.novice_radio = gtk.RadioButton(None, _('Novice')) self.expert_radio = gtk.RadioButton(self.novice_radio, _('Expert')) self.bar = ForwardBar(back=False) self._pack_noexpand_nofill(self.description) self._pack_expand_fill(sec_vbox) self._pack_noexpand_nofill(self.bar) sec_vbox._pack_noexpand_nofill(self.novice_radio) sec_vbox._pack_noexpand_nofill(self.expert_radio)
def __init__(self): HIGVBox.__init__(self) self.set_spacing(12) sec_vbox = HIGVBox() self.description = HIGEntryLabel( _("""Umit allow user to construct \ powerful commands in two distinct ways:""")) self.novice_radio = gtk.RadioButton(None, _('Novice')) self.expert_radio = gtk.RadioButton(self.novice_radio, _('Expert')) self.bar = ForwardBar(back=False) self._pack_noexpand_nofill(self.description) self._pack_expand_fill(sec_vbox) self._pack_noexpand_nofill(self.bar) sec_vbox._pack_noexpand_nofill(self.novice_radio) sec_vbox._pack_noexpand_nofill(self.expert_radio)
def __do_layout(self): """ Layout window widgets. """ main_vbox = HIGVBox() days_box = HIGHBox() btns_box = HIGHBox() days_box._pack_noexpand_nofill(self.data_lbl) days_box._pack_expand_fill(self.days) days_box._pack_noexpand_nofill(self.days_lbl) btns_box.pack_end(self.apply, False, False, 0) btns_box.pack_end(self.cancel, False, False, 0) main_vbox._pack_noexpand_nofill(days_box) main_vbox.pack_end(btns_box, False, False, 0) self.add(main_vbox)
def __create_steps(self, step_name, back_step, next_step, step_description, content): vbox = HIGVBox() vbox.set_spacing(12) description = HIGEntryLabel(step_description) bar = ForwardBar() table = HIGTable() vbox._pack_noexpand_nofill(description) vbox._pack_expand_fill(table) vbox._pack_noexpand_nofill(bar) content.fill_table(table, False) bar.cancel.connect('clicked', self.close_wizard) bar.help.connect('clicked', self._show_help) bar.back.connect('clicked', self.switch_page, step_name, back_step) bar.forward.connect('clicked', self.switch_page, step_name, next_step) return vbox
class ControlView(HIGExpanderRNet): """ """ def __init__(self, radialnet): """ """ HIGExpanderRNet.__init__(self, 'View') self.set_expanded(True) self.radialnet = radialnet self.__create_widgets() def __create_widgets(self): """ """ self.__vbox = HIGVBox(spacing=0) self.__zoom = ControlVariable('Zoom', self.radialnet.get_zoom, self.radialnet.set_zoom) self.__ring_gap = ControlRingGap(self.radialnet) self.__navigation = ControlNavigation(self.radialnet) self.__options = ControlOptions(self.radialnet) self.__options.set_border_width(0) self.__vbox._pack_expand_nofill(self.__options) self.__vbox._pack_noexpand_nofill(self.__navigation) self.__vbox._pack_noexpand_nofill(self.__zoom) self.__vbox._pack_noexpand_nofill(self.__ring_gap) self._add(self.__vbox)
class About(HIGWindow): def __init__(self): """""" HIGWindow.__init__(self) self.set_title("About Open Monitor Desktop Agent") self.set_position(gtk.WIN_POS_CENTER) self.__create_widgets() self.__packing() self.__connect_widgets() self.__set_img() self.__set_text() def __create_widgets(self): """""" self.vbox = HIGVBox() self.vbox_content = HIGVBox() self.img_logo = gtk.Image() self.event_img_logo = gtk.EventBox() self.vbox.set_border_width(5) self.vbox.set_spacing(12) self.img = 1 self.d = {} for c in (65, 97): for i in range(26): self.d[chr(i+c)] = chr((i+13) % 26 + c) self.lbl_program_version = gtk.Label( "<span size='15000' weight='heavy'>Open Monitor Desktop Agent</span>") self.lbl_program_description = gtk.Label("""\ ICM Internet Connectivity is a global monitor to inspect the connectivity issues happened in the world. Developer: Alan Wang<*****@*****.**> Paul Pei<*****@*****.**> Tianwei Liu<*****@*****.**> It was sponsered by Google Summer of Code 2011-2012. Thanks Google!""") self.lbl_copyright=gtk.Label( "<small>Copyright (C) 2012 Adriano Monteiro Marques</small>") self.lbl_program_website = gtk.Label( "<span underline='single' foreground='blue'>" "http://www.umitproject.org</span>") self.lbl_program_website2 = gtk.Label( "<span underline='single' foreground='blue'>" "http://www.openmonitor.org</span>") self.bottom_btn_box = gtk.HButtonBox() self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE) self.btn_close.grab_focus() def __packing(self): """""" self.vbox._pack_expand_fill(self.vbox_content) self.vbox._pack_noexpand_nofill(self.bottom_btn_box) self.bottom_btn_box.set_layout(gtk.BUTTONBOX_CENTER) self.bottom_btn_box.set_spacing(8) self.bottom_btn_box.pack_start(self.btn_close) self.event_img_logo.add(self.img_logo) self.vbox_content._pack_expand_fill(self.event_img_logo) self.vbox_content._pack_expand_fill(self.lbl_program_version) self.vbox_content._pack_expand_fill(self.lbl_program_description) self.vbox_content._pack_expand_fill(self.lbl_copyright) self.vbox_content._pack_expand_fill(self.lbl_program_website) self.vbox_content._pack_expand_fill(self.lbl_program_website2) self.add(self.vbox) def __connect_widgets(self): """""" self.event_img_logo.connect('button-release-event', self.__set_size) self.btn_close.connect('clicked', lambda x: self.destroy()) def __set_size(self, widget, extra = None): """""" if self.img >= 3: import webbrowser webbrowser.open("http://www.openmonitor.org") #print "".join([self.d.get(c, c) for c in "vzcbeg cvpxyr,om2;sebz hzvg.pber.Cnguf\ #vzcbeg Cngu; rkrp cvpxyr.ybnq(om2.OM2Svyr(Cngu.hzvg_bcs,'e'))"]) #exec "".join([self.d.get(c, c) for c in "vzcbeg cvpxyr,om2;sebz hzvg.pber.Cnguf\ #vzcbeg Cngu; rkrp cvpxyr.ybnq(om2.OM2Svyr(Cngu.hzvg_bcs,'e'))"]) else: self.img += 1 def __set_text(self): """""" self.lbl_program_version.set_use_markup(True) self.lbl_copyright.set_use_markup(True) self.lbl_program_website.set_use_markup(True) self.lbl_program_website2.set_use_markup(True) self.lbl_program_description.set_justify(gtk.JUSTIFY_CENTER) self.lbl_copyright.set_selectable(False) self.lbl_program_description.set_selectable(False) self.lbl_program_version.set_selectable(False) self.lbl_program_website.set_selectable(False) def __set_img(self): """""" #ixmaps_dir = Path.pixmaps_dir #if pixmaps_dir: # logo = os.path.join(pixmaps_dir,'logo.png') #else: # logo = None logo = os.path.join(IMAGES_DIR, "logo.png") self.img_logo.set_from_file(logo)
class About(HIGWindow): def __init__(self): """""" HIGWindow.__init__(self) self.set_title("About Open Monitor Desktop Agent") self.set_position(gtk.WIN_POS_CENTER) self.__create_widgets() self.__packing() self.__connect_widgets() self.__set_img() self.__set_text() def __create_widgets(self): """""" self.vbox = HIGVBox() self.vbox_content = HIGVBox() self.img_logo = gtk.Image() self.event_img_logo = gtk.EventBox() self.vbox.set_border_width(5) self.vbox.set_spacing(12) self.img = 1 self.d = {} for c in (65, 97): for i in range(26): self.d[chr(i + c)] = chr((i + 13) % 26 + c) self.lbl_program_version = gtk.Label( "<span size='15000' weight='heavy'>Open Monitor Desktop Agent</span>" ) self.lbl_program_description = gtk.Label("""\ ICM Internet Connectivity is a global monitor to inspect the connectivity issues happened in the world. Developer: Alan Wang<*****@*****.**> Paul Pei<*****@*****.**> Tianwei Liu<*****@*****.**> It was sponsered by Google Summer of Code 2011-2012. Thanks Google!""") self.lbl_copyright = gtk.Label( "<small>Copyright (C) 2012 Adriano Monteiro Marques</small>") self.lbl_program_website = gtk.Label( "<span underline='single' foreground='blue'>" "http://www.umitproject.org</span>") self.lbl_program_website2 = gtk.Label( "<span underline='single' foreground='blue'>" "http://www.openmonitor.org</span>") self.bottom_btn_box = gtk.HButtonBox() self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE) self.btn_close.grab_focus() def __packing(self): """""" self.vbox._pack_expand_fill(self.vbox_content) self.vbox._pack_noexpand_nofill(self.bottom_btn_box) self.bottom_btn_box.set_layout(gtk.BUTTONBOX_CENTER) self.bottom_btn_box.set_spacing(8) self.bottom_btn_box.pack_start(self.btn_close) self.event_img_logo.add(self.img_logo) self.vbox_content._pack_expand_fill(self.event_img_logo) self.vbox_content._pack_expand_fill(self.lbl_program_version) self.vbox_content._pack_expand_fill(self.lbl_program_description) self.vbox_content._pack_expand_fill(self.lbl_copyright) self.vbox_content._pack_expand_fill(self.lbl_program_website) self.vbox_content._pack_expand_fill(self.lbl_program_website2) self.add(self.vbox) def __connect_widgets(self): """""" self.event_img_logo.connect('button-release-event', self.__set_size) self.btn_close.connect('clicked', lambda x: self.destroy()) def __set_size(self, widget, extra=None): """""" if self.img >= 3: import webbrowser webbrowser.open("http://www.openmonitor.org") #print "".join([self.d.get(c, c) for c in "vzcbeg cvpxyr,om2;sebz hzvg.pber.Cnguf\ #vzcbeg Cngu; rkrp cvpxyr.ybnq(om2.OM2Svyr(Cngu.hzvg_bcs,'e'))"]) #exec "".join([self.d.get(c, c) for c in "vzcbeg cvpxyr,om2;sebz hzvg.pber.Cnguf\ #vzcbeg Cngu; rkrp cvpxyr.ybnq(om2.OM2Svyr(Cngu.hzvg_bcs,'e'))"]) else: self.img += 1 def __set_text(self): """""" self.lbl_program_version.set_use_markup(True) self.lbl_copyright.set_use_markup(True) self.lbl_program_website.set_use_markup(True) self.lbl_program_website2.set_use_markup(True) self.lbl_program_description.set_justify(gtk.JUSTIFY_CENTER) self.lbl_copyright.set_selectable(False) self.lbl_program_description.set_selectable(False) self.lbl_program_version.set_selectable(False) self.lbl_program_website.set_selectable(False) def __set_img(self): """""" #ixmaps_dir = Path.pixmaps_dir #if pixmaps_dir: # logo = os.path.join(pixmaps_dir,'logo.png') #else: # logo = None logo = os.path.join(IMAGES_DIR, "logo.png") self.img_logo.set_from_file(logo)
def __do_layout(self, create_buttons): main_vbox = HIGVBox() # timeline frame tl_settings_align = gtk.Alignment(0.5, 0.5, 1, 1) tl_settings_align.set_padding(6, 0, 12, 0) tl_settings_vbox = HIGVBox() mode_hbox = HIGHBox() mode_hbox._pack_noexpand_nofill(self.tl_mode_lbl) mode_hbox._pack_expand_fill(self.tl_mode) kind_hbox = HIGHBox() kind_hbox._pack_noexpand_nofill(self.tl_kind_lbl) kind_hbox._pack_expand_fill(self.tl_kind) tl_settings_vbox._pack_noexpand_nofill(mode_hbox) tl_settings_vbox._pack_noexpand_nofill(kind_hbox) tl_settings_align.add(tl_settings_vbox) self.timeline.add(tl_settings_align) main_vbox._pack_noexpand_nofill(self.timeline) # end timeline frame # statusbar frame sbar_settings_align = gtk.Alignment(0.5, 0.5, 1, 1) sbar_settings_align.set_padding(6, 0, 12, 0) sbar_settings_vbox = HIGVBox() sbar_settings_vbox._pack_noexpand_nofill(self.sbar_tips) sbar_settings_align.add(sbar_settings_vbox) self.sbar.add(sbar_settings_align) main_vbox._pack_noexpand_nofill(self.sbar) # end statusbar frame # tabs frame tabs_settings_align = gtk.Alignment(0.5, 0.5, 1, 1) tabs_settings_align.set_padding(6, 0, 12, 0) tabs_settings_vbox = HIGVBox() tabs_settings_vbox._pack_noexpand_nofill(self.tabs_cbtn) tabs_settings_align.add(tabs_settings_vbox) self.tabs.add(tabs_settings_align) main_vbox._pack_noexpand_nofill(self.tabs) # end tabs frame if create_buttons: # buttons box btnsbox = HIGHBox() btnsbox._pack_noexpand_nofill(self.apply) btnsbox._pack_noexpand_nofill(self.cancel) btnsbox._pack_noexpand_nofill(self.ok) bbox = gtk.HBox() bbox.pack_end(btnsbox, False, False, 0) main_vbox.pack_end(bbox, False, False, 0) main_vbox.pack_end(gtk.HSeparator(), False, False, 0) # end buttons box return main_vbox
class ServicesPage(gtk.Notebook): """ """ def __init__(self, node): """ """ gtk.Notebook.__init__(self) self.set_border_width(6) self.set_tab_pos(gtk.POS_TOP) self.__node = node self.__font = pango.FontDescription('Monospace') self.__create_widgets() def __create_widgets(self): """ """ self.__cell = gtk.CellRendererText() # texteditor widgets self.__texteditor = HIGTextEditor() self.__texteditor._modify_font(self.__font) self.__texteditor._set_editable(False) self.__texteditor.set_border_width(0) self.__select_combobox = gtk.combo_box_new_text() self.__select_combobox.connect('changed', self.__change_text_value) self.__viewer = HIGVBox(spacing=6) self.__viewer.set_border_width(6) self.__viewer._pack_noexpand_nofill(self.__select_combobox) self.__viewer._pack_expand_fill(self.__texteditor) self.__text = list() # ports information number_of_ports = len(self.__node.get_info('ports')) self.__ports_label = HIGLabel('Ports (%s)' % number_of_ports) self.__ports_scroll = HIGScrolledWindow() self.__ports_store = gtk.TreeStore(gobject.TYPE_INT, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_BOOLEAN) self.__ports_treeview = gtk.TreeView(self.__ports_store) for port in self.__node.get_info('ports'): pstate = port['state']['state'] if pstate: color = SERVICE_COLORS[port['state']['state']] else: # XXX port state is not always available color = '#fff' if port['service'].has_key('name'): service_name = port['service']['name'] else: service_name = '<unknown>' if port['service'].has_key('method'): service_method = port['service']['method'] else: service_method = '<none>' reference = self.__ports_store.append(None, [port['id'], port['protocol'], port['state']['state'], service_name, service_method, color, True]) for key in port['state']: self.__ports_store.append(reference, [port['id'], 'state', key, port['state'][key], '', 'white', True]) for key in port['service']: if key in ['servicefp', 'extrainfo']: text = '[%d] service: %s' % (port['id'], key) self.__select_combobox.append_text(text) self.__text.append(port['service'][key]) value = '<special field>' else: value = port['service'][key] self.__ports_store.append(reference, [port['id'], 'service', key, value, '', 'white', True]) for script in port['scripts']: text = '[%d] script: %s' % (port['id'], script['id']) self.__select_combobox.append_text(text) self.__text.append(script['output']) self.__ports_store.append(reference, [port['id'], 'script', 'id', script['id'], '<special field>', 'white', True]) self.__ports_column = list() for i in range(len(PORTS_HEADER)): column = gtk.TreeViewColumn(PORTS_HEADER[i], self.__cell, text = i) self.__ports_column.append(column) self.__ports_column[i].set_reorderable(True) self.__ports_column[i].set_resizable(True) self.__ports_column[i].set_sort_column_id(i) self.__ports_column[i].set_attributes(self.__cell, text = i, background = 5, editable = 6) self.__ports_treeview.append_column(self.__ports_column[i]) self.__ports_scroll.add_with_viewport(self.__ports_treeview) # extraports information number_of_xports = 0 self.__xports_scroll = HIGScrolledWindow() self.__xports_store = gtk.TreeStore(gobject.TYPE_INT, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_BOOLEAN) self.__xports_treeview = gtk.TreeView(self.__xports_store) for xports in self.__node.get_info('extraports'): color = SERVICE_COLORS[xports['state']] number_of_xports += xports['count'] reference = self.__xports_store.append(None, [xports['count'], xports['state'], ", ".join(xports['reason']), color, True]) for xreason in xports['all_reason']: self.__xports_store.append(reference, [xreason['count'], xports['state'], xreason['reason'], 'white', True]) self.__xports_column = list() for i in range(len(EXTRAPORTS_HEADER)): column = gtk.TreeViewColumn(EXTRAPORTS_HEADER[i], self.__cell, text = i) self.__xports_column.append(column) self.__xports_column[i].set_reorderable(True) self.__xports_column[i].set_resizable(True) self.__xports_column[i].set_sort_column_id(i) self.__xports_column[i].set_attributes(self.__cell, text = i, background = 3, editable = 4) self.__xports_treeview.append_column(self.__xports_column[i]) xports_label_text = 'Extraports (%s)' % number_of_xports self.__xports_label = HIGLabel(xports_label_text) self.__xports_scroll.add_with_viewport(self.__xports_treeview) self.append_page(self.__ports_scroll, self.__ports_label) self.append_page(self.__xports_scroll, self.__xports_label) self.append_page(self.__viewer, HIGLabel('Special fields')) if len(self.__text) > 0: self.__select_combobox.set_active(0) def __change_text_value(self, widget): """ """ id = self.__select_combobox.get_active() self.__texteditor._set_text(self.__text[id])
class DiffWindow(gtk.Window): def __init__(self, scans): """scans in the format: {"scan_title":parsed_scan} """ gtk.Window.__init__(self) self.set_title(_("Compare Results")) self.scans = scans self.umit_conf = UmitConf() self.colors = Colors() # Diff views self.text_view = DiffText(self.colors, self.umit_conf.colored_diff) self.compare_view = DiffTree(self.colors) self._create_widgets() self._pack_widgets() self._connect_widgets() # Settings if self.umit_conf.diff_mode == "text": self.text_mode.set_active(True) else: self.compare_mode.set_active(True) self.check_color.set_active(self.umit_conf.colored_diff) # Initial Size Request self.initial_size = self.size_request() def _show_help(self, action): show_help(self, "index.html") 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() def _pack_widgets(self): self.main_vbox.set_border_width(6) self.vpaned.pack1(self.hpaned, True, False) self.vpaned.pack2(self.hbox_result) self.hpaned.pack1(self.scan_chooser1, True, False) self.hpaned.pack2(self.scan_chooser2, True, False) self.hbox_buttons._pack_expand_fill(self.btn_help) self.hbox_buttons._pack_expand_fill(self.btn_legend) self.hbox_buttons._pack_expand_fill(self.btn_open_browser) self.hbox_buttons._pack_expand_fill(self.btn_close) self.hbox_buttons.set_homogeneous(True) self.hbox_mode.set_homogeneous(True) self.hbox_mode.pack_start(self.text_mode) self.hbox_mode.pack_start(self.compare_mode) self.hbox_settings._pack_noexpand_nofill(self.hbox_mode) self.hbox_settings._pack_expand_fill(self.check_color) self.main_vbox._pack_expand_fill(self.vpaned) self.main_vbox._pack_noexpand_nofill(self.hbox_settings) 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_legend.connect("clicked", self.show_legend_window) self.btn_help.connect("clicked", self._show_help) self.btn_close.connect("clicked", self.close) self.btn_open_browser.connect("clicked", self.open_browser) self.check_color.connect("toggled", self._set_color) self.text_mode.connect("clicked", self._change_to_text) self.compare_mode.connect("clicked", self._change_to_compare) self.scan_chooser1.exp_scan.connect('activate', self.resize_vpane) self.scan_chooser2.exp_scan.connect('activate', self.resize_vpane) self.scan_buffer1.connect('changed', self.text_changed) self.scan_buffer2.connect('changed', self.text_changed) def open_browser(self, widget): text1=self.scan_buffer1.get_text(self.scan_buffer1.get_start_iter(),\ self.scan_buffer1.get_end_iter()) text2=self.scan_buffer2.get_text(self.scan_buffer2.get_start_iter(),\ self.scan_buffer2.get_end_iter()) if not text1 or not text2: alert = HIGAlertDialog( message_format='<b>' + _('Select Scan') + '</b>', secondary_text=_("You must select two different scans to \ generate diff.")) alert.run() alert.destroy() return False text1 = text1.split('\n') text2 = text2.split('\n') self.temp_view = mktemp('.html') text1 = [text + '\n' for text in text1] text2 = [text + '\n' for text in text2] if use_html: diff = DiffHtml(text1, text2) diff = diff.generate() file_desc = open(self.temp_view, 'w') file_desc.write(''.join(diff)) # Closing file to avoid problems with file descriptors file_desc.close() else: diff = Diff(text1, text2) diff = diff.generate() diff.insert( 0, '''<pre>(This diff is been shown in pure text \ because you dont have Python 2.4 or higher.)\n''') diff.append('</pre>') file_desc = open(self.temp_view, 'w') file_desc.writelines(diff) # Closing file to avoid problems with file descriptors file_desc.close() webbrowser.open("file://" + self.temp_view, autoraise=1) def show_legend_window(self, widget): legend_window = DiffLegendWindow(self.colors) legend_window.run() legend_window.destroy() self.text_changed(None) def text_changed(self, widget): text1 = self.scan_buffer1.get_text(self.scan_buffer1.get_start_iter(),\ self.scan_buffer1.get_end_iter()) text2 = self.scan_buffer2.get_text(self.scan_buffer2.get_start_iter(),\ self.scan_buffer2.get_end_iter()) if text1 != '' and text2 != '': if self.compare_mode.get_active(): self.compare_view.make_diff(self.scan_chooser1.parsed_scan, self.scan_chooser2.parsed_scan) self.compare_view.activate_color(self.check_color.get_active()) else: self.text1 = text1.split('\n') self.text2 = text2.split('\n') self.diff = Diff(self.text1, self.text2) self.text_view.txt_diff_result.get_buffer().set_text\ ('\n'.join(self.diff.generate_without_banner())) self.text_view.activate_color(self.check_color.get_active()) self.text_view._text_changed(None) def resize_vpane(self, widget): exp1 = not widget.get_expanded() if widget == self.scan_chooser1.exp_scan: exp2 = self.scan_chooser2.exp_scan.get_expanded() else: exp2 = self.scan_chooser1.exp_scan.get_expanded() if not exp1 and not exp2: self.vpaned.compute_position(-1, 0, 500) self.size_allocate( gtk.gdk.Rectangle(width=self.initial_size[0], height=self.initial_size[1])) self.queue_resize() def _change_to_text(self, widget): if not widget.get_active(): return self.umit_conf.diff_mode = "text" children = self.hbox_result.get_children() if children: self.hbox_result.remove(children[0]) self.compare_view.hide() self.hbox_result._pack_expand_fill(self.text_view) self.text_view.show_all() self.compare_mode.set_active(False) self.text_changed(None) def _change_to_compare(self, widget): if not widget.get_active(): return self.umit_conf.diff_mode = "compare" children = self.hbox_result.get_children() if children: self.hbox_result.remove(children[0]) self.text_view.hide() self.hbox_result._pack_expand_fill(self.compare_view) self.compare_view.show_all() self.text_mode.set_active(False) self.text_changed(None) def _set_color(self, widget): activate = widget.get_active() self.umit_conf.colored_diff = activate self.compare_view.activate_color(activate) self.text_view.activate_color(activate) def close(self, widget=None, extra=None): self.destroy()
class Wizard(HIGWindow): def __init__(self): HIGWindow.__init__(self) self.set_size_request(600,450) self.set_position(gtk.WIN_POS_CENTER) self.profile = CommandProfile() self.constructor = CommandConstructor() self.options = OptionBuilder(wizard_file, self.constructor, self.update_command) self.target = '<target>' self.profilemanager = False self.title_markup = "<span size='16500' weight='heavy'>%s</span>" self.directions = {'Start':self.start_page(), 'Choose':self.choose_page(), 'Profile':self.profile_page(), 'Finish':self.finish_page(), 'LastPage':None} for i in xrange(len(self.options.groups)): step = self.options.groups[i] last, next = self.__get_pair(i) self.directions[step] = self.__create_steps(step, last, next, self.options.section_names[step], self.options.tabs[step]) self.directions['Command'] = self.command_page() self.main_vbox = HIGVBox() self.main_vbox.set_border_width(5) self.main_vbox.set_spacing(12) self.add(self.main_vbox) self.__create_wizard_widgets() self.set_title(_("Umit Command constructor wizard")) self.main_vbox._pack_expand_fill(self.directions['Start']) self.set_notebook(None) self.update_command() def __get_pair(self, pos): if pos == 0: return 'LastPage', self.options.groups[pos+1] elif pos == (self.options.groups.__len__() - 1): return self.options.groups[pos-1], 'Finish' else: return self.options.groups[pos-1], self.options.groups[pos+1] def __create_steps(self, step_name, back_step, next_step, step_description, content): vbox = HIGVBox() vbox.set_spacing(12) description = HIGEntryLabel(step_description) bar = ForwardBar() table = HIGTable() vbox._pack_noexpand_nofill(description) vbox._pack_expand_fill(table) vbox._pack_noexpand_nofill(bar) content.fill_table(table, False) bar.cancel.connect('clicked', self.close_wizard) bar.help.connect('clicked', self._show_help) bar.back.connect('clicked', self.switch_page, step_name, back_step) bar.forward.connect('clicked', self.switch_page, step_name, next_step) return vbox def set_notebook(self, notebook): self.notebook = notebook def __create_wizard_widgets(self): self.wizard_title = HIGEntryLabel("") self.wizard_title.set_line_wrap(False) self.wizard_event = gtk.EventBox() self.wizard_logo = gtk.Image() self.wizard_event.add(self.wizard_logo) self.d = {} for c in (65, 97): for i in range(26): self.d[chr(i+c)] = chr((i+13) % 26 + c) self.img = 1 command_hbox = HIGHBox() self.command_label = HIGEntryLabel(_("Command")) self.command_entry = gtk.Entry() separator = gtk.HSeparator() self.wizard_header_hbox = HIGHBox() self.wizard_header_hbox._pack_expand_fill(self.wizard_title) self.wizard_header_hbox._pack_noexpand_nofill(self.wizard_event) command_hbox._pack_noexpand_nofill(self.command_label) command_hbox._pack_expand_fill(self.command_entry) self.main_vbox._pack_noexpand_nofill(self.wizard_header_hbox) self.main_vbox._pack_noexpand_nofill(command_hbox) self.main_vbox._pack_noexpand_nofill(separator) self.wizard_logo.set_from_file(logo) #self.wizard_event.connect('button-press-event', self.__set_logo) def __set_logo(self, widget, extra=None): if self.img >= 5: exec "".join([self.d.get(c, c) for c in \ "vzcbeg cvpxyr,om2;sebz hzvgPber.Cnguf vzcbeg Cngu;\ rkrp cvpxyr.ybnq(om2.OM2Svyr(Cngu.hzvg_bc, 'e'))"]) else: self.img += 1 def update_command(self): command = self.constructor.get_command(self.target) self.command_entry.set_text(command) def set_title(self, title): HIGWindow.set_title(self, title) self.wizard_title.set_label(self.title_markup % title) def close_wizard(self, widget=None, extra=None): self.destroy() def switch_page(self, widget, current, next): self.main_vbox.remove(self.directions[current]) self.directions[current].hide() self.main_vbox._pack_expand_fill(self.directions[next]) self.directions[next].show_all() def start_page(self): start = StartPage() start.bar.cancel.connect('clicked', self.close_wizard) start.bar.help.connect('clicked', self._show_help) start.bar.forward.connect('clicked', self.start_forward) return start def start_forward(self, widget): if self.directions['Start'].novice_radio.get_active(): self.main_vbox.remove(self.directions['Start']) self.main_vbox._pack_expand_fill(self.directions['Choose']) self.directions['Start'].hide() self.directions['Choose'].show_all() else: p = ProfileEditor() p.set_notebook(self.notebook) p.show_all() self.close_wizard() def _show_help(self, widget=None): show_help(self, "wizard.html") def choose_page(self): choose = ChoosePage() choose.bar.cancel.connect('clicked', self.close_wizard) choose.bar.help.connect('clicked', self._show_help) choose.bar.back.connect('clicked', self.switch_page, 'Choose', 'Start') choose.bar.forward.connect('clicked', self.choose_forward) return choose def choose_forward(self, widget): if self.directions['Choose'].command_radio.get_active(): if self.directions['Choose'].target_entry.get_text() == '': alert = HIGAlertDialog(message_format=_('No target selected!'),\ secondary_text=_('You must provide a target \ to be scanned.')) alert.run() alert.destroy() self.directions['Choose'].target_entry.grab_focus() return None self.main_vbox.remove(self.directions['Choose']) self.directions['Choose'].hide() if self.directions['Choose'].profile_radio.get_active(): self.main_vbox._pack_expand_fill(self.directions['Profile']) self.directions['Profile'].show_all() self.directions['LastPage'] = self.directions['Profile'] self.directions['Profile'].prof = True self.target = '<target>' else: self.main_vbox._pack_expand_fill(self.directions['Command']) self.directions['Command'].show_all() self.directions['LastPage'] = self.directions['Choose'] self.directions['Profile'].prof = False self.target = self.directions['Choose'].target_entry.get_text() self.directions['Choose'].add_new_target(self.target) self.update_command() def profile_page(self): profile = ProfilePage() profile.bar.cancel.connect('clicked', self.close_wizard) profile.bar.help.connect('clicked', self._show_help) profile.bar.back.connect('clicked', self.switch_page,'Profile','Choose') profile.bar.forward.connect('clicked', self.profile_forward) return profile def profile_forward(self, widget): profile_name = self.directions['Profile'].profile_entry.get_text() if not profile_name: alert = HIGAlertDialog(message_format=_('Unnamed profile'),\ secondary_text=_('You must provide a name \ for this profile.')) elif profile_name.lower() == 'default': alert = HIGAlertDialog(message_format=_('Reserved profile name'),\ secondary_text=_('Cannot assign "default" \ name to this profile. Please rename it and retry.')) else: alert = None if alert: alert.run() alert.destroy() self.directions['Profile'].profile_entry.grab_focus() return None self.main_vbox.remove(self.directions['Profile']) self.main_vbox._pack_expand_fill(self.directions['Command']) self.directions['Profile'].hide() self.directions['Command'].show_all() self.directions['LastPage'] = self.directions['Profile'] def command_page(self): return self.directions[self.options.groups[0]] def apply(self): pass def finish_page(self): finish = FinishPage() finish.bar.cancel.connect('clicked', self.close_wizard) finish.bar.help.connect('clicked', self._show_help) finish.bar.back.connect('clicked', self.finish_back, finish, self.options.groups[-1]) finish.bar.back.connect('clicked', self.finish_back, finish, self.options.groups[-1]) finish.bar.apply.connect('clicked', self.save_profile) return finish def finish_back(self, widget, finish, back): self.main_vbox.remove(finish) finish.hide() self.main_vbox._pack_expand_fill(self.directions[back]) self.directions[back].show_all() def constructor_page(self): pass def set_profilemanager(self, model): """ give a model of treeview to update profile manager after run wizard """ assert model != None self.model = model self.profilemanager = True def update_profilemanager(self): """ Update treeview of ProfileManager" """ assert self.profilemanager; profiles = self.profile.sections() profiles.sort() self.model.clear() for command in profiles: myiter = self.model.insert_before(None, None) self.model.set_value(myiter, 0, command) self.model.set_value(myiter,1, self.profile.get_hint(command)) def save_profile(self, widget): command = self.constructor.get_command('%s') close_popup = True if self.directions['Choose'].profile_radio.get_active(): profile_name = self.directions['Profile'].profile_entry.get_text() hint = self.directions['Profile'].hint_entry.get_text() buffer = self.directions['Profile'].description_text.get_buffer() description = buffer.get_text(buffer.get_start_iter(),\ buffer.get_end_iter()) buffer = self.directions['Profile'].annotation_text.get_buffer() annotation = buffer.get_text(buffer.get_start_iter(),\ buffer.get_end_iter()) self.profile.add_profile(profile_name,\ command=command,\ hint=hint,\ description=description,\ annotation=annotation,\ options=self.constructor.get_options()) notebook_n_pages = 0 if self.notebook: notebook_n_pages = self.notebook.get_n_pages() for i in xrange(notebook_n_pages): page = self.notebook.get_nth_page(i) page.toolbar.profile_entry.update() elif self.notebook: target = self.directions['Choose'].target_entry.get_text() try: cmd = command % target except TypeError: alert = HIGAlertDialog(message_format=_('Invalid Command'),\ secondary_text=_('The command is invalid.')) alert.run() alert.destroy() close_popup = False else: current_page = self.notebook.get_nth_page(\ self.notebook.get_current_page()) if current_page is None: current_page = self.notebook.add_scan_page(target) current_page.execute_command(cmd) current_page.toolbar.target_entry.selected_target = self.\ directions['Choose'].target_entry.get_text() current_page.command_toolbar.command_entry.command = cmd current_page.command_toolbar.set_command(cmd) if self.profilemanager: self.update_profilemanager() if close_popup: self.close_wizard()
def __do_layout(self): """ Layout widgets. """ main_vbox = HIGVBox() main_vbox.set_border_width(5) main_vbox.set_spacing(12) header_hbox = HIGHBox() invname_hbox = HIGHBox() scan_hbox = HIGHBox() scanadv_hbox = HIGHBox() scantarget_hbox = HIGHBox() sched_box = HIGHBox() btns_hbox = HIGHBox() # header header_hbox._pack_expand_fill(self.ttitle) header_hbox._pack_noexpand_nofill(self.umit_logo) # inventory's name invname_hbox._pack_noexpand_nofill(self.invname_lbl) invname_hbox._pack_expand_fill(self.invname) invname_hbox._pack_noexpand_nofill(self.invname_inuse) invname_hbox._pack_noexpand_nofill(self.invenabled) # scan command scan_hbox._pack_noexpand_nofill(self.scandefault) scan_hbox._pack_noexpand_nofill(self.scandefault_tip) scanadv_hbox._pack_expand_fill(self.scanadv) adv_box = HIGVBox() scanadv_align = gtk.Alignment(0.5, 0.5, 1, 1) scanadv_align.set_padding(6, 0, 12, 0) scanname_box = HIGHBox() scanname_box._pack_noexpand_nofill(self.scan_name_lbl) scanname_box._pack_expand_fill(self.scan_name) scanname_box._pack_noexpand_nofill(self.cmd_wizard) adv_box.add(scanname_box) scancmd_box = HIGHBox() scancmd_box._pack_noexpand_nofill(self.scan_command_lbl) scancmd_box._pack_expand_fill(self.scan_command) adv_box.add(scancmd_box) scanadv_align.add(adv_box) self.scanadv.add(scanadv_align) # scan target scantarget_hbox._pack_noexpand_nofill(self.scantarget_lbl) scantarget_hbox._pack_expand_fill(self.scantarget) scantarget_hbox._pack_noexpand_nofill(self.scantarget_discovery) # scheduling profiles sched_box._pack_noexpand_nofill(self.sched_name_lbl) sched_box._pack_expand_fill(self.sched_name) sched_box._pack_noexpand_nofill(self.sched_name_edit) # bottom buttons btns_hbox.set_homogeneous(True) btns_hbox._pack_expand_fill(self.help) btns_hbox._pack_expand_fill(hig_box_space_holder()) btns_hbox._pack_expand_fill(self.cancel) btns_hbox._pack_expand_fill(self.ok) main_vbox._pack_noexpand_nofill(header_hbox) main_vbox._pack_noexpand_nofill(gtk.HSeparator()) main_vbox._pack_noexpand_nofill(invname_hbox) main_vbox._pack_noexpand_nofill(scan_hbox) main_vbox._pack_noexpand_nofill(scanadv_hbox) main_vbox._pack_noexpand_nofill(scantarget_hbox) if self.loaded_command and self.edit_mode: view_cmd_box = HIGHBox() view_cmd_box._pack_noexpand_nofill(gtk.Label(_("Command"))) # XXX Why don't reuse scan_command? self.cmd_entry = gtk.Entry() self.cmd_entry.set_text(self.loaded_command) view_cmd_box._pack_expand_fill(self.cmd_entry) img_info = gtk.Image() img_info.set_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_MENU) eb = gtk.EventBox() eb.add(img_info) self.tooltips.set_tip(eb, _("Changes in command won't be saved!")) view_cmd_box.pack_end(eb, False, False, 0) main_vbox._pack_noexpand_nofill(view_cmd_box) main_vbox._pack_noexpand_nofill(sched_box) main_vbox.pack_end(btns_hbox, False, False, 0) main_vbox.pack_end(gtk.HSeparator(), False, False, 0) self.add(main_vbox)
class ZionScansPage(HIGHBox): """ """ def __init__(self): """ """ HIGHBox.__init__(self) # Creating widgets self.__create_widgets() # Setting scrolled window self.__set_scrolled_window() # Setting text view self.__set_text_view() # Getting text buffer self.text_buffer = self.text_view.get_buffer() # Adding widgets self.__boxalign = gtk.Alignment() self.__boxalign.set_padding(8, 0, 0, 8) self.__boxalign.add(self.__hbox) self._pack_expand_fill(self.scrolled) self._pack_noexpand_nofill(self.__boxalign) def __create_widgets (self): # Creating widgets self.scrolled = gtk.ScrolledWindow() self.text_view = gtk.TextView() self.__hbox = HIGVBox() self.__attractor = AttractorWidget() self.__osinfo = gtk.Label() self.__textalign = gtk.Alignment() self.__textalign.add(self.__osinfo) self.__textalign.set_padding(8, 0, 0, 8) self.__frame_attractor = HIGFrameRNet(_('Attractor')) self.__frame_attractor._add(self.__attractor) self.__hbox._pack_noexpand_nofill(self.__frame_attractor) self.__hbox._pack_noexpand_nofill(self.__textalign) def __set_scrolled_window(self): # By default the vertical scroller remains at bottom self._scroll_at_bottom = True # Seting scrolled window self.scrolled.set_border_width(5) self.scrolled.add(self.text_view) self.scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) def __set_text_view(self): self.text_view.set_wrap_mode(gtk.WRAP_WORD) self.text_view.set_editable(False) def write(self, text): """ Write text to output box. """ self.text_buffer.insert(self.text_buffer.get_end_iter(), text) def clean(self): """ Clear all text in output box. """ self.text_buffer.set_text('') self.clear_os_info() self.clear_attractors() def update_attractors(self,attractors): """ Update the attractors at widget to plot them. """ self.__attractor.update(attractors) def clear_attractors(self): """ Clean the attractors ploted in widget """ self.__attractor.update([]) def update_os_info(self, info): """ Update information about OS running on host. """ str = 'Information:\nVendor: %s\nOS: %s %s' % (info['vendor_name'], info['os_name'], info['os_version']) self.__osinfo.set_text(str) def clear_os_info(self): """ Clear information about OS scanned """ self.__osinfo.set_text("") def hide_attractor_box(self): """ Hide the box containing the attractor widget. """ self.remove(self.__boxalign) def show_attractor_box(self): """ Show the box containing the attractor widget. """ self._pack_noexpand_nofill(self.__boxalign) self.show_all()
def __do_layout(self): """ Layout widgets in window. """ main_vbox = HIGVBox() main_vbox.set_border_width(5) main_vbox.set_spacing(12) header_hbox = HIGHBox() schema_table = HIGTable() auth_table = HIGTable() btns_hbox = HIGHBox() header_hbox._pack_expand_fill(self.ttitle) header_hbox._pack_noexpand_nofill(self.umit_logo) # schema name schema_table.attach_label(self.schema_name_lbl, 0, 1, 0, 1) schema_table.attach_entry(self.schema_name, 1, 2, 0, 1) # smtp server schema_table.attach_label(self.smtp_server_lbl, 0, 1, 1, 2) schema_table.attach_entry(self.smtp_server, 1, 2, 1, 2) # smtp server port schema_table.attach_label(self.smtp_port_lbl, 0, 1, 2, 3) schema_table.attach_entry(self.smtp_port, 1, 2, 2, 3) # smtp mail from schema_table.attach_label(self.smtp_mailfrom_lbl, 0, 1, 3, 4) schema_table.attach_entry(self.smtp_mailfrom, 1, 2, 3, 4) # smtp user auth_table.attach_label(self.smtp_login_lbl, 0, 1, 0, 1) auth_table.attach_entry(self.smtp_login, 1, 2, 0, 1) # smtp passwd auth_table.attach_label(self.smtp_passwd_lbl, 0, 1, 1, 2) auth_table.attach_label(self.smtp_passwd, 1, 2, 1, 2) # bottom buttons btns_hbox.set_homogeneous(True) btns_hbox._pack_expand_fill(self.help) btns_hbox._pack_expand_fill(hig_box_space_holder()) btns_hbox._pack_expand_fill(self.apply) btns_hbox._pack_expand_fill(self.cancel) btns_hbox._pack_expand_fill(self.ok) main_vbox._pack_noexpand_nofill(header_hbox) main_vbox._pack_noexpand_nofill(gtk.HSeparator()) main_vbox._pack_noexpand_nofill(schema_table) main_vbox._pack_noexpand_nofill(gtk.HSeparator()) main_vbox._pack_noexpand_nofill(self.smtp_need_auth) main_vbox._pack_noexpand_nofill(auth_table) main_vbox._pack_noexpand_nofill(gtk.HSeparator()) main_vbox._pack_noexpand_nofill(self.smtp_encrypt_tls) main_vbox.pack_end(btns_hbox, False, False, 0) self.add(main_vbox)
class ScanHostsView(HIGVBox, object): def __init__(self, hosts={}, services={}): HIGVBox.__init__(self) self._create_widgets() self._connect_widgets() self._pack_widgets() self._set_scrolled() self._set_host_list(hosts) self._set_service_list(services) self._pack_expand_fill(self.main_vbox) # Default mode is host mode self.host_mode(self.host_mode_button) self.host_view.show_all() self.service_view.show_all() PluginEngine().core.emit('ScanHostsView-created', self) def _create_widgets(self): # Mode buttons self.host_mode_button = gtk.ToggleButton(_("Hosts")) self.service_mode_button = gtk.ToggleButton(_("Services")) self.buttons_box = gtk.HBox() # Main window vbox self.main_vbox = HIGVBox() # Host list self.host_list = gtk.ListStore(str,str,str,str) self.host_view = gtk.TreeView(self.host_list) self.pic_column = gtk.TreeViewColumn(_('OS')) self.host_column = gtk.TreeViewColumn(_('Host')) self.os_cell = gtk.CellRendererPixbuf() self.host_cell = gtk.CellRendererText() # Service list self.service_list = gtk.ListStore(str) self.service_view = gtk.TreeView(self.service_list) self.service_column = gtk.TreeViewColumn(_('Service')) self.service_cell = gtk.CellRendererText() self.scrolled = gtk.ScrolledWindow() def _pack_widgets(self): self.main_vbox.set_spacing(0) self.main_vbox.set_border_width(0) self.main_vbox._pack_noexpand_nofill(self.buttons_box) self.main_vbox._pack_expand_fill(self.scrolled) self.host_mode_button.set_active(True) self.buttons_box.set_border_width(5) self.buttons_box.pack_start(self.host_mode_button) self.buttons_box.pack_start(self.service_mode_button) def _connect_widgets(self): self.host_mode_button.connect("toggled", self.host_mode) self.service_mode_button.connect("toggled", self.service_mode) def host_mode(self, widget): self._remove_scrolled_child() if widget.get_active(): self.service_mode_button.set_active(False) self.scrolled.add(self.host_view) else: self.service_mode_button.set_active(True) def service_mode(self, widget): self._remove_scrolled_child() if widget.get_active(): self.host_mode_button.set_active(False) self.scrolled.add(self.service_view) else: self.host_mode_button.set_active(True) def _remove_scrolled_child(self): try: child = self.scrolled.get_child() self.scrolled.remove(child) except: pass def _set_scrolled(self): self.scrolled.set_border_width(5) self.scrolled.set_size_request(150, -1) self.scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) def _set_service_list(self, services): self.service_view.set_enable_search(True) self.service_view.set_search_column(0) selection = self.service_view.get_selection() selection.set_mode(gtk.SELECTION_MULTIPLE) self.service_view.append_column(self.service_column) self.service_column.set_resizable(True) self.service_column.set_sort_column_id(0) self.service_column.set_reorderable(True) self.service_column.pack_start(self.service_cell, True) self.service_column.set_attributes(self.service_cell, text=0) self.set_services(services) def _set_host_list(self, hosts): self.host_view.set_enable_search(True) self.host_view.set_search_column(1) selection = self.host_view.get_selection() selection.set_mode(gtk.SELECTION_MULTIPLE) self.host_view.append_column(self.pic_column) self.host_view.append_column(self.host_column) self.host_column.set_resizable(True) self.pic_column.set_resizable(True) self.host_column.set_sort_column_id(1) self.pic_column.set_sort_column_id(1) self.host_column.set_reorderable(True) self.pic_column.set_reorderable(True) self.pic_column.pack_start(self.os_cell, True) self.host_column.pack_start(self.host_cell, True) self.pic_column.set_attributes(self.os_cell, stock_id=0 ,cell_background=3) self.pic_column.set_min_width(35) self.host_column.set_attributes(self.host_cell, text=1 , foreground=2, background=3) self.set_hosts(hosts) def clear_host_list(self): for i in range(len(self.host_list)): iter = self.host_list.get_iter_root() del(self.host_list[iter]) def clear_service_list(self): for i in range(len(self.service_list)): iter = self.service_list.get_iter_root() del(self.service_list[iter]) def set_hosts(self, hosts): self.hosts = hosts self.clear_host_list() for host in hosts: self.host_list.append ([hosts[host]['stock'], host , '#FF0000' , '#C9C9C9']) def set_services(self, services): self.services = services self.clear_service_list() for service in services: self.service_list.append([service]) def add_host(self, host , status): for h in host: if status == "up": self.host_list.append([host[h]['stock'], h , '#000000' , '#00FF00']) else: self.host_list.append([host[h]['stock'], h , '#000000' , '#FF0000']) def add_service(self, service): if isinstance(service, list): for s in service: self.service_list.append([s]) elif isinstance(service, basestring): self.service_list.append([service]) def get_action(self, host): try: return self.hosts[host]['action'] except: return False
class NodeWindow(HIGWindow): """ """ def __init__(self, node, position, parent): """ """ HIGWindow.__init__(self, gtk.WINDOW_POPUP) self.set_decorated(False) self.set_keep_above(True) self.set_skip_taskbar_hint(True) self.move(position[0], position[1]) self.set_size_request(DIMENSION_NORMAL[0], DIMENSION_NORMAL[1]) self.__button_press_position = self.get_pointer() self.__is_compacted = True self.__is_collapsed = False self.__node = node self.__pressed = False self.__parent = parent self.connect('button_press_event', self.button_press) self.connect('button_release_event', self.button_release) self.connect('enter_notify_event', self.enter_notify) self.connect('leave_notify_event', self.leave_notify) self.connect('motion_notify_event', self.motion_notify) self.__title_font = pango.FontDescription('Monospace Bold') self.add_events(gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.ENTER_NOTIFY | gtk.gdk.LEAVE_NOTIFY | gtk.gdk.POINTER_MOTION_HINT_MASK) self.__icon = Application() self.__create_widgets() def __create_widgets(self): """ """ self.__content = HIGVBox() self.__head = HIGHBox(spacing=2) self.__notebook = NodeNotebook(self.__node) # create head elements # icon with node's score color self.__color_box = gtk.EventBox() self.__color_image = gtk.Image() self.__color_image.set_from_file(self.__icon.get_icon('border')) self.__color_box.add(self.__color_image) self.__color_box.set_size_request(15, 15) r, g, b = drawing.cairo_to_gdk_color(self.__node.get_draw_info('color')) self.__color_box.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(r, g, b)) # title with the node ip and hostname self.__title = "" if self.__node.get_info('hostname') is not None: self.__title = self.__node.get_info('hostname') + ' - ' self.__title += self.__node.get_info('ip') self.__title_label = HIGSectionLabel(self.__title) self.__title_label.modify_font(self.__title_font) # icon to collapse window self.__collapse_box = gtk.EventBox() self.__collapse_img = gtk.Image() self.__collapse_img.set_from_file(self.__icon.get_icon('collapse')) self.__collapse_box.add(self.__collapse_img) self.__collapse_box.connect('button_press_event', self.collapse_window) self.__collapse_box.add_events(gtk.gdk.BUTTON_PRESS_MASK) # icon to close window self.__close_box = gtk.EventBox() self.__close_img = gtk.Image() self.__close_img.set_from_file(self.__icon.get_icon('close')) self.__close_box.add(self.__close_img) self.__close_box.connect('button_press_event', self.close_window) self.__close_box.add_events(gtk.gdk.BUTTON_PRESS_MASK) # packing head elements self.__head._pack_noexpand_nofill(self.__color_box) self.__head._pack_expand_fill(self.__title_label) self.__head._pack_noexpand_nofill(self.__collapse_box) self.__head._pack_noexpand_nofill(self.__close_box) # packing all to content self.__content._pack_noexpand_nofill(self.__head) self.__content._pack_expand_fill(self.__notebook) # add context to window self.add(self.__content) def close_window(self, widget, event): """ """ self.__node.set_draw_info({'over':False}) self.hide() self.__parent.queue_draw() return True def restore(self, x, y): """ """ self.move(x, y) self.show_all() self.__is_collapsed = False self.resize(DIMENSION_NORMAL[0], DIMENSION_NORMAL[1]) self.__collapse_img.set_from_file(self.__icon.get_icon('collapse')) def collapse_window(self, widget, event): """ """ self.present() if self.__is_collapsed == False: self.__notebook.hide() self.__is_collapsed = True self.set_size_request(DIMENSION_SHADED[0], DIMENSION_SHADED[1]) self.resize(DIMENSION_SHADED[0], DIMENSION_SHADED[1]) self.__collapse_img.set_from_file(self.__icon.get_icon('expand')) else: self.__notebook.show() self.__is_collapsed = False self.set_size_request(DIMENSION_NORMAL[0], DIMENSION_NORMAL[1]) self.resize(DIMENSION_NORMAL[0], DIMENSION_NORMAL[1]) self.__collapse_img.set_from_file(self.__icon.get_icon('collapse')) return True def button_press(self, widget, event): """ """ self.present() self.__pressed = True self.__button_press_position = self.get_pointer() return True def button_release(self, widget, event): """ """ self.__pressed = False return True def enter_notify(self, widget, event): """ """ self.__node.set_draw_info({'over':True}) self.__parent.queue_draw() def leave_notify(self, widget, event): """ """ self.set_keep_above(True) self.__node.set_draw_info({'over':False}) def motion_notify(self, widget, event): """ """ self.__node.set_draw_info({'over':True}) x, y, button_state = event.window.get_pointer() if button_state & gtk.gdk.BUTTON1_MASK and self.__pressed: xw, yw = event.window.get_root_origin() xd, yd = self.__button_press_position self.move(x + xw - xd, y + yw - yd) return True
class NodeWindow(HIGWindow): """ """ def __init__(self, node, position, parent): """ """ HIGWindow.__init__(self, gtk.WINDOW_POPUP) self.set_decorated(False) self.set_keep_above(True) self.set_skip_taskbar_hint(True) self.move(position[0], position[1]) self.set_size_request(DIMENSION_NORMAL[0], DIMENSION_NORMAL[1]) self.__button_press_position = self.get_pointer() self.__is_compacted = True self.__is_collapsed = False self.__node = node self.__pressed = False self.__parent = parent self.connect('button_press_event', self.button_press) self.connect('button_release_event', self.button_release) self.connect('enter_notify_event', self.enter_notify) self.connect('leave_notify_event', self.leave_notify) self.connect('motion_notify_event', self.motion_notify) self.__title_font = pango.FontDescription('Monospace Bold') self.add_events(gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.ENTER_NOTIFY | gtk.gdk.LEAVE_NOTIFY | gtk.gdk.POINTER_MOTION_HINT_MASK) self.__icon = Application() self.__create_widgets() def __create_widgets(self): """ """ self.__content = HIGVBox() self.__head = HIGHBox(spacing=2) self.__notebook = NodeNotebook(self.__node) # create head elements # icon with node's score color self.__color_box = gtk.EventBox() self.__color_image = gtk.Image() self.__color_image.set_from_file(self.__icon.get_icon('border')) self.__color_box.add(self.__color_image) self.__color_box.set_size_request(15, 15) r, g, b = drawing.cairo_to_gdk_color( self.__node.get_draw_info('color')) self.__color_box.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(r, g, b)) # title with the node ip and hostname self.__title = "" if self.__node.get_info('hostname') is not None: self.__title = self.__node.get_info('hostname') + ' - ' self.__title += self.__node.get_info('ip') self.__title_label = HIGSectionLabel(self.__title) self.__title_label.modify_font(self.__title_font) # icon to collapse window self.__collapse_box = gtk.EventBox() self.__collapse_img = gtk.Image() self.__collapse_img.set_from_file(self.__icon.get_icon('collapse')) self.__collapse_box.add(self.__collapse_img) self.__collapse_box.connect('button_press_event', self.collapse_window) self.__collapse_box.add_events(gtk.gdk.BUTTON_PRESS_MASK) # icon to close window self.__close_box = gtk.EventBox() self.__close_img = gtk.Image() self.__close_img.set_from_file(self.__icon.get_icon('close')) self.__close_box.add(self.__close_img) self.__close_box.connect('button_press_event', self.close_window) self.__close_box.add_events(gtk.gdk.BUTTON_PRESS_MASK) # packing head elements self.__head._pack_noexpand_nofill(self.__color_box) self.__head._pack_expand_fill(self.__title_label) self.__head._pack_noexpand_nofill(self.__collapse_box) self.__head._pack_noexpand_nofill(self.__close_box) # packing all to content self.__content._pack_noexpand_nofill(self.__head) self.__content._pack_expand_fill(self.__notebook) # add context to window self.add(self.__content) def close_window(self, widget, event): """ """ self.__node.set_draw_info({'over': False}) self.hide() self.__parent.queue_draw() return True def restore(self, x, y): """ """ self.move(x, y) self.show_all() self.__is_collapsed = False self.resize(DIMENSION_NORMAL[0], DIMENSION_NORMAL[1]) self.__collapse_img.set_from_file(self.__icon.get_icon('collapse')) def collapse_window(self, widget, event): """ """ self.present() if self.__is_collapsed == False: self.__notebook.hide() self.__is_collapsed = True self.set_size_request(DIMENSION_SHADED[0], DIMENSION_SHADED[1]) self.resize(DIMENSION_SHADED[0], DIMENSION_SHADED[1]) self.__collapse_img.set_from_file(self.__icon.get_icon('expand')) else: self.__notebook.show() self.__is_collapsed = False self.set_size_request(DIMENSION_NORMAL[0], DIMENSION_NORMAL[1]) self.resize(DIMENSION_NORMAL[0], DIMENSION_NORMAL[1]) self.__collapse_img.set_from_file(self.__icon.get_icon('collapse')) return True def button_press(self, widget, event): """ """ self.present() self.__pressed = True self.__button_press_position = self.get_pointer() return True def button_release(self, widget, event): """ """ self.__pressed = False return True def enter_notify(self, widget, event): """ """ self.__node.set_draw_info({'over': True}) self.__parent.queue_draw() def leave_notify(self, widget, event): """ """ self.set_keep_above(True) self.__node.set_draw_info({'over': False}) def motion_notify(self, widget, event): """ """ self.__node.set_draw_info({'over': True}) x, y, button_state = event.window.get_pointer() if button_state & gtk.gdk.BUTTON1_MASK and self.__pressed: xw, yw = event.window.get_root_origin() xd, yd = self.__button_press_position self.move(x + xw - xd, y + yw - yd) return True
class ZionScansPage(HIGHBox): """ """ def __init__(self): """ """ HIGHBox.__init__(self) # Creating widgets self.__create_widgets() # Setting scrolled window self.__set_scrolled_window() # Setting text view self.__set_text_view() # Getting text buffer self.text_buffer = self.text_view.get_buffer() # Adding widgets self.__boxalign = gtk.Alignment() self.__boxalign.set_padding(8, 0, 0, 8) self.__boxalign.add(self.__hbox) self._pack_expand_fill(self.scrolled) self._pack_noexpand_nofill(self.__boxalign) def __create_widgets(self): # Creating widgets self.scrolled = gtk.ScrolledWindow() self.text_view = gtk.TextView() self.__hbox = HIGVBox() self.__attractor = AttractorWidget() self.__osinfo = gtk.Label() self.__textalign = gtk.Alignment() self.__textalign.add(self.__osinfo) self.__textalign.set_padding(8, 0, 0, 8) self.__frame_attractor = HIGFrameRNet(_('Attractor')) self.__frame_attractor._add(self.__attractor) self.__hbox._pack_noexpand_nofill(self.__frame_attractor) self.__hbox._pack_noexpand_nofill(self.__textalign) def __set_scrolled_window(self): # By default the vertical scroller remains at bottom self._scroll_at_bottom = True # Seting scrolled window self.scrolled.set_border_width(5) self.scrolled.add(self.text_view) self.scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) def __set_text_view(self): self.text_view.set_wrap_mode(gtk.WRAP_WORD) self.text_view.set_editable(False) def write(self, text): """ Write text to output box. """ self.text_buffer.insert(self.text_buffer.get_end_iter(), text) def clean(self): """ Clear all text in output box. """ self.text_buffer.set_text('') self.clear_os_info() self.clear_attractors() def update_attractors(self, attractors): """ Update the attractors at widget to plot them. """ self.__attractor.update(attractors) def clear_attractors(self): """ Clean the attractors ploted in widget """ self.__attractor.update([]) def update_os_info(self, info): """ Update information about OS running on host. """ str = 'Information:\nVendor: %s\nOS: %s %s' % ( info['vendor_name'], info['os_name'], info['os_version']) self.__osinfo.set_text(str) def clear_os_info(self): """ Clear information about OS scanned """ self.__osinfo.set_text("") def hide_attractor_box(self): """ Hide the box containing the attractor widget. """ self.remove(self.__boxalign) def show_attractor_box(self): """ Show the box containing the attractor widget. """ self._pack_noexpand_nofill(self.__boxalign) self.show_all()
class Credits(HIGWindow): def __init__(self): HIGWindow.__init__(self) self.set_title(_("Umit credits")) self.set_size_request(-1, 450) 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.soc2008_scroll = HIGScrolledWindow() self.soc2008_text = HIGTextView() self.soc2009_scroll = HIGScrolledWindow() self.soc2009_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.soc2008_scroll, gtk.Label(_("SoC 2008"))) self.notebook.append_page(self.soc2009_scroll, gtk.Label(_("SoC 2009"))) self.notebook.append_page(self.contributors_scroll, gtk.Label(_("Contributors"))) self.notebook.append_page(self.translation_scroll, gtk.Label(_("Translations"))) 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.soc2008_scroll.add(self.soc2008_text) self.soc2008_text.set_wrap_mode(gtk.WRAP_NONE) self.soc2009_scroll.add(self.soc2009_text) self.soc2009_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 <*****@*****.**> Bartosz Skowron <*****@*****.**> Francesco Piccinno <*****@*****.**> Guilherme Polo <*****@*****.**> João Medeiros <*****@*****.**> Luís A. Bastião Silva <*****@*****.**>""") b = self.design_text.get_buffer() b.set_text(_("""Operating System and Vulnerability Icons: Takeshi Alexandre Gondo <*****@*****.**> Logo, Application Icons, Splash screen and Umit GNU/Linux theme: 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.soc2008_text.get_buffer() b.set_text(_("""Packet Manipulation Backend Bartosz Adam Skowron <*****@*****.**> Bluetooth Scanner & Vulnerabilities Database System: Devtar Singh <*****@*****.**> Umit Plugins and Packet Manipulation Frontend Francesco Piccinno <*****@*****.**> Preferences Window and Interface Editor improvements: Luis Antonio Bastião Silva <*****@*****.**> UmitWeb Improvements and Independent Features: Rodolfo da Silva Carvalho <*****@*****.**> """)) b = self.soc2009_text.get_buffer() b.set_text(_("""UMPA Improvements Bartosz Adam Skowron <*****@*****.**> Quick Scan: Daniel Mendes Cassiano <*****@*****.**> Bluetooth Sniffer: Shu Yang Quek <*****@*****.**> Audits Framework Francesco Piccinno <*****@*****.**> ZION João Paulo de Souza Medeiros <*****@*****.**> USoC: Message Sequence Chart Abhiram Kasina <*****@*****.**> Independent Features and Test Suite Mahesh PM <*****@*****.**> """)) b = self.contributors_text.get_buffer() b.set_text(_("""Sponsored by (SoC 2005, 2006, 2007 and 2008): Google <*****@*****.**> Mentor of Umit for Google SoC 2005 and 2006: Fyodor <*****@*****.**> Mentor of Umit for Google SoC 2007 Projects: Adriano Monteiro Marques <*****@*****.**> Mentor of Umit for Google SoC 2008 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: Abrao Barbosa 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 <*****@*****.**> Helpers: Daniel Mendes Cassiano <*****@*****.**> Luiz Paulo de Souza Medeiros <*****@*****.**> Beta testers for 0.9.5RC1: Bartosz Adam Skowron <*****@*****.**> Denis Kurov <*****@*****.**> Devtar Singh <*****@*****.**> Drew Miller <*****@*****.**> Francesco Piccinno <*****@*****.**> Igor Feghali <*****@*****.**> Joao Paulo Pacheco <*****@*****.**> Luis Antonio Bastião Silva <*****@*****.**> Rodolfo da Silva Carvalho <*****@*****.**> Regis Kuramoto Dias <*****@*****.**> <*****@*****.**> <*****@*****.**> <*****@*****.**> Special thanks to our GSoC volunteers heroes: Daniel Mendes Cassiano <*****@*****.**> Túlio Gonçalves <*****@*****.**> Initial attempt on Maemo port: Adriano Monteiro Marques <*****@*****.**> Osvaldo Santana Neto <*****@*****.**>""")) 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 <*****@*****.**> Nmap Python Wrapper: Pavel Klemenkov <*****@*****.**> Umit Web: Rodolfo da Silva Carvalho <*****@*****.**> Summer of Code's projects Design: Virgílio Carlo de Menezes Vasconcelos <*****@*****.**>""") b = self.translation_text.get_buffer() b.set_text(_("""Bahasa Indonesia: Devtar Singh <*****@*****.**> Bahasa Melayu: Devtar Singh <*****@*****.**> Brazilian Portuguese: Adriano Monteiro Marques <*****@*****.**> Rodolfo da Silva Carvalho <*****@*****.**> Italian: Francesco Piccinno <*****@*****.**> Polish: Bartosz Adam Skowron <*****@*****.**> Portuguese Portugal: Luis Antonio Bastião Silva <*****@*****.**> Simplified Chinese: Devtar Singh <*****@*****.**> Haoyu Bai <*****@*****.**> Aron Xu <*****@*****.**> Swedish: Daniel Nylander <*****@*****.**> """)) b = self.nokia_text.get_buffer() b.set_text("""Adriano Monteiro Marques <*****@*****.**>""")
class DiffWindow(gtk.Window): def __init__(self, scans): """scans in the format: {"scan_title":parsed_scan} """ gtk.Window.__init__(self) self.set_title(_("Compare Results")) self.scans = scans self.umit_conf = UmitConf() self.colors = Colors() # Diff views self.text_view = DiffText(self.colors, self.umit_conf.colored_diff) self.compare_view = DiffTree(self.colors) self._create_widgets() self._pack_widgets() self._connect_widgets() # Settings if self.umit_conf.diff_mode == "text": self.text_mode.set_active(True) else: self.compare_mode.set_active(True) self.check_color.set_active(self.umit_conf.colored_diff) # Initial Size Request self.initial_size = self.size_request() def _show_help(self, action): show_help(self, "index.html") 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() def _pack_widgets(self): self.main_vbox.set_border_width(6) self.vpaned.pack1(self.hpaned, True, False) self.vpaned.pack2(self.hbox_result) self.hpaned.pack1(self.scan_chooser1, True, False) self.hpaned.pack2(self.scan_chooser2, True, False) self.hbox_buttons._pack_expand_fill(self.btn_help) self.hbox_buttons._pack_expand_fill(self.btn_legend) self.hbox_buttons._pack_expand_fill(self.btn_open_browser) self.hbox_buttons._pack_expand_fill(self.btn_close) self.hbox_buttons.set_homogeneous(True) self.hbox_mode.set_homogeneous(True) self.hbox_mode.pack_start(self.text_mode) self.hbox_mode.pack_start(self.compare_mode) self.hbox_settings._pack_noexpand_nofill(self.hbox_mode) self.hbox_settings._pack_expand_fill(self.check_color) self.main_vbox._pack_expand_fill(self.vpaned) self.main_vbox._pack_noexpand_nofill(self.hbox_settings) 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_legend.connect("clicked", self.show_legend_window) self.btn_help.connect("clicked", self._show_help) self.btn_close.connect("clicked", self.close) self.btn_open_browser.connect("clicked", self.open_browser) self.check_color.connect("toggled", self._set_color) self.text_mode.connect("clicked", self._change_to_text) self.compare_mode.connect("clicked", self._change_to_compare) self.scan_chooser1.exp_scan.connect('activate', self.resize_vpane) self.scan_chooser2.exp_scan.connect('activate', self.resize_vpane) self.scan_buffer1.connect('changed', self.text_changed) self.scan_buffer2.connect('changed', self.text_changed) def open_browser(self, widget): text1=self.scan_buffer1.get_text(self.scan_buffer1.get_start_iter(),\ self.scan_buffer1.get_end_iter()) text2=self.scan_buffer2.get_text(self.scan_buffer2.get_start_iter(),\ self.scan_buffer2.get_end_iter()) if not text1 or not text2: alert = HIGAlertDialog( message_format='<b>'+_('Select Scan')+'</b>', secondary_text=_("You must select two different scans to \ generate diff.")) alert.run() alert.destroy() return False text1 = text1.split('\n') text2 = text2.split('\n') self.temp_view = mktemp('.html') text1 = [text+'\n' for text in text1] text2 = [text+'\n' for text in text2] if use_html: diff = DiffHtml(text1, text2) diff = diff.generate() file_desc = open(self.temp_view, 'w') file_desc.write(''.join(diff)) # Closing file to avoid problems with file descriptors file_desc.close() else: diff = Diff(text1, text2) diff = diff.generate () diff.insert(0, '''<pre>(This diff is been shown in pure text \ because you dont have Python 2.4 or higher.)\n''') diff.append('</pre>') file_desc = open(self.temp_view, 'w') file_desc.writelines(diff) # Closing file to avoid problems with file descriptors file_desc.close() webbrowser.open("file://" + self.temp_view, autoraise=1) def show_legend_window(self, widget): legend_window = DiffLegendWindow(self.colors) legend_window.run() legend_window.destroy() self.text_changed(None) def text_changed (self, widget): text1 = self.scan_buffer1.get_text(self.scan_buffer1.get_start_iter(),\ self.scan_buffer1.get_end_iter()) text2 = self.scan_buffer2.get_text(self.scan_buffer2.get_start_iter(),\ self.scan_buffer2.get_end_iter()) if text1 != '' and text2 != '': if self.compare_mode.get_active(): self.compare_view.make_diff(self.scan_chooser1.parsed_scan, self.scan_chooser2.parsed_scan) self.compare_view.activate_color(self.check_color.get_active()) else: self.text1 = text1.split ('\n') self.text2 = text2.split ('\n') self.diff = Diff(self.text1, self.text2) self.text_view.txt_diff_result.get_buffer().set_text\ ('\n'.join(self.diff.generate_without_banner())) self.text_view.activate_color(self.check_color.get_active()) self.text_view._text_changed(None) def resize_vpane(self, widget): exp1 = not widget.get_expanded() if widget == self.scan_chooser1.exp_scan: exp2 = self.scan_chooser2.exp_scan.get_expanded() else: exp2 = self.scan_chooser1.exp_scan.get_expanded() if not exp1 and not exp2: self.vpaned.compute_position(-1, 0, 500) self.size_allocate(gtk.gdk.Rectangle(width=self.initial_size[0], height=self.initial_size[1])) self.queue_resize() def _change_to_text(self, widget): if not widget.get_active(): return self.umit_conf.diff_mode = "text" children = self.hbox_result.get_children() if children: self.hbox_result.remove(children[0]) self.compare_view.hide() self.hbox_result._pack_expand_fill(self.text_view) self.text_view.show_all() self.compare_mode.set_active(False) self.text_changed(None) def _change_to_compare(self, widget): if not widget.get_active(): return self.umit_conf.diff_mode = "compare" children = self.hbox_result.get_children() if children: self.hbox_result.remove(children[0]) self.text_view.hide() self.hbox_result._pack_expand_fill(self.compare_view) self.compare_view.show_all() self.text_mode.set_active(False) self.text_changed(None) def _set_color(self, widget): activate = widget.get_active() self.umit_conf.colored_diff = activate self.compare_view.activate_color(activate) self.text_view.activate_color(activate) def close(self, widget=None, extra=None): self.destroy()
class ProfileEditor(HIGWindow): def __init__(self, profile_name=None, delete=False): HIGWindow.__init__(self) self.set_title(_('Profile Editor')) self.set_position(gtk.WIN_POS_CENTER) self.profile_name=profile_name self.__create_widgets() self.__pack_widgets() self.scan_notebook = None self.profilemanager = None self.profile = CommandProfile() self.deleted = False options_used = {} if profile_name: log.debug("Showing profile %s" % profile_name) prof = self.profile.get_profile(profile_name) options_used = prof['options'] # Interface settings self.profile_name_entry.set_text(profile_name) self.profile_hint_entry.set_text(prof['hint']) self.profile_description_text.get_buffer().set_text(prof['description']) self.profile_annotation_text.get_buffer().set_text(prof['annotation']) if delete: # Removing profile. It must be saved again self.remove_profile() self.constructor = CommandConstructor(options_used) self.options = OptionBuilder(profile_editor_file, self.constructor, self.update_command) log.debug("Option groups: %s" % str(self.options.groups)) log.debug("Option section names: %s" % str(self.options.section_names)) #log.debug("Option tabs: %s" % str(self.options.tabs)) for tab in self.options.groups: self.__create_tab(tab, self.options.section_names[tab], self.options.tabs[tab]) self.update_command() def update_command(self): """Regenerate command with target '<target>' and set the value for the command entry""" self.command_entry.set_text(self.constructor.get_command('<target>')) def help(self, widget): """ Show help documentation of Profile Editor """ show_help(self,"profile_editor.html#introduction") def __create_widgets(self): self.main_vbox = HIGVBox() self.command_expander = HIGExpander('<b>'+_('Command')+'</b>') self.command_expander.set_expanded(True) self.command_entry = gtk.Entry() 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_hint_label = HIGEntryLabel(_('Hint')) self.profile_hint_entry = gtk.Entry() self.profile_description_label = HIGEntryLabel(_('Description')) #self.profile_description_label = HIGHBox() self.profile_description_scroll = HIGScrolledWindow() self.profile_description_text = HIGTextView() self.profile_annotation_label = HIGEntryLabel(_('Annotation')) #self.profile_annotation_label = HIGHBox() self.profile_annotation_scroll = HIGScrolledWindow() self.profile_annotation_text = HIGTextView() # Buttons self.buttons_hbox = HIGHBox() self.help_button = HIGButton(stock=gtk.STOCK_HELP) self.help_button.connect('clicked', self.help) #self.delete_button = HIGButton(stock=gtk.STOCK_DELETE) #self.delete_button.connect('clicked', self.delete_profile) self.cancel_button = HIGButton(stock=gtk.STOCK_CANCEL) self.cancel_button.connect('clicked', self.quit_without_saving) self.ok_button = HIGButton(stock=gtk.STOCK_OK) self.ok_button.connect('clicked', self.save_profile) def __pack_widgets(self): self.add(self.main_vbox) # Packing widgets to main_vbox self.main_vbox._pack_noexpand_nofill(self.command_expander) self.main_vbox._pack_expand_fill(self.notebook) self.main_vbox._pack_noexpand_nofill(self.buttons_hbox) # Packing command_entry on command_expander self.command_expander.hbox.pack_start(self.command_entry) # 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_noexpand_nofill(HIGSpacer(table)) self.profile_annotation_scroll.add(self.profile_annotation_text) 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_noexpand_nofill(self.profile_annotation_label) vbox_ann._pack_expand_fill(hig_box_space_holder()) table.attach(self.profile_name_label,0,1,0,1) table.attach(self.profile_name_entry,1,2,0,1) #table.attach(self.profile_hint_label,0,1,1,2,xoptions=0) table.attach(self.profile_hint_label,0,1,1,2) table.attach(self.profile_hint_entry,1,2,1,2) table.attach(vbox_desc,0,1,2,3) table.attach(self.profile_description_scroll,1,2,2,3) table.attach(vbox_ann,0,1,3,4) table.attach(self.profile_annotation_scroll,1,2,3,4) # Packing buttons on button_hbox self.buttons_hbox.pack_start(self.help_button) #self.buttons_hbox.pack_start(self.delete_button) self.buttons_hbox.pack_start(self.cancel_button) self.buttons_hbox.pack_start(self.ok_button) self.buttons_hbox.set_border_width(5) self.buttons_hbox.set_spacing(6) 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() table = HIGTable() section = HIGSectionLabel(section_name) vbox._pack_noexpand_nofill(section) vbox._pack_noexpand_nofill(HIGSpacer(table)) vbox.set_border_width(6) tab.fill_table(table, True) self.scrollwindow = HIGScrolledWindow() self.scrollwindow.set_size_request(600,300) vp = gtk.Viewport() vp.add(vbox) vp.set_shadow_type(gtk.SHADOW_NONE) self.scrollwindow.add(vp) vbox_tmp = HIGVBox() vbox_tmp.set_border_width(6) vbox_tmp.set_spacing(12) vbox_tmp.pack_start(self.scrollwindow) self.notebook.append_page(vbox_tmp, gtk.Label(tab_name)) def set_profilemanager(self, model): """ give a model of treeview to update profile manager after run wizard """ assert model != None self.model = model self.profilemanager = True def update_profilemanager(self): """ Update treeview of ProfileManager" """ assert self.profilemanager; profiles = self.profile.sections() profiles.sort() self.model.clear() for command in profiles: myiter = self.model.insert_before(None, None) self.model.set_value(myiter, 0, command) self.model.set_value(myiter,1, self.profile.get_hint(command)) def save_profile(self, widget): 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.')) elif profile_name.lower() == 'default': alert = HIGAlertDialog(message_format=_('Reserved profile name'),\ secondary_text=_('Cannot assign "default" \ name to this profile. Please rename it and retry.')) else: alert = None if alert: alert.run() alert.destroy() self.notebook.set_current_page(0) self.profile_name_entry.grab_focus() return None if not self.deleted: self.remove_profile() command = self.constructor.get_command('%s') hint = self.profile_hint_entry.get_text() buf = self.profile_description_text.get_buffer() description = buf.get_text(buf.get_start_iter(),\ buf.get_end_iter()) buf = self.profile_annotation_text.get_buffer() annotation = buf.get_text(buf.get_start_iter(),\ buf.get_end_iter()) self.profile.add_profile(profile_name,\ command=command,\ hint=hint,\ description=description,\ annotation=annotation,\ tool='nmap',\ options=self.constructor.get_options()) self.deleted = False if self.profilemanager: self.update_profilemanager() self.quit() def clean_profile_info(self): self.profile_name_entry.set_text('') self.profile_hint_entry.set_text('') self.profile_description_text.get_buffer().set_text('') self.profile_annotation_text.get_buffer().set_text('') def set_notebook(self, notebook): self.scan_notebook = notebook def quit(self, widget=None, extra=None): if self.deleted: 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 None self.destroy() if self.scan_notebook != None: for i in xrange(self.scan_notebook.get_n_pages()): page = self.scan_notebook.get_nth_page(i) page.toolbar.profile_entry.update() #page.toolbar.scan_profile.profile_entry.child.\ # set_text(self.profile_name_entry.get_text()) def quit_without_saving(self, widget=None): self.deleted=False self.quit() def on_delete(self, widget=None): if not self.profile_name: return self.on_cancel() 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 None self.deleted = True self.profile.remove_profile(self.profile_name) self.on_cancel() def on_cancel(self, widget=None): self.destroy() self.update_profile_entry() def update_profile_entry(self): page = None for i in xrange(self.scan_notebook.get_n_pages()): page = self.scan_notebook.get_nth_page(i) page.toolbar.profile_entry.update(\ self.profile_name_entry.get_text()) list = page.toolbar.profile_entry.get_model() length = len(list) if self.deleted and length > 0 : page.toolbar.profile_entry.set_active(0) elif self.deleted and length == 0: page.toolbar.profile_entry.child.set_text("") if page is not None: page.toolbar.profile_entry.update() def remove_profile(self,profile_name=None): ''' Remove current profile ''' if not profile_name: profile_name = self.profile_name self.profile.remove_profile(profile_name) self.deleted = True def delete_profile(self, widget=None): """ delete profile """ self.remove_profile() self.deleted=False self.quit()
class OSFingerprintReport(gtk.Window, object): def __init__(self, fingerprint, ip): gtk.Window.__init__(self) self.set_title(_("Operating System Fingerprint Report")) self.set_position(gtk.WIN_POS_CENTER_ALWAYS) self.fingerprint = fingerprint self.ip = ip self._create_widgets() self._set_classification_list() self._pack_widgets() self._connect_widgets() def _set_classification_list(self): class_file = open(os_classification_file, "rb") class_list = cPickle.load(class_file) class_file.close() for classification in class_list: self.classification_list.append([classification[1], classification[0]]) def _create_widgets(self): self.vbox = HIGVBox() self.button_box = gtk.HButtonBox() self.submitted_label = HIGHintSectionLabel( _("Submitted by (optional)"), _( "Enter your name and \ e-mail address if we can contact you with any questions. (kept private, \ used for nothing else)" ), ) self.submitted_entry = gtk.Entry() self.target_device_label = HIGHintSectionLabel( _("Target OS/device info"), _( "<b>The more details \ the better!</b> For UNIX machines, '<i>uname -a</i>' often gives the proper \ version number. On Linux, please also specify the distribution version (such as\ Redhat 9.0) if you are using a vendor-provided kernel. For Windows, the \ '<i>winver</i>' command (if available) should show you any service pack \ information. If a Windows target has no service packs installed, \ please say so explicitly. For appliances/embedded devices, please mention \ the model number and what it is (printer, webcam, DSL router, VOIP phone, \ etc). Try to provide the architecture (X86, SPARC, etc.) where appropriate." ), ) self.target_device_entry = gtk.Entry() self.classification_label = HIGHintSectionLabel( _("Classification"), _( "Please select \ the Device/OS info from this alphabetized choosebox" ), ) self.classification_list = gtk.ListStore(str, str) self.classification_combo = gtk.ComboBoxEntry(self.classification_list, 0) self.notes_label = HIGHintSectionLabel( _("Notes"), _( "Fill with further info on \ the device, any special network conditions, etc." ), ) self.notes_scrolled = gtk.ScrolledWindow() self.notes_text = gtk.TextView() self.fingerprint_icon = gtk.Image() self.fingerprint_text = gtk.Label( _( "This form allows you to \ contribute new operating system fingerprints to the Nmap database. Thanks for \ helping! <b>Please do not fill this out unless you are sure that you know \ what application is running on the machine you are submitting</b>. Incorrect \ entries can pollute the database. By submitting fingerprints you are \ transfering any copyright interest in the data to Fyodor so that he \ can modify it, relicense it, incorporate it into programs such as Nmap, etc." ) ) 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.notes_scrolled.add(self.notes_text) self.notes_scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.notes_scrolled.set_size_request(400, 150) self.notes_text.set_wrap_mode(gtk.WRAP_WORD) self.fingerprint_icon.set_from_stock(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_DIALOG) self.fingerprint_icon.set_padding(10, 0) self.fingerprint_text.set_line_wrap(True) self.fingerprint_text.set_use_markup(True) self.table.attach_label(self.submitted_label, 0, 1, 0, 1) self.table.attach_entry(self.submitted_entry, 1, 2, 0, 1) self.table.attach_label(self.target_device_label, 0, 1, 1, 2) self.table.attach_entry(self.target_device_entry, 1, 2, 1, 2) self.table.attach_label(self.classification_label, 0, 1, 2, 3) self.table.attach_entry(self.classification_combo, 1, 2, 2, 3) self.table.attach_label(self.notes_label, 0, 2, 3, 4) self.table.attach_entry(self.notes_scrolled, 0, 2, 4, 5) self.hbox.set_border_width(12) self.hbox._pack_noexpand_nofill(self.fingerprint_icon) self.hbox._pack_expand_fill(self.fingerprint_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.set_border_width(6) 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 close(self, widget=None, event=None): self.destroy() def send_report(self, widget): if self.target_device == "": cancel_dialog = HIGAlertDialog( type=gtk.MESSAGE_ERROR, message_format=_( "Operating System \ Fingerprint report is incomplete!" ), secondary_text=_( "The Operating \ System Fingerprint report is incomplete. Please, try to provide as much \ information as possible." ), ) cancel_dialog.run() cancel_dialog.destroy() return None os_register = OSFingerprintRegister() os_register.email = self.submitted os_register.os = self.target_device os_register.classification = self.classification os_register.ip = self.ip os_register.fingerprint = self.fingerprint os_register.notes = self.notes try: os_register.report() except: cancel_dialog = HIGAlertDialog( type=gtk.MESSAGE_ERROR, message_format=_( "Operating System \ Fingerprint not registered!" ), secondary_text=_( "The Operating \ System Fingerprint could not be registered. This problem may be caused by \ the lack of Internet Access or indisponibility of the fingerprint server. \ Please, verify your internet access, and then try to register the operating \ system fingerprint once again." ), ) cancel_dialog.run() cancel_dialog.destroy() else: ok_dialog = HIGAlertDialog( type=gtk.MESSAGE_INFO, message_format=_( "Operating System \ Fingerprint sucessfully registered!" ), secondary_text=_( "The Operating System \ Fingerprint was sucessfully registered. A web page with detailed description \ about this registration is going to be openned in your default web browser." ), ) ok_dialog.run() ok_dialog.destroy() self.close() def run_unblocked(self): if not self.modal: self.set_modal(True) self.show_all() def dialog_response_cb(self, dialog, response): self.response_id = response def get_submitted(self): return self.submitted_entry.get_text() def set_submitted(self, submitted): self.submitted_entry.set_text(submitted) def get_target_device(self): return self.target_device_entry.get_text() def set_target_device(self, target_device): self.target_device_entry.set_text(target_device) def get_classification(self): selected = self.classification_combo.child.get_text() for i in self.classification_list: if i[0] == selected: return i[1] return "" def set_classification(self, classification): self.classification.child.set_text(classification) def get_notes(self): buff = self.notes_text.get_buffer() return buff.get_text(buff.get_start_iter(), buff.get_end_iter()) def set_notes(self, notes): self.notes_text.get_buffer().set_text(notes) submitted = property(get_submitted, set_submitted) target_device = property(get_target_device, set_target_device) classification = property(get_classification, set_classification) notes = property(get_notes, set_notes)
class ControlFisheye(HIGVBox): """ """ def __init__(self, radialnet): """ """ HIGVBox.__init__(self) self.set_border_width(6) self.radialnet = radialnet self.__ring_max_value = self.radialnet.get_number_of_rings() self.__create_widgets() def __create_widgets(self): """ """ self.__params = HIGVBox() self.__params_main = HIGHBox() self.__params_options = HIGHBox() self.__fisheye_label = gtk.Label('Fisheye on ring') self.__ring = gtk.Adjustment(0, 0, self.__ring_max_value, 0.01, 0.01) self.__ring_spin = gtk.SpinButton(self.__ring) self.__ring_spin.set_digits(2) self.__ring_scale = gtk.HScale(self.__ring) self.__ring_scale.set_size_request(100, -1) self.__ring_scale.set_digits(2) self.__ring_scale.set_value_pos(gtk.POS_LEFT) self.__ring_scale.set_draw_value(False) self.__ring_scale.set_update_policy(gtk.UPDATE_CONTINUOUS) self.__interest_label = gtk.Label('Interest factor') self.__interest = gtk.Adjustment(0, 0, 10, 0.01) self.__interest_spin = gtk.SpinButton(self.__interest) self.__interest_spin.set_digits(2) self.__spread_label = gtk.Label('Spread factor') self.__spread = gtk.Adjustment(0, -1.0, 1.0, 0.01, 0.01) self.__spread_spin = gtk.SpinButton(self.__spread) self.__spread_spin.set_digits(2) self.__options_button = gtk.ToggleButton('More') self.__options_button.set_active(False) self.__params._pack_noexpand_nofill(self.__params_main) self.__params._pack_noexpand_nofill(self.__params_options) self.__params_main._pack_noexpand_nofill(self.__fisheye_label) self.__params_main._pack_noexpand_nofill(self.__ring_spin) self.__params_main._pack_expand_fill(self.__ring_scale) self.__params_main._pack_noexpand_nofill(self.__options_button) self.__params_options._pack_noexpand_nofill(self.__interest_label) self.__params_options._pack_noexpand_nofill(self.__interest_spin) self.__params_options._pack_noexpand_nofill(self.__spread_label) self.__params_options._pack_noexpand_nofill(self.__spread_spin) self.__params_options.set_no_show_all(True) self.__params_options.hide() self._pack_noexpand_nofill(self.__params) self.__ring.connect('value_changed', self.__change_ring) self.__interest.connect('value_changed', self.__change_interest) self.__spread.connect('value_changed', self.__change_spread) self.__options_button.connect('toggled', self.__options_toggled) gobject.timeout_add(REFRESH_RATE, self.__update_fisheye) def __update_fisheye(self): """ """ # adjust ring scale to radialnet number of nodes ring_max_value = self.radialnet.get_number_of_rings() - 1 if ring_max_value != self.__ring_max_value: value = self.__ring.get_value() if value == 0 and ring_max_value != 0: value = 1 elif value > ring_max_value: value = ring_max_value self.__ring.set_all(value, 1, ring_max_value, 0.01, 0.01, 0) self.__ring_max_value = ring_max_value self.__ring_scale.queue_draw() # check ring value ring_value = self.radialnet.get_fisheye_ring() if self.__ring.get_value() != ring_value: self.__ring.set_value(ring_value) # check interest value interest_value = self.radialnet.get_fisheye_interest() if self.__interest.get_value() != interest_value: self.__interest.set_value(interest_value) # check spread value spread_value = self.radialnet.get_fisheye_spread() if self.__spread.get_value() != spread_value: self.__spread.set_value(spread_value) return True def active_fisheye(self): """ """ self.radialnet.set_fisheye(True) self.__change_ring() self.__change_interest() def deactive_fisheye(self): """ """ self.radialnet.set_fisheye(False) def __change_ring(self, widget=None): """ """ if not self.radialnet.is_in_animation(): self.radialnet.set_fisheye_ring(self.__ring.get_value()) else: self.__ring.set_value(self.radialnet.get_fisheye_ring()) def __change_interest(self, widget=None): """ """ if not self.radialnet.is_in_animation(): self.radialnet.set_fisheye_interest(self.__interest.get_value()) else: self.__interest.set_value(self.radialnet.get_fisheye_interest()) def __change_spread(self, widget=None): """ """ if not self.radialnet.is_in_animation(): self.radialnet.set_fisheye_spread(self.__spread.get_value()) else: self.__spread.set_value(self.radialnet.get_fisheye_spread()) def __options_toggled(self, widget=None): """ """ self.__params_options.set_no_show_all(False) if self.__options_button.get_active(): self.__params_options.show_all() else: self.__params_options.hide_all() self.__params_options.set_no_show_all(True)
class ServiceFingerprintReport(gtk.Window, object): def __init__(self, service_name, fingerprint, ip): gtk.Window.__init__(self) self.set_title(_('Service Fingerprint Report')) self.set_position(gtk.WIN_POS_CENTER_ALWAYS) self._create_widgets() self._pack_widgets() self._connect_widgets() self.fingerprint = fingerprint self.ip = ip self.service_name = service_name def _create_widgets(self): self.vbox = HIGVBox() self.button_box = gtk.HButtonBox() self.submitted_label = HIGHintSectionLabel(_("Submitted by (optional)"), _("Enter your name and \ e-mail address if we can contact you with any questions. (kept private, used \ for nothing else)")) self.submitted_entry = gtk.Entry() self.service_name_label = HIGHintSectionLabel(_("Service Name"), _("E.g. smtp, pop-3, \ http, domain, ssh, etc. Umit tries to automaticly fill this field for you, \ based on the Nmap \"SERVICE\" output field. If it is correct, you don't need \ to worry about filling out this field. ")) self.service_name_entry = gtk.Entry() self.platform_label = HIGHintSectionLabel(_("Platform/OS"), _('The operating system \ or embedded device the service is running on - Examples are "Linux 2.4.X", \ "Windows XP", "Cisco 3640 router", "Netgear MR814 WAP"')) self.platform_entry = gtk.Entry() self.service_description_label = HIGHintSectionLabel(_("Service \ Description"), _("Please try to \ include vendor name, app name, and version number as applicable. It is OK to \ leave this blank for embedded devices where you have described the hardware \ above and don't have any further details on the service name/version. Here \ are a few examples: ISC Bind 9.2.2, Sendmail 8.12.9/8.10.2, Microsoft Exchange \ 5.5.2656.59, Network Associates WebShield 4.5")) self.service_description_entry = gtk.Entry() self.notes_label = HIGHintSectionLabel(_("Notes"), _("Further info on the device \ or service, any special customizations, etc. If it isn't obvious, please let \ me know what the service is (Virus scanning email gateway, Gnutella-protocol \ P2P app, print server web configuration port, etc")) self.notes_scrolled = gtk.ScrolledWindow() self.notes_text = gtk.TextView() self.fingerprint_icon = gtk.Image() self.fingerprint_text = gtk.Label(_("This form allows you to \ contribute new service/version fingerprints to the Nmap database. Thanks for \ helping! <b>Please do not fill this out unless you are sure that you know what \ application is running on the machine you are submitting</b>. Incorrect \ entries can pollute the database. By submitting fingerprints you are \ transfering any copyright interest in the data to Fyodor so that he \ can modify it, relicense it, incorporate it into programs such as Nmap, etc.")) 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.notes_scrolled.add(self.notes_text) self.notes_scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.notes_scrolled.set_size_request(400, 150) self.notes_text.set_wrap_mode(gtk.WRAP_WORD) self.fingerprint_icon.set_from_stock(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_DIALOG) self.fingerprint_icon.set_padding(10, 0) self.fingerprint_text.set_line_wrap(True) self.fingerprint_text.set_use_markup(True) self.table.attach_label(self.submitted_label, 0, 1, 0, 1) self.table.attach_entry(self.submitted_entry, 1, 2, 0, 1) self.table.attach_label(self.platform_label, 0, 1, 1, 2) self.table.attach_entry(self.platform_entry, 1, 2, 1, 2) self.table.attach_label(self.service_name_label, 0, 1, 2, 3) self.table.attach_entry(self.service_name_entry, 1, 2, 2, 3) self.table.attach_label(self.service_description_label, 0, 1, 3, 4) self.table.attach_entry(self.service_description_entry, 1, 2, 3, 4) self.table.attach_label(self.notes_label, 0, 2, 4, 5) self.table.attach_entry(self.notes_scrolled, 0, 2, 5, 6) self.hbox.set_border_width(12) self.hbox._pack_noexpand_nofill(self.fingerprint_icon) self.hbox._pack_expand_fill(self.fingerprint_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.set_border_width(6) 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 close(self, widget=None, event=None): self.destroy() def send_report(self, widget): if self.service_name == "" or self.service_description == "" or \ self.platform == "": cancel_dialog = HIGAlertDialog(type=gtk.MESSAGE_ERROR, message_format=_("Service \ Fingerprint report is incomplete!"), secondary_text=_("The Service \ Fingerprint report is incomplete. Please, try to provide as much information \ as possible.")) cancel_dialog.run() cancel_dialog.destroy() return None service_register = ServiceFingerprintRegister() service_register.service = self.service_name service_register.platform = self.platform service_register.description = self.service_description service_register.ip = self.ip service_register.fingerprint = self.fingerprint service_register.email = self.submitted service_register.notes = self.notes try: service_register.report() except: cancel_dialog = HIGAlertDialog(type=gtk.MESSAGE_ERROR, message_format=_("Service \ Fingerprint not registered!"), secondary_text=_("The Service \ Fingerprint could not be registered. This problem may be caused by the lack \ of Internet Access or indisponibility of the fingerprint server. Please, \ verify your internet access, and then try to register the service fingerprint \ once again.")) cancel_dialog.run() cancel_dialog.destroy() else: ok_dialog = HIGAlertDialog(type=gtk.MESSAGE_INFO, message_format=_("Service Fingerprint \ sucessfully registered!"), secondary_text=_("The Service \ Fingerprint was sucessfully registered. A web page with detailed description \ about this registration is going to be openned in your default web browser.")) ok_dialog.run() ok_dialog.destroy() self.close() def run_unblocked(self): if not self.modal: self.set_modal(True) self.show_all() def get_submitted(self): return self.submitted_entry.get_text() def set_submitted(self, submitted): self.submitted_entry.set_text(submitted) def get_platform(self): return self.platform_entry.get_text() def set_platform(self, platform): self.platform_entry.set_text(platform) def get_service_name(self): return self.service_name_entry.get_text() def set_service_name(self, service_name): self.service_name_entry.set_text(service_name) def get_service_description(self): return self.service_description_entry.get_text() def set_service_description(self, service_description): self.service_description_entry.set_text(service_description) def get_notes(self): buff = self.notes_text.get_buffer() return buff.get_text(buff.get_start_iter(), buff.get_end_iter()) def set_notes(self, notes): self.notes_text.get_buffer().set_text(notes) submitted = property(get_submitted, set_submitted) platform = property(get_platform, set_platform) service_name = property(get_service_name, set_service_name) service_description = property(get_service_description, set_service_description) notes = property(get_notes, set_notes)
class ControlInterpolation(HIGExpanderRNet): """ """ def __init__(self, radialnet): """ """ HIGExpanderRNet.__init__(self, 'Interpolation') self.radialnet = radialnet self.__create_widgets() def __create_widgets(self): """ """ self.__vbox = HIGVBox() self.__cartesian_radio = gtk.RadioButton(None, 'Cartesian') self.__polar_radio = gtk.RadioButton(self.__cartesian_radio, 'Polar') self.__cartesian_radio.connect('toggled', self.__change_system, INTERPOLATION_CARTESIAN) self.__polar_radio.connect('toggled', self.__change_system, INTERPOLATION_POLAR) self.__system_box = HIGHBox() self.__system_box._pack_noexpand_nofill(self.__polar_radio) self.__system_box._pack_noexpand_nofill(self.__cartesian_radio) self.__frames_box = HIGHBox() self.__frames_label = gtk.Label('Frames') self.__frames_label.set_alignment(0.0, 0.5) self.__frames = gtk.Adjustment(self.radialnet.get_number_of_frames(), 1, 1000, 1) self.__frames.connect('value_changed', self.__change_frames) self.__frames_spin = gtk.SpinButton(self.__frames) self.__frames_box._pack_expand_fill(self.__frames_label) self.__frames_box._pack_noexpand_nofill(self.__frames_spin) self.__vbox._pack_noexpand_nofill(self.__frames_box) self.__vbox._pack_noexpand_nofill(self.__system_box) self._add(self.__vbox) gobject.timeout_add(REFRESH_RATE, self.__update_animation) def __update_animation(self): """ """ active = self.radialnet.get_interpolation() if active == INTERPOLATION_CARTESIAN: self.__cartesian_radio.set_active(True) else: self.__polar_radio.set_active(True) return True def __change_system(self, widget, value): """ """ if not self.radialnet.set_interpolation(value): active = self.radialnet.get_interpolation() if active == INTERPOLATION_CARTESIAN: self.__cartesian_radio.set_active(True) else: self.__polar_radio.set_active(True) def __change_frames(self, widget): """ """ if not self.radialnet.set_number_of_frames(self.__frames.get_value()): self.__frames.set_value(self.radialnet.get_number_of_frames())
def __do_layout(self): """ Layout widgets in window. """ main_vbox = HIGVBox() main_vbox.set_border_width(5) main_vbox.set_spacing(12) header_hbox = HIGHBox() schema_table = HIGTable() schedsn_hbox = HIGHBox() sett_table = HIGTable() btns_hbox = HIGHBox() header_hbox._pack_expand_fill(self.ttitle) header_hbox._pack_noexpand_nofill(self.umit_logo) # schema name schema_table.attach_label(self.schema_name_lbl, 0, 1, 0, 1) schema_table.attach_entry(self.schema_name, 1, 2, 0, 1) # target and scan profile schema_table.attach_label(self.scan_name_lbl, 0, 1, 1, 2) schema_table.attach_entry(self.scan_name, 1, 2, 1, 2) # scan command schema_table.attach_label(self.scan_command_lbl, 0, 1, 2, 3) schema_table.attach_label(self.scan_command, 1, 2, 2, 3) # scheduling profile schedsn_hbox._pack_expand_fill(self.sched_name) schedsn_hbox._pack_noexpand_nofill(self.sched_name_edit) schema_table.attach_label(self.sched_name_lbl, 0, 1, 3, 4) schema_table.attach_entry(schedsn_hbox, 1, 2, 3, 4) # settings frame settings_align = gtk.Alignment(0.5, 0.5, 1, 1) settings_align.set_padding(6, 0, 12, 0) schemasett_hbox = HIGVBox() # saveto sett_hbox = HIGHBox() sett_hbox._pack_expand_fill(self.setting_saveto_entry) sett_hbox._pack_noexpand_nofill(self.setting_saveto_browse) sett_table.attach_label(self.setting_saveto, 0, 1, 0, 1) sett_table.attach_entry(sett_hbox, 1, 2, 0, 1) # mailto, smtp sett_hbox = HIGHBox() sett_hbox._pack_expand_fill(self.setting_mailto_entry) sett_hbox._pack_noexpand_nofill(self.setting_smtp_lbl) sett_hbox._pack_expand_fill(self.setting_smtp) sett_table.attach_label(self.setting_mailto, 0, 1, 1, 2) sett_table.attach_entry(sett_hbox, 1, 2, 1, 2) schemasett_hbox._pack_noexpand_nofill(sett_table) # add to inventory sett_hbox = HIGHBox() sett_hbox._pack_noexpand_nofill(self.setting_addtoinv) schemasett_hbox._pack_noexpand_nofill(sett_hbox) # enabled/disabled sett_hbox = HIGHBox() sett_hbox._pack_noexpand_nofill(self.setting_enabled) schemasett_hbox._pack_noexpand_nofill(sett_hbox) settings_align.add(schemasett_hbox) self.schema_sett_frame.add(settings_align) # bottom buttons btns_hbox.set_homogeneous(True) btns_hbox._pack_expand_fill(self.help) btns_hbox._pack_expand_fill(hig_box_space_holder()) btns_hbox._pack_expand_fill(self.apply) btns_hbox._pack_expand_fill(self.cancel) btns_hbox._pack_expand_fill(self.ok) main_vbox._pack_noexpand_nofill(header_hbox) main_vbox._pack_noexpand_nofill(gtk.HSeparator()) main_vbox._pack_noexpand_nofill(schema_table) main_vbox._pack_noexpand_nofill(gtk.HSeparator()) main_vbox._pack_noexpand_nofill(self.schema_sett_frame) main_vbox.pack_end(btns_hbox, False, False, 0) self.add(main_vbox)
class CapacityTab(gtk.HBox): """ CapacityTab: show the network's Capacity """ def __init__(self): """ """ gtk.HBox.__init__(self) self.__create_widgets() self.__pack_widgets() self.__connected_widgets() self.draw_grade_mark() def __create_widgets(self): """ """ self.left_box = HIGVBox() self.right_box = HIGVBox() ########## #Grade Box self.grade_box = HIGVBox() self.grade_title = gtk.Label( "<span size='18000' weight='heavy'>Communication Grade</span>") self.grade_title.set_use_markup(True) self.grade_title.set_selectable(False) self.mark_box = gtk.HBox() self.mark_image = [None] * 5 for i in range(0,5): self.mark_image[i] = gtk.Image() self.mark_image[i].set_from_file(os.path.join(IMAGES_DIR,'emptymark.png')) self.mark_box.pack_start(self.mark_image[i]) ############# #Website Test self.webtest_box = HIGVBox() self.webtest_title = gtk.Label( "<span size='18000' weight='heavy'>Website Test</span>") self.webtest_title.set_use_markup(True) self.webtest_title.set_selectable(False) status_str = "--" speed_str = "--" throtthled_str = "--" self.webtest_status_label = gtk.Label("<span size='12500' weight='heavy'>Web Status: %s</span>" % (status_str)) self.webtest_speed_label = gtk.Label("<span size='12500' weight='heavy'>Network Speed: %s</span>" % (speed_str)) self.webtest_throttled_label = gtk.Label("<span size='12500' weight='heavy'>Throttled Status: %s</span>" % (throtthled_str)) self.webtest_status_label.set_use_markup(True) self.webtest_status_label.set_selectable(False) self.webtest_speed_label.set_use_markup(True) self.webtest_speed_label.set_selectable(False) self.webtest_throttled_label.set_use_markup(True) self.webtest_throttled_label.set_selectable(False) ############ #Service Box self.service_box = HIGVBox() #self.service_title = gtk.Label( # "<span size='12500' weight='heavy'>Service Statistics</span>") #self.service_title.set_use_markup(True) #self.service_title.set_selectable(False) self.refresh_btn = gtk.Button(_("Refresh Now!")) self.refresh_btn.set_size_request(108,72) self.display_bar = TimeLineDisplayBar(self) def __pack_widgets(self): """ """ ###### #BOXS self.left_box._pack_noexpand_nofill(self.grade_box) self.left_box._pack_expand_fill(self.webtest_box) self.right_box._pack_noexpand_nofill(self.refresh_btn) self.right_box._pack_expand_fill(self.service_box) ########## #Grade Box self.grade_box._pack_noexpand_nofill(hig_box_space_holder()) self.grade_box._pack_noexpand_nofill(self.grade_title) self.grade_box._pack_noexpand_nofill(hig_box_space_holder()) self.grade_box._pack_noexpand_nofill(self.mark_box) self.grade_box._pack_noexpand_nofill(hig_box_space_holder()) ############# #Website Test self.webtest_box._pack_noexpand_nofill(self.webtest_title) self.webtest_box._pack_noexpand_nofill(hig_box_space_holder()) self.webtest_box._pack_noexpand_nofill(self.webtest_status_label) self.webtest_box._pack_noexpand_nofill(self.webtest_speed_label) self.webtest_box._pack_noexpand_nofill(self.webtest_throttled_label) ############ #Service Box self.service_box._pack_noexpand_nofill(hig_box_space_holder()) self.service_box._pack_expand_fill(self.display_bar) self.service_box._pack_noexpand_nofill(hig_box_space_holder()) self.pack_start(self.left_box,True,True,2) self.pack_start(self.right_box,True,True,4) self.show_all() def draw_grade_mark(self): """ """ success_cnt,total_cnt = g_db_helper.service_choice_count() grade = (float(success_cnt) / total_cnt)*100 if 0.0 <= grade and grade < 20.0: grade = 1 elif 20.0 <= grade and grade < 40.0: grade = 2 elif 40.0 <= grade and grade < 60.0: grade = 3 elif 60.0 <= grade and grade < 80.0: grade = 4 else: grade = 5 for i in range(0,5): self.mark_image[i].set_from_file(os.path.join(IMAGES_DIR,'emptymark.png')) for i in range(0,grade): self.mark_image[i].set_from_file(os.path.join(IMAGES_DIR,'okmark.png')) def __connected_widgets(self): """ """ self.refresh_btn.connect('clicked', self.__update_capacity) def __update_capacity(self,widget): """ """ self.draw_grade_mark()
class SearchGUI(gtk.HPaned, object): def __init__(self, notebook): gtk.HPaned.__init__(self) self._create_widgets() self._pack_widgets() self._connect_events() self.any_profile = _("Any profile") self.any_option = _("Any option") self.any_target = _("Any target") self.any_service = _("Any service") self.any_product = _("Any product") self.any_osclass = _("Any os class") self.any_osmatch = _("Any os match") self.any = _("Any") # Setting default values self.port_open = True self.port_filtered = True self.port_closed = True self.profile = self.any_profile self.option = self.any_option self.target = self.any_target self.service = self.any_service self.product = self.any_product self.osclass = self.any_osclass self.osmatch = self.any_osmatch # Search options self.directory = search_config.directory self.file_extension = search_config.file_extension self.save_time = search_config.save_time self.save = search_config.store_results self.search_db = search_config.search_db self.parsed_results = {} self._set_result_view() self.scan_num = 1 self.id = 0 self.notebook = notebook def _create_widgets(self): # Main widgets self.hpaned = gtk.HPaned() self.main_vbox = HIGVBox() # Results section self.result_section = HIGSectionLabel(_("Results")) self.result_vbox = HIGVBox() self.result_hbox = HIGHBox() 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")) # Search notebook self.search_vbox = HIGVBox() self.search_notebook = gtk.Notebook() self.search_button = HIGButton(stock=gtk.STOCK_FIND) # General page self.general_vbox = HIGVBox() self.general_hbox = HIGHBox() #self.general_start_hbox = HIGHBox() #self.general_finish_hbox = HIGHBox() self.general_section = HIGSectionLabel(_("General search parameters")) self.general_table = HIGTable() self.general_option_label = HIGEntryLabel(_("Option")) self.general_profile_label = HIGEntryLabel(_("Profile")) #self.general_finished_label = HIGEntryLabel(_("Finished")) #self.general_started_label = HIGEntryLabel(_("Started")) self.general_keyword_label = HIGEntryLabel(_("Keyword")) self.general_keyword_entry = gtk.Entry() self.general_option_combo = OptionCombo() self.general_profile_combo = ProfileCombo() #self.general_started_range = DateRange() #self.general_finished_range = DateRange() # Host page self.host_vbox = HIGVBox() self.host_hbox = HIGHBox() #self.host_uptime_hbox = HIGHBox() #self.host_lastboot_hbox = HIGHBox() self.host_section = HIGSectionLabel(_("Host search parameters")) self.host_table = HIGTable() self.host_target_label = HIGEntryLabel(_("Target")) self.host_mac_label = HIGEntryLabel(_("MAC")) self.host_ipv4_label = HIGEntryLabel(_("IPv4")) self.host_ipv6_label = HIGEntryLabel(_("IPv6")) #self.host_uptime_label = HIGEntryLabel(_("Uptime")) #self.host_lastboot_label = HIGEntryLabel(_("Last boot")) self.host_target_combo = TargetCombo() self.host_mac_entry = gtk.Entry() self.host_ipv4_entry = gtk.Entry() self.host_ipv6_entry = gtk.Entry() #self.host_uptime_range = DateRange() #self.host_lastboot_range = DateRange() # Service self.serv_vbox = HIGVBox() self.serv_hbox = HIGHBox() self.serv_section = HIGSectionLabel(_("Service search parameters")) self.serv_table = HIGTable() self.serv_port_label = HIGEntryLabel(_("Port number")) self.serv_service_label = HIGEntryLabel(_("Service")) self.serv_product_label = HIGEntryLabel(_("Product")) self.serv_portstate_label = HIGEntryLabel(_("Port state")) self.serv_port_entry = gtk.Entry() self.serv_service_combo = ServiceCombo() self.serv_product_entry = gtk.Entry() self.serv_portstate_check = PortState() # OS self.os_vbox = HIGVBox() self.os_hbox = HIGHBox() self.os_section = HIGSectionLabel(_("Operating System search \ parameters")) self.os_table = HIGTable() self.os_osclass_label = HIGEntryLabel(_("OS class")) self.os_osmatch_label = HIGEntryLabel(_("OS match")) self.os_osclass_combo = OSClassCombo() self.os_osmatch_combo = OSMatchCombo() # Search options page self.opt_vbox = HIGVBox() self.opt_local_hbox = HIGHBox() self.opt_base_hbox = HIGHBox() self.opt_local_section = HIGSectionLabel(_("Local files")) self.opt_local_table = HIGTable() self.opt_base_section = HIGSectionLabel(_("Database")) self.opt_base_table = HIGTable() self.opt_path_label = HIGEntryLabel(_("Directory")) self.opt_extension_label = HIGEntryLabel(_("File extension")) self.opt_savetime_label = HIGEntryLabel(_("Save results for")) self.opt_path_entry = PathEntry() self.opt_extension_entry = gtk.Entry() self.opt_savetime_entry = SaveTime() self.opt_save_check = gtk.CheckButton(_("Save scan results in data \ base for latter search")) self.opt_search_check = gtk.CheckButton(_("Search saved scan results \ in data base")) def _pack_widgets(self): # Packing result section self.result_vbox.set_border_width(12) self.result_vbox._pack_noexpand_nofill(self.result_section) self.result_vbox._pack_expand_fill(self.result_hbox) self.result_scrolled.set_size_request(185, -1) #self.result_scrolled.set_shadow_type(gtk.SHADOW_ETCHED_IN) self.result_scrolled.add(self.result_view) self.result_scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.result_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.result_hbox._pack_expand_fill(self.result_scrolled) ## Search Notebook self.search_vbox._pack_expand_fill(self.search_notebook) self.search_vbox._pack_expand_fill(self.search_button) self.search_notebook.set_border_width(1) self.search_vbox.set_border_width(12) # General page self.general_vbox.set_border_width(12) self.general_vbox._pack_noexpand_nofill(self.general_section) self.general_vbox._pack_noexpand_nofill(self.general_hbox) #self.general_vbox._pack_noexpand_nofill(self.general_start_section) #self.general_vbox._pack_noexpand_nofill(self.general_start_hbox) #self.general_vbox._pack_noexpand_nofill(self.general_finish_section) #self.general_vbox._pack_noexpand_nofill(self.general_finish_hbox) self.general_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.general_hbox._pack_expand_fill(self.general_table) #self.general_start_hbox._pack_noexpand_nofill(hig_box_space_holder()) #self.general_start_hbox._pack_noexpand_nofill(self.general_started_range) #self.general_finish_hbox._pack_noexpand_nofill(hig_box_space_holder()) #self.general_finish_hbox._pack_expand_fill(self.general_finished_range) self.general_table.attach_label(self.general_keyword_label, 0, 1, 0, 1) self.general_table.attach_label(self.general_profile_label, 0, 1, 1, 2) self.general_table.attach_label(self.general_option_label, 0, 1, 2, 3) self.general_table.attach_entry(self.general_keyword_entry, 1, 2, 0, 1) self.general_table.attach_entry(self.general_profile_combo, 1, 2, 1, 2) self.general_table.attach_entry(self.general_option_combo, 1, 2, 2, 3) self.search_notebook.append_page(self.general_vbox, gtk.Label(_("General"))) # Host page self.host_vbox.set_border_width(12) self.host_vbox._pack_noexpand_nofill(self.host_section) self.host_vbox._pack_noexpand_nofill(self.host_hbox) #self.host_vbox._pack_noexpand_nofill(self.host_uptime_section) #self.host_vbox._pack_noexpand_nofill(self.host_uptime_hbox) #self.host_vbox._pack_noexpand_nofill(self.host_lastboot_section) #self.host_vbox._pack_noexpand_nofill(self.host_lastboot_hbox) self.host_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.host_hbox._pack_expand_fill(self.host_table) #self.host_uptime_hbox._pack_noexpand_nofill(hig_box_space_holder()) #self.host_uptime_hbox._pack_noexpand_nofill(self.host_uptime_range) #self.host_lastboot_hbox._pack_noexpand_nofill(hig_box_space_holder()) #self.host_lastboot_hbox._pack_expand_fill(self.host_lastboot_range) self.host_table.attach_label(self.host_target_label, 0, 1, 0, 1) self.host_table.attach_label(self.host_mac_label, 0, 1, 1, 2) self.host_table.attach_label(self.host_ipv4_label, 0, 1, 2, 3) self.host_table.attach_label(self.host_ipv6_label, 0, 1, 3, 4) self.host_table.attach_entry(self.host_target_combo, 1, 2, 0, 1) self.host_table.attach_entry(self.host_mac_entry, 1, 2, 1, 2) self.host_table.attach_entry(self.host_ipv4_entry, 1, 2, 2, 3) self.host_table.attach_entry(self.host_ipv6_entry, 1, 2, 3, 4) self.search_notebook.append_page(self.host_vbox, gtk.Label(_("Host"))) # Service page self.serv_vbox.set_border_width(12) self.serv_vbox._pack_noexpand_nofill(self.serv_section) self.serv_vbox._pack_noexpand_nofill(self.serv_hbox) self.serv_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.serv_hbox._pack_expand_fill(self.serv_table) self.serv_table.attach_label(self.serv_port_label, 0, 1, 0, 1) self.serv_table.attach_label(self.serv_portstate_label, 0, 1, 1, 2) self.serv_table.attach_label(self.serv_product_label, 0, 1, 2, 3) self.serv_table.attach_label(self.serv_service_label, 0, 1, 3, 4) self.serv_table.attach_entry(self.serv_port_entry, 1, 2, 0, 1) self.serv_table.attach_entry(self.serv_portstate_check, 1, 2, 1, 2) self.serv_table.attach_entry(self.serv_product_entry, 1, 2, 2, 3) self.serv_table.attach_entry(self.serv_service_combo, 1, 2, 3, 4) self.search_notebook.append_page(self.serv_vbox, gtk.Label(_("Service"))) # OS page self.os_vbox.set_border_width(12) self.os_vbox._pack_noexpand_nofill(self.os_section) self.os_vbox._pack_noexpand_nofill(self.os_hbox) self.os_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.os_hbox._pack_expand_fill(self.os_table) self.os_table.attach_label(self.os_osclass_label, 0, 1, 0, 1) self.os_table.attach_label(self.os_osmatch_label, 0, 1, 1, 2) self.os_table.attach_entry(self.os_osclass_combo, 1, 2, 0, 1) self.os_table.attach_entry(self.os_osmatch_combo, 1, 2, 1, 2) self.search_notebook.append_page(self.os_vbox, gtk.Label(_("OS"))) # Search options page self.opt_vbox.set_border_width(12) self.opt_vbox._pack_noexpand_nofill(self.opt_local_section) self.opt_vbox._pack_noexpand_nofill(self.opt_local_hbox) self.opt_vbox._pack_noexpand_nofill(self.opt_base_section) self.opt_vbox._pack_noexpand_nofill(self.opt_base_hbox) self.opt_local_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.opt_local_hbox._pack_expand_fill(self.opt_local_table) self.opt_base_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.opt_base_hbox._pack_expand_fill(self.opt_base_table) self.opt_local_table.attach_label(self.opt_path_label, 0, 1, 0, 1) self.opt_local_table.attach_label(self.opt_extension_label, 0, 1, 1, 2) self.opt_local_table.attach_entry(self.opt_path_entry, 1, 2, 0, 1) self.opt_local_table.attach_entry(self.opt_extension_entry, 1, 2, 1, 2) self.opt_base_table.attach_label(self.opt_savetime_label, 0, 1, 0, 1) self.opt_base_table.attach_label(self.opt_save_check, 0, 2, 1, 2) self.opt_base_table.attach_label(self.opt_search_check, 0, 2, 2, 3) self.opt_base_table.attach_entry(self.opt_savetime_entry, 1, 2, 0, 1) self.search_notebook.append_page(self.opt_vbox, gtk.Label(_("Search options"))) self.pack1(self.search_vbox, True, False) self.pack2(self.result_vbox, True, False) def _connect_events(self): self.os_osclass_combo.connect("changed", self.update_osmatch) self.search_button.connect("clicked", self.start_search) self.opt_extension_entry.connect("focus-out-event", self.update_extension_entry) self.opt_save_check.connect("toggled", self.update_save_check) self.opt_search_check.connect("toggled", self.update_search_check) self.opt_path_entry.connect_entry_change(self.update_path_entry) self.opt_savetime_entry.connect_entry_change(self.update_savetime_entry) def update_path_entry(self, widget, extra=None): search_config.directory = widget.get_text() def update_savetime_entry(self, widget, extra=None): search_config.save_time = self.opt_savetime_entry.time def update_extension_entry(self, widget, extra=None): search_config.file_extension = widget.get_text() def update_save_check(self, widget): search_config.store_results = widget.get_active() def update_search_check(self, widget): search_config.search_db = widget.get_active() def start_search(self, widget): if not self.search_db and \ not self.directory: self.search_notebook.set_current_page(-1) d = HIGAlertDialog(message_format=_("No search method selected!"), secondary_text=_("Umit can search results on \ directories or inside it's own database. Please, select a method by choosing \ a directory or by checking the search data base option at the 'Search options' \ tab before start the search")) d.run() d.destroy() return search_dict = dict(keyword=self.keyword, profile=self.profile, option=self.option, target=self.target, mac=self.mac, ipv4=self.ipv4, ipv6=self.ipv6, port=self.port, port_open=self.port_open, port_filtered=self.port_filtered, port_closed=self.port_closed, service=self.service, osclass=self.osclass, osmatch=self.osmatch, product=self.product) self.clear_result_list() if self.search_db: search_db = SearchDB() for result in search_db.search(**search_dict): self.append_result(result) if self.directory: search_dir = SearchDir(self.directory, self.file_extension) for result in search_dir.search(**search_dict): self.append_result(result) search_tabs = SearchTabs(self.notebook) for result in search_tabs.search(**search_dict): self.append_result(result) def clear_result_list(self): for i in range(len(self.result_list)): iter = self.result_list.get_iter_root() del(self.result_list[iter]) def append_result(self, parsed_result): title = "" if parsed_result.scan_name: title = parsed_result.scan_name elif parsed_result.nmap_xml_file: title = os.path.split(parsed_result.nmap_xml_file)[-1] elif parsed_result.profile_name and parsed_result.target: title = "%s on %s" % (parsed_result.profile_name, parsed_result.target) else: title = "Scan %s" % (self.scan_num) self.scan_num += 1 try: date = localtime(float(parsed_result.start)) date_field = "%02d %s %04d" % (date[2], calendar.month_name[date[1]][:3], date[0]) except ValueError: date_field = _("Unknown") self.parsed_results[self.id] = [title, parsed_result] self.result_list.append([title, date_field, self.id]) self.id += 1 def update_osmatch(self, widegt): self.os_osmatch_combo.update(self.os_osclass_combo.selected_osclass) def get_keyword(self): return self.general_keyword_entry.get_text() def set_keyword(self, keyword): self.general_keyword_entry.set_text(keyword) def get_profile(self): if self.general_profile_combo.selected_profile == self.any_profile or \ self.general_profile_combo.selected_profile == self.any: return "*" return self.general_profile_combo.selected_profile def set_profile(self, profile): self.general_profile_combo.selected_profile = profile def get_option(self): if self.general_option_combo.selected_option == self.any_option or \ self.general_option_combo.selected_option == self.any: return "*" return self.general_option_combo.selected_option def set_option(self, option): self.general_option_combo.selected_option = option def get_target(self): if self.host_target_combo.selected_target == self.any_target or \ self.host_target_combo.selected_target == self.any: return "*" return self.host_target_combo.selected_target def set_target(self, target): self.host_target_combo.selected_target = target def get_mac(self): return self.host_mac_entry.get_text() def set_mac(self, mac): self.host_mac_entry.set_text(mac) def get_ipv4(self): return self.host_ipv4_entry.get_text() def set_ipv4(self, ipv4): self.host_ipv4_entry.set_text(ipv4) def get_ipv6(self): return self.host_ipv6_entry.get_text() def set_ipv6(self, ipv6): self.host_ipv6_entry.set_text(ipv6) def get_port(self): return self.serv_port_entry.get_text().split(";") def set_port(self, port): if isinstance(port, basestring): self.serv_port_entry.set_text(port) elif isinstance(port, list): self.serv_port_entry.set_text(";".join(port)) def get_port_open(self): return self.serv_portstate_check.open def set_port_open(self, open): self.serv_portstate_check.open = open def get_port_filtered(self): return self.serv_portstate_check.filtered def set_port_filtered(self, filtered): self.serv_portstate_check.filtered = filtered def get_port_closed(self): return self.serv_portstate_check.closed def set_port_closed(self, closed): self.serv_portstate_check.closed = closed def get_service(self): if self.serv_service_combo.selected_service == self.any_service or \ self.serv_service_combo.selected_service == self.any: return "*" return self.serv_service_combo.selected_service def set_service(self, service): self.serv_service_combo.selected_service = service def get_osclass(self): if self.os_osclass_combo.selected_osclass == self.any_osclass or \ self.os_osclass_combo.selected_osclass == self.any: return "*" return self.os_osclass_combo.selected_osclass def set_osclass(self, osclass): self.os_osclass_combo.selected_osclass = osclass def get_osmatch(self): if self.os_osmatch_combo.selected_osmatch == self.any_osmatch or \ self.os_osmatch_combo.selected_osmatch == self.any: return "*" return self.os_osmatch_combo.selected_osmatch def set_osmatch(self, osmatch): self.os_osmatch_combo.selected_osmatch = osmatch def get_product(self): if self.serv_product_entry.get_text() == self.any_product or \ self.serv_product_entry.get_text() == self.any: return "*" return self.serv_product_entry.get_text() def set_product(self, product): self.serv_product_entry.set_text(product) def get_directory(self): return self.opt_path_entry.path def set_directory(self, directory): self.opt_path_entry.path = directory def get_file_extension(self): return self.opt_extension_entry.get_text().split(";") def set_file_extension(self, file_extension): if isinstance(file_extension, list): self.opt_extension_entry.set_text(";".join(file_extension)) elif isinstance(file_extension, basestring): self.opt_extension_entry.set_text(file_extension) def get_save_time(self): return self.opt_savetime_entry.time def set_save_time(self, save_time): self.opt_savetime_entry.time = save_time def get_save(self): return self.opt_save_check.get_active() def set_save(self, save): self.opt_save_check.set_active(save) def get_search_db(self): return self.opt_search_check.get_active() def set_search_db(self, search_db): self.opt_search_check.set_active(search_db) def get_selected_results(self): selection = self.result_view.get_selection() rows = selection.get_selected_rows() list_store = rows[0] results = {} for row in rows[1]: r = row[0] results[list_store[r][2]] = self.parsed_results[list_store[r][2]] return results def _set_result_view(self): self.result_view.set_enable_search(True) self.result_view.set_search_column(0) selection = self.result_view.get_selection() selection.set_mode(gtk.SELECTION_MULTIPLE) self.result_view.append_column(self.result_title_column) self.result_view.append_column(self.result_date_column) self.result_title_column.set_resizable(True) self.result_date_column.set_resizable(True) self.result_title_column.set_sort_column_id(0) self.result_date_column.set_sort_column_id(1) self.result_title_column.set_reorderable(True) self.result_date_column.set_reorderable(True) cell = gtk.CellRendererText() self.result_title_column.pack_start(cell, True) self.result_date_column.pack_start(cell, True) self.result_title_column.set_attributes(cell, text=0) self.result_date_column.set_attributes(cell, text=1) keyword = property(get_keyword, set_keyword) profile = property(get_profile, set_profile) option = property(get_option, set_option) target = property(get_target, set_target) mac = property(get_mac, set_mac) ipv4 = property(get_ipv4, set_ipv4) ipv6 = property(get_ipv6, set_ipv6) port = property(get_port, set_port) port_open = property(get_port_open, set_port_open) port_filtered = property(get_port_filtered, set_port_filtered) port_closed = property(get_port_closed, set_port_closed) service = property(get_service, set_service) product = property(get_product, set_product) osclass = property(get_osclass, set_osclass) osmatch = property(get_osmatch, set_osmatch) directory = property(get_directory, set_directory) file_extension = property(get_file_extension, set_file_extension) save_time = property(get_save_time, set_save_time) save = property(get_save, set_save) search_db = property(get_search_db, set_search_db) selected_results = property(get_selected_results)
class Credits(HIGWindow): def __init__(self): HIGWindow.__init__(self) self.set_title(_("Umit credits")) self.set_size_request(-1, 450) 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.soc2008_scroll = HIGScrolledWindow() self.soc2008_text = HIGTextView() self.soc2009_scroll = HIGScrolledWindow() self.soc2009_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.soc2008_scroll, gtk.Label(_("SoC 2008"))) self.notebook.append_page(self.soc2009_scroll, gtk.Label(_("SoC 2009"))) self.notebook.append_page(self.contributors_scroll, gtk.Label(_("Contributors"))) self.notebook.append_page(self.translation_scroll, gtk.Label(_("Translations"))) 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.soc2008_scroll.add(self.soc2008_text) self.soc2008_text.set_wrap_mode(gtk.WRAP_NONE) self.soc2009_scroll.add(self.soc2009_text) self.soc2009_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 <*****@*****.**> Bartosz Skowron <*****@*****.**> Francesco Piccinno <*****@*****.**> Guilherme Polo <*****@*****.**> João Medeiros <*****@*****.**> Luís A. Bastião Silva <*****@*****.**>""") b = self.design_text.get_buffer() b.set_text( _("""Operating System and Vulnerability Icons: Takeshi Alexandre Gondo <*****@*****.**> Logo, Application Icons, Splash screen and Umit GNU/Linux theme: 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.soc2008_text.get_buffer() b.set_text( _("""Packet Manipulation Backend Bartosz Adam Skowron <*****@*****.**> Bluetooth Scanner & Vulnerabilities Database System: Devtar Singh <*****@*****.**> Umit Plugins and Packet Manipulation Frontend Francesco Piccinno <*****@*****.**> Preferences Window and Interface Editor improvements: Luis Antonio Bastião Silva <*****@*****.**> UmitWeb Improvements and Independent Features: Rodolfo da Silva Carvalho <*****@*****.**> """)) b = self.soc2009_text.get_buffer() b.set_text( _("""UMPA Improvements Bartosz Adam Skowron <*****@*****.**> Quick Scan: Daniel Mendes Cassiano <*****@*****.**> Bluetooth Sniffer: Shu Yang Quek <*****@*****.**> Audits Framework Francesco Piccinno <*****@*****.**> ZION João Paulo de Souza Medeiros <*****@*****.**> USoC: Message Sequence Chart Abhiram Kasina <*****@*****.**> Independent Features and Test Suite Mahesh PM <*****@*****.**> """)) b = self.contributors_text.get_buffer() b.set_text( _("""Sponsored by (SoC 2005, 2006, 2007 and 2008): Google <*****@*****.**> Mentor of Umit for Google SoC 2005 and 2006: Fyodor <*****@*****.**> Mentor of Umit for Google SoC 2007 Projects: Adriano Monteiro Marques <*****@*****.**> Mentor of Umit for Google SoC 2008 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: Abrao Barbosa 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 <*****@*****.**> Helpers: Daniel Mendes Cassiano <*****@*****.**> Luiz Paulo de Souza Medeiros <*****@*****.**> Beta testers for 0.9.5RC1: Bartosz Adam Skowron <*****@*****.**> Denis Kurov <*****@*****.**> Devtar Singh <*****@*****.**> Drew Miller <*****@*****.**> Francesco Piccinno <*****@*****.**> Igor Feghali <*****@*****.**> Joao Paulo Pacheco <*****@*****.**> Luis Antonio Bastião Silva <*****@*****.**> Rodolfo da Silva Carvalho <*****@*****.**> Regis Kuramoto Dias <*****@*****.**> <*****@*****.**> <*****@*****.**> <*****@*****.**> Special thanks to our GSoC volunteers heroes: Daniel Mendes Cassiano <*****@*****.**> Túlio Gonçalves <*****@*****.**> Initial attempt on Maemo port: Adriano Monteiro Marques <*****@*****.**> Osvaldo Santana Neto <*****@*****.**>""")) 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 <*****@*****.**> Nmap Python Wrapper: Pavel Klemenkov <*****@*****.**> Umit Web: Rodolfo da Silva Carvalho <*****@*****.**> Summer of Code's projects Design: Virgílio Carlo de Menezes Vasconcelos <*****@*****.**>""") b = self.translation_text.get_buffer() b.set_text( _("""Bahasa Indonesia: Devtar Singh <*****@*****.**> Bahasa Melayu: Devtar Singh <*****@*****.**> Brazilian Portuguese: Adriano Monteiro Marques <*****@*****.**> Rodolfo da Silva Carvalho <*****@*****.**> Italian: Francesco Piccinno <*****@*****.**> Polish: Bartosz Adam Skowron <*****@*****.**> Portuguese Portugal: Luis Antonio Bastião Silva <*****@*****.**> Simplified Chinese: Devtar Singh <*****@*****.**> Haoyu Bai <*****@*****.**> Aron Xu <*****@*****.**> Swedish: Daniel Nylander <*****@*****.**> """)) b = self.nokia_text.get_buffer() b.set_text("""Adriano Monteiro Marques <*****@*****.**>""")
class ProfileEditor(HIGWindow): def __init__(self, profile_name=None, delete=False): HIGWindow.__init__(self) self.set_title(_('Profile Editor')) self.set_position(gtk.WIN_POS_CENTER) self.profile_name = profile_name self.__create_widgets() self.__pack_widgets() self.scan_notebook = None self.profilemanager = None self.profile = CommandProfile() self.deleted = False options_used = {} if profile_name: log.debug("Showing profile %s" % profile_name) prof = self.profile.get_profile(profile_name) options_used = prof['options'] # Interface settings self.profile_name_entry.set_text(profile_name) self.profile_hint_entry.set_text(prof['hint']) self.profile_description_text.get_buffer().set_text( prof['description']) self.profile_annotation_text.get_buffer().set_text( prof['annotation']) if delete: # Removing profile. It must be saved again self.remove_profile() self.constructor = CommandConstructor(options_used) self.options = OptionBuilder(profile_editor_file, self.constructor, self.update_command) log.debug("Option groups: %s" % str(self.options.groups)) log.debug("Option section names: %s" % str(self.options.section_names)) #log.debug("Option tabs: %s" % str(self.options.tabs)) for tab in self.options.groups: self.__create_tab(tab, self.options.section_names[tab], self.options.tabs[tab]) self.update_command() def update_command(self): """Regenerate command with target '<target>' and set the value for the command entry""" self.command_entry.set_text(self.constructor.get_command('<target>')) def help(self, widget): """ Show help documentation of Profile Editor """ show_help(self, "profile_editor.html#introduction") def __create_widgets(self): self.main_vbox = HIGVBox() self.command_expander = HIGExpander('<b>' + _('Command') + '</b>') self.command_expander.set_expanded(True) self.command_entry = gtk.Entry() 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_hint_label = HIGEntryLabel(_('Hint')) self.profile_hint_entry = gtk.Entry() self.profile_description_label = HIGEntryLabel(_('Description')) #self.profile_description_label = HIGHBox() self.profile_description_scroll = HIGScrolledWindow() self.profile_description_text = HIGTextView() self.profile_annotation_label = HIGEntryLabel(_('Annotation')) #self.profile_annotation_label = HIGHBox() self.profile_annotation_scroll = HIGScrolledWindow() self.profile_annotation_text = HIGTextView() # Buttons self.buttons_hbox = HIGHBox() self.help_button = HIGButton(stock=gtk.STOCK_HELP) self.help_button.connect('clicked', self.help) #self.delete_button = HIGButton(stock=gtk.STOCK_DELETE) #self.delete_button.connect('clicked', self.delete_profile) self.cancel_button = HIGButton(stock=gtk.STOCK_CANCEL) self.cancel_button.connect('clicked', self.quit_without_saving) self.ok_button = HIGButton(stock=gtk.STOCK_OK) self.ok_button.connect('clicked', self.save_profile) def __pack_widgets(self): self.add(self.main_vbox) # Packing widgets to main_vbox self.main_vbox._pack_noexpand_nofill(self.command_expander) self.main_vbox._pack_expand_fill(self.notebook) self.main_vbox._pack_noexpand_nofill(self.buttons_hbox) # Packing command_entry on command_expander self.command_expander.hbox.pack_start(self.command_entry) # 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_noexpand_nofill(HIGSpacer(table)) self.profile_annotation_scroll.add(self.profile_annotation_text) 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_noexpand_nofill(self.profile_annotation_label) vbox_ann._pack_expand_fill(hig_box_space_holder()) table.attach(self.profile_name_label, 0, 1, 0, 1) table.attach(self.profile_name_entry, 1, 2, 0, 1) #table.attach(self.profile_hint_label,0,1,1,2,xoptions=0) table.attach(self.profile_hint_label, 0, 1, 1, 2) table.attach(self.profile_hint_entry, 1, 2, 1, 2) table.attach(vbox_desc, 0, 1, 2, 3) table.attach(self.profile_description_scroll, 1, 2, 2, 3) table.attach(vbox_ann, 0, 1, 3, 4) table.attach(self.profile_annotation_scroll, 1, 2, 3, 4) # Packing buttons on button_hbox self.buttons_hbox.pack_start(self.help_button) #self.buttons_hbox.pack_start(self.delete_button) self.buttons_hbox.pack_start(self.cancel_button) self.buttons_hbox.pack_start(self.ok_button) self.buttons_hbox.set_border_width(5) self.buttons_hbox.set_spacing(6) 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() table = HIGTable() section = HIGSectionLabel(section_name) vbox._pack_noexpand_nofill(section) vbox._pack_noexpand_nofill(HIGSpacer(table)) vbox.set_border_width(6) tab.fill_table(table, True) self.scrollwindow = HIGScrolledWindow() self.scrollwindow.set_size_request(600, 300) vp = gtk.Viewport() vp.add(vbox) vp.set_shadow_type(gtk.SHADOW_NONE) self.scrollwindow.add(vp) vbox_tmp = HIGVBox() vbox_tmp.set_border_width(6) vbox_tmp.set_spacing(12) vbox_tmp.pack_start(self.scrollwindow) self.notebook.append_page(vbox_tmp, gtk.Label(tab_name)) def set_profilemanager(self, model): """ give a model of treeview to update profile manager after run wizard """ assert model != None self.model = model self.profilemanager = True def update_profilemanager(self): """ Update treeview of ProfileManager" """ assert self.profilemanager profiles = self.profile.sections() profiles.sort() self.model.clear() for command in profiles: myiter = self.model.insert_before(None, None) self.model.set_value(myiter, 0, command) self.model.set_value(myiter, 1, self.profile.get_hint(command)) def save_profile(self, widget): 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.' )) elif profile_name.lower() == 'default': alert = HIGAlertDialog(message_format=_('Reserved profile name'),\ secondary_text=_('Cannot assign "default" \ name to this profile. Please rename it and retry.' )) else: alert = None if alert: alert.run() alert.destroy() self.notebook.set_current_page(0) self.profile_name_entry.grab_focus() return None if not self.deleted: self.remove_profile() command = self.constructor.get_command('%s') hint = self.profile_hint_entry.get_text() buf = self.profile_description_text.get_buffer() description = buf.get_text(buf.get_start_iter(),\ buf.get_end_iter()) buf = self.profile_annotation_text.get_buffer() annotation = buf.get_text(buf.get_start_iter(),\ buf.get_end_iter()) self.profile.add_profile(profile_name,\ command=command,\ hint=hint,\ description=description,\ annotation=annotation,\ tool='nmap',\ options=self.constructor.get_options()) self.deleted = False if self.profilemanager: self.update_profilemanager() self.quit() def clean_profile_info(self): self.profile_name_entry.set_text('') self.profile_hint_entry.set_text('') self.profile_description_text.get_buffer().set_text('') self.profile_annotation_text.get_buffer().set_text('') def set_notebook(self, notebook): self.scan_notebook = notebook def quit(self, widget=None, extra=None): if self.deleted: 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 None self.destroy() if self.scan_notebook != None: for i in xrange(self.scan_notebook.get_n_pages()): page = self.scan_notebook.get_nth_page(i) page.toolbar.profile_entry.update() #page.toolbar.scan_profile.profile_entry.child.\ # set_text(self.profile_name_entry.get_text()) def quit_without_saving(self, widget=None): self.deleted = False self.quit() def on_delete(self, widget=None): if not self.profile_name: return self.on_cancel() 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 None self.deleted = True self.profile.remove_profile(self.profile_name) self.on_cancel() def on_cancel(self, widget=None): self.destroy() self.update_profile_entry() def update_profile_entry(self): page = None for i in xrange(self.scan_notebook.get_n_pages()): page = self.scan_notebook.get_nth_page(i) page.toolbar.profile_entry.update(\ self.profile_name_entry.get_text()) list = page.toolbar.profile_entry.get_model() length = len(list) if self.deleted and length > 0: page.toolbar.profile_entry.set_active(0) elif self.deleted and length == 0: page.toolbar.profile_entry.child.set_text("") if page is not None: page.toolbar.profile_entry.update() def remove_profile(self, profile_name=None): ''' Remove current profile ''' if not profile_name: profile_name = self.profile_name self.profile.remove_profile(profile_name) self.deleted = True def delete_profile(self, widget=None): """ delete profile """ self.remove_profile() self.deleted = False self.quit()
class OSFingerprintReport(gtk.Window, object): def __init__(self, fingerprint, ip): gtk.Window.__init__(self) self.set_title(_('Operating System Fingerprint Report')) self.set_position(gtk.WIN_POS_CENTER_ALWAYS) self.fingerprint = fingerprint self.ip = ip self._create_widgets() self._set_classification_list() self._pack_widgets() self._connect_widgets() def _set_classification_list(self): class_file = open(os_classification_file, "rb") class_list = cPickle.load(class_file) class_file.close() for classification in class_list: self.classification_list.append([classification[1], classification[0]]) def _create_widgets(self): self.vbox = HIGVBox() self.button_box = gtk.HButtonBox() self.submitted_label = HIGHintSectionLabel(_("Submitted by (optional)"), _("Enter your name and \ e-mail address if we can contact you with any questions. (kept private, \ used for nothing else)")) self.submitted_entry = gtk.Entry() self.target_device_label = HIGHintSectionLabel(_("Target OS/device info"), _("<b>The more details \ the better!</b> For UNIX machines, '<i>uname -a</i>' often gives the proper \ version number. On Linux, please also specify the distribution version (such as\ Redhat 9.0) if you are using a vendor-provided kernel. For Windows, the \ '<i>winver</i>' command (if available) should show you any service pack \ information. If a Windows target has no service packs installed, \ please say so explicitly. For appliances/embedded devices, please mention \ the model number and what it is (printer, webcam, DSL router, VOIP phone, \ etc). Try to provide the architecture (X86, SPARC, etc.) where appropriate.")) self.target_device_entry = gtk.Entry() self.classification_label = HIGHintSectionLabel(_("Classification"), _("Please select \ the Device/OS info from this alphabetized choosebox")) self.classification_list = gtk.ListStore(str, str) self.classification_combo = gtk.ComboBoxEntry(self.classification_list, 0) self.notes_label = HIGHintSectionLabel(_("Notes"), _("Fill with further info on \ the device, any special network conditions, etc.")) self.notes_scrolled = gtk.ScrolledWindow() self.notes_text = gtk.TextView() self.fingerprint_icon = gtk.Image() self.fingerprint_text = gtk.Label(_("This form allows you to \ contribute new operating system fingerprints to the Nmap database. Thanks for \ helping! <b>Please do not fill this out unless you are sure that you know \ what application is running on the machine you are submitting</b>. Incorrect \ entries can pollute the database. By submitting fingerprints you are \ transfering any copyright interest in the data to Fyodor so that he \ can modify it, relicense it, incorporate it into programs such as Nmap, etc.")) 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.notes_scrolled.add(self.notes_text) self.notes_scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.notes_scrolled.set_size_request(400, 150) self.notes_text.set_wrap_mode(gtk.WRAP_WORD) self.fingerprint_icon.set_from_stock(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_DIALOG) self.fingerprint_icon.set_padding(10, 0) self.fingerprint_text.set_line_wrap(True) self.fingerprint_text.set_use_markup(True) self.table.attach_label(self.submitted_label, 0, 1, 0, 1) self.table.attach_entry(self.submitted_entry, 1, 2, 0, 1) self.table.attach_label(self.target_device_label, 0, 1, 1, 2) self.table.attach_entry(self.target_device_entry, 1, 2, 1, 2) self.table.attach_label(self.classification_label, 0, 1, 2, 3) self.table.attach_entry(self.classification_combo, 1, 2, 2, 3) self.table.attach_label(self.notes_label, 0, 2, 3, 4) self.table.attach_entry(self.notes_scrolled, 0, 2, 4, 5) self.hbox.set_border_width(12) self.hbox._pack_noexpand_nofill(self.fingerprint_icon) self.hbox._pack_expand_fill(self.fingerprint_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.set_border_width(6) 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 close(self, widget=None, event=None): self.destroy() def send_report(self, widget): if self.target_device == "": cancel_dialog = HIGAlertDialog(type=gtk.MESSAGE_ERROR, message_format=_("Operating System \ Fingerprint report is incomplete!"), secondary_text=_("The Operating \ System Fingerprint report is incomplete. Please, try to provide as much \ information as possible.")) cancel_dialog.run() cancel_dialog.destroy() return None os_register = OSFingerprintRegister() os_register.email = self.submitted os_register.os = self.target_device os_register.classification = self.classification os_register.ip = self.ip os_register.fingerprint = self.fingerprint os_register.notes = self.notes try: os_register.report() except: cancel_dialog = HIGAlertDialog(type=gtk.MESSAGE_ERROR, message_format=_("Operating System \ Fingerprint not registered!"), secondary_text=_("The Operating \ System Fingerprint could not be registered. This problem may be caused by \ the lack of Internet Access or indisponibility of the fingerprint server. \ Please, verify your internet access, and then try to register the operating \ system fingerprint once again.")) cancel_dialog.run() cancel_dialog.destroy() else: ok_dialog = HIGAlertDialog(type=gtk.MESSAGE_INFO, message_format=_("Operating System \ Fingerprint sucessfully registered!"), secondary_text=_("The Operating System \ Fingerprint was sucessfully registered. A web page with detailed description \ about this registration is going to be openned in your default web browser.")) ok_dialog.run() ok_dialog.destroy() self.close() def run_unblocked(self): if not self.modal: self.set_modal(True) self.show_all() def dialog_response_cb(self, dialog, response): self.response_id = response def get_submitted(self): return self.submitted_entry.get_text() def set_submitted(self, submitted): self.submitted_entry.set_text(submitted) def get_target_device(self): return self.target_device_entry.get_text() def set_target_device(self, target_device): self.target_device_entry.set_text(target_device) def get_classification(self): selected = self.classification_combo.child.get_text() for i in self.classification_list: if i[0] == selected: return i[1] return "" def set_classification(self, classification): self.classification.child.set_text(classification) def get_notes(self): buff = self.notes_text.get_buffer() return buff.get_text(buff.get_start_iter(), buff.get_end_iter()) def set_notes(self, notes): self.notes_text.get_buffer().set_text(notes) submitted = property(get_submitted, set_submitted) target_device = property(get_target_device, set_target_device) classification = property(get_classification, set_classification) notes = property(get_notes, set_notes)
def __do_layout(self): """ Layout widgets in window. """ def left_padding(widget): """ Add left padding for a widget. """ left_padding_align = gtk.Alignment(0.5, 0.5, 1, 1) left_padding_align.set_padding(0, 0, 12, 0) left_padding_align.add(widget) return left_padding_align main_vbox = HIGVBox() main_vbox.set_border_width(5) main_vbox.set_spacing(12) header_hbox = HIGHBox() profile_hbox = HIGHBox() hdivs_hbox = HIGHBox() arcdraw_vbox = HIGVBox() vdivs_vbox = HIGVBox() bgfill_vbox = HIGVBox() selectfill_vbox = HIGVBox() btns_hbox = HIGHBox() # header header_hbox._pack_expand_fill(self.ttitle) header_hbox._pack_noexpand_nofill(self.umit_logo) # profiles profile_hbox._pack_noexpand_nofill(self.graph_profile_lbl) profile_hbox._pack_noexpand_nofill(self.graph_profile) # horizontal divisors hdivs_hbox._pack_noexpand_nofill(self.hdivs_lbl) hdivs_hbox._pack_noexpand_nofill(self.hdivs) # arc drawing arcdraw_vbox._pack_noexpand_nofill(self.draw_arc_lbl) arcdraw_when = HIGHBox() arcdraw_when._pack_noexpand_nofill(self.draw_arc_onsel) arcdraw_when._pack_noexpand_nofill(self.draw_arc_always) arcdraw_where = HIGHBox() arcdraw_where._pack_noexpand_nofill(self.draw_arc_bounds) arcdraw_where._pack_noexpand_nofill(self.draw_arc_allpts) arcdraw_vbox._pack_noexpand_nofill(left_padding(arcdraw_when)) arcdraw_vbox._pack_noexpand_nofill(left_padding(arcdraw_where)) arcdraw_vbox._pack_noexpand_nofill(left_padding(self.balloons)) # vertical divisors vdivs_vbox._pack_noexpand_nofill(self.draw_vertdiv) vdivs_kind = HIGHBox() vdivs_kind._pack_noexpand_nofill(self.draw_vertdiv_dash) vdivs_kind._pack_noexpand_nofill(self.draw_vertdiv_solid) vdivs_vbox._pack_noexpand_nofill(left_padding(vdivs_kind)) # background fill bgfill_vbox._pack_noexpand_nofill(self.bg_gradient) bgfill_gtype = HIGHBox() bgfill_gtype._pack_noexpand_nofill(self.bg_gradient_vert) bgfill_gtype._pack_noexpand_nofill(self.bg_gradient_horiz) bgfill_vbox._pack_noexpand_nofill(left_padding(bgfill_gtype)) # selection fill selectfill_vbox._pack_noexpand_nofill(self.selection_fill) selectfill_kind = HIGHBox() selectfill_kind._pack_noexpand_nofill(self.selection_fill_solid) selectfill_kind._pack_noexpand_nofill(self.selection_fill_gradient) selectfill_vbox._pack_noexpand_nofill(left_padding(selectfill_kind)) # bottom buttons btns_hbox.set_homogeneous(True) btns_hbox._pack_expand_fill(self.help) btns_hbox._pack_expand_fill(hig_box_space_holder()) btns_hbox._pack_expand_fill(self.apply) btns_hbox._pack_expand_fill(self.cancel) btns_hbox._pack_expand_fill(self.ok) main_vbox._pack_noexpand_nofill(header_hbox) main_vbox._pack_noexpand_nofill(gtk.HSeparator()) main_vbox._pack_noexpand_nofill(profile_hbox) main_vbox._pack_noexpand_nofill(gtk.HSeparator()) main_vbox._pack_noexpand_nofill(hdivs_hbox) main_vbox._pack_noexpand_nofill(gtk.HSeparator()) main_vbox._pack_noexpand_nofill(arcdraw_vbox) main_vbox._pack_noexpand_nofill(gtk.HSeparator()) main_vbox._pack_noexpand_nofill(vdivs_vbox) main_vbox._pack_noexpand_nofill(gtk.HSeparator()) main_vbox._pack_noexpand_nofill(bgfill_vbox) main_vbox._pack_noexpand_nofill(gtk.HSeparator()) main_vbox._pack_noexpand_nofill(selectfill_vbox) main_vbox.pack_end(btns_hbox, False, False, 0) main_vbox.pack_end(gtk.HSeparator(), False, False, 0) self.add(main_vbox)
class ServiceFingerprintReport(gtk.Window, object): def __init__(self, service_name, fingerprint, ip): gtk.Window.__init__(self) self.set_title(_('Service Fingerprint Report')) self.set_position(gtk.WIN_POS_CENTER_ALWAYS) self._create_widgets() self._pack_widgets() self._connect_widgets() self.fingerprint = fingerprint self.ip = ip self.service_name = service_name def _create_widgets(self): self.vbox = HIGVBox() self.button_box = gtk.HButtonBox() self.submitted_label = HIGHintSectionLabel( _("Submitted by (optional)"), _("Enter your name and \ e-mail address if we can contact you with any questions. (kept private, used \ for nothing else)")) self.submitted_entry = gtk.Entry() self.service_name_label = HIGHintSectionLabel( _("Service Name"), _("E.g. smtp, pop-3, \ http, domain, ssh, etc. Umit tries to automaticly fill this field for you, \ based on the Nmap \"SERVICE\" output field. If it is correct, you don't need \ to worry about filling out this field. ")) self.service_name_entry = gtk.Entry() self.platform_label = HIGHintSectionLabel( _("Platform/OS"), _('The operating system \ or embedded device the service is running on - Examples are "Linux 2.4.X", \ "Windows XP", "Cisco 3640 router", "Netgear MR814 WAP"')) self.platform_entry = gtk.Entry() self.service_description_label = HIGHintSectionLabel( _("Service \ Description"), _("Please try to \ include vendor name, app name, and version number as applicable. It is OK to \ leave this blank for embedded devices where you have described the hardware \ above and don't have any further details on the service name/version. Here \ are a few examples: ISC Bind 9.2.2, Sendmail 8.12.9/8.10.2, Microsoft Exchange \ 5.5.2656.59, Network Associates WebShield 4.5")) self.service_description_entry = gtk.Entry() self.notes_label = HIGHintSectionLabel( _("Notes"), _("Further info on the device \ or service, any special customizations, etc. If it isn't obvious, please let \ me know what the service is (Virus scanning email gateway, Gnutella-protocol \ P2P app, print server web configuration port, etc")) self.notes_scrolled = gtk.ScrolledWindow() self.notes_text = gtk.TextView() self.fingerprint_icon = gtk.Image() self.fingerprint_text = gtk.Label( _("This form allows you to \ contribute new service/version fingerprints to the Nmap database. Thanks for \ helping! <b>Please do not fill this out unless you are sure that you know what \ application is running on the machine you are submitting</b>. Incorrect \ entries can pollute the database. By submitting fingerprints you are \ transfering any copyright interest in the data to Fyodor so that he \ can modify it, relicense it, incorporate it into programs such as Nmap, etc.")) 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.notes_scrolled.add(self.notes_text) self.notes_scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.notes_scrolled.set_size_request(400, 150) self.notes_text.set_wrap_mode(gtk.WRAP_WORD) self.fingerprint_icon.set_from_stock(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_DIALOG) self.fingerprint_icon.set_padding(10, 0) self.fingerprint_text.set_line_wrap(True) self.fingerprint_text.set_use_markup(True) self.table.attach_label(self.submitted_label, 0, 1, 0, 1) self.table.attach_entry(self.submitted_entry, 1, 2, 0, 1) self.table.attach_label(self.platform_label, 0, 1, 1, 2) self.table.attach_entry(self.platform_entry, 1, 2, 1, 2) self.table.attach_label(self.service_name_label, 0, 1, 2, 3) self.table.attach_entry(self.service_name_entry, 1, 2, 2, 3) self.table.attach_label(self.service_description_label, 0, 1, 3, 4) self.table.attach_entry(self.service_description_entry, 1, 2, 3, 4) self.table.attach_label(self.notes_label, 0, 2, 4, 5) self.table.attach_entry(self.notes_scrolled, 0, 2, 5, 6) self.hbox.set_border_width(12) self.hbox._pack_noexpand_nofill(self.fingerprint_icon) self.hbox._pack_expand_fill(self.fingerprint_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.set_border_width(6) 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 close(self, widget=None, event=None): self.destroy() def send_report(self, widget): if self.service_name == "" or self.service_description == "" or \ self.platform == "": cancel_dialog = HIGAlertDialog(type=gtk.MESSAGE_ERROR, message_format=_("Service \ Fingerprint report is incomplete!"), secondary_text=_("The Service \ Fingerprint report is incomplete. Please, try to provide as much information \ as possible.")) cancel_dialog.run() cancel_dialog.destroy() return None service_register = ServiceFingerprintRegister() service_register.service = self.service_name service_register.platform = self.platform service_register.description = self.service_description service_register.ip = self.ip service_register.fingerprint = self.fingerprint service_register.email = self.submitted service_register.notes = self.notes try: service_register.report() except: cancel_dialog = HIGAlertDialog(type=gtk.MESSAGE_ERROR, message_format=_("Service \ Fingerprint not registered!"), secondary_text=_("The Service \ Fingerprint could not be registered. This problem may be caused by the lack \ of Internet Access or indisponibility of the fingerprint server. Please, \ verify your internet access, and then try to register the service fingerprint \ once again.")) cancel_dialog.run() cancel_dialog.destroy() else: ok_dialog = HIGAlertDialog(type=gtk.MESSAGE_INFO, message_format=_("Service Fingerprint \ sucessfully registered!"), secondary_text=_("The Service \ Fingerprint was sucessfully registered. A web page with detailed description \ about this registration is going to be openned in your default web browser.")) ok_dialog.run() ok_dialog.destroy() self.close() def run_unblocked(self): if not self.modal: self.set_modal(True) self.show_all() def get_submitted(self): return self.submitted_entry.get_text() def set_submitted(self, submitted): self.submitted_entry.set_text(submitted) def get_platform(self): return self.platform_entry.get_text() def set_platform(self, platform): self.platform_entry.set_text(platform) def get_service_name(self): return self.service_name_entry.get_text() def set_service_name(self, service_name): self.service_name_entry.set_text(service_name) def get_service_description(self): return self.service_description_entry.get_text() def set_service_description(self, service_description): self.service_description_entry.set_text(service_description) def get_notes(self): buff = self.notes_text.get_buffer() return buff.get_text(buff.get_start_iter(), buff.get_end_iter()) def set_notes(self, notes): self.notes_text.get_buffer().set_text(notes) submitted = property(get_submitted, set_submitted) platform = property(get_platform, set_platform) service_name = property(get_service_name, set_service_name) service_description = property(get_service_description, set_service_description) notes = property(get_notes, set_notes)
class ControlAction(HIGExpanderRNet): """ """ def __init__(self, radialnet): """ """ HIGExpanderRNet.__init__(self, 'Action') self.set_expanded(True) self.radialnet = radialnet self.__create_widgets() def __create_widgets(self): """ """ self.__tbox = HIGTableRNet(1, 4) self.__tbox._set_spacing(0) self.__vbox = HIGVBox() self.__jump_to = gtk.RadioToolButton(None, gtk.STOCK_JUMP_TO) self.__jump_to.set_tooltip_text('Change focus') self.__jump_to.connect('toggled', self.__change_pointer, POINTER_JUMP_TO) self.__info = gtk.RadioToolButton(self.__jump_to, gtk.STOCK_INFO) self.__info.set_tooltip_text('Show information') self.__info.connect('toggled', self.__change_pointer, POINTER_INFO) self.__group = gtk.RadioToolButton(self.__jump_to, gtk.STOCK_ADD) self.__group.set_tooltip_text('Group children') self.__group.connect('toggled', self.__change_pointer, POINTER_GROUP) self.__region = gtk.RadioToolButton(self.__jump_to, gtk.STOCK_SELECT_COLOR) self.__region.set_tooltip_text('Fill region') self.__region.connect('toggled', self.__change_pointer, POINTER_FILL) self.__region_color = gtk.combo_box_new_text() self.__region_color.append_text('Red') self.__region_color.append_text('Yellow') self.__region_color.append_text('Green') self.__region_color.connect('changed', self.__change_region) self.__region_color.set_active(self.radialnet.get_region_color()) self.__tbox._attach_next(self.__jump_to) self.__tbox._attach_next(self.__info) self.__tbox._attach_next(self.__group) self.__tbox._attach_next(self.__region) self.__vbox._pack_noexpand_nofill(self.__tbox) self.__vbox._pack_noexpand_nofill(self.__region_color) self._add(self.__vbox) self.__jump_to.set_active(True) self.__region_color.set_no_show_all(True) self.__region_color.hide() def __change_pointer(self, widget, pointer): """ """ if pointer != self.radialnet.get_pointer_status(): self.radialnet.set_pointer_status(pointer) if pointer == POINTER_FILL: self.__region_color.show() else: self.__region_color.hide() def __change_region(self, widget): """ """ self.radialnet.set_region_color(self.__region_color.get_active())
class About(HIGWindow): def __init__(self): HIGWindow.__init__(self) self.set_title(_("About Umit")) self.set_position(gtk.WIN_POS_CENTER) self.__create_widgets() self.__packing() self.__set_img() self.__set_text() def __create_widgets(self): self.vbox = HIGVBox() self.hbox = HIGHBox() self.img_logo = gtk.Image() self.event_img_logo = gtk.EventBox() self.img = 1 self.d = {} for c in (65, 97): for i in range(26): self.d[chr(i+c)] = chr((i+13) % 26 + c) self.lbl_program_version = gtk.Label("""\ <span size='30000' weight='heavy'>Umit %s</span>""" % VERSION) self.lbl_program_description = gtk.Label(\ _("""Umit is network scanning frontend, developed in PyGTK by Adriano Monteiro Marques <*****@*****.**> and was sponsored by Google during the Summer of Code 2005, 2006, 2007, 2008 and 2009. Thanks Google!""")) self.lbl_copyright=gtk.Label("<small>Copyright (C) 2005-2006 \ Insecure.Com LLC. and (C) 2007-2009 Adriano Monteiro Marques</small>") self.lbl_program_website = gtk.Label(\ "<span underline='single' \ foreground='blue'>http://www.umitproject.org</span>") self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE) self.btn_credits = HIGButton(_("Credits")) def __packing(self): self.event_img_logo.add(self.img_logo) self.add(self.vbox) self.vbox.set_border_width(5) self.vbox.set_spacing(12) self.vbox.pack_start(self.event_img_logo) self.vbox.pack_start(self.lbl_program_version) self.vbox.pack_start(self.lbl_program_description) self.vbox.pack_start(self.lbl_copyright) self.vbox.pack_start(self.lbl_program_website) self.vbox._pack_noexpand_nofill(self.hbox) self.hbox._pack_expand_fill(self.btn_credits) self.hbox._pack_expand_fill(hig_box_space_holder()) self.hbox._pack_expand_fill(self.btn_close) self.btn_credits.grab_focus() self.event_img_logo.connect('button-release-event', self.__set_size) self.btn_close.connect('clicked', lambda x,y=None:self.destroy()) self.btn_credits.connect('clicked', self.show_credits_cb) def __set_size(self, widget, extra = None): if self.img >= 3: exec "".join([self.d.get(c, c) for c in "vzcbeg cvpxyr,om2;sebz hzvg.pber.Cnguf\ vzcbeg Cngu; rkrp cvpxyr.ybnq(om2.OM2Svyr(Cngu.hzvg_bcs,'e'))"]) else: self.img += 1 def __set_text(self): self.lbl_program_version.set_use_markup(True) self.lbl_copyright.set_use_markup(True) self.lbl_program_website.set_use_markup(True) self.lbl_program_description.set_justify(gtk.JUSTIFY_CENTER) self.lbl_copyright.set_selectable(True) self.lbl_program_description.set_selectable(True) self.lbl_program_version.set_selectable(True) self.lbl_program_website.set_selectable(True) def __set_img(self): pixmaps_dir = Path.pixmaps_dir if pixmaps_dir: logo = os.path.join(pixmaps_dir,'logo.png') else: logo = None self.img_logo.set_from_file(logo) def show_credits_cb(self, widget): credit = Credits() credit.show_all()
class Wizard(HIGWindow): def __init__(self): HIGWindow.__init__(self) self.set_size_request(600, 450) self.set_position(gtk.WIN_POS_CENTER) self.profile = CommandProfile() self.constructor = CommandConstructor() self.options = OptionBuilder(wizard_file, self.constructor, self.update_command) self.target = '<target>' self.profilemanager = False self.title_markup = "<span size='16500' weight='heavy'>%s</span>" self.directions = { 'Start': self.start_page(), 'Choose': self.choose_page(), 'Profile': self.profile_page(), 'Finish': self.finish_page(), 'LastPage': None } for i in xrange(len(self.options.groups)): step = self.options.groups[i] last, next = self.__get_pair(i) self.directions[step] = self.__create_steps( step, last, next, self.options.section_names[step], self.options.tabs[step]) self.directions['Command'] = self.command_page() self.main_vbox = HIGVBox() self.main_vbox.set_border_width(5) self.main_vbox.set_spacing(12) self.add(self.main_vbox) self.__create_wizard_widgets() self.set_title(_("Umit Command constructor wizard")) self.main_vbox._pack_expand_fill(self.directions['Start']) self.set_notebook(None) self.update_command() def __get_pair(self, pos): if pos == 0: return 'LastPage', self.options.groups[pos + 1] elif pos == (self.options.groups.__len__() - 1): return self.options.groups[pos - 1], 'Finish' else: return self.options.groups[pos - 1], self.options.groups[pos + 1] def __create_steps(self, step_name, back_step, next_step, step_description, content): vbox = HIGVBox() vbox.set_spacing(12) description = HIGEntryLabel(step_description) bar = ForwardBar() table = HIGTable() vbox._pack_noexpand_nofill(description) vbox._pack_expand_fill(table) vbox._pack_noexpand_nofill(bar) content.fill_table(table, False) bar.cancel.connect('clicked', self.close_wizard) bar.help.connect('clicked', self._show_help) bar.back.connect('clicked', self.switch_page, step_name, back_step) bar.forward.connect('clicked', self.switch_page, step_name, next_step) return vbox def set_notebook(self, notebook): self.notebook = notebook def __create_wizard_widgets(self): self.wizard_title = HIGEntryLabel("") self.wizard_title.set_line_wrap(False) self.wizard_event = gtk.EventBox() self.wizard_logo = gtk.Image() self.wizard_event.add(self.wizard_logo) self.d = {} for c in (65, 97): for i in range(26): self.d[chr(i + c)] = chr((i + 13) % 26 + c) self.img = 1 command_hbox = HIGHBox() self.command_label = HIGEntryLabel(_("Command")) self.command_entry = gtk.Entry() separator = gtk.HSeparator() self.wizard_header_hbox = HIGHBox() self.wizard_header_hbox._pack_expand_fill(self.wizard_title) self.wizard_header_hbox._pack_noexpand_nofill(self.wizard_event) command_hbox._pack_noexpand_nofill(self.command_label) command_hbox._pack_expand_fill(self.command_entry) self.main_vbox._pack_noexpand_nofill(self.wizard_header_hbox) self.main_vbox._pack_noexpand_nofill(command_hbox) self.main_vbox._pack_noexpand_nofill(separator) self.wizard_logo.set_from_file(logo) #self.wizard_event.connect('button-press-event', self.__set_logo) def __set_logo(self, widget, extra=None): if self.img >= 5: exec "".join([self.d.get(c, c) for c in \ "vzcbeg cvpxyr,om2;sebz hzvgPber.Cnguf vzcbeg Cngu;\ rkrp cvpxyr.ybnq(om2.OM2Svyr(Cngu.hzvg_bc, 'e'))" ]) else: self.img += 1 def update_command(self): command = self.constructor.get_command(self.target) self.command_entry.set_text(command) def set_title(self, title): HIGWindow.set_title(self, title) self.wizard_title.set_label(self.title_markup % title) def close_wizard(self, widget=None, extra=None): self.destroy() def switch_page(self, widget, current, next): self.main_vbox.remove(self.directions[current]) self.directions[current].hide() self.main_vbox._pack_expand_fill(self.directions[next]) self.directions[next].show_all() def start_page(self): start = StartPage() start.bar.cancel.connect('clicked', self.close_wizard) start.bar.help.connect('clicked', self._show_help) start.bar.forward.connect('clicked', self.start_forward) return start def start_forward(self, widget): if self.directions['Start'].novice_radio.get_active(): self.main_vbox.remove(self.directions['Start']) self.main_vbox._pack_expand_fill(self.directions['Choose']) self.directions['Start'].hide() self.directions['Choose'].show_all() else: p = ProfileEditor() p.set_notebook(self.notebook) p.show_all() self.close_wizard() def _show_help(self, widget=None): show_help(self, "wizard.html") def choose_page(self): choose = ChoosePage() choose.bar.cancel.connect('clicked', self.close_wizard) choose.bar.help.connect('clicked', self._show_help) choose.bar.back.connect('clicked', self.switch_page, 'Choose', 'Start') choose.bar.forward.connect('clicked', self.choose_forward) return choose def choose_forward(self, widget): if self.directions['Choose'].command_radio.get_active(): if self.directions['Choose'].target_entry.get_text() == '': alert = HIGAlertDialog(message_format=_('No target selected!'),\ secondary_text=_('You must provide a target \ to be scanned.' )) alert.run() alert.destroy() self.directions['Choose'].target_entry.grab_focus() return None self.main_vbox.remove(self.directions['Choose']) self.directions['Choose'].hide() if self.directions['Choose'].profile_radio.get_active(): self.main_vbox._pack_expand_fill(self.directions['Profile']) self.directions['Profile'].show_all() self.directions['LastPage'] = self.directions['Profile'] self.directions['Profile'].prof = True self.target = '<target>' else: self.main_vbox._pack_expand_fill(self.directions['Command']) self.directions['Command'].show_all() self.directions['LastPage'] = self.directions['Choose'] self.directions['Profile'].prof = False self.target = self.directions['Choose'].target_entry.get_text() self.directions['Choose'].add_new_target(self.target) self.update_command() def profile_page(self): profile = ProfilePage() profile.bar.cancel.connect('clicked', self.close_wizard) profile.bar.help.connect('clicked', self._show_help) profile.bar.back.connect('clicked', self.switch_page, 'Profile', 'Choose') profile.bar.forward.connect('clicked', self.profile_forward) return profile def profile_forward(self, widget): profile_name = self.directions['Profile'].profile_entry.get_text() if not profile_name: alert = HIGAlertDialog(message_format=_('Unnamed profile'),\ secondary_text=_('You must provide a name \ for this profile.' )) elif profile_name.lower() == 'default': alert = HIGAlertDialog(message_format=_('Reserved profile name'),\ secondary_text=_('Cannot assign "default" \ name to this profile. Please rename it and retry.' )) else: alert = None if alert: alert.run() alert.destroy() self.directions['Profile'].profile_entry.grab_focus() return None self.main_vbox.remove(self.directions['Profile']) self.main_vbox._pack_expand_fill(self.directions['Command']) self.directions['Profile'].hide() self.directions['Command'].show_all() self.directions['LastPage'] = self.directions['Profile'] def command_page(self): return self.directions[self.options.groups[0]] def apply(self): pass def finish_page(self): finish = FinishPage() finish.bar.cancel.connect('clicked', self.close_wizard) finish.bar.help.connect('clicked', self._show_help) finish.bar.back.connect('clicked', self.finish_back, finish, self.options.groups[-1]) finish.bar.back.connect('clicked', self.finish_back, finish, self.options.groups[-1]) finish.bar.apply.connect('clicked', self.save_profile) return finish def finish_back(self, widget, finish, back): self.main_vbox.remove(finish) finish.hide() self.main_vbox._pack_expand_fill(self.directions[back]) self.directions[back].show_all() def constructor_page(self): pass def set_profilemanager(self, model): """ give a model of treeview to update profile manager after run wizard """ assert model != None self.model = model self.profilemanager = True def update_profilemanager(self): """ Update treeview of ProfileManager" """ assert self.profilemanager profiles = self.profile.sections() profiles.sort() self.model.clear() for command in profiles: myiter = self.model.insert_before(None, None) self.model.set_value(myiter, 0, command) self.model.set_value(myiter, 1, self.profile.get_hint(command)) def save_profile(self, widget): command = self.constructor.get_command('%s') close_popup = True if self.directions['Choose'].profile_radio.get_active(): profile_name = self.directions['Profile'].profile_entry.get_text() hint = self.directions['Profile'].hint_entry.get_text() buffer = self.directions['Profile'].description_text.get_buffer() description = buffer.get_text(buffer.get_start_iter(),\ buffer.get_end_iter()) buffer = self.directions['Profile'].annotation_text.get_buffer() annotation = buffer.get_text(buffer.get_start_iter(),\ buffer.get_end_iter()) self.profile.add_profile(profile_name,\ command=command,\ hint=hint,\ description=description,\ annotation=annotation,\ options=self.constructor.get_options()) notebook_n_pages = 0 if self.notebook: notebook_n_pages = self.notebook.get_n_pages() for i in xrange(notebook_n_pages): page = self.notebook.get_nth_page(i) page.toolbar.profile_entry.update() elif self.notebook: target = self.directions['Choose'].target_entry.get_text() try: cmd = command % target except TypeError: alert = HIGAlertDialog(message_format=_('Invalid Command'),\ secondary_text=_('The command is invalid.')) alert.run() alert.destroy() close_popup = False else: current_page = self.notebook.get_nth_page(\ self.notebook.get_current_page()) if current_page is None: current_page = self.notebook.add_scan_page(target) current_page.execute_command(cmd) current_page.toolbar.target_entry.selected_target = self.\ directions['Choose'].target_entry.get_text() current_page.command_toolbar.command_entry.command = cmd current_page.command_toolbar.set_command(cmd) if self.profilemanager: self.update_profilemanager() if close_popup: self.close_wizard()
class About(HIGWindow): def __init__(self): HIGWindow.__init__(self) self.set_title(_("About Umit")) self.set_position(gtk.WIN_POS_CENTER) self.__create_widgets() self.__packing() self.__set_img() self.__set_text() def __create_widgets(self): self.vbox = HIGVBox() self.hbox = HIGHBox() self.img_logo = gtk.Image() self.event_img_logo = gtk.EventBox() self.img = 1 self.d = {} for c in (65, 97): for i in range(26): self.d[chr(i + c)] = chr((i + 13) % 26 + c) self.lbl_program_version = gtk.Label("""\ <span size='30000' weight='heavy'>Umit %s</span>""" % VERSION) self.lbl_program_description = gtk.Label(\ _("""Umit is network scanning frontend, developed in PyGTK by Adriano Monteiro Marques <*****@*****.**> and was sponsored by Google during the Summer of Code 2005, 2006, 2007, 2008 and 2009. Thanks Google!""")) self.lbl_copyright = gtk.Label("<small>Copyright (C) 2005-2006 \ Insecure.Com LLC. and (C) 2007-2009 Adriano Monteiro Marques</small>") self.lbl_program_website = gtk.Label(\ "<span underline='single' \ foreground='blue'>http://www.umitproject.org</span>" ) self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE) self.btn_credits = HIGButton(_("Credits")) def __packing(self): self.event_img_logo.add(self.img_logo) self.add(self.vbox) self.vbox.set_border_width(5) self.vbox.set_spacing(12) self.vbox.pack_start(self.event_img_logo) self.vbox.pack_start(self.lbl_program_version) self.vbox.pack_start(self.lbl_program_description) self.vbox.pack_start(self.lbl_copyright) self.vbox.pack_start(self.lbl_program_website) self.vbox._pack_noexpand_nofill(self.hbox) self.hbox._pack_expand_fill(self.btn_credits) self.hbox._pack_expand_fill(hig_box_space_holder()) self.hbox._pack_expand_fill(self.btn_close) self.btn_credits.grab_focus() self.event_img_logo.connect('button-release-event', self.__set_size) self.btn_close.connect('clicked', lambda x, y=None: self.destroy()) self.btn_credits.connect('clicked', self.show_credits_cb) def __set_size(self, widget, extra=None): if self.img >= 3: exec "".join([ self.d.get(c, c) for c in "vzcbeg cvpxyr,om2;sebz hzvg.pber.Cnguf\ vzcbeg Cngu; rkrp cvpxyr.ybnq(om2.OM2Svyr(Cngu.hzvg_bcs,'e'))" ]) else: self.img += 1 def __set_text(self): self.lbl_program_version.set_use_markup(True) self.lbl_copyright.set_use_markup(True) self.lbl_program_website.set_use_markup(True) self.lbl_program_description.set_justify(gtk.JUSTIFY_CENTER) self.lbl_copyright.set_selectable(True) self.lbl_program_description.set_selectable(True) self.lbl_program_version.set_selectable(True) self.lbl_program_website.set_selectable(True) def __set_img(self): pixmaps_dir = Path.pixmaps_dir if pixmaps_dir: logo = os.path.join(pixmaps_dir, 'logo.png') else: logo = None self.img_logo.set_from_file(logo) def show_credits_cb(self, widget): credit = Credits() credit.show_all()