code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def load_markdown_data(self, md_data, html_file_uri=None, gh_flavor=True, template=None, template_vars=None): """ Load markdown data, render it into HTML and then load it in to the WebKit engine. When *gh_flavor* is enabled, the markdown data is rendered using partial GitHub flavor support as provided by :py:...
Load markdown data, render it into HTML and then load it in to the WebKit engine. When *gh_flavor* is enabled, the markdown data is rendered using partial GitHub flavor support as provided by :py:class:`~mdx_partial_gfm.PartialGithubFlavoredMarkdownExtension`. If *template* is specified, it is used to load a...
load_markdown_data
python
rsmusllp/king-phisher
king_phisher/client/widget/extras.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/widget/extras.py
BSD-3-Clause
def load_markdown_file(self, md_file, **kwargs): """ Load markdown data from a file and render it using :py:meth:`~.load_markdown_data`. :param str md_file: The path to the file to load markdown data from. :param kwargs: Additional keyword arguments to pass to :py:meth:`~.load_markdown_data`. """ with co...
Load markdown data from a file and render it using :py:meth:`~.load_markdown_data`. :param str md_file: The path to the file to load markdown data from. :param kwargs: Additional keyword arguments to pass to :py:meth:`~.load_markdown_data`.
load_markdown_file
python
rsmusllp/king-phisher
king_phisher/client/widget/extras.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/widget/extras.py
BSD-3-Clause
def __init__(self, glade_gobject, widget_type, group_name): """ :param glade_gobject: The gobject which has the radio buttons set. :type glade_gobject: :py:class:`.GladeGObject` :param str group_name: The name of the group of buttons. """ utilities.assert_arg_type(glade_gobject, gui_utilities.GladeGObject) ...
:param glade_gobject: The gobject which has the radio buttons set. :type glade_gobject: :py:class:`.GladeGObject` :param str group_name: The name of the group of buttons.
__init__
python
rsmusllp/king-phisher
king_phisher/client/widget/managers.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/widget/managers.py
BSD-3-Clause
def get_active(self): """ Return the name of the active button if one in the group is active. If no button in the group is active, None is returned. :return: The name of the active button. :rtype: str """ for name, button in self.buttons.items(): if button.get_active(): return name return
Return the name of the active button if one in the group is active. If no button in the group is active, None is returned. :return: The name of the active button. :rtype: str
get_active
python
rsmusllp/king-phisher
king_phisher/client/widget/managers.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/widget/managers.py
BSD-3-Clause
def set_active(self, buttons): """ Set the specified buttons to active or not. :param dict buttons: A mapping of button names to boolean values. """ for name, active in buttons.items(): button = self.buttons.get(name) if button is None: raise ValueError('invalid button name: ' + name) button.set...
Set the specified buttons to active or not. :param dict buttons: A mapping of button names to boolean values.
set_active
python
rsmusllp/king-phisher
king_phisher/client/widget/managers.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/widget/managers.py
BSD-3-Clause
def __init__(self, menu=None): """ :param menu: An optional menu to start with. If a menu is specified it is used as is, otherwise a new instance is used and is set to be visible using :py:meth:`~Gtk.Widget.show`. :type menu: :py:class:`Gtk.Menu` """ if menu is None: menu = Gtk.Menu() menu.show() ...
:param menu: An optional menu to start with. If a menu is specified it is used as is, otherwise a new instance is used and is set to be visible using :py:meth:`~Gtk.Widget.show`. :type menu: :py:class:`Gtk.Menu`
__init__
python
rsmusllp/king-phisher
king_phisher/client/widget/managers.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/widget/managers.py
BSD-3-Clause
def append(self, label, activate=None, activate_args=()): """ Create and append a new :py:class:`Gtk.MenuItem` with the specified label to the menu. :param str label: The label for the new menu item. :param activate: An optional callback function to connect to the new menu item's ``activate`` signal. :r...
Create and append a new :py:class:`Gtk.MenuItem` with the specified label to the menu. :param str label: The label for the new menu item. :param activate: An optional callback function to connect to the new menu item's ``activate`` signal. :return: Returns the newly created and added menu item. :rtype:...
append
python
rsmusllp/king-phisher
king_phisher/client/widget/managers.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/widget/managers.py
BSD-3-Clause
def append_item(self, menu_item, set_show=True): """ Append the specified menu item to the menu. :param menu_item: The item to append to the menu. :type menu_item: :py:class:`Gtk.MenuItem` :param bool set_show: Whether to set the item to being visible or leave it as is. """ if set_show: menu_item.s...
Append the specified menu item to the menu. :param menu_item: The item to append to the menu. :type menu_item: :py:class:`Gtk.MenuItem` :param bool set_show: Whether to set the item to being visible or leave it as is.
append_item
python
rsmusllp/king-phisher
king_phisher/client/widget/managers.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/widget/managers.py
BSD-3-Clause
def append_submenu(self, label): """ Create and append a submenu item, then return a new menu manager instance for it. :param str label: The label for the new menu item. :return: Returns the newly created and added menu item. :rtype: :py:class:`Gtk.MenuManager` """ submenu = self.__class__() submenu_...
Create and append a submenu item, then return a new menu manager instance for it. :param str label: The label for the new menu item. :return: Returns the newly created and added menu item. :rtype: :py:class:`Gtk.MenuManager`
append_submenu
python
rsmusllp/king-phisher
king_phisher/client/widget/managers.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/widget/managers.py
BSD-3-Clause
def __init__(self, treeview, selection_mode=None, cb_delete=None, cb_refresh=None): """ :param treeview: The treeview to wrap and manage. :type treeview: :py:class:`Gtk.TreeView` :param selection_mode: The selection mode to set for the treeview. :type selection_mode: :py:class:`Gtk.SelectionMode` :param cb_...
:param treeview: The treeview to wrap and manage. :type treeview: :py:class:`Gtk.TreeView` :param selection_mode: The selection mode to set for the treeview. :type selection_mode: :py:class:`Gtk.SelectionMode` :param cb_delete: An optional callback that can be used to delete entries. :type cb_delete: funct...
__init__
python
rsmusllp/king-phisher
king_phisher/client/widget/managers.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/widget/managers.py
BSD-3-Clause
def get_popup_menu(self, handle_button_press=True): """ Create a :py:class:`Gtk.Menu` with entries for copying and optionally delete cell data from within the treeview. The delete option will only be available if a delete callback was previously set. :param bool handle_button_press: Whether or not to connect...
Create a :py:class:`Gtk.Menu` with entries for copying and optionally delete cell data from within the treeview. The delete option will only be available if a delete callback was previously set. :param bool handle_button_press: Whether or not to connect a handler for displaying the popup menu. :return: The ...
get_popup_menu
python
rsmusllp/king-phisher
king_phisher/client/widget/managers.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/widget/managers.py
BSD-3-Clause
def get_popup_copy_submenu(self): """ Create a :py:class:`Gtk.Menu` with entries for copying cell data from the treeview. :return: The populated copy popup menu. :rtype: :py:class:`Gtk.Menu` """ copy_menu = Gtk.Menu.new() for column_title, store_id in self.column_titles.items(): menu_item = Gtk.Menu...
Create a :py:class:`Gtk.Menu` with entries for copying cell data from the treeview. :return: The populated copy popup menu. :rtype: :py:class:`Gtk.Menu`
get_popup_copy_submenu
python
rsmusllp/king-phisher
king_phisher/client/widget/managers.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/widget/managers.py
BSD-3-Clause
def set_column_color(self, background=None, foreground=None, column_titles=None): """ Set a column in the model to be used as either the background or foreground RGBA color for a cell. :param int background: The column id of the model to use as the background color. :param int foreground: The column id of th...
Set a column in the model to be used as either the background or foreground RGBA color for a cell. :param int background: The column id of the model to use as the background color. :param int foreground: The column id of the model to use as the foreground color. :param column_titles: The columns to set the ...
set_column_color
python
rsmusllp/king-phisher
king_phisher/client/widget/managers.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/widget/managers.py
BSD-3-Clause
def set_column_titles(self, column_titles, column_offset=0, renderers=None): """ Populate the column names of a GTK TreeView and set their sort IDs. This also populates the :py:attr:`.column_titles` attribute. :param list column_titles: The titles of the columns. :param int column_offset: The offset to start...
Populate the column names of a GTK TreeView and set their sort IDs. This also populates the :py:attr:`.column_titles` attribute. :param list column_titles: The titles of the columns. :param int column_offset: The offset to start setting column names at. :param list renderers: A list containing custom render...
set_column_titles
python
rsmusllp/king-phisher
king_phisher/client/widget/managers.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/widget/managers.py
BSD-3-Clause
def __init__(self, application, button, value=None): """ :param button: The button used for activation. :type button: :py:class:`Gtk.ToggleButton` :param application: The application instance which owns this object. :param value: The present datetime value (defaults to 00:00). :type value: :py:class:`dateti...
:param button: The button used for activation. :type button: :py:class:`Gtk.ToggleButton` :param application: The application instance which owns this object. :param value: The present datetime value (defaults to 00:00). :type value: :py:class:`datetime.time`
__init__
python
rsmusllp/king-phisher
king_phisher/client/widget/managers.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/widget/managers.py
BSD-3-Clause
def time(self, value): """ :param value: value from self.popover.gobjects['spinbutton_xx'] :return: The new time value to self.time """ if not isinstance(value, datetime.time): raise TypeError('argument 1 must be a datetime.time instance') self._hour_spin.set_value(value.hour) self._minute_spin.set_val...
:param value: value from self.popover.gobjects['spinbutton_xx'] :return: The new time value to self.time
time
python
rsmusllp/king-phisher
king_phisher/client/widget/managers.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/widget/managers.py
BSD-3-Clause
def _update_id(self, element, id_fields, old_id, new_id): """ Iterates through the element and replaces the specified old ID with the new ID in the requested ID fields. :param element: Element to iterate over where the old id values can be found. :type element: :py:class:`xml.etree.ElementTree.Element` :pa...
Iterates through the element and replaces the specified old ID with the new ID in the requested ID fields. :param element: Element to iterate over where the old id values can be found. :type element: :py:class:`xml.etree.ElementTree.Element` :param list id_fields: The list of fields to look for old_id. :p...
_update_id
python
rsmusllp/king-phisher
king_phisher/client/windows/campaign_import.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/windows/campaign_import.py
BSD-3-Clause
def signal_entry_change(self, _): """ When there is a change in the campaign entry field it will check to see if the name is already in use. If it is not in use it will change the sensitivity of the :py:attr:`.button_import_campaign` to allow the user to start the import process. """ if not self.campaign_...
When there is a change in the campaign entry field it will check to see if the name is already in use. If it is not in use it will change the sensitivity of the :py:attr:`.button_import_campaign` to allow the user to start the import process.
signal_entry_change
python
rsmusllp/king-phisher
king_phisher/client/windows/campaign_import.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/windows/campaign_import.py
BSD-3-Clause
def signal_window_delete_event(self, _, event): """ Checks to make sure the import campaign thread is closed before closing the window. """ if not self.campaign_info: return False if not self.thread_import_campaign: return False if not self.thread_import_campaign.is_alive(): return False respon...
Checks to make sure the import campaign thread is closed before closing the window.
signal_window_delete_event
python
rsmusllp/king-phisher
king_phisher/client/windows/campaign_import.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/windows/campaign_import.py
BSD-3-Clause
def remove_import_campaign(self): """ Used to delete the imported campaign on failure or early exit of the import window, if the user selects to have it removed. """ campaign_id = self.campaign_info.find('id').text campaign_name = self.campaign_info.find('name').text campaign_check = self.rpc('db/table/ge...
Used to delete the imported campaign on failure or early exit of the import window, if the user selects to have it removed.
remove_import_campaign
python
rsmusllp/king-phisher
king_phisher/client/windows/campaign_import.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/windows/campaign_import.py
BSD-3-Clause
def signal_import_button(self, _): """ This will check to see if the campaign information is present. If campaign information is present it will launch an py:class:`ImportThread` to import the campaign in the background, freeing up the GUI for the user to conduct other functions. """ if not self.campaign_...
This will check to see if the campaign information is present. If campaign information is present it will launch an py:class:`ImportThread` to import the campaign in the background, freeing up the GUI for the user to conduct other functions.
signal_import_button
python
rsmusllp/king-phisher
king_phisher/client/windows/campaign_import.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/windows/campaign_import.py
BSD-3-Clause
def select_xml_campaign(self): """ Prompts the user with a file dialog window to select the King Phisher Campaign XML file to import. Validates the file to make sure it is a Campaign exported from King Phisher and is the correct version to import. """ dialog = extras.FileChooserDialog('Import Campaign from ...
Prompts the user with a file dialog window to select the King Phisher Campaign XML file to import. Validates the file to make sure it is a Campaign exported from King Phisher and is the correct version to import.
select_xml_campaign
python
rsmusllp/king-phisher
king_phisher/client/windows/campaign_import.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/windows/campaign_import.py
BSD-3-Clause
def _check_campaign_name(self, campaign_name, verbose=False): """ Will check to see if the provided campaign name is safe to use. :param str campaign_name: campaign name to check :param bool verbose: If true will update output to text buffer. :return: True if campaign name can be used :rtype: bool """ ...
Will check to see if the provided campaign name is safe to use. :param str campaign_name: campaign name to check :param bool verbose: If true will update output to text buffer. :return: True if campaign name can be used :rtype: bool
_check_campaign_name
python
rsmusllp/king-phisher
king_phisher/client/windows/campaign_import.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/windows/campaign_import.py
BSD-3-Clause
def preprep_xml_data(self): """ This function provides the actions required to see if required IDs are already in the database. If they are not it will clear them out and set subelement.attrib['type'] to null. If the element is required it will set it to a default value. This will normalize the data and ready...
This function provides the actions required to see if required IDs are already in the database. If they are not it will clear them out and set subelement.attrib['type'] to null. If the element is required it will set it to a default value. This will normalize the data and ready it for import into the databas...
preprep_xml_data
python
rsmusllp/king-phisher
king_phisher/client/windows/campaign_import.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/windows/campaign_import.py
BSD-3-Clause
def _import_campaign(self): """ Used by the import thread to import the campaign into the database. Through this process after every major action, the thread will check to see if it has been requested to stop. """ self.logger.debug("import campaign running in tid: 0x{0:x}".format(threading.current_thread()....
Used by the import thread to import the campaign into the database. Through this process after every major action, the thread will check to see if it has been requested to stop.
_import_campaign
python
rsmusllp/king-phisher
king_phisher/client/windows/campaign_import.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/windows/campaign_import.py
BSD-3-Clause
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...
:param dict config: The main King Phisher client configuration. :param application: The application instance to which this window belongs. :type application: :py:class:`.KingPhisherClientApplication`
__init__
python
rsmusllp/king-phisher
king_phisher/client/windows/main.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/windows/main.py
BSD-3-Clause
def export_campaign_xlsx(self): """Export the current campaign to an Excel compatible XLSX workbook.""" dialog = extras.FileChooserDialog('Export Campaign To Excel', self) file_name = self.config['campaign_name'] + '.xlsx' response = dialog.run_quick_save(file_name) dialog.destroy() if not response: retu...
Export the current campaign to an Excel compatible XLSX workbook.
export_campaign_xlsx
python
rsmusllp/king-phisher
king_phisher/client/windows/main.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/windows/main.py
BSD-3-Clause
def export_campaign_xml(self): """Export the current campaign to an XML data file.""" dialog = extras.FileChooserDialog('Export Campaign XML Data', self) file_name = self.config['campaign_name'] + '.xml' response = dialog.run_quick_save(file_name) dialog.destroy() if not response: return destination_fi...
Export the current campaign to an XML data file.
export_campaign_xml
python
rsmusllp/king-phisher
king_phisher/client/windows/main.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/windows/main.py
BSD-3-Clause
def export_campaign_visit_geojson(self): """ Export the current campaign visit information to a GeoJSON data file. """ dialog = extras.FileChooserDialog('Export Campaign Visit GeoJSON Data', self) file_name = self.config['campaign_name'] + '.geojson' response = dialog.run_quick_save(file_name) dialog.dest...
Export the current campaign visit information to a GeoJSON data file.
export_campaign_visit_geojson
python
rsmusllp/king-phisher
king_phisher/client/windows/main.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/windows/main.py
BSD-3-Clause
def __init__(self, application, plugin_id): """ :param application: The parent application for this object. :type application: :py:class:`Gtk.Application` :param str plugin_id: The identifier of this plugin. """ super(PluginDocumentationWindow, self).__init__(application) plugin_path = self.application.pl...
:param application: The parent application for this object. :type application: :py:class:`Gtk.Application` :param str plugin_id: The identifier of this plugin.
__init__
python
rsmusllp/king-phisher
king_phisher/client/windows/plugin_manager.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/windows/plugin_manager.py
BSD-3-Clause
def __store_add_node(self, node, parent=None): """ Add a :py:class:`._ModelNode` to :py:attr:`._model`, recursively adding child :py:class:`._ModelNode` or :py:class:`._ModelNamedRow` instances as necessary. This is *not* tsafe. :param node: The node to add to the TreeView model. :type node: :py:class:`._M...
Add a :py:class:`._ModelNode` to :py:attr:`._model`, recursively adding child :py:class:`._ModelNode` or :py:class:`._ModelNamedRow` instances as necessary. This is *not* tsafe. :param node: The node to add to the TreeView model. :type node: :py:class:`._ModelNode` :param parent: An optional parent for th...
__store_add_node
python
rsmusllp/king-phisher
king_phisher/client/windows/plugin_manager.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/windows/plugin_manager.py
BSD-3-Clause
def _add_catalog_to_tree_tsafe(self, catalog): """ Create a :py:class:`._ModelNode` instance to representing the catalog, its data and add it to the TreeView model. :param catalog: The catalog to add to the TreeView. :type catalog: :py:class:`.Catalog` """ catalog_node = _ModelNode( id=catalog.id, ...
Create a :py:class:`._ModelNode` instance to representing the catalog, its data and add it to the TreeView model. :param catalog: The catalog to add to the TreeView. :type catalog: :py:class:`.Catalog`
_add_catalog_to_tree_tsafe
python
rsmusllp/king-phisher
king_phisher/client/windows/plugin_manager.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/windows/plugin_manager.py
BSD-3-Clause
def _worker_thread_start(self, target, *args, **kwargs): """ Start a worker thread. This must only be called from the main GUI thread and *target* must be a tsafe method. """ if not self._worker_thread_is_ready: self._show_dialog_busy() self.logger.debug('plugin manager worker thread is alive, can not s...
Start a worker thread. This must only be called from the main GUI thread and *target* must be a tsafe method.
_worker_thread_start
python
rsmusllp/king-phisher
king_phisher/client/windows/plugin_manager.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/windows/plugin_manager.py
BSD-3-Clause
def _load_catalog_local_tsafe(self): """ Load the plugins which are available into the treeview to make them visible to the user. """ self.logger.debug('loading the local catalog') pm = self.application.plugin_manager self.__load_errors = {} pm.load_all(on_error=self._on_plugin_load_error_tsafe) node ...
Load the plugins which are available into the treeview to make them visible to the user.
_load_catalog_local_tsafe
python
rsmusllp/king-phisher
king_phisher/client/windows/plugin_manager.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/windows/plugin_manager.py
BSD-3-Clause
def __init__(self, application): """ :param application: The application instance to which this window belongs. :type application: :py:class:`.KingPhisherClientApplication` """ utilities.assert_arg_type(application, Gtk.Application, arg_pos=1) self.application = application self.logger = logging.getLogger...
:param application: The application instance to which this window belongs. :type application: :py:class:`.KingPhisherClientApplication`
__init__
python
rsmusllp/king-phisher
king_phisher/client/windows/rpc_terminal.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/windows/rpc_terminal.py
BSD-3-Clause
def __init__(self, user): """ :param user: The user object of the authenticated user. :type user: :py:class:`~king_phisher.server.database.models.User` """ self.user = user.id self.user_access_level = user.access_level self.user_is_admin = user.is_admin self.created = db_models.current_timestamp() sel...
:param user: The user object of the authenticated user. :type user: :py:class:`~king_phisher.server.database.models.User`
__init__
python
rsmusllp/king-phisher
king_phisher/server/aaa.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/aaa.py
BSD-3-Clause
def event_socket(self): """ An optional :py:class:`~.EventSocket` associated with the client. If the client has not opened an event socket, this is None. """ if self._event_socket is None: return None return self._event_socket()
An optional :py:class:`~.EventSocket` associated with the client. If the client has not opened an event socket, this is None.
event_socket
python
rsmusllp/king-phisher
king_phisher/server/aaa.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/aaa.py
BSD-3-Clause
def from_db_authenticated_session(cls, stored_session): """ Load an instance from a record stored in the database. :param stored_session: The authenticated session from the database to load. :return: A new :py:class:`.AuthenticatedSession` instance. """ utilities.assert_arg_type(stored_session, db_models.A...
Load an instance from a record stored in the database. :param stored_session: The authenticated session from the database to load. :return: A new :py:class:`.AuthenticatedSession` instance.
from_db_authenticated_session
python
rsmusllp/king-phisher
king_phisher/server/aaa.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/aaa.py
BSD-3-Clause
def __init__(self, timeout='30m'): """ :param timeout: The length of time in seconds for which sessions are valid. :type timeout: int, str """ self.logger = logging.getLogger('KingPhisher.Server.SessionManager') timeout = smoke_zephyr.utilities.parse_timespan(timeout) self.session_timeout = datetime.timed...
:param timeout: The length of time in seconds for which sessions are valid. :type timeout: int, str
__init__
python
rsmusllp/king-phisher
king_phisher/server/aaa.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/aaa.py
BSD-3-Clause
def put(self, user): """ Create and store a new :py:class:`.AuthenticatedSession` object for the specified user id. Any previously existing sessions for the specified user are removed from the manager. :param user: The user object of the authenticated user. :type user: :py:class:`~king_phisher.server.datab...
Create and store a new :py:class:`.AuthenticatedSession` object for the specified user id. Any previously existing sessions for the specified user are removed from the manager. :param user: The user object of the authenticated user. :type user: :py:class:`~king_phisher.server.database.models.User` :return...
put
python
rsmusllp/king-phisher
king_phisher/server/aaa.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/aaa.py
BSD-3-Clause
def get(self, session_id, update_timestamp=True): """ Look up an :py:class:`.AuthenticatedSession` instance from it's unique identifier and optionally update the last seen timestamp. If the session is not found or has expired, None will be returned. :param str session_id: The unique identifier of the session...
Look up an :py:class:`.AuthenticatedSession` instance from it's unique identifier and optionally update the last seen timestamp. If the session is not found or has expired, None will be returned. :param str session_id: The unique identifier of the session to retrieve. :param bool update_timestamp: Whether o...
get
python
rsmusllp/king-phisher
king_phisher/server/aaa.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/aaa.py
BSD-3-Clause
def __init__(self, pw_hash): """ :param bytes pw_hash: The salted hash of the password to cache. """ self.pw_hash = pw_hash self.time = time.time()
:param bytes pw_hash: The salted hash of the password to cache.
__init__
python
rsmusllp/king-phisher
king_phisher/server/aaa.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/aaa.py
BSD-3-Clause
def new_from_password(cls, password): """ Create a new instance from a plaintext password. :param str password: The password to cache in memory. """ password = (cls.salt + password).encode('utf-8') pw_hash = hashlib.new(cls.hash_algorithm, password).digest() for _ in range(cls.iterations - 1): pw_hash...
Create a new instance from a plaintext password. :param str password: The password to cache in memory.
new_from_password
python
rsmusllp/king-phisher
king_phisher/server/aaa.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/aaa.py
BSD-3-Clause
def __init__(self, cache_timeout='10m', required_group=None, pam_service='sshd'): """ :param cache_timeout: The life time of cached credentials in seconds. :type cache_timeout: int, str :param str required_group: A group that if specified, users must be a member of to be authenticated. :param str pam_service:...
:param cache_timeout: The life time of cached credentials in seconds. :type cache_timeout: int, str :param str required_group: A group that if specified, users must be a member of to be authenticated. :param str pam_service: The service to use for identification to pam when authenticating.
__init__
python
rsmusllp/king-phisher
king_phisher/server/aaa.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/aaa.py
BSD-3-Clause
def send(self, request): """ Encode and send a request through the pipe to the opposite end. This also sets the 'sequence' member of the request and increments the stored value. :param dict request: A request. """ request['sequence'] = self.sequence_number self.sequence_number += 1 if self.sequence_n...
Encode and send a request through the pipe to the opposite end. This also sets the 'sequence' member of the request and increments the stored value. :param dict request: A request.
send
python
rsmusllp/king-phisher
king_phisher/server/aaa.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/aaa.py
BSD-3-Clause
def _raw_recv(self, timeout=None): """ Receive a request from the other process and decode it. This makes no attempt to validate the 'sequence' member of the request. """ if timeout is not None: ready, _, _ = select.select([self.rfile], [], [], timeout) if not ready: raise errors.KingPhisherTimeoutE...
Receive a request from the other process and decode it. This makes no attempt to validate the 'sequence' member of the request.
_raw_recv
python
rsmusllp/king-phisher
king_phisher/server/aaa.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/aaa.py
BSD-3-Clause
def _seq_recv(self): """ Receive a response from the other process and decode it. This also ensures that 'sequence' member of the response is the expected value. """ timeout = self.response_timeout expected_sequence = self.sequence_number - 1 while timeout > 0: start_time = time.time() response = se...
Receive a response from the other process and decode it. This also ensures that 'sequence' member of the response is the expected value.
_seq_recv
python
rsmusllp/king-phisher
king_phisher/server/aaa.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/aaa.py
BSD-3-Clause
def child_routine(self): """ The main routine that is executed by the child after the object forks. This loop does not exit unless a stop request is made. """ self.logger = logging.getLogger('KingPhisher.Server.Authenticator.Child') while True: request = self._raw_recv(timeout=None) if 'action' not in...
The main routine that is executed by the child after the object forks. This loop does not exit unless a stop request is made.
child_routine
python
rsmusllp/king-phisher
king_phisher/server/aaa.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/aaa.py
BSD-3-Clause
def authenticate(self, username, password): """ Check if a username and password are valid. If they are, the password will be salted, hashed with SHA-512 and stored so the next call with the same values will not require sending a request to the forked child. :param str username: The username to check. :par...
Check if a username and password are valid. If they are, the password will be salted, hashed with SHA-512 and stored so the next call with the same values will not require sending a request to the forked child. :param str username: The username to check. :param str password: The password to check. :return...
authenticate
python
rsmusllp/king-phisher
king_phisher/server/aaa.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/aaa.py
BSD-3-Clause
def stop(self): """ Send a stop request to the child process and wait for it to exit. """ if not os.path.exists("/proc/{0}".format(self.child_pid)): return request = {'action': 'stop'} with self._lock: self.send(request) os.waitpid(self.child_pid, 0) self.rfile.close() self.wfile.close()
Send a stop request to the child process and wait for it to exit.
stop
python
rsmusllp/king-phisher
king_phisher/server/aaa.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/aaa.py
BSD-3-Clause
def get_bind_addresses(config): """ Retrieve the addresses on which the server should bind to. Each of these addresses should be an IP address, port and optionally enable SSL. The returned list will contain tuples for each address found in the configuration. These tuples will be in the (host, port, use_ssl) format...
Retrieve the addresses on which the server should bind to. Each of these addresses should be an IP address, port and optionally enable SSL. The returned list will contain tuples for each address found in the configuration. These tuples will be in the (host, port, use_ssl) format that is compatible with AdvancedHT...
get_bind_addresses
python
rsmusllp/king-phisher
king_phisher/server/build.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/build.py
BSD-3-Clause
def get_ssl_hostnames(config): """ Retrieve the SSL hosts that are specified within the configuration. This also ensures that the settings appear to be valid by ensuring that the necessary files are defined and readable. :param config: Configuration to retrieve settings from. :type config: :py:class:`smoke_zephy...
Retrieve the SSL hosts that are specified within the configuration. This also ensures that the settings appear to be valid by ensuring that the necessary files are defined and readable. :param config: Configuration to retrieve settings from. :type config: :py:class:`smoke_zephyr.configuration.Configuration` :re...
get_ssl_hostnames
python
rsmusllp/king-phisher
king_phisher/server/build.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/build.py
BSD-3-Clause
def server_from_config(config, handler_klass=None, plugin_manager=None): """ Build a server from a provided configuration instance. If *handler_klass* is specified, then the object must inherit from the corresponding KingPhisherServer base class. :param config: Configuration to retrieve settings from. :type conf...
Build a server from a provided configuration instance. If *handler_klass* is specified, then the object must inherit from the corresponding KingPhisherServer base class. :param config: Configuration to retrieve settings from. :type config: :py:class:`smoke_zephyr.configuration.Configuration` :param handler_klas...
server_from_config
python
rsmusllp/king-phisher
king_phisher/server/build.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/build.py
BSD-3-Clause
def iter_schema_errors(self, schema_file): """ Iterate over the :py:class:`~jsonschema.exceptions.ValidationError` instances for all errors found within the specified schema. :param str schema_file: The path to the schema file to use for validation. :return: Each of the validation errors. :rtype: :py:class...
Iterate over the :py:class:`~jsonschema.exceptions.ValidationError` instances for all errors found within the specified schema. :param str schema_file: The path to the schema file to use for validation. :return: Each of the validation errors. :rtype: :py:class:`~jsonschema.exceptions.ValidationError`
iter_schema_errors
python
rsmusllp/king-phisher
king_phisher/server/configuration.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/configuration.py
BSD-3-Clause
def ex_load_config(config_file, validate_schema=True): """ Load the server configuration from the specified file. This function is meant to be called early on during a scripts execution and if any error occurs, details will be printed and the process will exit. :param str config_file: The path to the configuratio...
Load the server configuration from the specified file. This function is meant to be called early on during a scripts execution and if any error occurs, details will be printed and the process will exit. :param str config_file: The path to the configuration file to load. :param bool validate_schema: Whether or no...
ex_load_config
python
rsmusllp/king-phisher
king_phisher/server/configuration.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/configuration.py
BSD-3-Clause
def chown(path, user=None, group=constants.AUTOMATIC, recursive=True): """ This is a high-level wrapper around :py:func:`os.chown` to provide additional functionality. ``None`` can be specified as the *user* or *group* to leave the value unchanged. At least one of either *user* or *group* must be specified. .. v...
This is a high-level wrapper around :py:func:`os.chown` to provide additional functionality. ``None`` can be specified as the *user* or *group* to leave the value unchanged. At least one of either *user* or *group* must be specified. .. versionadded:: 1.14.0 :param str path: The path to change the owner inform...
chown
python
rsmusllp/king-phisher
king_phisher/server/fs_utilities.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/fs_utilities.py
BSD-3-Clause
def access(path, mode, user=constants.AUTOMATIC, group=constants.AUTOMATIC): """ This is a high-level wrapper around :py:func:`os.access` to provide additional functionality. Similar to `os.access` this high-level wrapper will test the given path for a variety of access modes. Additionally *user* or *group* can be...
This is a high-level wrapper around :py:func:`os.access` to provide additional functionality. Similar to `os.access` this high-level wrapper will test the given path for a variety of access modes. Additionally *user* or *group* can be specified to test access for a specific user or group. .. versionadded:: 1.14....
access
python
rsmusllp/king-phisher
king_phisher/server/fs_utilities.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/fs_utilities.py
BSD-3-Clause
def certbot_issue(webroot, hostname, bin_path=None, unified_directory=None): """ Issue a certificate using Let's Encrypt's ``certbot`` utility. This function wraps the ``certbot`` binary and configures the parameters as appropriate. By default, the resulting certificate will be placed under :py:data:`.LETS_ENCRYPT...
Issue a certificate using Let's Encrypt's ``certbot`` utility. This function wraps the ``certbot`` binary and configures the parameters as appropriate. By default, the resulting certificate will be placed under :py:data:`.LETS_ENCRYPT_DEFAULT_DATA_PATH`, however if *unified_directory* is used then it will be unde...
certbot_issue
python
rsmusllp/king-phisher
king_phisher/server/letsencrypt.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/letsencrypt.py
BSD-3-Clause
def get_certbot_bin_path(config=None): """ Get the path to Let's Encrypt's ``certbot`` command line utility. If the path is found, it is verified to be both a file and executable. If the path verification fails, ``None`` is returned. .. versionadded:: 1.14.0 :param config: Configuration to retrieve settings fro...
Get the path to Let's Encrypt's ``certbot`` command line utility. If the path is found, it is verified to be both a file and executable. If the path verification fails, ``None`` is returned. .. versionadded:: 1.14.0 :param config: Configuration to retrieve settings from. :type config: :py:class:`smoke_zephyr.c...
get_certbot_bin_path
python
rsmusllp/king-phisher
king_phisher/server/letsencrypt.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/letsencrypt.py
BSD-3-Clause
def get_sni_hostname_config(hostname, config=None): """ Search for and return the SNI configuration for the specified *hostname*. This method will first check to see if the entry exists in the database before searching the Let's Encrypt data directory (if ``data_path`` is present in the server configuration). If n...
Search for and return the SNI configuration for the specified *hostname*. This method will first check to see if the entry exists in the database before searching the Let's Encrypt data directory (if ``data_path`` is present in the server configuration). If no configuration data is found, or the data file paths a...
get_sni_hostname_config
python
rsmusllp/king-phisher
king_phisher/server/letsencrypt.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/letsencrypt.py
BSD-3-Clause
def config(self): """ A dictionary that can be used by this plugin to access it's configuration. Any changes to this configuration will be lost with the server restarts. """ config = self.root_config.get('server.plugins').get(self.name) if config is None: config = {} self.root_config.get('server.plu...
A dictionary that can be used by this plugin to access it's configuration. Any changes to this configuration will be lost with the server restarts.
config
python
rsmusllp/king-phisher
king_phisher/server/plugins.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/plugins.py
BSD-3-Clause
def register_http(self, path, method): """ Register a new HTTP request handler at *path* that is handled by *method*. Two parameters are passed to the method. The first parameter is a :py:class:`~king_phisher.server.server.KingPhisherRequestHandler` instance and the second is a dictionary of the HTTP query pa...
Register a new HTTP request handler at *path* that is handled by *method*. Two parameters are passed to the method. The first parameter is a :py:class:`~king_phisher.server.server.KingPhisherRequestHandler` instance and the second is a dictionary of the HTTP query parameters. The specified path is added with...
register_http
python
rsmusllp/king-phisher
king_phisher/server/plugins.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/plugins.py
BSD-3-Clause
def register_rpc(self, path, method, database_access=False): """ Register a new RPC function at *path* that is handled by *method*. This RPC function can only be called by authenticated users. A single parameter of the :py:class:`~king_phisher.server.server.KingPhisherRequestHandler` instance is passed to *...
Register a new RPC function at *path* that is handled by *method*. This RPC function can only be called by authenticated users. A single parameter of the :py:class:`~king_phisher.server.server.KingPhisherRequestHandler` instance is passed to *method* when the RPC function is invoked. The specified path is ...
register_rpc
python
rsmusllp/king-phisher
king_phisher/server/plugins.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/plugins.py
BSD-3-Clause
def getgrnam(name, encoding='utf-8'): """ Get the structure containing the fields from the specified entry in the group database. See `getgrnam(3) <http://man7.org/linux/man-pages/man3/getgrnam.3.html>`_ for more information. :param str name: The group name to look up. :param str encoding: The encoding to use f...
Get the structure containing the fields from the specified entry in the group database. See `getgrnam(3) <http://man7.org/linux/man-pages/man3/getgrnam.3.html>`_ for more information. :param str name: The group name to look up. :param str encoding: The encoding to use for strings. :return: The entry from the g...
getgrnam
python
rsmusllp/king-phisher
king_phisher/server/pylibc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/pylibc.py
BSD-3-Clause
def getgrouplist(user, group=constants.AUTOMATIC, encoding='utf-8'): """ Get the groups that the specified user belongs to. If *group* is not specified, it will be looked up from the password record for *user*. See `getgrouplist(3) <http://man7.org/linux/man-pages/man3/getgrouplist.3.html>`_ for more information. ...
Get the groups that the specified user belongs to. If *group* is not specified, it will be looked up from the password record for *user*. See `getgrouplist(3) <http://man7.org/linux/man-pages/man3/getgrouplist.3.html>`_ for more information. :param str user: The user name to look up. :param int group: An option...
getgrouplist
python
rsmusllp/king-phisher
king_phisher/server/pylibc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/pylibc.py
BSD-3-Clause
def getpwnam(name, encoding='utf-8'): """ Get the structure containing the fields from the specified entry in the password database. See `getpwnam(3) <http://man7.org/linux/man-pages/man3/getpwnam.3.html>`_ for more information. :param str name: The user name to look up. :param str encoding: The encoding to use...
Get the structure containing the fields from the specified entry in the password database. See `getpwnam(3) <http://man7.org/linux/man-pages/man3/getpwnam.3.html>`_ for more information. :param str name: The user name to look up. :param str encoding: The encoding to use for strings. :return: The entry from the...
getpwnam
python
rsmusllp/king-phisher
king_phisher/server/pylibc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/pylibc.py
BSD-3-Clause
def getpwuid(uid): """ Get the structure containing the fields from the specified entry in the password database. See `getpwuid(3) <http://man7.org/linux/man-pages/man3/getpwuid.3.html>`_ for more information. :param int uid: The user id to look up. :return: The entry from the user database or ``None`` if it wa...
Get the structure containing the fields from the specified entry in the password database. See `getpwuid(3) <http://man7.org/linux/man-pages/man3/getpwuid.3.html>`_ for more information. :param int uid: The user id to look up. :return: The entry from the user database or ``None`` if it was not found. :rtype: t...
getpwuid
python
rsmusllp/king-phisher
king_phisher/server/pylibc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/pylibc.py
BSD-3-Clause
def rest_handler(handle_function): """ A function for decorating REST API handlers. The function checks the API token in the request and encodes the handler response in JSON to be sent to the client. :param handle_function: The REST API handler. """ def wrapped(handler, params): client_ip = ipaddress.ip_addre...
A function for decorating REST API handlers. The function checks the API token in the request and encodes the handler response in JSON to be sent to the client. :param handle_function: The REST API handler.
rest_handler
python
rsmusllp/king-phisher
king_phisher/server/rest_api.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/rest_api.py
BSD-3-Clause
def issue_alert(self, campaign_id, table, count): """ Send a campaign alert for the specified table. :param int campaign_id: The campaign subscribers to send the alert to. :param str table: The type of event to use as the sender when it is forwarded. :param int count: The number associated with the event ale...
Send a campaign alert for the specified table. :param int campaign_id: The campaign subscribers to send the alert to. :param str table: The type of event to use as the sender when it is forwarded. :param int count: The number associated with the event alert.
issue_alert
python
rsmusllp/king-phisher
king_phisher/server/server.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server.py
BSD-3-Clause
def adjust_path(self): """Adjust the :py:attr:`~.KingPhisherRequestHandler.path` attribute based on multiple factors.""" self.request_path = self.path.split('?', 1)[0] if not self.config.get('server.vhost_directories'): return if not self.vhost: raise errors.KingPhisherAbortRequestError() if self.vhost ...
Adjust the :py:attr:`~.KingPhisherRequestHandler.path` attribute based on multiple factors.
adjust_path
python
rsmusllp/king-phisher
king_phisher/server/server.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server.py
BSD-3-Clause
def get_template_vars_client(self): """ Build a dictionary of variables for a client with an associated campaign. :return: The client specific template variables. :rtype: dict """ client_vars = { 'address': self.get_client_ip() } if not self.message_id: return client_vars credential_count = 0...
Build a dictionary of variables for a client with an associated campaign. :return: The client specific template variables. :rtype: dict
get_template_vars_client
python
rsmusllp/king-phisher
king_phisher/server/server.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server.py
BSD-3-Clause
def _set_ids(self): """ Handle lazy resolution of the ``*_id`` properties necessary to track information. """ self._visit_id = None kp_cookie_name = self.config.get('server.cookie_name') if kp_cookie_name in self.cookies: value = self.cookies[kp_cookie_name].value if db_manager.get_row_by_id(self._s...
Handle lazy resolution of the ``*_id`` properties necessary to track information.
_set_ids
python
rsmusllp/king-phisher
king_phisher/server/server.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server.py
BSD-3-Clause
def campaign_id(self): """ The campaign id that is associated with the current request's visitor. This is retrieved by looking up the :py:attr:`~.KingPhisherRequestHandler.message_id` value in the database. If no campaign is associated, this value is None. """ if not hasattr(self, '_campaign_id'): self...
The campaign id that is associated with the current request's visitor. This is retrieved by looking up the :py:attr:`~.KingPhisherRequestHandler.message_id` value in the database. If no campaign is associated, this value is None.
campaign_id
python
rsmusllp/king-phisher
king_phisher/server/server.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server.py
BSD-3-Clause
def message_id(self): """ The message id that is associated with the current request's visitor. This is retrieved by looking at an 'id' parameter in the query and then by checking the :py:attr:`~.KingPhisherRequestHandler.visit_id` value in the database. If no message id is associated, this value is None. The...
The message id that is associated with the current request's visitor. This is retrieved by looking at an 'id' parameter in the query and then by checking the :py:attr:`~.KingPhisherRequestHandler.visit_id` value in the database. If no message id is associated, this value is None. The resulting value will be ...
message_id
python
rsmusllp/king-phisher
king_phisher/server/server.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server.py
BSD-3-Clause
def visit_id(self): """ The visit id that is associated with the current request's visitor. This is retrieved by looking for the King Phisher cookie. If no cookie is set, this value is None. """ if not hasattr(self, '_visit_id'): self.logger.warning('using lazy resolution for the request visit id') se...
The visit id that is associated with the current request's visitor. This is retrieved by looking for the King Phisher cookie. If no cookie is set, this value is None.
visit_id
python
rsmusllp/king-phisher
king_phisher/server/server.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server.py
BSD-3-Clause
def get_client_ip(self): """ Intelligently get the IP address of the HTTP client, optionally accounting for proxies that may be in use. :return: The clients IP address. :rtype: str """ address = self.client_address[0] header_name = self.config.get_if_exists('server.client_ip_header') # ...
Intelligently get the IP address of the HTTP client, optionally accounting for proxies that may be in use. :return: The clients IP address. :rtype: str
get_client_ip
python
rsmusllp/king-phisher
king_phisher/server/server.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server.py
BSD-3-Clause
def __init__(self, config, plugin_manager, handler_klass, *args, **kwargs): """ :param config: Configuration to retrieve settings from. :type config: :py:class:`smoke_zephyr.configuration.Configuration` """ # additional mime types to be treated as html because they're probably cloned pages handler_klass.ext...
:param config: Configuration to retrieve settings from. :type config: :py:class:`smoke_zephyr.configuration.Configuration`
__init__
python
rsmusllp/king-phisher
king_phisher/server/server.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server.py
BSD-3-Clause
def _maintenance(self, interval): """ Execute periodic maintenance related tasks. :param int interval: The interval of time (in seconds) at which this method is being executed. """ self.logger.debug('running periodic maintenance tasks') now = db_models.current_timestamp() session = db_manager.Session() ...
Execute periodic maintenance related tasks. :param int interval: The interval of time (in seconds) at which this method is being executed.
_maintenance
python
rsmusllp/king-phisher
king_phisher/server/server.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server.py
BSD-3-Clause
def shutdown(self, *args, **kwargs): """ Request that the server perform any cleanup necessary and then shut down. This will wait for the server to stop before it returns. """ with self.__shutdown_lock: if self.__is_shutdown.is_set(): return self.logger.warning('processing shutdown request') supe...
Request that the server perform any cleanup necessary and then shut down. This will wait for the server to stop before it returns.
shutdown
python
rsmusllp/king-phisher
king_phisher/server/server.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server.py
BSD-3-Clause
def register_rpc(path, database_access=False, log_call=False): """ Register an RPC function with the HTTP request handler. This allows the method to be remotely invoked using King Phisher's standard RPC interface. If *database_access* is specified, a SQLAlchemy session will be passed as the second argument, after ...
Register an RPC function with the HTTP request handler. This allows the method to be remotely invoked using King Phisher's standard RPC interface. If *database_access* is specified, a SQLAlchemy session will be passed as the second argument, after the standard :py:class:`~advancedhttpserver.RequestHandler` instan...
register_rpc
python
rsmusllp/king-phisher
king_phisher/server/server_rpc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py
BSD-3-Clause
def rpc_shutdown(handler): """ This method can be used to shut down the server. This function will return, however no subsequent requests will be processed. .. warning:: This action will stop the server process and there is no confirmation before it takes place. """ shutdown_thread = threading.Thread(target=...
This method can be used to shut down the server. This function will return, however no subsequent requests will be processed. .. warning:: This action will stop the server process and there is no confirmation before it takes place.
rpc_shutdown
python
rsmusllp/king-phisher
king_phisher/server/server_rpc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py
BSD-3-Clause
def rpc_version(handler): """ Get the version information of the server. This returns a dictionary with keys of version, version_info and rpc_api_version. These values are provided for the client to determine compatibility. :return: A dictionary with version information. :rtype: dict """ if not ipaddress.ip_a...
Get the version information of the server. This returns a dictionary with keys of version, version_info and rpc_api_version. These values are provided for the client to determine compatibility. :return: A dictionary with version information. :rtype: dict
rpc_version
python
rsmusllp/king-phisher
king_phisher/server/server_rpc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py
BSD-3-Clause
def rpc_config_get(handler, option_name): """ Retrieve a value from the server's configuration. :param str option_name: The name of the configuration option. :return: The option's value. """ if isinstance(option_name, (list, tuple)): option_names = option_name option_values = {} for option_name in option_n...
Retrieve a value from the server's configuration. :param str option_name: The name of the configuration option. :return: The option's value.
rpc_config_get
python
rsmusllp/king-phisher
king_phisher/server/server_rpc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py
BSD-3-Clause
def rpc_config_set(handler, options): """ Set options in the server's configuration. Any changes to the server's configuration are not written to disk. :param dict options: A dictionary of option names and values """ if rpc_logger.isEnabledFor(logging.DEBUG): _log_rpc_call(handler, 'rpc_config_set', dict((key,...
Set options in the server's configuration. Any changes to the server's configuration are not written to disk. :param dict options: A dictionary of option names and values
rpc_config_set
python
rsmusllp/king-phisher
king_phisher/server/server_rpc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py
BSD-3-Clause
def rpc_campaign_new(handler, session, name, description=None): """ Create a new King Phisher campaign and initialize the database information. :param str name: The new campaign's name. :param str description: The new campaign's description. :return: The ID of the new campaign. :rtype: int """ if session.quer...
Create a new King Phisher campaign and initialize the database information. :param str name: The new campaign's name. :param str description: The new campaign's description. :return: The ID of the new campaign. :rtype: int
rpc_campaign_new
python
rsmusllp/king-phisher
king_phisher/server/server_rpc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py
BSD-3-Clause
def rpc_campaign_alerts_is_subscribed(handler, session, campaign_id): """ Check if the user is subscribed to alerts for the specified campaign. :param int campaign_id: The ID of the campaign. :return: The alert subscription status. :rtype: bool """ query = session.query(db_models.AlertSubscription) query = que...
Check if the user is subscribed to alerts for the specified campaign. :param int campaign_id: The ID of the campaign. :return: The alert subscription status. :rtype: bool
rpc_campaign_alerts_is_subscribed
python
rsmusllp/king-phisher
king_phisher/server/server_rpc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py
BSD-3-Clause
def rpc_campaign_alerts_subscribe(handler, session, campaign_id): """ Subscribe to alerts for the specified campaign. :param int campaign_id: The ID of the campaign. """ user_id = handler.rpc_session.user query = session.query(db_models.AlertSubscription) query = query.filter_by(campaign_id=campaign_id, user_id...
Subscribe to alerts for the specified campaign. :param int campaign_id: The ID of the campaign.
rpc_campaign_alerts_subscribe
python
rsmusllp/king-phisher
king_phisher/server/server_rpc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py
BSD-3-Clause
def rpc_campaign_alerts_unsubscribe(handler, session, campaign_id): """ Unsubscribe to alerts for the specified campaign. :param int campaign_id: The ID of the campaign. """ user_id = handler.rpc_session.user query = session.query(db_models.AlertSubscription) query = query.filter_by(campaign_id=campaign_id, use...
Unsubscribe to alerts for the specified campaign. :param int campaign_id: The ID of the campaign.
rpc_campaign_alerts_unsubscribe
python
rsmusllp/king-phisher
king_phisher/server/server_rpc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py
BSD-3-Clause
def rpc_campaign_landing_page_new(handler, session, campaign_id, hostname, page): """ Add a landing page for the specified campaign. Landing pages refer to resources that when visited by a user should cause the visit counter to be incremented. :param int campaign_id: The ID of the campaign. :param str hostname: ...
Add a landing page for the specified campaign. Landing pages refer to resources that when visited by a user should cause the visit counter to be incremented. :param int campaign_id: The ID of the campaign. :param str hostname: The hostname which will be used to serve the request. :param str page: The request re...
rpc_campaign_landing_page_new
python
rsmusllp/king-phisher
king_phisher/server/server_rpc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py
BSD-3-Clause
def rpc_campaign_message_new(handler, session, campaign_id, email_id, target_email, first_name, last_name, department_name=None): """ Record a message that has been sent as part of a campaign. These details can be retrieved later for value substitution in template pages. :param int campaign_id: The ID of the campa...
Record a message that has been sent as part of a campaign. These details can be retrieved later for value substitution in template pages. :param int campaign_id: The ID of the campaign. :param str email_id: The message id of the sent email. :param str target_email: The email address that the message was sent to....
rpc_campaign_message_new
python
rsmusllp/king-phisher
king_phisher/server/server_rpc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py
BSD-3-Clause
def rpc_campaign_stats(handler, session, campaign_id): """ Generate statistics regarding the specified campaign and return them in a dictionary. The dictionary will contain the keys credentials, credentials-unique, messages, messages-trained, visits, visits-unique. Values with unique in the key are counted unique ...
Generate statistics regarding the specified campaign and return them in a dictionary. The dictionary will contain the keys credentials, credentials-unique, messages, messages-trained, visits, visits-unique. Values with unique in the key are counted unique by the message id for which they are associated. :param ...
rpc_campaign_stats
python
rsmusllp/king-phisher
king_phisher/server/server_rpc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py
BSD-3-Clause
def rpc_database_count_rows(handler, session, table_name, query_filter=None): """ Get a count of the rows in the specified table where the search criteria matches. :param str table_name: The name of the database table to query. :param dict query_filter: A dictionary mapping optional search criteria for matching t...
Get a count of the rows in the specified table where the search criteria matches. :param str table_name: The name of the database table to query. :param dict query_filter: A dictionary mapping optional search criteria for matching the query. :return: The number of matching rows. :rtype: int
rpc_database_count_rows
python
rsmusllp/king-phisher
king_phisher/server/server_rpc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py
BSD-3-Clause
def rpc_database_view_rows(handler, session, table_name, page=0, query_filter=None): """ Retrieve the rows from the specified table where the search criteria matches. :param str table_name: The name of the database table to query. :param int page: The page number to retrieve results for. :param dict query_filter...
Retrieve the rows from the specified table where the search criteria matches. :param str table_name: The name of the database table to query. :param int page: The page number to retrieve results for. :param dict query_filter: A dictionary mapping optional search criteria for matching the query. :return: A dicti...
rpc_database_view_rows
python
rsmusllp/king-phisher
king_phisher/server/server_rpc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py
BSD-3-Clause
def rpc_database_delete_row_by_id(handler, session, table_name, row_id): """ Delete the row from the table with the specified value in the id column. If the row does not exist, no error is raised. :param str table_name: The name of the database table to delete a row from. :param row_id: The id value. """ metata...
Delete the row from the table with the specified value in the id column. If the row does not exist, no error is raised. :param str table_name: The name of the database table to delete a row from. :param row_id: The id value.
rpc_database_delete_row_by_id
python
rsmusllp/king-phisher
king_phisher/server/server_rpc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py
BSD-3-Clause
def rpc_database_delete_rows_by_id(handler, session, table_name, row_ids): """ Delete multiple rows from a table with the specified values in the id column. If a row id specified in *row_ids* does not exist, then it will be skipped and no error will be thrown. :param str table_name: The name of the database table...
Delete multiple rows from a table with the specified values in the id column. If a row id specified in *row_ids* does not exist, then it will be skipped and no error will be thrown. :param str table_name: The name of the database table to delete rows from. :param list row_ids: The row ids to delete. :return: Th...
rpc_database_delete_rows_by_id
python
rsmusllp/king-phisher
king_phisher/server/server_rpc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py
BSD-3-Clause
def rpc_database_get_row_by_id(handler, session, table_name, row_id): """ Retrieve a row from a given table with the specified value in the id column. :param str table_name: The name of the database table to retrieve a row from. :param row_id: The id value. :return: The specified row data. :rtype: dict """ me...
Retrieve a row from a given table with the specified value in the id column. :param str table_name: The name of the database table to retrieve a row from. :param row_id: The id value. :return: The specified row data. :rtype: dict
rpc_database_get_row_by_id
python
rsmusllp/king-phisher
king_phisher/server/server_rpc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py
BSD-3-Clause
def rpc_database_insert_row(handler, session, table_name, keys, values): """ Insert a new row into the specified table. :param str table_name: The name of the database table to insert a new row into. :param list keys: The column names of *values*. :param list values: The values to be inserted in the row. :return...
Insert a new row into the specified table. :param str table_name: The name of the database table to insert a new row into. :param list keys: The column names of *values*. :param list values: The values to be inserted in the row. :return: The id of the new row that has been added.
rpc_database_insert_row
python
rsmusllp/king-phisher
king_phisher/server/server_rpc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py
BSD-3-Clause
def rpc_database_insert_row_multi(handler, session, table_name, keys, rows, deconflict_ids=False): """ Insert multiple new rows into the specified table. If *deconflict_ids* is true, new id values will be assigned as necessary to merge the data into the database. This function will fail if constraints for the table...
Insert multiple new rows into the specified table. If *deconflict_ids* is true, new id values will be assigned as necessary to merge the data into the database. This function will fail if constraints for the table are not met. :param str table_name: The name of the database table to insert data into. :param lis...
rpc_database_insert_row_multi
python
rsmusllp/king-phisher
king_phisher/server/server_rpc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py
BSD-3-Clause
def rpc_database_set_row_value(handler, session, table_name, row_id, keys, values): """ Set values for a row in the specified table with an id of *row_id*. :param str table_name: The name of the database table to set the values of the specified row. :param tuple keys: The column names of *values*. :param tuple va...
Set values for a row in the specified table with an id of *row_id*. :param str table_name: The name of the database table to set the values of the specified row. :param tuple keys: The column names of *values*. :param tuple values: The values to be updated in the row.
rpc_database_set_row_value
python
rsmusllp/king-phisher
king_phisher/server/server_rpc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py
BSD-3-Clause
def rpc_events_is_subscribed(handler, event_id, event_type): """ Check if the client is currently subscribed to the specified server event. :param str event_id: The identifier of the event to subscribe to. :param str event_type: A sub-type for the corresponding event. :return: Whether or not the client is subscri...
Check if the client is currently subscribed to the specified server event. :param str event_id: The identifier of the event to subscribe to. :param str event_type: A sub-type for the corresponding event. :return: Whether or not the client is subscribed to the event. :rtype: bool
rpc_events_is_subscribed
python
rsmusllp/king-phisher
king_phisher/server/server_rpc.py
https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py
BSD-3-Clause