1.2.9. server_rpc
¶
This module provides the RPC server functionality that is used by the client to communicate with the server application.
1.2.9.1. Data¶
1.2.9.2. Functions¶
-
register_rpc
(path, database_access=False, log_call=False)[source]¶ 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
RequestHandler
instance.Parameters:
-
rpc_campaign_alerts_is_subscribed
(handler, session, campaign_id)[source]¶ Check if the user is subscribed to alerts for the specified campaign.
Parameters: campaign_id (int) – The ID of the campaign. Returns: The alert subscription status. Return type: bool
-
rpc_campaign_alerts_subscribe
(handler, session, campaign_id)[source]¶ Subscribe to alerts for the specified campaign.
Parameters: campaign_id (int) – The ID of the campaign.
-
rpc_campaign_alerts_unsubscribe
(handler, session, campaign_id)[source]¶ Unsubscribe to alerts for the specified campaign.
Parameters: campaign_id (int) – The ID of the campaign.
-
rpc_campaign_landing_page_new
(handler, session, campaign_id, hostname, page)[source]¶ 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.
Parameters:
-
rpc_campaign_message_new
(handler, session, campaign_id, email_id, target_email, first_name, last_name, department_name=None)[source]¶ Record a message that has been sent as part of a campaign. These details can be retrieved later for value substitution in template pages.
Parameters: - campaign_id (int) – The ID of the campaign.
- email_id (str) – The message id of the sent email.
- target_email (str) – The email address that the message was sent to.
- first_name (str) – The first name of the message’s recipient.
- last_name (str) – The last name of the message’s recipient.
- department_name (str) – The name of the company department that the message’s recipient belongs to.
-
rpc_campaign_new
(handler, session, name, description=None)[source]¶ Create a new King Phisher campaign and initialize the database information.
Parameters: Returns: The ID of the new campaign.
Return type:
-
rpc_campaign_stats
(handler, session, campaign_id)[source]¶ 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.
Parameters: campaign_id – The unique ID of the campaign to generate statistics for. Returns: The statistics for the specified campaign. Return type: dict
-
rpc_config_get
(handler, option_name)[source]¶ Retrieve a value from the server’s configuration.
Parameters: option_name (str) – The name of the configuration option. Returns: The option’s value.
-
rpc_config_set
(handler, options)[source]¶ Set options in the server’s configuration. Any changes to the server’s configuration are not written to disk.
Parameters: options (dict) – A dictionary of option names and values
-
rpc_events_is_subscribed
(handler, event_id, event_type)[source]¶ Check if the client is currently subscribed to the specified server event.
Parameters: Returns: Whether or not the client is subscribed to the event.
Return type:
-
rpc_events_subscribe
(handler, event_id, event_types=None, attributes=None)[source]¶ Subscribe the client to the specified event published by the server. When the event is published the specified attributes of it and it’s corresponding id and type information will be sent to the client.
Parameters:
-
rpc_events_unsubscribe
(handler, event_id, event_types=None, attributes=None)[source]¶ Unsubscribe from an event published by the server that the client previously subscribed to.
Parameters:
-
rpc_database_count_rows
(handler, session, table_name, query_filter=None)[source]¶ Get a count of the rows in the specified table where the search criteria matches.
Parameters: Returns: The number of matching rows.
Return type:
-
rpc_database_delete_row_by_id
(handler, session, table_name, row_id)[source]¶ Delete the row from the table with the specified value in the id column. If the row does not exist, no error is raised.
Parameters: - table_name (str) – The name of the database table to delete a row from.
- row_id – The id value.
-
rpc_database_delete_rows_by_id
(handler, session, table_name, row_ids)[source]¶ 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.
Parameters: Returns: The row ids that were deleted.
Return type:
-
rpc_database_get_row_by_id
(handler, session, table_name, row_id)[source]¶ Retrieve a row from a given table with the specified value in the id column.
Parameters: - table_name (str) – The name of the database table to retrieve a row from.
- row_id – The id value.
Returns: The specified row data.
Return type:
-
rpc_database_insert_row
(handler, session, table_name, keys, values)[source]¶ Insert a new row into the specified table.
Parameters: Returns: The id of the new row that has been added.
-
rpc_database_set_row_value
(handler, session, table_name, row_id, keys, values)[source]¶ Set values for a row in the specified table with an id of row_id.
Parameters:
-
rpc_database_view_rows
(handler, session, table_name, page=0, query_filter=None)[source]¶ Retrieve the rows from the specified table where the search criteria matches.
Parameters: Returns: A dictionary with columns and rows keys.
Return type:
-
rpc_geoip_lookup
(handler, ip, lang=None)[source]¶ Look up an IP address in the servers GeoIP database. If the IP address can not be found in the database, None will be returned.
Parameters: Returns: The geographic information for the specified IP address.
Return type:
-
rpc_geoip_lookup_multi
(handler, ips, lang=None)[source]¶ Look up multiple IP addresses in the servers GeoIP database. Each IP address that can not be found in the database will have its result set to None.
Parameters: Returns: A dictionary containing the results keyed by the specified IP addresses.
Return type:
-
rpc_graphql
(handler, session, query, query_vars=None)[source]¶ Execute a GraphQL query and return the results. If the query fails to execute the errors returned are populated in the errors key of the results dictionary. If the query executes successfully the returned data is available in the data key of the results dictionary.
Parameters: Returns: The results of the query as a dictionary.
Return type:
-
rpc_hostnames_add
(handler, hostname)[source]¶ Add a hostname to the list of values that are configured for use with this server. At this time, these changes (like other config changes) are not persisted in the server so they will be lost when the server reboots.
New in version 1.13.0.
Parameters: hostname (str) – The hostname to add.
-
rpc_hostnames_get
(handler)[source]¶ Get the hostnames that are configured for use with this server.
New in version 1.13.0.
Returns: The configured hostnames. Return type: list
-
rpc_ping
(handler)[source]¶ An RPC method that can be used by clients to assert the status and responsiveness of this server.
Returns: This method always returns True. Return type: bool
-
rpc_plugins_list
(handler)[source]¶ Return information regarding enabled plugins in the server.
Returns: A dictionary representing enabled plugins and their meta-data. Return type: dict