1.2.13. signals

This module contains the signals which are used by the server to dispatch events. Additional signal details regarding how these signals are used is available in the Server Signals documentation.

1.2.13.1. Functions

send_safe(signal, logger, sender, **kwargs)[source]

Send a signal and catch any exception which may be raised during it’s emission. Details regarding the error that occurs (including a stack trace) are logged to the specified logger. This is suitable for allowing signals to be emitted in critical code paths without interrupting the emitter.

Parameters:
  • signal (str) – The name of the signal to send safely.
  • logger (logging.Logger) – The logger to use for logging exceptions.
  • sender – The sender for this signal emission.
  • kwargs – The key word arguments to be forward to the signal as it is sent.

1.2.13.2. Signals

campaign_alert[source]

Emitted for each user who is subscribed to alerts for a particular campaign. Users subscribe to campaign alerts through the GUI by enabling the “Subscribe To Event Alerts” setting. Alerts are for either the “credentials” or “visits” table.

Note

This signal is not emitted for every entry into the respective tables but rather at progressively longer intervals to prevent the user from receiving an excessive amount of messages within a short period of time.

Parameters:
  • table (str) – The table name that the alert is for.
  • alert_subscription (king_phisher.server.database.models.AlertSubscription) – The alert subscription.
  • count (int) – The number associated with the alert event per the specified sender.
credentials_received[source]

Sent when a new pair of credentials have been submitted.

Parameters:
  • request_handler – The handler for the received request.
  • username (str) – The username of the credentials that were submitted.
  • password (str) – The password of the credentials that were submitted.
db_initialized[source]

Emitted after a connection has been made and the database has been fully initialized. At this point, it is safe to operate on the database.

Parameters:connection_url (sqlalchemy.engine.url.URL) – The connection string for the database that has been initialized.
db_session_deleted[source]

Emitted after one or more rows have been deleted on a SQLAlchemy session. At this point, references are valid but objects can not be modified. See sqlalchemy.orm.events.SessionEvents.after_flush() for more details.

Parameters:
  • table (str) – The name of the table for which the target objects belong.
  • targets (tuple) – The objects that have been deleted with the session.
  • session (sqlalchemy.orm.session.Session) – The SQLAlchemy session with which the targets are associated.
db_session_inserted[source]

Emitted after one or more rows have been inserted in a SQLAlchemy session. At this point, references are valid but objects can not be modified. See sqlalchemy.orm.events.SessionEvents.after_flush() for more details.

Parameters:
  • table (str) – The name of the table for which the target objects belong.
  • targets (tuple) – The objects that have been inserted with the session.
  • session (sqlalchemy.orm.session.Session) – The SQLAlchemy session with which the targets are associated.
db_session_updated[source]

Emitted after one or more rows have been updated in a SQLAlchemy session. At this point, references are valid but objects can not be modified. See sqlalchemy.orm.events.SessionEvents.after_flush() for more details.

Parameters:
  • table (str) – The name of the table for which the target objects belong.
  • targets (tuple) – The objects that have been updated with the session.
  • session (sqlalchemy.orm.session.Session) – The SQLAlchemy session with which the targets are associated.
db_table_delete[source]

Emitted before a row inheriting from Base is deleted from the database table. To only subscribe to delete events for a specific table, specify the table’s name as the sender parameter when calling blinker.base.Signal.connect(). See sqlalchemy.orm.events.MapperEvents.before_delete() for more details.

Parameters:
  • table (str) – The name of the table for which the target object belongs.
  • mapper (sqlalchemy.orm.mapper.Mapper) – The Mapper object which is the target of the event.
  • connection (sqlalchemy.engine.Connection) – The SQLAlchemy connection object which is being used to emit the SQL statements for the instance.
  • target – The target object instance.
db_table_insert[source]

Emitted before a row inheriting from Base is inserted into the database table. To only subscribe to insert events for a specific table, specify the table’s name as the sender parameter when calling blinker.base.Signal.connect(). See sqlalchemy.orm.events.MapperEvents.before_insert() for more details.

Parameters:
  • table (str) – The name of the table for which the target object belongs.
  • mapper (sqlalchemy.orm.mapper.Mapper) – The Mapper object which is the target of the event.
  • connection (sqlalchemy.engine.Connection) – The SQLAlchemy connection object which is being used to emit the SQL statements for the instance.
  • target – The target object instance.
db_table_update[source]

Emitted before a row inheriting from Base is updated in the database table. To only subscribe to update events for a specific table, specify the table’s name as the sender parameter when calling blinker.base.Signal.connect(). See sqlalchemy.orm.events.MapperEvents.before_update() for more details.

Parameters:
  • table (str) – The name of the table for which the target object belongs.
  • mapper (sqlalchemy.orm.mapper.Mapper) – The Mapper object which is the target of the event.
  • connection (sqlalchemy.engine.Connection) – The SQLAlchemy connection object which is being used to emit the SQL statements for the instance.
  • target – The target object instance.
email_opened[source]

Sent when a request for the embedded image is received.

Parameters:request_handler – The handler for the received request.
request_handle[source]

Sent after a new HTTP request has been received and is about to be handled. This signal is suitable for implementing custom request handlers or aborting requests. This signal is emitted after request_received to allow subscribers the opportunity to handle requests themselves.

Note

If a request has been handled by the signal, the signal handler must raise the KingPhisherAbortRequestError exception to prevent further processing.

Parameters:request_handler – The handler for the received request.
request_received[source]

Sent when a new HTTP request has been received and is about to be handled. This signal is not suitable for implementing custom request handlers or aborting requests. This signal is emitted before request_handle allowing subscribers to be notified before a request may be blocked.

Parameters:request_handler – The handler for the received request.
response_sent[source]

Sent after a response to an HTTP request has been sent to the client. At this point headers may be added to the response body.

Parameters:
  • request_handler – The handler for the received request.
  • code (int) – The HTTP status code that was sent in the response.
  • message (str) – The HTTP message that was sent in the response.
rpc_method_call[source]

Sent when a new RPC request has been received and it’s corresponding method is about to be called.

Parameters:
  • method (str) – The RPC method which is about to be executed.
  • request_handler – The handler for the received request.
  • args (tuple) – The arguments that are to be passed to the method.
  • kwargs (dict) – The key word arguments that are to be passed to the method.
rpc_method_called[source]

Sent after an RPC request has been received and it’s corresponding method has been called.

Parameters:
  • method (str) – The RPC method which has been executed.
  • request_handler – The handler for the received request.
  • args (tuple) – The arguments that were passed to the method.
  • kwargs (dict) – The key word arguments that were passed to the method.
  • retval – The value returned from the RPC method invocation.
rpc_user_logged_in[source]

Sent when a new RPC user has successfully logged in and created a new authenticated session.

Parameters:
  • request_handler – The handler for the received request.
  • session (str) – The session ID of the newly logged in user.
  • name (str) – The username of the newly logged in user.
rpc_user_logged_out[source]

Sent when an authenticated RPC user has successfully logged out and terminated their authenticated session.

Parameters:
  • request_handler – The handler for the received request.
  • session (str) – The session ID of the user who has logged out.
  • name (str) – The username of the user who has logged out.
server_initialized[source]

Sent when a new instance of KingPhisherServer is initialized.

Parameters:server – The newly initialized server instance.
visit_received[source]

Sent when a new visit is received on a landing page. This is only emitted when a new visit entry is added to the database.

Parameters:request_handler – The handler for the received request.