def set_scan_infos(self, scan_info): for scan in scan_info: exp = gtk.Expander('<b>%s - %s</b>' % (_('Scan Info'), scan['type'].capitalize())) exp.set_use_markup(True) hbox = HIGHBox() table = HIGTable() table.set_border_width(5) table.set_row_spacings(6) table.set_col_spacings(6) table.attach(HIGEntryLabel(_('Scan type:')), 0, 1, 0, 1) table.attach(HIGEntryLabel(scan['type']), 1, 2, 0, 1) table.attach(HIGEntryLabel(_('Protocol:')), 0, 1, 1, 2) table.attach(HIGEntryLabel(scan['protocol']), 1, 2, 1, 2) table.attach(HIGEntryLabel(_('# scanned ports:')), 0, 1, 2, 3) table.attach(HIGEntryLabel(scan['numservices']), 1, 2, 2, 3) table.attach(HIGEntryLabel(_('Services:')), 0, 1, 3, 4) table.attach(self.get_service_view(scan['services'].split(',')),\ 1,2,3,4) hbox._pack_noexpand_nofill(hig_box_space_holder()) hbox._pack_noexpand_nofill(table) exp.add(hbox) self._pack_noexpand_nofill(exp)
def set_scan_infos(self, scan_info): for scan in scan_info: exp = gtk.Expander('<b>%s - %s</b>' % (_('Scan Info'), scan['type'].capitalize())) exp.set_use_markup(True) hbox = HIGHBox() table = HIGTable() table.set_border_width(5) table.set_row_spacings(6) table.set_col_spacings(6) table.attach(HIGEntryLabel(_('Scan type:')),0,1,0,1) table.attach(HIGEntryLabel(scan['type']),1,2,0,1) table.attach(HIGEntryLabel(_('Protocol:')),0,1,1,2) table.attach(HIGEntryLabel(scan['protocol']),1,2,1,2) table.attach(HIGEntryLabel(_('# scanned ports:')),0,1,2,3) table.attach(HIGEntryLabel(scan['numservices']),1,2,2,3) table.attach(HIGEntryLabel(_('Services:')),0,1,3,4) table.attach(self.get_service_view(scan['services'].split(',')),\ 1,2,3,4) hbox._pack_noexpand_nofill(hig_box_space_holder()) hbox._pack_noexpand_nofill(table) exp.add (hbox) self._pack_noexpand_nofill(exp)
class LoginDialog(HIGDialog): """""" #---------------------------------------------------------------------- def __init__(self, title=_('Open Monitor 2012')): """Constructor""" HIGDialog.__init__(self, title=title, flags=gtk.DIALOG_MODAL, buttons=(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) self.set_position(gtk.WIN_POS_CENTER_ALWAYS) self.set_default_response(gtk.RESPONSE_ACCEPT) self.set_keep_above(True) self.set_size_request(480, 240) self.set_border_width(2) self._create_widgets() self._pack_widgets() self._connect_widgets() def _create_widgets(self): #Username self.username_label = HIGLabel(_("Username")) self.username_entry = HIGTextEntry() self.username_entry.set_activates_default(True) #Password self.password_label = HIGLabel(_("Password")) self.password_entry = HIGPasswordEntry() self.password_entry.set_activates_default(True) #Logo self.logo_openmonitor = gtk.gdk.pixbuf_new_from_file\ (os.path.join(IMAGES_DIR, 'logoOM.png')) self.logo_image = gtk.Image() self.logo_image.set_from_pixbuf(self.logo_openmonitor) #self.login_text = gtk.Label(_("Log into your ICM agent.")) #Register #self.register_button = HIGStockButton(gtk.STOCK_DIALOG_INFO,_("Register")) self.register_label = \ gtk.Label(_("<span foreground='blue'>" \ "Register id</span>")) self.register_label.set_use_markup(True) self.register_button = gtk.Button() self.register_button.add(self.register_label) self.register_button.set_relief(gtk.RELIEF_NONE) #Forget Password self.forgot_password_label = \ gtk.Label(_("<span foreground='blue'>" \ "Forgot password?</span>")) self.forgot_password_label.set_use_markup(True) self.forgot_password = gtk.Button() self.forgot_password.add(self.forgot_password_label) self.forgot_password.set_relief(gtk.RELIEF_NONE) #Auto Login self.auto_login_checkbtn = gtk.CheckButton(_("Auto login")) #Settings self.settings_button = HIGStockButton(gtk.STOCK_DIALOG_INFO,_("settings")) #Container self.hbox = HIGHBox(False,2) self.table = HIGTable(8,4,False) self.table.set_row_spacings(5) self.table.set_col_spacings(10) self.action_area.set_homogeneous(False) #tab orders self.orders = [self.username_entry, self.password_entry, self.register_button, self.forgot_password] def _pack_widgets(self): self.hbox.set_border_width(8) self.table.set_focus_chain(self.orders) self.table.attach(self.logo_image,0,7,0,5,gtk.FILL,gtk.FILL,0,0) self.table.attach(self.username_label,0,1,5,6,gtk.FILL,gtk.FILL,0,0) self.table.attach(self.username_entry,1,5,5,6,gtk.FILL|gtk.EXPAND,gtk.FILL|gtk.EXPAND,0,0) self.table.attach(self.password_label,0,1,6,7,gtk.FILL,gtk.FILL,0,0) self.table.attach(self.password_entry,1,5,6,7,gtk.FILL|gtk.EXPAND,gtk.FILL|gtk.EXPAND,0,0) self.table.attach(self.register_button,5,6,5,6,gtk.FILL,gtk.FILL,0,0) self.table.attach(self.forgot_password,5,6,6,7,gtk.FILL,gtk.FILL,0,0) self.table.attach(self.auto_login_checkbtn,1,3,7,8,gtk.FILL,gtk.FILL,0,0) self.hbox._pack_expand_fill(self.table) self.vbox.pack_start(self.hbox, False, False) spaceholder1 = hig_box_space_holder() spaceholder2 = hig_box_space_holder() spaceholder3 = hig_box_space_holder() self.action_area.pack_end(spaceholder1) self.action_area.pack_end(spaceholder2) self.action_area.pack_end(spaceholder3) self.action_area.pack_end(self.settings_button) self.action_area.reorder_child(self.settings_button, 0) self.action_area.reorder_child(spaceholder1, 1) self.action_area.reorder_child(spaceholder2, 2) self.action_area.reorder_child(spaceholder3, 2) def _connect_widgets(self): self.connect('response', self.check_response) self.register_button.connect('clicked', self._register) self.forgot_password.connect('clicked', self._forgot_password) self.settings_button.connect('clicked', self._settings) def _register(self, widget): #registration_form = RegistrationDialog() #registration_form.show_all() webbrowser.open(theApp.aggregator.base_url + "/accounts/register/") def _forgot_password(self, widget): webbrowser.open(theApp.aggregator.base_url + "/accounts/password/reset/") def check_response(self, widget, response_id): #There should collect the error information: help the user to check problem if response_id == gtk.RESPONSE_ACCEPT: # clicked on Ok btn username = self.username_entry.get_text() password = self.password_entry.get_text() save_login = self.auto_login_checkbtn.get_active() #Bug in this: If the user go to this window, the theApp.peer_info cannot is_registered #if not theApp.peer_info.is_registered: defer_ = theApp.login(username, password, save_login) # defer_ = theApp.register_agent(username, password) # defer_.addCallback( # lambda x: theApp.login(username, password, save_login)) #else: # defer_ = theApp.login(username, password, save_login) self.destroy() theApp.gtk_main.login_dlg = None elif response_id in (gtk.RESPONSE_DELETE_EVENT, gtk.RESPONSE_CANCEL, gtk.RESPONSE_NONE): self.destroy() theApp.gtk_main.login_dlg = None def _settings(self,widget): ''' configure settings: Server IP/Port: popup a new window ''' settings_form = SettingsDialog() settings_form.show_all()
class ScanRunDetailsPage(HIGVBox): def __init__(self): HIGVBox.__init__(self) self.__create_widgets() def __create_widgets(self): na = _('Not available') self.command_expander = gtk.Expander("<b>" + _("Command Info") + "</b>") self.general_expander = gtk.Expander("<b>" + _("General Info") + "</b>") # Command info self.command_label = HIGEntryLabel(_('Command:')) self.info_command_label = HIGEntryLabel(na) self.nmap_version_label = HIGEntryLabel(_('Nmap Version:')) self.info_nmap_version_label = HIGEntryLabel(na) self.verbose_label = HIGEntryLabel(_('Verbosity level:')) self.info_verbose_label = HIGEntryLabel(na) self.debug_label = HIGEntryLabel(_('Debug level:')) self.info_debug_label = HIGEntryLabel(na) self.command_table = HIGTable() self.command_hbox = HIGHBox() # General info: self.start_label = HIGEntryLabel(_('Started on:')) self.info_start_label = HIGEntryLabel(na) self.finished_label = HIGEntryLabel(_('Finished on:')) self.info_finished_label = HIGEntryLabel(na) self.host_up_label = HIGEntryLabel(_('Hosts up:')) self.info_hosts_up_label = HIGEntryLabel(na) self.host_down_label = HIGEntryLabel(_('Hosts down:')) self.info_hosts_down_label = HIGEntryLabel(na) self.host_scanned_label = HIGEntryLabel(_('Hosts scanned:')) self.info_hosts_scanned_label = HIGEntryLabel(na) self.open_label = HIGEntryLabel(_('Open ports:')) self.info_open_label = HIGEntryLabel(na) self.filtered_label = HIGEntryLabel(_('Filtered ports:')) self.info_filtered_label = HIGEntryLabel(na) self.closed_label = HIGEntryLabel(_('Closed ports:')) self.info_closed_label = HIGEntryLabel(na) self.general_table = HIGTable() self.general_hbox = HIGHBox() def set_command_info(self, info): # Fix aligment! self.command_expander.set_use_markup(True) self.command_table.set_border_width(5) self.command_table.set_row_spacings(6) self.command_table.set_col_spacings(6) try: self.info_command_label.set_text(info['command']) except: pass try: self.info_nmap_version_label.set_text(info['version']) except: pass try: self.info_verbose_label.set_text(info['verbose']) except: pass try: self.info_debug_label.set_text(info['debug']) except: pass self.command_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.command_hbox._pack_noexpand_nofill(self.command_table) self.command_table.attach(self.command_label, 0, 1, 0, 1) self.command_table.attach(self.info_command_label, 1, 2, 0, 1) self.command_table.attach(self.nmap_version_label, 0, 1, 1, 2) self.command_table.attach(self.info_nmap_version_label, 1, 2, 1, 2) self.command_table.attach(self.verbose_label, 0, 1, 2, 3) self.command_table.attach(self.info_verbose_label, 1, 2, 2, 3) self.command_table.attach(self.debug_label, 0, 1, 3, 4) self.command_table.attach(self.info_debug_label, 1, 2, 3, 4) self.command_expander.add(self.command_hbox) self._pack_noexpand_nofill(self.command_expander) self.command_expander.set_expanded(True) def set_general_info(self, info): # Fix aligment! self.general_expander.set_use_markup(True) self.general_table.set_border_width(5) self.general_table.set_row_spacings(6) self.general_table.set_col_spacings(6) try: self.info_start_label.set_text(info['start']) except: pass try: self.info_finished_label.set_text(info['finish']) except: pass try: self.info_hosts_up_label.set_text(info['hosts_up']) except: pass try: self.info_hosts_down_label.set_text(info['hosts_down']) except: pass try: self.info_hosts_scanned_label.set_text(info['hosts_scanned']) except: pass #try: self.info_open_label.set_text(info['open_ports']) #except:pass #try: self.info_filtered_label.set_text(info['filtered_ports']) #except:pass #try: self.info_closed_label.set_text(info['closed_ports']) #except:pass self.general_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.general_hbox._pack_noexpand_nofill(self.general_table) self.general_table.attach(self.start_label, 0, 1, 0, 1) self.general_table.attach(self.info_start_label, 1, 2, 0, 1) self.general_table.attach(self.finished_label, 0, 1, 1, 2) self.general_table.attach(self.info_finished_label, 1, 2, 1, 2) self.general_table.attach(self.host_up_label, 0, 1, 2, 3) self.general_table.attach(self.info_hosts_up_label, 1, 2, 2, 3) self.general_table.attach(self.host_down_label, 0, 1, 3, 4) self.general_table.attach(self.info_hosts_down_label, 1, 2, 3, 4) self.general_table.attach(self.host_scanned_label, 0, 1, 4, 5) self.general_table.attach(self.info_hosts_scanned_label, 1, 2, 4, 5) self.general_table.attach(self.open_label, 0, 1, 5, 6) self.general_table.attach(self.info_open_label, 1, 2, 5, 6) self.general_table.attach(self.filtered_label, 0, 1, 6, 7) self.general_table.attach(self.info_filtered_label, 1, 2, 6, 7) self.general_table.attach(self.closed_label, 0, 1, 7, 8) self.general_table.attach(self.info_closed_label, 1, 2, 7, 8) self.general_expander.add(self.general_hbox) self._pack_noexpand_nofill(self.general_expander) self.general_expander.set_expanded(True) def set_scan_infos(self, scan_info): for scan in scan_info: exp = gtk.Expander('<b>%s - %s</b>' % (_('Scan Info'), scan['type'].capitalize())) exp.set_use_markup(True) hbox = HIGHBox() table = HIGTable() table.set_border_width(5) table.set_row_spacings(6) table.set_col_spacings(6) table.attach(HIGEntryLabel(_('Scan type:')), 0, 1, 0, 1) table.attach(HIGEntryLabel(scan['type']), 1, 2, 0, 1) table.attach(HIGEntryLabel(_('Protocol:')), 0, 1, 1, 2) table.attach(HIGEntryLabel(scan['protocol']), 1, 2, 1, 2) table.attach(HIGEntryLabel(_('# scanned ports:')), 0, 1, 2, 3) table.attach(HIGEntryLabel(scan['numservices']), 1, 2, 2, 3) table.attach(HIGEntryLabel(_('Services:')), 0, 1, 3, 4) table.attach(self.get_service_view(scan['services'].split(',')),\ 1,2,3,4) hbox._pack_noexpand_nofill(hig_box_space_holder()) hbox._pack_noexpand_nofill(table) exp.add(hbox) self._pack_noexpand_nofill(exp) def get_service_view(self, services): combo = gtk.combo_box_new_text() for i in services: combo.append_text(i) return combo
class ScanRunDetailsPage(HIGVBox): def __init__(self): HIGVBox.__init__(self) self.__create_widgets() def __create_widgets(self): na = _('Not available') self.command_expander = gtk.Expander("<b>"+_("Command Info")+"</b>") self.general_expander = gtk.Expander("<b>"+_("General Info")+"</b>") # Command info self.command_label = HIGEntryLabel(_('Command:')) self.info_command_label = HIGEntryLabel(na) self.nmap_version_label = HIGEntryLabel(_('Nmap Version:')) self.info_nmap_version_label = HIGEntryLabel(na) self.verbose_label = HIGEntryLabel(_('Verbosity level:')) self.info_verbose_label = HIGEntryLabel(na) self.debug_label = HIGEntryLabel(_('Debug level:')) self.info_debug_label = HIGEntryLabel(na) self.command_table = HIGTable() self.command_hbox = HIGHBox() # General info: self.start_label = HIGEntryLabel(_('Started on:')) self.info_start_label = HIGEntryLabel(na) self.finished_label = HIGEntryLabel(_('Finished on:')) self.info_finished_label = HIGEntryLabel(na) self.host_up_label = HIGEntryLabel(_('Hosts up:')) self.info_hosts_up_label = HIGEntryLabel(na) self.host_down_label = HIGEntryLabel(_('Hosts down:')) self.info_hosts_down_label = HIGEntryLabel(na) self.host_scanned_label = HIGEntryLabel(_('Hosts scanned:')) self.info_hosts_scanned_label = HIGEntryLabel(na) self.open_label = HIGEntryLabel(_('Open ports:')) self.info_open_label = HIGEntryLabel(na) self.filtered_label = HIGEntryLabel(_('Filtered ports:')) self.info_filtered_label = HIGEntryLabel(na) self.closed_label = HIGEntryLabel(_('Closed ports:')) self.info_closed_label = HIGEntryLabel(na) self.general_table = HIGTable() self.general_hbox = HIGHBox() def set_command_info(self, info): # Fix aligment! self.command_expander.set_use_markup(True) self.command_table.set_border_width(5) self.command_table.set_row_spacings(6) self.command_table.set_col_spacings(6) try:self.info_command_label.set_text(info['command']) except:pass try:self.info_nmap_version_label.set_text(info['version']) except:pass try:self.info_verbose_label.set_text(info['verbose']) except:pass try:self.info_debug_label.set_text(info['debug']) except:pass self.command_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.command_hbox._pack_noexpand_nofill(self.command_table) self.command_table.attach(self.command_label,0,1,0,1) self.command_table.attach(self.info_command_label,1,2,0,1) self.command_table.attach(self.nmap_version_label,0,1,1,2) self.command_table.attach(self.info_nmap_version_label,1,2,1,2) self.command_table.attach(self.verbose_label,0,1,2,3) self.command_table.attach(self.info_verbose_label,1,2,2,3) self.command_table.attach(self.debug_label,0,1,3,4) self.command_table.attach(self.info_debug_label,1,2,3,4) self.command_expander.add(self.command_hbox) self._pack_noexpand_nofill(self.command_expander) self.command_expander.set_expanded(True) def set_general_info(self, info): # Fix aligment! self.general_expander.set_use_markup(True) self.general_table.set_border_width(5) self.general_table.set_row_spacings(6) self.general_table.set_col_spacings(6) try:self.info_start_label.set_text(info['start']) except:pass try:self.info_finished_label.set_text(info['finish']) except:pass try:self.info_hosts_up_label.set_text(info['hosts_up']) except:pass try:self.info_hosts_down_label.set_text(info['hosts_down']) except:pass try:self.info_hosts_scanned_label.set_text(info['hosts_scanned']) except:pass #try: self.info_open_label.set_text(info['open_ports']) #except:pass #try: self.info_filtered_label.set_text(info['filtered_ports']) #except:pass #try: self.info_closed_label.set_text(info['closed_ports']) #except:pass self.general_hbox._pack_noexpand_nofill(hig_box_space_holder()) self.general_hbox._pack_noexpand_nofill(self.general_table) self.general_table.attach(self.start_label,0,1,0,1) self.general_table.attach(self.info_start_label,1,2,0,1) self.general_table.attach(self.finished_label,0,1,1,2) self.general_table.attach(self.info_finished_label,1,2,1,2) self.general_table.attach(self.host_up_label,0,1,2,3) self.general_table.attach(self.info_hosts_up_label,1,2,2,3) self.general_table.attach(self.host_down_label,0,1,3,4) self.general_table.attach(self.info_hosts_down_label,1,2,3,4) self.general_table.attach(self.host_scanned_label,0,1,4,5) self.general_table.attach(self.info_hosts_scanned_label,1,2,4,5) self.general_table.attach(self.open_label,0,1,5,6) self.general_table.attach(self.info_open_label,1,2,5,6) self.general_table.attach(self.filtered_label,0,1,6,7) self.general_table.attach(self.info_filtered_label,1,2,6,7) self.general_table.attach(self.closed_label,0,1,7,8) self.general_table.attach(self.info_closed_label,1,2,7,8) self.general_expander.add(self.general_hbox) self._pack_noexpand_nofill(self.general_expander) self.general_expander.set_expanded(True) def set_scan_infos(self, scan_info): for scan in scan_info: exp = gtk.Expander('<b>%s - %s</b>' % (_('Scan Info'), scan['type'].capitalize())) exp.set_use_markup(True) hbox = HIGHBox() table = HIGTable() table.set_border_width(5) table.set_row_spacings(6) table.set_col_spacings(6) table.attach(HIGEntryLabel(_('Scan type:')),0,1,0,1) table.attach(HIGEntryLabel(scan['type']),1,2,0,1) table.attach(HIGEntryLabel(_('Protocol:')),0,1,1,2) table.attach(HIGEntryLabel(scan['protocol']),1,2,1,2) table.attach(HIGEntryLabel(_('# scanned ports:')),0,1,2,3) table.attach(HIGEntryLabel(scan['numservices']),1,2,2,3) table.attach(HIGEntryLabel(_('Services:')),0,1,3,4) table.attach(self.get_service_view(scan['services'].split(',')),\ 1,2,3,4) hbox._pack_noexpand_nofill(hig_box_space_holder()) hbox._pack_noexpand_nofill(table) exp.add (hbox) self._pack_noexpand_nofill(exp) def get_service_view(self, services): combo = gtk.combo_box_new_text() for i in services: combo.append_text(i) return combo