Esempio n. 1
0
    def __init__(self, config, application):
        """
		:param dict config: The main King Phisher client configuration.
		:param application: The application instance to which this window belongs.
		:type application: :py:class:`.KingPhisherClientApplication`
		"""
        utilities.assert_arg_type(application, Gtk.Application, arg_pos=2)
        super(MainAppWindow, self).__init__(application=application)
        self.application = application
        self.logger = logging.getLogger('KingPhisher.Client.MainWindow')
        self.config = config
        """The main King Phisher client configuration."""
        self.set_property('title', 'King Phisher')
        vbox = Gtk.Box()
        vbox.set_property('orientation', Gtk.Orientation.VERTICAL)
        vbox.show()
        self.add(vbox)

        default_icon_file = find.data_file('king-phisher-icon.svg')
        if default_icon_file:
            icon_pixbuf = GdkPixbuf.Pixbuf.new_from_file(default_icon_file)
            self.set_default_icon(icon_pixbuf)
        self.accel_group = Gtk.AccelGroup()
        self.add_accel_group(self.accel_group)

        self.menu_bar = MainMenuBar(application, self)
        vbox.pack_start(self.menu_bar.menubar, False, False, 0)

        # create notebook and tabs
        self.notebook = Gtk.Notebook()
        """The primary :py:class:`Gtk.Notebook` that holds the top level taps of the client GUI."""
        self.notebook.connect('switch-page', self.signal_notebook_switch_page)
        self.notebook.set_scrollable(True)
        vbox.pack_start(self.notebook, True, True, 0)

        self.tabs = {}
        current_page = self.notebook.get_current_page()
        self.last_page_id = current_page

        mailer_tab = MailSenderTab(self, self.application)
        self.tabs['mailer'] = mailer_tab
        self.notebook.insert_page(mailer_tab.box, mailer_tab.label,
                                  current_page + 1)
        self.notebook.set_current_page(current_page + 1)

        campaign_tab = CampaignViewTab(self, self.application)
        campaign_tab.box.show()
        self.tabs['campaign'] = campaign_tab
        self.notebook.insert_page(campaign_tab.box, campaign_tab.label,
                                  current_page + 2)

        self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
        self.set_size_request(800, 600)
        self.connect('delete-event', self.signal_delete_event)
        self.notebook.show()

        self.show()
        self.rpc = None  # needs to be initialized last
        """The :py:class:`.KingPhisherRPCClient` instance."""

        self.application.connect('server-connected',
                                 self.signal_kp_server_connected)

        self.login_dialog = dialogs.LoginDialog(self.application)
        self.login_dialog.dialog.connect('response',
                                         self.signal_login_dialog_response)
        self.login_dialog.show()
Esempio n. 2
0
    def __init__(self, config, application):
        """
		:param dict config: The main King Phisher client configuration.
		:param application: The application instance to which this window belongs.
		:type application: :py:class:`.KingPhisherClientApplication`
		"""
        assert isinstance(application, Gtk.Application)
        super(KingPhisherClient, self).__init__(application=application)
        self.application = application
        self.logger = logging.getLogger('KingPhisher.Client.MainWindow')
        self.config = config
        """The main King Phisher client configuration."""
        self._ssh_forwarder = None
        self.set_property('title', 'King Phisher')
        vbox = Gtk.Box()
        vbox.set_property('orientation', Gtk.Orientation.VERTICAL)
        vbox.show()
        self.add(vbox)
        default_icon_file = find.find_data_file('king-phisher-icon.svg')
        if default_icon_file:
            icon_pixbuf = GdkPixbuf.Pixbuf.new_from_file(default_icon_file)
            self.set_default_icon(icon_pixbuf)
        action_group = Gtk.ActionGroup(name="client_window_actions")
        self._add_menu_actions(action_group)
        uimanager = self._create_ui_manager()
        self._add_menu_optional_actions(action_group, uimanager)
        self.add_accel_group(uimanager.get_accel_group())
        uimanager.insert_action_group(action_group)
        self.uimanager = uimanager
        menubar = uimanager.get_widget("/MenuBar")
        vbox.pack_start(menubar, False, False, 0)

        # create notebook and tabs
        self.notebook = Gtk.Notebook()
        """The primary :py:class:`Gtk.Notebook` that holds the top level taps of the client GUI."""
        self.notebook.connect('switch-page', self.signal_notebook_switch_page)
        self.notebook.set_scrollable(True)
        vbox.pack_start(self.notebook, True, True, 0)

        self.tabs = {}
        current_page = self.notebook.get_current_page()
        self.last_page_id = current_page

        mailer_tab = MailSenderTab(self.config, self, self.application)
        self.tabs['mailer'] = mailer_tab
        self.notebook.insert_page(mailer_tab.box, mailer_tab.label,
                                  current_page + 1)
        self.notebook.set_current_page(current_page + 1)

        campaign_tab = CampaignViewTab(self.config, self, self.application)
        campaign_tab.box.show()
        self.tabs['campaign'] = campaign_tab
        self.notebook.insert_page(campaign_tab.box, campaign_tab.label,
                                  current_page + 2)

        self.set_size_request(800, 600)
        self.connect('delete-event', self.signal_delete_event)
        self.notebook.show()
        self.show()
        self.rpc = None  # needs to be initialized last
        """The :py:class:`.KingPhisherRPCClient` instance."""

        login_dialog = dialogs.LoginDialog(self.config, self)
        login_dialog.dialog.connect('response',
                                    self.signal_login_dialog_response,
                                    login_dialog)
        login_dialog.dialog.show()