def _add_menu_optional_actions(self, action_group, uimanager): if sys.platform.startswith('linux'): action = Gtk.Action(name='ToolsSFTPClient', label='SFTP Client', tooltip='SFTP Client', stock_id=None) action.connect('activate', lambda x: self.start_sftp_client()) action_group.add_action_with_accel(action, '<control>F2') merge_id = uimanager.new_merge_id() uimanager.add_ui(merge_id, '/MenuBar/ToolsMenu', 'ToolsSFTPClient', 'ToolsSFTPClient', Gtk.UIManagerItemType.MENUITEM, False) if graphs.has_matplotlib: action = Gtk.Action(name='ToolsGraphMenu', label='Create Graph', tooltip='Create A Graph', stock_id=None) action_group.add_action(action) for graph_name in graphs.get_graphs(): action_name = 'ToolsGraph' + graph_name graph = graphs.get_graph(graph_name) action = Gtk.Action(name=action_name, label=graph.name_human, tooltip=graph.name_human, stock_id=None) action.connect('activate', self.signal_activate_popup_menu_create_graph, graph_name) action_group.add_action(action) merge_id = uimanager.new_merge_id() uimanager.add_ui(merge_id, '/MenuBar/ToolsMenu', 'ToolsGraphMenu', 'ToolsGraphMenu', Gtk.UIManagerItemType.MENU, False) for graph_name in sorted( graphs.get_graphs(), key=lambda gn: graphs.get_graph(gn).name_human): action_name = 'ToolsGraph' + graph_name uimanager.add_ui(merge_id, '/MenuBar/ToolsMenu/ToolsGraphMenu', action_name, action_name, Gtk.UIManagerItemType.MENUITEM, False)
def _configure_settings_dashboard(self): if not graphs.has_matplotlib: self.gtk_builder_get('frame_dashboard').set_sensitive(False) return graph_providers = Gtk.ListStore(str, str) for graph in graphs.get_graphs(): graph = graphs.get_graph(graph) graph_providers.append([graph.name_human, graph.name]) for dash_position in ['top_left', 'top_right', 'bottom']: combobox = self.gtk_builder_get('combobox_dashboard_' + dash_position) combobox.set_model(graph_providers) ti = gui_utilities.gtk_list_store_search(graph_providers, self.config.get('dashboard.' + dash_position), column=1) combobox.set_active_iter(ti)
def _add_menu_optional_actions(self, action_group, uimanager): if graphs.has_matplotlib: action = Gtk.Action(name='ToolsGraphMenu', label='Create Graph', tooltip=None, stock_id=None) action_group.add_action(action) for graph_name in graphs.get_graphs(): action_name = 'ToolsGraph' + graph_name action = Gtk.Action(name=action_name, label=graph_name, tooltip=graph_name, stock_id=None) action.connect('activate', lambda _: self.show_campaign_graph(graph_name)) action_group.add_action(action) merge_id = uimanager.new_merge_id() uimanager.add_ui(merge_id, '/MenuBar/ToolsMenu', 'ToolsGraphMenu', 'ToolsGraphMenu', Gtk.UIManagerItemType.MENU, False) for graph_name in graphs.get_graphs(): action_name = 'ToolsGraph' + graph_name uimanager.add_ui(merge_id, '/MenuBar/ToolsMenu/ToolsGraphMenu', action_name, action_name, Gtk.UIManagerItemType.MENUITEM, False) if sys.platform.startswith('linux'): action = Gtk.Action(name='ToolsSFTPClient', label='SFTP Client', tooltip='SFTP Client', stock_id=None) action.connect('activate', lambda x: self.start_sftp_client()) action_group.add_action(action) merge_id = uimanager.new_merge_id() uimanager.add_ui(merge_id, '/MenuBar/ToolsMenu', 'ToolsSFTPClient', 'ToolsSFTPClient', Gtk.UIManagerItemType.MENUITEM, False)
def _configure_settings_dashboard(self): if not graphs.has_matplotlib: self.gtk_builder_get('frame_dashboard').set_sensitive(False) return graph_providers = Gtk.ListStore(str, str) for graph in graphs.get_graphs(): graph = graphs.get_graph(graph) graph_providers.append([graph.name_human, graph.name]) for dash_position in ['top_left', 'top_right', 'bottom']: combobox = self.gtk_builder_get('combobox_dashboard_' + dash_position) combobox.set_model(graph_providers) ti = gui_utilities.gtk_list_store_search(graph_providers, self.config.get('dashboard.' + dash_position), column=1) combobox.set_active_iter(ti)
def _create_ui_manager(self): uimanager = Gtk.UIManager() with open(find.find_data_file('ui_info/client_window.xml')) as ui_info_file: ui_data = ui_info_file.read() uimanager.add_ui_from_string(ui_data) if graphs.has_matplotlib: merge_id = uimanager.new_merge_id() uimanager.add_ui(merge_id, '/MenuBar/ToolsMenu', 'ToolsGraphMenu', 'ToolsGraphMenu', Gtk.UIManagerItemType.MENU, False) for graph_name in graphs.get_graphs(): action_name = 'ToolsGraph' + graph_name uimanager.add_ui(merge_id, '/MenuBar/ToolsMenu/ToolsGraphMenu', action_name, action_name, Gtk.UIManagerItemType.MENUITEM, False) accelgroup = uimanager.get_accel_group() self.add_accel_group(accelgroup) return uimanager
def _add_menu_optional_actions(self, action_group, uimanager): if sys.platform.startswith('linux'): action = Gtk.Action(name='ToolsSFTPClient', label='SFTP Client', tooltip='SFTP Client', stock_id=None) action.connect('activate', lambda x: self.start_sftp_client()) action_group.add_action_with_accel(action, '<control>F2') merge_id = uimanager.new_merge_id() uimanager.add_ui(merge_id, '/MenuBar/ToolsMenu', 'ToolsSFTPClient', 'ToolsSFTPClient', Gtk.UIManagerItemType.MENUITEM, False) if graphs.has_matplotlib: action = Gtk.Action(name='ToolsGraphMenu', label='Create Graph', tooltip='Create A Graph', stock_id=None) action_group.add_action(action) for graph_name in graphs.get_graphs(): action_name = 'ToolsGraph' + graph_name graph = graphs.get_graph(graph_name) action = Gtk.Action(name=action_name, label=graph.name_human, tooltip=graph.name_human, stock_id=None) action.connect('activate', self.signal_activate_popup_menu_create_graph, graph_name) action_group.add_action(action) merge_id = uimanager.new_merge_id() uimanager.add_ui(merge_id, '/MenuBar/ToolsMenu', 'ToolsGraphMenu', 'ToolsGraphMenu', Gtk.UIManagerItemType.MENU, False) for graph_name in sorted(graphs.get_graphs(), key=lambda gn: graphs.get_graph(gn).name_human): action_name = 'ToolsGraph' + graph_name uimanager.add_ui(merge_id, '/MenuBar/ToolsMenu/ToolsGraphMenu', action_name, action_name, Gtk.UIManagerItemType.MENUITEM, False)
def __init__(self, application, window): assert isinstance(window, MainAppWindow) super(MainMenuBar, self).__init__(application) self.window = weakref.proxy(window) self._add_accelerators() graphs_menu_item = self.gtk_builder_get('menuitem_tools_create_graph') if graphs.has_matplotlib: graphs_submenu = Gtk.Menu.new() for graph_name in graphs.get_graphs(): graph = graphs.get_graph(graph_name) menu_item = Gtk.MenuItem.new_with_label(graph.name_human) menu_item.connect('activate', self.do_tools_show_campaign_graph, graph_name) graphs_submenu.append(menu_item) graphs_menu_item.set_submenu(graphs_submenu) graphs_menu_item.show_all() else: graphs_menu_item.set_sensitive(False)
def __init__(self, application, window): utilities.assert_arg_type(application, Gtk.Application, arg_pos=1) utilities.assert_arg_type(window, MainAppWindow, arg_pos=2) super(MainMenuBar, self).__init__(application) self.window = weakref.proxy(window) self._add_accelerators() graphs_menu_item = self.gtk_builder_get('menuitem_tools_create_graph') if graphs.has_matplotlib: graphs_submenu = Gtk.Menu.new() for graph_name in graphs.get_graphs(): graph = graphs.get_graph(graph_name) menu_item = Gtk.MenuItem.new_with_label(graph.name_human) menu_item.connect('activate', self.signal_activate_tools_show_campaign_graph, graph_name) graphs_submenu.append(menu_item) graphs_menu_item.set_submenu(graphs_submenu) graphs_menu_item.show_all() else: graphs_menu_item.set_sensitive(False)
def test_graphs_found(self): self.assertGreaterEqual(len(graphs.get_graphs()), 6)
def test_graph_classes(self): for graph in graphs.get_graphs(): self.assertTrue(isinstance(graph, str)) self.assertTrue(issubclass(graphs.get_graph(graph), graphs.CampaignGraph))
def test_graphs_found(self): self.assertGreaterEqual(len(graphs.get_graphs()), 6)
def test_graph_classes(self): for graph in graphs.get_graphs(): self.assertTrue(isinstance(graph, str)) self.assertTrue( issubclass(graphs.get_graph(graph), graphs.CampaignGraph))
def test_graph_classes(self): for graph in graphs.get_graphs(): self.assertIsInstance(graph, str) self.assertIsSubclass(graphs.get_graph(graph), graphs.CampaignGraph)
def test_graph_classes(self): for graph in graphs.get_graphs(): self.assertIsInstance(graph, str) self.assertIsSubclass(graphs.get_graph(graph), graphs.CampaignGraph)
def _add_menu_actions(self, action_group): # File Menu Actions action = Gtk.Action('FileMenu', 'File', None, None) action_group.add_action(action) action = Gtk.Action('FileOpenCampaign', '_Open Campaign', 'Open a Campaign', Gtk.STOCK_NEW) action.connect('activate', lambda x: self.show_campaign_selection()) action_group.add_action_with_accel(action, '<control>O') action = Gtk.Action('FileExportMenu', 'Export', None, None) action_group.add_action(action) action = Gtk.Action('FileExportXML', 'Export XML', 'Export XML', None) action.connect('activate', lambda x: self.export_xml()) action_group.add_action(action) action = Gtk.Action('FileQuit', None, None, Gtk.STOCK_QUIT) action.connect('activate', lambda x: self.client_quit()) action_group.add_action_with_accel(action, '<control>Q') # Edit Menu Actions action = Gtk.Action('EditMenu', 'Edit', None, None) action_group.add_action(action) action = Gtk.Action('EditPreferences', 'Preferences', 'Edit preferences', Gtk.STOCK_EDIT) action.connect('activate', lambda x: self.edit_preferences()) action_group.add_action(action) action = Gtk.Action('EditDeleteCampaign', 'Delete Campaign', 'Delete Campaign', None) action.connect('activate', lambda x: self.delete_campaign()) action_group.add_action(action) action = Gtk.Action('EditStopService', 'Stop Service', 'Stop Remote King-Phisher Service', None) action.connect('activate', lambda x: self.stop_remote_service()) action_group.add_action(action) # Tools Menu Action action = Gtk.Action('ToolsMenu', 'Tools', None, None) action_group.add_action(action) action = Gtk.Action('ToolsRPCTerminal', 'RPC Terminal', 'RPC Terminal', None) action.connect('activate', lambda x: KingPhisherClientRPCTerminal(self.config, self)) action_group.add_action(action) # Help Menu Actions action = Gtk.Action('HelpMenu', 'Help', None, None) action_group.add_action(action) if graphs.has_matplotlib: action = Gtk.Action('ToolsGraphMenu', 'Create Graph', None, None) action_group.add_action(action) for graph_name in graphs.get_graphs(): action_name = 'ToolsGraph' + graph_name action = Gtk.Action(action_name, graph_name, graph_name, None) action.connect('activate', lambda _: self.show_campaign_graph(graph_name)) action_group.add_action(action) action = Gtk.Action('HelpAbout', 'About', 'About', None) action.connect('activate', lambda x: self.show_about_dialog()) action_group.add_action(action) action = Gtk.Action('HelpWiki', 'Wiki', 'Wiki', None) action.connect('activate', lambda x: utilities.open_uri('https://github.com/securestate/king-phisher/wiki')) action_group.add_action(action)