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 run_process(process_args, cwd=None, tee=False, encoding='utf-8'):
"""
Run a subprocess, wait for it to complete and return a
:py:class:`~.ProcessResults` object. This function differs from
:py:func:`.start_process` in the type it returns and the fact that it always
waits for the subprocess to finish before ret... |
Run a subprocess, wait for it to complete and return a
:py:class:`~.ProcessResults` object. This function differs from
:py:func:`.start_process` in the type it returns and the fact that it always
waits for the subprocess to finish before returning.
.. versionchanged:: 1.15.0
Added the *tee* parameter.
:param... | run_process | python | rsmusllp/king-phisher | king_phisher/startup.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/startup.py | BSD-3-Clause |
def start_process(process_args, wait=True, cwd=None):
"""
Start a subprocess and optionally wait for it to finish. If not **wait**, a
handle to the subprocess is returned instead of ``True`` when it exits
successfully. This function differs from :py:func:`.run_process` in that it
optionally waits for the subproces... |
Start a subprocess and optionally wait for it to finish. If not **wait**, a
handle to the subprocess is returned instead of ``True`` when it exits
successfully. This function differs from :py:func:`.run_process` in that it
optionally waits for the subprocess to finish, and can return a handle to
it.
:param tupl... | start_process | python | rsmusllp/king-phisher | king_phisher/startup.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/startup.py | BSD-3-Clause |
def which(program):
"""
Examine the ``PATH`` environment variable to determine the location for the
specified program. If it can not be found None is returned. This is
fundamentally similar to the Unix utility of the same name.
:param str program: The name of the program to search for.
:return: The absolute path... |
Examine the ``PATH`` environment variable to determine the location for the
specified program. If it can not be found None is returned. This is
fundamentally similar to the Unix utility of the same name.
:param str program: The name of the program to search for.
:return: The absolute path to the program if found... | which | python | rsmusllp/king-phisher | king_phisher/startup.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/startup.py | BSD-3-Clause |
def argp_add_default_args(parser, default_root=''):
"""
Add standard arguments to a new :py:class:`argparse.ArgumentParser`
instance. Used to add the utilities argparse options to the wrapper for
display.
:param parser: The parser to add arguments to.
:type parser: :py:class:`argparse.ArgumentParser`
:param str... |
Add standard arguments to a new :py:class:`argparse.ArgumentParser`
instance. Used to add the utilities argparse options to the wrapper for
display.
:param parser: The parser to add arguments to.
:type parser: :py:class:`argparse.ArgumentParser`
:param str default_root: The default root logger to specify.
| argp_add_default_args | python | rsmusllp/king-phisher | king_phisher/startup.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/startup.py | BSD-3-Clause |
def argp_add_client(parser):
"""
Add client-specific arguments to a new :py:class:`argparse.ArgumentParser`
instance.
:param parser: The parser to add arguments to.
:type parser: :py:class:`argparse.ArgumentParser`
"""
kpc_group = parser.add_argument_group('client specific options')
kpc_group.add_argument('-c'... |
Add client-specific arguments to a new :py:class:`argparse.ArgumentParser`
instance.
:param parser: The parser to add arguments to.
:type parser: :py:class:`argparse.ArgumentParser`
| argp_add_client | python | rsmusllp/king-phisher | king_phisher/startup.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/startup.py | BSD-3-Clause |
def argp_add_server(parser):
"""
Add server-specific arguments to a new :py:class:`argparse.ArgumentParser`
instance.
:param parser: The parser to add arguments to.
:type parser: :py:class:`argparse.ArgumentParser`
"""
kps_group = parser.add_argument_group('server specific options')
kps_group.add_argument('-f'... |
Add server-specific arguments to a new :py:class:`argparse.ArgumentParser`
instance.
:param parser: The parser to add arguments to.
:type parser: :py:class:`argparse.ArgumentParser`
| argp_add_server | python | rsmusllp/king-phisher | king_phisher/startup.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/startup.py | BSD-3-Clause |
def __init__(self, loader=None, global_vars=None):
"""
:param loader: The loader to supply to the environment.
:type loader: :py:class:`jinja2.BaseLoader`
:param dict global_vars: Additional global variables for the environment.
"""
self.logger = logging.getLogger('KingPhisher.TemplateEnvironment')
autoes... |
:param loader: The loader to supply to the environment.
:type loader: :py:class:`jinja2.BaseLoader`
:param dict global_vars: Additional global variables for the environment.
| __init__ | python | rsmusllp/king-phisher | king_phisher/templates.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/templates.py | BSD-3-Clause |
def from_file(self, path, **kwargs):
"""
A convenience method to load template data from a specified file,
passing it to :py:meth:`~jinja2.Environment.from_string`.
.. warning::
Because this method ultimately passes the template data to the
:py:meth:`~jinja2.Environment.from_string` method, the data will... |
A convenience method to load template data from a specified file,
passing it to :py:meth:`~jinja2.Environment.from_string`.
.. warning::
Because this method ultimately passes the template data to the
:py:meth:`~jinja2.Environment.from_string` method, the data will not
be automatically escaped based on ... | from_file | python | rsmusllp/king-phisher | king_phisher/templates.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/templates.py | BSD-3-Clause |
def join_path(self, template, parent):
"""
Over ride the default :py:meth:`jinja2.Environment.join_path` method to
explicitly specifying relative paths by prefixing the path with either
"./" or "../".
:param str template: The path of the requested template file.
:param str parent: The path of the template ... |
Over ride the default :py:meth:`jinja2.Environment.join_path` method to
explicitly specifying relative paths by prefixing the path with either
"./" or "../".
:param str template: The path of the requested template file.
:param str parent: The path of the template file which requested the load.
:return: Th... | join_path | python | rsmusllp/king-phisher | king_phisher/templates.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/templates.py | BSD-3-Clause |
def standard_variables(self):
"""
Additional standard variables that can optionally be used in templates.
"""
std_vars = {
'time': {
'local': datetime.datetime.now(),
'utc': datetime.datetime.utcnow()
}
}
return std_vars |
Additional standard variables that can optionally be used in templates.
| standard_variables | python | rsmusllp/king-phisher | king_phisher/templates.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/templates.py | BSD-3-Clause |
def set_mode(self, mode):
"""
Set the operation mode for the environment. Valid values are the MODE_*
constants.
:param int mode: The operation mode.
"""
if mode not in (self.MODE_PREVIEW, self.MODE_ANALYZE, self.MODE_SEND):
raise ValueError('mode must be one of the MODE_* constants')
self._mode = mod... |
Set the operation mode for the environment. Valid values are the MODE_*
constants.
:param int mode: The operation mode.
| set_mode | python | rsmusllp/king-phisher | king_phisher/templates.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/templates.py | BSD-3-Clause |
def skip_if_offline(test_method):
"""
A decorator to skip running tests when the KING_PHISHER_TEST_OFFLINE
environment variable is set. This allows unit tests which require a internet
connection to be skipped when network connectivity is known to be inactive.
"""
@functools.wraps(test_method)
def decorated(self,... |
A decorator to skip running tests when the KING_PHISHER_TEST_OFFLINE
environment variable is set. This allows unit tests which require a internet
connection to be skipped when network connectivity is known to be inactive.
| skip_if_offline | python | rsmusllp/king-phisher | king_phisher/testing.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/testing.py | BSD-3-Clause |
def skip_on_travis(test_method):
"""
A decorator to skip running a test when executing in the travis-ci environment.
"""
@functools.wraps(test_method)
def decorated(self, *args, **kwargs):
if os.environ.get('TRAVIS'):
self.skipTest('due to running in travis-ci environment')
return test_method(self, *args, *... |
A decorator to skip running a test when executing in the travis-ci environment.
| skip_on_travis | python | rsmusllp/king-phisher | king_phisher/testing.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/testing.py | BSD-3-Clause |
def assertIsEmpty(self, obj, msg=None):
"""Test that *obj* is empty as determined by :py:func:`len`."""
if len(obj):
self.fail(msg or 'the test object is not empty') | Test that *obj* is empty as determined by :py:func:`len`. | assertIsEmpty | python | rsmusllp/king-phisher | king_phisher/testing.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/testing.py | BSD-3-Clause |
def assertIsNotEmpty(self, obj, msg=None):
"""Test that *obj* is not empty as determined by :py:func:`len`."""
if not len(obj):
self.fail(msg or 'the test object is empty') | Test that *obj* is not empty as determined by :py:func:`len`. | assertIsNotEmpty | python | rsmusllp/king-phisher | king_phisher/testing.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/testing.py | BSD-3-Clause |
def assertIsSubclass(self, obj, cls, msg=None):
"""
Test that *obj* is a subclass of *cls* (which can be a class or a tuple
of classes as supported by :py:func:`issubclass`).
"""
if not issubclass(obj, cls):
self.fail(msg or "the test object is not a subclass of '{}'".format(cls.__name__)) |
Test that *obj* is a subclass of *cls* (which can be a class or a tuple
of classes as supported by :py:func:`issubclass`).
| assertIsSubclass | python | rsmusllp/king-phisher | king_phisher/testing.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/testing.py | BSD-3-Clause |
def assertHasAttribute(self, obj, attribute, msg=None):
"""Test that *obj* has the named *attribute*."""
if not hasattr(obj, attribute):
self.fail(msg or "the test object has no attribute '{}'".format(attribute)) | Test that *obj* has the named *attribute*. | assertHasAttribute | python | rsmusllp/king-phisher | king_phisher/testing.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/testing.py | BSD-3-Clause |
def assertHTTPStatus(self, http_response, status):
"""
Check an HTTP response to ensure that the correct HTTP status code is
specified.
:param http_response: The response object to check.
:type http_response: :py:class:`httplib.HTTPResponse`
:param int status: The status to check for.
"""
self.assertIs... |
Check an HTTP response to ensure that the correct HTTP status code is
specified.
:param http_response: The response object to check.
:type http_response: :py:class:`httplib.HTTPResponse`
:param int status: The status to check for.
| assertHTTPStatus | python | rsmusllp/king-phisher | king_phisher/testing.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/testing.py | BSD-3-Clause |
def assertRPCPermissionDenied(self, method, *args, **kwargs):
"""
Assert that the specified RPC method fails with a
:py:exc:`~king_phisher.errors.KingPhisherPermissionError` exception.
:param method: The RPC method that is to be tested
"""
try:
self.rpc(method, *args, **kwargs)
except advancedhttpserv... |
Assert that the specified RPC method fails with a
:py:exc:`~king_phisher.errors.KingPhisherPermissionError` exception.
:param method: The RPC method that is to be tested
| assertRPCPermissionDenied | python | rsmusllp/king-phisher | king_phisher/testing.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/testing.py | BSD-3-Clause |
def http_request(self, resource, method='GET', include_id=True, body=None, headers=None):
"""
Make an HTTP request to the specified resource on the test server.
:param str resource: The resource to send the request to.
:param str method: The HTTP method to use for the request.
:param bool include_id: Whether... |
Make an HTTP request to the specified resource on the test server.
:param str resource: The resource to send the request to.
:param str method: The HTTP method to use for the request.
:param bool include_id: Whether to include the the id parameter.
:param body: The data to include in the body of the request... | http_request | python | rsmusllp/king-phisher | king_phisher/testing.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/testing.py | BSD-3-Clause |
def parse_user_agent(user_agent):
"""
Parse a user agent string and return normalized information regarding the
operating system.
:param str user_agent: The user agent to parse.
:return: A parsed user agent, None is returned if the data can not be processed.
:rtype: :py:class:`.UserAgent`
"""
os_parts = USER_A... |
Parse a user agent string and return normalized information regarding the
operating system.
:param str user_agent: The user agent to parse.
:return: A parsed user agent, None is returned if the data can not be processed.
:rtype: :py:class:`.UserAgent`
| parse_user_agent | python | rsmusllp/king-phisher | king_phisher/ua_parser.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/ua_parser.py | BSD-3-Clause |
def argp_add_args(parser, default_root=''):
"""
Add standard arguments to a new :py:class:`argparse.ArgumentParser` instance
for configuring logging options from the command line and displaying the
version information.
.. note::
This function installs a hook to *parser.parse_args* to automatically
handle opti... |
Add standard arguments to a new :py:class:`argparse.ArgumentParser` instance
for configuring logging options from the command line and displaying the
version information.
.. note::
This function installs a hook to *parser.parse_args* to automatically
handle options which it adds. This includes setting up a st... | argp_add_args | python | rsmusllp/king-phisher | king_phisher/utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/utilities.py | BSD-3-Clause |
def assert_arg_type(arg, arg_type, arg_pos=1, func_name=None):
"""
Check that an argument is an instance of the specified type and if not
raise a :py:exc:`TypeError` exception with a meaningful message. If
*func_name* is not specified, it will be determined by examining the stack.
:param arg: The argument to chec... |
Check that an argument is an instance of the specified type and if not
raise a :py:exc:`TypeError` exception with a meaningful message. If
*func_name* is not specified, it will be determined by examining the stack.
:param arg: The argument to check.
:param arg_type: The type or sequence of types that *arg* can b... | assert_arg_type | python | rsmusllp/king-phisher | king_phisher/utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/utilities.py | BSD-3-Clause |
def configure_stream_logger(logger, level=None):
"""
Configure the default stream handler for logging messages to the console.
This also configures the basic logging environment for the application.
:param str logger: The logger to add the stream handler for.
:param level: The level to set the logger to, will def... |
Configure the default stream handler for logging messages to the console.
This also configures the basic logging environment for the application.
:param str logger: The logger to add the stream handler for.
:param level: The level to set the logger to, will default to WARNING if no level is specified.
:type leve... | configure_stream_logger | python | rsmusllp/king-phisher | king_phisher/utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/utilities.py | BSD-3-Clause |
def datetime_local_to_utc(dt):
"""
Convert a :py:class:`datetime.datetime` instance from the local time to UTC
time.
:param dt: The time to convert from local to UTC.
:type dt: :py:class:`datetime.datetime`
:return: The time converted to the UTC timezone.
:rtype: :py:class:`datetime.datetime`
"""
dt = dt.repl... |
Convert a :py:class:`datetime.datetime` instance from the local time to UTC
time.
:param dt: The time to convert from local to UTC.
:type dt: :py:class:`datetime.datetime`
:return: The time converted to the UTC timezone.
:rtype: :py:class:`datetime.datetime`
| datetime_local_to_utc | python | rsmusllp/king-phisher | king_phisher/utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/utilities.py | BSD-3-Clause |
def datetime_utc_to_local(dt):
"""
Convert a :py:class:`datetime.datetime` instance from UTC time to the local
time.
:param dt: The time to convert from UTC to local.
:type dt: :py:class:`datetime.datetime`
:return: The time converted to the local timezone.
:rtype: :py:class:`datetime.datetime`
"""
dt = dt.re... |
Convert a :py:class:`datetime.datetime` instance from UTC time to the local
time.
:param dt: The time to convert from UTC to local.
:type dt: :py:class:`datetime.datetime`
:return: The time converted to the local timezone.
:rtype: :py:class:`datetime.datetime`
| datetime_utc_to_local | python | rsmusllp/king-phisher | king_phisher/utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/utilities.py | BSD-3-Clause |
def format_datetime(dt, encoding='utf-8'):
"""
Format a date time object into a string. If the object *dt* is not an
instance of :py:class:`datetime.datetime` then an empty string will be
returned.
:param dt: The object to format.
:type dt: :py:class:`datetime.datetime`
:param str encoding: The encoding to use ... |
Format a date time object into a string. If the object *dt* is not an
instance of :py:class:`datetime.datetime` then an empty string will be
returned.
:param dt: The object to format.
:type dt: :py:class:`datetime.datetime`
:param str encoding: The encoding to use to coerce the return value into a unicode strin... | format_datetime | python | rsmusllp/king-phisher | king_phisher/utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/utilities.py | BSD-3-Clause |
def is_valid_email_address(email_address):
"""
Check that the string specified appears to be a valid email address.
:param str email_address: The email address to validate.
:return: Whether the email address appears to be valid or not.
:rtype: bool
"""
if email_address is None:
return False
try:
email_vali... |
Check that the string specified appears to be a valid email address.
:param str email_address: The email address to validate.
:return: Whether the email address appears to be valid or not.
:rtype: bool
| is_valid_email_address | python | rsmusllp/king-phisher | king_phisher/utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/utilities.py | BSD-3-Clause |
def open_uri(uri):
"""
Open a URI in a platform intelligent way. On Windows this will use
'cmd.exe /c start' and on Linux this will use gvfs-open or xdg-open
depending on which is available. If no suitable application can be
found to open the URI, a RuntimeError will be raised.
:param str uri: The URI to open.
... |
Open a URI in a platform intelligent way. On Windows this will use
'cmd.exe /c start' and on Linux this will use gvfs-open or xdg-open
depending on which is available. If no suitable application can be
found to open the URI, a RuntimeError will be raised.
:param str uri: The URI to open.
| open_uri | python | rsmusllp/king-phisher | king_phisher/utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/utilities.py | BSD-3-Clause |
def parse_datetime(ts):
"""
Parse a time stamp into a :py:class:`datetime.datetime` instance. The time
stamp must be in a compatible format, as would have been returned from the
:py:func:`.format_datetime` function.
:param str ts: The timestamp to parse.
:return: The parsed timestamp.
:rtype: :py:class:`datetim... |
Parse a time stamp into a :py:class:`datetime.datetime` instance. The time
stamp must be in a compatible format, as would have been returned from the
:py:func:`.format_datetime` function.
:param str ts: The timestamp to parse.
:return: The parsed timestamp.
:rtype: :py:class:`datetime.datetime`
| parse_datetime | python | rsmusllp/king-phisher | king_phisher/utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/utilities.py | BSD-3-Clause |
def password_is_complex(password, min_len=12):
"""
Check that the specified string meets standard password complexity
requirements.
:param str password: The password to validate.
:param int min_len: The minimum length the password should be.
:return: Whether the strings appears to be complex or not.
:rtype: bool... |
Check that the specified string meets standard password complexity
requirements.
:param str password: The password to validate.
:param int min_len: The minimum length the password should be.
:return: Whether the strings appears to be complex or not.
:rtype: bool
| password_is_complex | python | rsmusllp/king-phisher | king_phisher/utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/utilities.py | BSD-3-Clause |
def make_message_uid(upper=True, lower=True, digits=True):
"""
Creates a random string of specified character set to be used as a message
id. At least one of *upper*, *lower*, or *digits* must be ``True``.
:param bool upper: Include upper case characters in the UID.
:param bool lower: Include lower case character... |
Creates a random string of specified character set to be used as a message
id. At least one of *upper*, *lower*, or *digits* must be ``True``.
:param bool upper: Include upper case characters in the UID.
:param bool lower: Include lower case characters in the UID.
:param bool digits: Include digits in the UID.
... | make_message_uid | python | rsmusllp/king-phisher | king_phisher/utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/utilities.py | BSD-3-Clause |
def make_webrelpath(path):
"""
Forcefully make *path* into a web-suitable relative path. This will strip
off leading and trailing directory separators.
.. versionadded:: 1.14.0
:param str path: The path to convert into a web-suitable relative path.
:return: The converted path.
:rtype: str
"""
if not path.sta... |
Forcefully make *path* into a web-suitable relative path. This will strip
off leading and trailing directory separators.
.. versionadded:: 1.14.0
:param str path: The path to convert into a web-suitable relative path.
:return: The converted path.
:rtype: str
| make_webrelpath | python | rsmusllp/king-phisher | king_phisher/utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/utilities.py | BSD-3-Clause |
def nonempty_string(value):
"""
Convert *value* into either a non-empty string or None. This will also
strip leading and trailing whitespace.
:param str value: The value to convert.
:return: Either the non-empty string or None.
"""
if not value:
return None
value = value.strip()
return value if value else N... |
Convert *value* into either a non-empty string or None. This will also
strip leading and trailing whitespace.
:param str value: The value to convert.
:return: Either the non-empty string or None.
| nonempty_string | python | rsmusllp/king-phisher | king_phisher/utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/utilities.py | BSD-3-Clause |
def random_string(size, charset=None):
"""
Generate a random string consisting of uppercase letters, lowercase letters
and numbers of the specified size.
:param int size: The size of the string to make.
:return: The string containing the random characters.
:rtype: str
"""
charset = charset or string.ascii_lett... |
Generate a random string consisting of uppercase letters, lowercase letters
and numbers of the specified size.
:param int size: The size of the string to make.
:return: The string containing the random characters.
:rtype: str
| random_string | python | rsmusllp/king-phisher | king_phisher/utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/utilities.py | BSD-3-Clause |
def switch(value, comp=operator.eq, swapped=False):
"""
A pure Python implementation of a switch case statement. *comp* will be used
as a comparison function and passed two arguments of *value* and the
provided case respectively.
Switch case example usage:
.. code-block:: python
for case in switch(2):
... |
A pure Python implementation of a switch case statement. *comp* will be used
as a comparison function and passed two arguments of *value* and the
provided case respectively.
Switch case example usage:
.. code-block:: python
for case in switch(2):
if case(1):
print('case 1 matched!')
... | switch | python | rsmusllp/king-phisher | king_phisher/utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/utilities.py | BSD-3-Clause |
def validate_json_schema(data, schema_file_id):
"""
Validate the specified data against the specified schema. The schema file
will be searched for and loaded based on it's id. If the validation fails
a :py:class:`~jsonschema.exceptions.ValidationError` will be raised.
:param data: The data to validate against the... |
Validate the specified data against the specified schema. The schema file
will be searched for and loaded based on it's id. If the validation fails
a :py:class:`~jsonschema.exceptions.ValidationError` will be raised.
:param data: The data to validate against the schema.
:param schema_file_id: The id of the schem... | validate_json_schema | python | rsmusllp/king-phisher | king_phisher/utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/utilities.py | BSD-3-Clause |
def __init__(self, prefix, *args, **kwargs):
"""
:param str prefix: The string to prefix all messages with.
"""
self.prefix = prefix + ' '
super(PrefixLoggerAdapter, self).__init__(*args, **kwargs) |
:param str prefix: The string to prefix all messages with.
| __init__ | python | rsmusllp/king-phisher | king_phisher/utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/utilities.py | BSD-3-Clause |
def get_revision(encoding='utf-8'):
"""
Retrieve the current git revision identifier. If the git binary can not be
found or the repository information is unavailable, None will be returned.
:param str encoding: The encoding to use for strings.
:return: The git revision tag if it's available.
:rtype: str
"""
# ... |
Retrieve the current git revision identifier. If the git binary can not be
found or the repository information is unavailable, None will be returned.
:param str encoding: The encoding to use for strings.
:return: The git revision tag if it's available.
:rtype: str
| get_revision | python | rsmusllp/king-phisher | king_phisher/version.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/version.py | BSD-3-Clause |
def xor_encode(data, seed_key=None, encoding='utf-8'):
"""
Encode data using the XOR algorithm. This is not suitable for encryption
purposes and should only be used for light obfuscation. The key is
prepended to the data as the first byte which is required to be decoded
py the :py:func:`.xor_decode` function.
:p... |
Encode data using the XOR algorithm. This is not suitable for encryption
purposes and should only be used for light obfuscation. The key is
prepended to the data as the first byte which is required to be decoded
py the :py:func:`.xor_decode` function.
:param bytes data: The data to encode.
:param int seed_key: ... | xor_encode | python | rsmusllp/king-phisher | king_phisher/xor.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/xor.py | BSD-3-Clause |
def xor_decode(data, encoding='utf-8'):
"""
Decode data using the XOR algorithm. This is not suitable for encryption
purposes and should only be used for light obfuscation. This function
requires the key to be set as the first byte of *data* as done in the
:py:func:`.xor_encode` function.
:param str data: The da... |
Decode data using the XOR algorithm. This is not suitable for encryption
purposes and should only be used for light obfuscation. This function
requires the key to be set as the first byte of *data* as done in the
:py:func:`.xor_encode` function.
:param str data: The data to decode.
:return: The decoded data.
:... | xor_decode | python | rsmusllp/king-phisher | king_phisher/xor.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/xor.py | BSD-3-Clause |
def _create_ssh_forwarder(self, server, username, password, window=None):
"""
Create and set the
:py:attr:`~.KingPhisherClientApplication._ssh_forwarder` attribute.
:param tuple server: The server information as a host and port tuple.
:param str username: The username to authenticate to the SSH server with.
... |
Create and set the
:py:attr:`~.KingPhisherClientApplication._ssh_forwarder` attribute.
:param tuple server: The server information as a host and port tuple.
:param str username: The username to authenticate to the SSH server with.
:param str password: The password to authenticate to the SSH server with.
:... | _create_ssh_forwarder | python | rsmusllp/king-phisher | king_phisher/client/application.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/application.py | BSD-3-Clause |
def add_reference(self, ref_object):
"""
Add *ref_object* to the :py:attr:`.references` so the object won't be
garbage collected. The object must either be a
:py:class:`.GladeGObject` or :py:class:`Gtk.Widget` instance so a
cleanup function can be attached to a ``destroy`` signal to remove the
reference aut... |
Add *ref_object* to the :py:attr:`.references` so the object won't be
garbage collected. The object must either be a
:py:class:`.GladeGObject` or :py:class:`Gtk.Widget` instance so a
cleanup function can be attached to a ``destroy`` signal to remove the
reference automatically.
:param ref_object: The obje... | add_reference | python | rsmusllp/king-phisher | king_phisher/client/application.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/application.py | BSD-3-Clause |
def do_campaign_delete(self, campaign_id):
"""
Delete the campaign on the server. A confirmation dialog will be
displayed before the operation is performed. If the campaign is deleted
and a new campaign is not selected with
:py:meth:`.show_campaign_selection`, the client will quit.
"""
self.rpc('db/table/... |
Delete the campaign on the server. A confirmation dialog will be
displayed before the operation is performed. If the campaign is deleted
and a new campaign is not selected with
:py:meth:`.show_campaign_selection`, the client will quit.
| do_campaign_delete | python | rsmusllp/king-phisher | king_phisher/client/application.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/application.py | BSD-3-Clause |
def get_graphql_campaign(self, campaign_id=None):
"""
Retrieve the GraphQL representation of the specified campaign. If
*campaign_id* is not specified, then the data for the current campaign
is retrieved.
:param str campaign_id: The ID for the campaign whose information should be retrieved.
:return: The ca... |
Retrieve the GraphQL representation of the specified campaign. If
*campaign_id* is not specified, then the data for the current campaign
is retrieved.
:param str campaign_id: The ID for the campaign whose information should be retrieved.
:return: The campaign's GraphQL representation.
:rtype: dict
| get_graphql_campaign | python | rsmusllp/king-phisher | king_phisher/client/application.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/application.py | BSD-3-Clause |
def do_server_disconnected(self):
"""
Clean up the connections to the server and disconnect. This logs out of
the RPC, closes the server event socket, and stops the SSH forwarder.
"""
if self.rpc is not None:
if self.server_events is not None:
self.server_events.reconnect = False
GLib.source_remove(... |
Clean up the connections to the server and disconnect. This logs out of
the RPC, closes the server event socket, and stops the SSH forwarder.
| do_server_disconnected | python | rsmusllp/king-phisher | king_phisher/client/application.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/application.py | BSD-3-Clause |
def do_config_load(self, load_defaults):
"""
Load the client configuration from disk and set the
:py:attr:`~.KingPhisherClientApplication.config` attribute.
Check the proxy environment variable and set them appropriately.
:param bool load_defaults: Load missing options from the template configuration file.
... |
Load the client configuration from disk and set the
:py:attr:`~.KingPhisherClientApplication.config` attribute.
Check the proxy environment variable and set them appropriately.
:param bool load_defaults: Load missing options from the template configuration file.
| do_config_load | python | rsmusllp/king-phisher | king_phisher/client/application.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/application.py | BSD-3-Clause |
def merge_config(self, config_file, strict=True):
"""
Merge the configuration information from the specified configuration
file. Only keys which exist in the currently loaded configuration are
copied over while non-existent keys are skipped. The contents of the new
configuration overwrites the existing.
:p... |
Merge the configuration information from the specified configuration
file. Only keys which exist in the currently loaded configuration are
copied over while non-existent keys are skipped. The contents of the new
configuration overwrites the existing.
:param bool strict: Do not try remove trailing commas fro... | merge_config | python | rsmusllp/king-phisher | king_phisher/client/application.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/application.py | BSD-3-Clause |
def load_server_config(self):
"""Load the necessary values from the server's configuration."""
self.config['server_config'] = self.rpc(
'config/get',
[
'server.require_id',
'server.secret_id',
'server.tracking_image',
'server.web_root',
'server.addresses',
'server.vhost_directories'
... | Load the necessary values from the server's configuration. | load_server_config | python | rsmusllp/king-phisher | king_phisher/client/application.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/application.py | BSD-3-Clause |
def server_connect(self, username, password, otp=None, window=None):
"""
Initialize the connection to the King Phisher server.
:param str username: The username to authenticate with.
:param str password: The password to authenticate with.
:param str otp: The optional one-time password to authenticate with.
... |
Initialize the connection to the King Phisher server.
:param str username: The username to authenticate with.
:param str password: The password to authenticate with.
:param str otp: The optional one-time password to authenticate with.
:param window: The GTK window to use as the parent for error dialogs.
:... | server_connect | python | rsmusllp/king-phisher | king_phisher/client/application.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/application.py | BSD-3-Clause |
def show_campaign_graph(self, graph_name):
"""
Create a new :py:class:`.CampaignGraph` instance and make it into
a window. *graph_name* must be the name of a valid, exported
graph provider.
:param str graph_name: The name of the graph to make a window of.
"""
cls = graphs.get_graph(graph_name)
graph_in... |
Create a new :py:class:`.CampaignGraph` instance and make it into
a window. *graph_name* must be the name of a valid, exported
graph provider.
:param str graph_name: The name of the graph to make a window of.
| show_campaign_graph | python | rsmusllp/king-phisher | king_phisher/client/application.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/application.py | BSD-3-Clause |
def show_campaign_selection(self):
"""
Display the campaign selection dialog in a new
:py:class:`.CampaignSelectionDialog` instance.
:return: Whether or not a campaign was selected.
:rtype: bool
"""
dialog = dialogs.CampaignSelectionDialog(self)
return dialog.interact() == Gtk.ResponseType.APPLY |
Display the campaign selection dialog in a new
:py:class:`.CampaignSelectionDialog` instance.
:return: Whether or not a campaign was selected.
:rtype: bool
| show_campaign_selection | python | rsmusllp/king-phisher | king_phisher/client/application.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/application.py | BSD-3-Clause |
def show_preferences(self):
"""
Display a
:py:class:`.dialogs.configuration.ConfigurationDialog`
instance and saves the configuration to disk if cancel is not selected.
"""
dialog = dialogs.ConfigurationDialog(self)
if dialog.interact() != Gtk.ResponseType.CANCEL:
self.emit('config-save') |
Display a
:py:class:`.dialogs.configuration.ConfigurationDialog`
instance and saves the configuration to disk if cancel is not selected.
| show_preferences | python | rsmusllp/king-phisher | king_phisher/client/application.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/application.py | BSD-3-Clause |
def do_sftp_client_start(self):
"""
Start the client's preferred sftp client application in a new process.
"""
if not self.config['sftp_client']:
gui_utilities.show_dialog_error('Invalid SFTP Configuration', self.get_active_window(), 'An SFTP client is not configured.\nOne can be configured in the Client Pre... |
Start the client's preferred sftp client application in a new process.
| do_sftp_client_start | python | rsmusllp/king-phisher | king_phisher/client/application.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/application.py | BSD-3-Clause |
def stop_remote_service(self):
"""
Stop the remote King Phisher server. This will request that the
server stop processing new requests and exit. This will display
a confirmation dialog before performing the operation. If the
remote service is stopped, the client will quit.
"""
active_window = self.get_act... |
Stop the remote King Phisher server. This will request that the
server stop processing new requests and exit. This will display
a confirmation dialog before performing the operation. If the
remote service is stopped, the client will quit.
| stop_remote_service | python | rsmusllp/king-phisher | king_phisher/client/application.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/application.py | BSD-3-Clause |
def commit(self):
"""Send this object to the server to update the remote instance."""
values = tuple(getattr(self, attr) for attr in self.__slots__[1:])
values = collections.OrderedDict(((k, v) for (k, v) in zip(self.__slots__[1:], values) if v is not UNRESOLVED))
self.__rpc__('db/table/set', self.__table__, se... | Send this object to the server to update the remote instance. | commit | python | rsmusllp/king-phisher | king_phisher/client/client_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/client_rpc.py | BSD-3-Clause |
def async_call(self, method, args=None, kwargs=None, on_success=None, on_error=None, when_idle=False, cb_args=None, cb_kwargs=None):
"""
Perform an asynchronous RPC call to the server. This will queue a work
item for a thread to issue the RPC call and then specifies the behavior
for completion. See :ref:`Asynch... |
Perform an asynchronous RPC call to the server. This will queue a work
item for a thread to issue the RPC call and then specifies the behavior
for completion. See :ref:`Asynchronous Methods
<client-rpc-async-methods>` for more information.
.. versionadded:: 1.14.0
:param str method: The RPC method name t... | async_call | python | rsmusllp/king-phisher | king_phisher/client/client_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/client_rpc.py | BSD-3-Clause |
def async_graphql(self, query, query_vars=None, on_success=None, on_error=None, when_idle=False, cb_args=None, cb_kwargs=None):
"""
Perform an asynchronous RPC GraphQL query to the server. This will queue
a work item for a thread to issue the RPC call and then specifies the
behavior for completion. See :ref:`As... |
Perform an asynchronous RPC GraphQL query to the server. This will queue
a work item for a thread to issue the RPC call and then specifies the
behavior for completion. See :ref:`Asynchronous Methods
<client-rpc-async-methods>` for more information.
.. versionadded:: 1.14.0
:param str query: The GraphQL q... | async_graphql | python | rsmusllp/king-phisher | king_phisher/client/client_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/client_rpc.py | BSD-3-Clause |
def async_graphql_file(self, file_or_path, *args, **kwargs):
"""
Perform an asynchronous RPC GraphQL query from a file on the server.
This will queue a work item for a thread to issue the RPC call and then
specifies the behavior for completion. See :ref:`Asynchronous Methods
<client-rpc-async-methods>` for mo... |
Perform an asynchronous RPC GraphQL query from a file on the server.
This will queue a work item for a thread to issue the RPC call and then
specifies the behavior for completion. See :ref:`Asynchronous Methods
<client-rpc-async-methods>` for more information.
.. versionadded:: 1.14.0
:param file_or_path... | async_graphql_file | python | rsmusllp/king-phisher | king_phisher/client/client_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/client_rpc.py | BSD-3-Clause |
def graphql(self, query, query_vars=None):
"""
Execute a GraphQL query on the server and return the results. This will
raise :py:exc:`~king_phisher.errors.KingPhisherGraphQLQueryError` if
the query fails.
:param str query: The GraphQL query string to execute.
:param query_vars: Any variable definitions req... |
Execute a GraphQL query on the server and return the results. This will
raise :py:exc:`~king_phisher.errors.KingPhisherGraphQLQueryError` if
the query fails.
:param str query: The GraphQL query string to execute.
:param query_vars: Any variable definitions required by the GraphQL
*query*.
:return: The ... | graphql | python | rsmusllp/king-phisher | king_phisher/client/client_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/client_rpc.py | BSD-3-Clause |
def graphql_file(self, file_or_path, query_vars=None):
"""
This method wraps :py:meth:`~.graphql` to provide a convenient way to
execute GraphQL queries from files.
:param file_or_path: The file object or path to the file from which to read.
:param query_vars: The variables for *query*.
:return: The query ... |
This method wraps :py:meth:`~.graphql` to provide a convenient way to
execute GraphQL queries from files.
:param file_or_path: The file object or path to the file from which to read.
:param query_vars: The variables for *query*.
:return: The query results.
:rtype: dict
| graphql_file | python | rsmusllp/king-phisher | king_phisher/client/client_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/client_rpc.py | BSD-3-Clause |
def graphql_find_file(self, query_file, **query_vars):
"""
This method is similar to :py:meth:`~.graphql_file`. The first argument
(*query_file*) is the name of a query file that will be located using
:py:func:`find.data_file`. Additional keyword arguments are passed as
the variables to the query.
:param s... |
This method is similar to :py:meth:`~.graphql_file`. The first argument
(*query_file*) is the name of a query file that will be located using
:py:func:`find.data_file`. Additional keyword arguments are passed as
the variables to the query.
:param str query_file: The name of the query file to locate.
:para... | graphql_find_file | python | rsmusllp/king-phisher | king_phisher/client/client_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/client_rpc.py | BSD-3-Clause |
def remote_row_resolve(self, row):
"""
Take a :py:class:`~.RemoteRow` instance and load all fields which are
:py:data:`~.UNRESOLVED`. If all fields are present, no modifications
are made.
:param row: The row who's data is to be resolved.
:rtype: :py:class:`~.RemoteRow`
:return: The row with all of it's f... |
Take a :py:class:`~.RemoteRow` instance and load all fields which are
:py:data:`~.UNRESOLVED`. If all fields are present, no modifications
are made.
:param row: The row who's data is to be resolved.
:rtype: :py:class:`~.RemoteRow`
:return: The row with all of it's fields fully resolved.
:rtype: :py:clas... | remote_row_resolve | python | rsmusllp/king-phisher | king_phisher/client/client_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/client_rpc.py | BSD-3-Clause |
def remote_table(self, table, query_filter=None):
"""
Iterate over a remote database table hosted on the server. Rows are
yielded as named tuples whose fields are the columns of the specified
table.
:param str table: The table name to retrieve.
:return: A generator which yields rows of named tuples.
:rty... |
Iterate over a remote database table hosted on the server. Rows are
yielded as named tuples whose fields are the columns of the specified
table.
:param str table: The table name to retrieve.
:return: A generator which yields rows of named tuples.
:rtype: tuple
| remote_table | python | rsmusllp/king-phisher | king_phisher/client/client_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/client_rpc.py | BSD-3-Clause |
def remote_table_row(self, table, row_id, cache=False, refresh=False):
"""
Get a row from the specified table by it's id, optionally caching it.
:param str table: The table in which the row exists.
:param row_id: The value of the row's id column.
:param bool cache: Whether to use the cache for this row.
:p... |
Get a row from the specified table by it's id, optionally caching it.
:param str table: The table in which the row exists.
:param row_id: The value of the row's id column.
:param bool cache: Whether to use the cache for this row.
:param bool refresh: If *cache* is True, get the current row value and store i... | remote_table_row | python | rsmusllp/king-phisher | king_phisher/client/client_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/client_rpc.py | BSD-3-Clause |
def geoip_lookup(self, ip):
"""
Look up the geographic location information for the specified IP
address in the server's geoip database.
:param ip: The IP address to lookup.
:type ip: :py:class:`ipaddress.IPv4Address`, str
:return: The geographic location information for the specified IP address.
:rtype:... |
Look up the geographic location information for the specified IP
address in the server's geoip database.
:param ip: The IP address to lookup.
:type ip: :py:class:`ipaddress.IPv4Address`, str
:return: The geographic location information for the specified IP address.
:rtype: :py:class:`~king_phisher.geoip.G... | geoip_lookup | python | rsmusllp/king-phisher | king_phisher/client/client_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/client_rpc.py | BSD-3-Clause |
def geoip_lookup_multi(self, ips):
"""
Look up the geographic location information for the specified IP
addresses in the server's geoip database. Because results are cached
for optimal performance, IP addresses to be queried should be grouped
and sorted in a way that is unlikely to change, i.e. by a timestamp... |
Look up the geographic location information for the specified IP
addresses in the server's geoip database. Because results are cached
for optimal performance, IP addresses to be queried should be grouped
and sorted in a way that is unlikely to change, i.e. by a timestamp.
:param ips: The IP addresses to loo... | geoip_lookup_multi | python | rsmusllp/king-phisher | king_phisher/client/client_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/client_rpc.py | BSD-3-Clause |
def get_tag_model(self, tag_table, model=None):
"""
Load tag information from a remote table into a
:py:class:`Gtk.ListStore` instance. Tables compatible with the tag
interface must have id, name and description fields. If no *model* is
provided a new one will be created, else the current model will be
clea... |
Load tag information from a remote table into a
:py:class:`Gtk.ListStore` instance. Tables compatible with the tag
interface must have id, name and description fields. If no *model* is
provided a new one will be created, else the current model will be
cleared.
:param str tag_table: The name of the table t... | get_tag_model | python | rsmusllp/king-phisher | king_phisher/client/client_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/client_rpc.py | BSD-3-Clause |
def login(self, username, password, otp=None):
"""
Authenticate to the remote server. This is required before calling RPC
methods which require an authenticated session.
:param str username: The username to authenticate with.
:param str password: The password to authenticate with.
:param str otp: An option... |
Authenticate to the remote server. This is required before calling RPC
methods which require an authenticated session.
:param str username: The username to authenticate with.
:param str password: The password to authenticate with.
:param str otp: An optional one time password as a 6 digit string to provide ... | login | python | rsmusllp/king-phisher | king_phisher/client/client_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/client_rpc.py | BSD-3-Clause |
def vte_child_routine(config):
"""
This is the method which is executed within the child process spawned
by VTE. It expects additional values to be set in the *config*
object so it can initialize a new :py:class:`.KingPhisherRPCClient`
instance. It will then drop into an interpreter where the user may directly
in... |
This is the method which is executed within the child process spawned
by VTE. It expects additional values to be set in the *config*
object so it can initialize a new :py:class:`.KingPhisherRPCClient`
instance. It will then drop into an interpreter where the user may directly
interact with the rpc object.
:para... | vte_child_routine | python | rsmusllp/king-phisher | king_phisher/client/client_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/client_rpc.py | BSD-3-Clause |
def convert_value(table_name, key, value):
"""
Perform any conversions necessary to neatly display the data in XML format.
:param str table_name: The table name that the key and value pair are from.
:param str key: The data key.
:param value: The data value to convert.
:return: The converted value.
:rtype: str
... |
Perform any conversions necessary to neatly display the data in XML format.
:param str table_name: The table name that the key and value pair are from.
:param str key: The data key.
:param value: The data value to convert.
:return: The converted value.
:rtype: str
| convert_value | python | rsmusllp/king-phisher | king_phisher/client/export.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/export.py | BSD-3-Clause |
def campaign_to_xml(rpc, campaign_id, xml_file, encoding='utf-8'):
"""
Load all information for a particular campaign and dump it to an XML file.
:param rpc: The connected RPC instance to load the information with.
:type rpc: :py:class:`.KingPhisherRPCClient`
:param campaign_id: The ID of the campaign to load the... |
Load all information for a particular campaign and dump it to an XML file.
:param rpc: The connected RPC instance to load the information with.
:type rpc: :py:class:`.KingPhisherRPCClient`
:param campaign_id: The ID of the campaign to load the information for.
:param str xml_file: The destination file for the XM... | campaign_to_xml | python | rsmusllp/king-phisher | king_phisher/client/export.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/export.py | BSD-3-Clause |
def campaign_credentials_to_msf_txt(rpc, campaign_id, target_file):
"""
Export credentials into a format that can easily be used with Metasploit's
USERPASS_FILE option.
:param rpc: The connected RPC instance to load the information with.
:type rpc: :py:class:`.KingPhisherRPCClient`
:param campaign_id: The ID of ... |
Export credentials into a format that can easily be used with Metasploit's
USERPASS_FILE option.
:param rpc: The connected RPC instance to load the information with.
:type rpc: :py:class:`.KingPhisherRPCClient`
:param campaign_id: The ID of the campaign to load the information for.
:param str target_file: The d... | campaign_credentials_to_msf_txt | python | rsmusllp/king-phisher | king_phisher/client/export.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/export.py | BSD-3-Clause |
def campaign_visits_to_geojson(rpc, campaign_id, geojson_file):
"""
Export the geo location information for all the visits of a campaign into
the `GeoJSON <http://geojson.org/>`_ format.
:param rpc: The connected RPC instance to load the information with.
:type rpc: :py:class:`.KingPhisherRPCClient`
:param campa... |
Export the geo location information for all the visits of a campaign into
the `GeoJSON <http://geojson.org/>`_ format.
:param rpc: The connected RPC instance to load the information with.
:type rpc: :py:class:`.KingPhisherRPCClient`
:param campaign_id: The ID of the campaign to load the information for.
:param ... | campaign_visits_to_geojson | python | rsmusllp/king-phisher | king_phisher/client/export.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/export.py | BSD-3-Clause |
def message_data_from_kpm(target_file, dest_dir, encoding='utf-8'):
"""
Retrieve the stored details describing a message from a previously exported
file.
:param str target_file: The file to load as a message archive.
:param str dest_dir: The directory to extract data and attachment files to.
:param str encoding:... |
Retrieve the stored details describing a message from a previously exported
file.
:param str target_file: The file to load as a message archive.
:param str dest_dir: The directory to extract data and attachment files to.
:param str encoding: The encoding to use for strings.
:return: The restored details from th... | message_data_from_kpm | python | rsmusllp/king-phisher | king_phisher/client/export.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/export.py | BSD-3-Clause |
def message_data_to_kpm(message_config, target_file, encoding='utf-8'):
"""
Save details describing a message to the target file.
:param dict message_config: The message details from the client configuration.
:param str target_file: The file to write the data to.
:param str encoding: The encoding to use for strin... |
Save details describing a message to the target file.
:param dict message_config: The message details from the client configuration.
:param str target_file: The file to write the data to.
:param str encoding: The encoding to use for strings.
| message_data_to_kpm | python | rsmusllp/king-phisher | king_phisher/client/export.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/export.py | BSD-3-Clause |
def liststore_export(store, columns, cb_write, cb_write_args, row_offset=0, write_columns=True):
"""
A function to facilitate writing values from a list store to an arbitrary
callback for exporting to different formats. The callback will be called
with the row number, the column values and the additional arguments
... |
A function to facilitate writing values from a list store to an arbitrary
callback for exporting to different formats. The callback will be called
with the row number, the column values and the additional arguments
specified in *\*cb_write_args*.
.. code-block:: python
cb_write(row, column_values, *cb_write_... | liststore_export | python | rsmusllp/king-phisher | king_phisher/client/export.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/export.py | BSD-3-Clause |
def liststore_to_csv(store, target_file, columns):
"""
Write the contents of a :py:class:`Gtk.ListStore` to a csv file.
:param store: The store to export the information from.
:type store: :py:class:`Gtk.ListStore`
:param str target_file: The destination file for the CSV data.
:param dict columns: A dictionary m... |
Write the contents of a :py:class:`Gtk.ListStore` to a csv file.
:param store: The store to export the information from.
:type store: :py:class:`Gtk.ListStore`
:param str target_file: The destination file for the CSV data.
:param dict columns: A dictionary mapping store column ids to the value names.
:return: T... | liststore_to_csv | python | rsmusllp/king-phisher | king_phisher/client/export.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/export.py | BSD-3-Clause |
def liststore_to_xlsx_worksheet(store, worksheet, columns, title_format, xlsx_options=None):
"""
Write the contents of a :py:class:`Gtk.ListStore` to an XLSX worksheet.
:param store: The store to export the information from.
:type store: :py:class:`Gtk.ListStore`
:param worksheet: The destination sheet for the st... |
Write the contents of a :py:class:`Gtk.ListStore` to an XLSX worksheet.
:param store: The store to export the information from.
:type store: :py:class:`Gtk.ListStore`
:param worksheet: The destination sheet for the store's data.
:type worksheet: :py:class:`xlsxwriter.worksheet.Worksheet`
:param dict columns: A ... | liststore_to_xlsx_worksheet | python | rsmusllp/king-phisher | king_phisher/client/export.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/export.py | BSD-3-Clause |
def export_graph_provider(cls):
"""
Decorator to mark classes as valid graph providers. This decorator also sets
the :py:attr:`~.CampaignGraph.name` attribute.
:param class cls: The class to mark as a graph provider.
:return: The *cls* parameter is returned.
"""
if not issubclass(cls, CampaignGraph):
raise Ru... |
Decorator to mark classes as valid graph providers. This decorator also sets
the :py:attr:`~.CampaignGraph.name` attribute.
:param class cls: The class to mark as a graph provider.
:return: The *cls* parameter is returned.
| export_graph_provider | python | rsmusllp/king-phisher | king_phisher/client/graphs.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/graphs.py | BSD-3-Clause |
def __init__(self, application, size_request=None, style_context=None):
"""
:param tuple size_request: The size to set for the canvas.
"""
self.logger = logging.getLogger('KingPhisher.Client.Graph.' + self.__class__.__name__[13:])
self.application = application
self.style_context = style_context
self.conf... |
:param tuple size_request: The size to set for the canvas.
| __init__ | python | rsmusllp/king-phisher | king_phisher/client/graphs.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/graphs.py | BSD-3-Clause |
def get_color(self, color_name, default):
"""
Get a color by its style name such as 'fg' for foreground. If the
specified color does not exist, default will be returned. The underlying
logic for this function is provided by
:py:func:`~.gui_utilities.gtk_style_context_get_color`.
:param str color_name: The ... |
Get a color by its style name such as 'fg' for foreground. If the
specified color does not exist, default will be returned. The underlying
logic for this function is provided by
:py:func:`~.gui_utilities.gtk_style_context_get_color`.
:param str color_name: The style name of the color.
:param default: The ... | get_color | python | rsmusllp/king-phisher | king_phisher/client/graphs.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/graphs.py | BSD-3-Clause |
def make_window(self):
"""
Create a window from the figure manager.
:return: The graph in a new, dedicated window.
:rtype: :py:class:`Gtk.Window`
"""
if self.manager is None:
self.manager = FigureManager(self.canvas, 0)
self.navigation_toolbar.destroy()
self.navigation_toolbar = self.manager.toolbar... |
Create a window from the figure manager.
:return: The graph in a new, dedicated window.
:rtype: :py:class:`Gtk.Window`
| make_window | python | rsmusllp/king-phisher | king_phisher/client/graphs.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/graphs.py | BSD-3-Clause |
def resize(self, width=0, height=0):
"""
Attempt to resize the canvas. Regardless of the parameters the canvas
will never be resized to be smaller than :py:attr:`.minimum_size`.
:param int width: The desired width of the canvas.
:param int height: The desired height of the canvas.
"""
min_width, min_heig... |
Attempt to resize the canvas. Regardless of the parameters the canvas
will never be resized to be smaller than :py:attr:`.minimum_size`.
:param int width: The desired width of the canvas.
:param int height: The desired height of the canvas.
| resize | python | rsmusllp/king-phisher | king_phisher/client/graphs.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/graphs.py | BSD-3-Clause |
def refresh(self, info_cache=None, stop_event=None):
"""
Refresh the graph data by retrieving the information from the
remote server.
:param dict info_cache: An optional cache of data tables.
:param stop_event: An optional object indicating that the operation should stop.
:type stop_event: :py:class:`threa... |
Refresh the graph data by retrieving the information from the
remote server.
:param dict info_cache: An optional cache of data tables.
:param stop_event: An optional object indicating that the operation should stop.
:type stop_event: :py:class:`threading.Event`
:return: A dictionary of cached tables from ... | refresh | python | rsmusllp/king-phisher | king_phisher/client/graphs.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/graphs.py | BSD-3-Clause |
def _barh_stacked(self, ax, bars, bar_colors, height):
"""
:param ax: This axis to use for the graph.
:param tuple bars: A two dimensional array of bars, and their respective stack sizes.
:param tuple bar_colors: A one dimensional array of colors for each of the stacks.
:param float height: The height of the ... |
:param ax: This axis to use for the graph.
:param tuple bars: A two dimensional array of bars, and their respective stack sizes.
:param tuple bar_colors: A one dimensional array of colors for each of the stacks.
:param float height: The height of the bars.
:return:
| _barh_stacked | python | rsmusllp/king-phisher | king_phisher/client/graphs.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/graphs.py | BSD-3-Clause |
def graph_bar(self, bars, yticklabels, xlabel=None):
"""
Create a horizontal bar graph with better defaults for the standard use
cases.
:param list bars: The values of the bars to graph.
:param list yticklabels: The labels to use on the x-axis.
:param str xlabel: The label to give to the y-axis.
:return:... |
Create a horizontal bar graph with better defaults for the standard use
cases.
:param list bars: The values of the bars to graph.
:param list yticklabels: The labels to use on the x-axis.
:param str xlabel: The label to give to the y-axis.
:return: The bars created using :py:mod:`matplotlib`
:rtype: `ma... | graph_bar | python | rsmusllp/king-phisher | king_phisher/client/graphs.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/graphs.py | BSD-3-Clause |
def load_graph(self, campaigns):
"""
Load the information to compare the specified and paint it to the
canvas. Campaigns are graphed on the X-axis in the order that they are
provided. No sorting of campaigns is done by this method.
:param tuple campaigns: A tuple containing campaign IDs to compare.
"""
a... |
Load the information to compare the specified and paint it to the
canvas. Campaigns are graphed on the X-axis in the order that they are
provided. No sorting of campaigns is done by this method.
:param tuple campaigns: A tuple containing campaign IDs to compare.
| load_graph | python | rsmusllp/king-phisher | king_phisher/client/graphs.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/graphs.py | BSD-3-Clause |
def _cmp(item1, item2):
"""
Compare two arbitrary Python objects. The object types should either be the
same or one or both may be ``None``.
:rtype: int
:return: ``-1`` if *item1* is less than *item2*, ``0`` if they are equal or
``1`` if *item1* is greater than *item2*.
"""
if item1 is None:
return 0 if ite... |
Compare two arbitrary Python objects. The object types should either be the
same or one or both may be ``None``.
:rtype: int
:return: ``-1`` if *item1* is less than *item2*, ``0`` if they are equal or
``1`` if *item1* is greater than *item2*.
| _cmp | python | rsmusllp/king-phisher | king_phisher/client/gui_utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/gui_utilities.py | BSD-3-Clause |
def glib_idle_add_store_extend(store, things, clear=False, wait=False):
"""
Extend a GTK store object (either :py:class:`Gtk.ListStore` or
:py:class:`Gtk.TreeStore`) object using :py:func:`GLib.idle_add`. This
function is suitable for use in non-main GUI threads for synchronizing data.
:param store: The GTK stora... |
Extend a GTK store object (either :py:class:`Gtk.ListStore` or
:py:class:`Gtk.TreeStore`) object using :py:func:`GLib.idle_add`. This
function is suitable for use in non-main GUI threads for synchronizing data.
:param store: The GTK storage object to add *things* to.
:type store: :py:class:`Gtk.ListStore`, :py:c... | glib_idle_add_store_extend | python | rsmusllp/king-phisher | king_phisher/client/gui_utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/gui_utilities.py | BSD-3-Clause |
def glib_idle_add_once(function, *args, **kwargs):
"""
Execute *function* in the main GTK loop using :py:func:`GLib.idle_add`
one time. This is useful for threads that need to update GUI data.
:param function function: The function to call.
:param args: The positional arguments to *function*.
:param kwargs: The ... |
Execute *function* in the main GTK loop using :py:func:`GLib.idle_add`
one time. This is useful for threads that need to update GUI data.
:param function function: The function to call.
:param args: The positional arguments to *function*.
:param kwargs: The key word arguments to *function*.
:return: The result ... | glib_idle_add_once | python | rsmusllp/king-phisher | king_phisher/client/gui_utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/gui_utilities.py | BSD-3-Clause |
def glib_idle_add_wait(function, *args, **kwargs):
"""
Execute *function* in the main GTK loop using :py:func:`GLib.idle_add`
and block until it has completed. This is useful for threads that need
to update GUI data.
:param function function: The function to call.
:param args: The positional arguments to *functi... |
Execute *function* in the main GTK loop using :py:func:`GLib.idle_add`
and block until it has completed. This is useful for threads that need
to update GUI data.
:param function function: The function to call.
:param args: The positional arguments to *function*.
:param kwargs: The key word arguments to *functio... | glib_idle_add_wait | python | rsmusllp/king-phisher | king_phisher/client/gui_utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/gui_utilities.py | BSD-3-Clause |
def gobject_get_value(gobject, gtype=None):
"""
Retrieve the value of a GObject widget. Only objects with corresponding
entries present in the :py:data:`.GOBJECT_PROPERTY_MAP` can be processed by
this function.
:param gobject: The object to retrieve the value for.
:type gobject: :py:class:`GObject.Object`
:para... |
Retrieve the value of a GObject widget. Only objects with corresponding
entries present in the :py:data:`.GOBJECT_PROPERTY_MAP` can be processed by
this function.
:param gobject: The object to retrieve the value for.
:type gobject: :py:class:`GObject.Object`
:param str gtype: An explicit type to treat *gobject*... | gobject_get_value | python | rsmusllp/king-phisher | king_phisher/client/gui_utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/gui_utilities.py | BSD-3-Clause |
def gobject_set_value(gobject, value, gtype=None):
"""
Set the value of a GObject widget. Only objects with corresponding entries
present in the :py:data:`.GOBJECT_PROPERTY_MAP` can be processed by this
function.
:param gobject: The object to set the value for.
:type gobject: :py:class:`GObject.Object`
:param v... |
Set the value of a GObject widget. Only objects with corresponding entries
present in the :py:data:`.GOBJECT_PROPERTY_MAP` can be processed by this
function.
:param gobject: The object to set the value for.
:type gobject: :py:class:`GObject.Object`
:param value: The value to set for the object.
:param str gtyp... | gobject_set_value | python | rsmusllp/king-phisher | king_phisher/client/gui_utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/gui_utilities.py | BSD-3-Clause |
def gobject_signal_blocked(gobject, signal_name):
"""
This is a context manager that can be used with the 'with' statement
to execute a block of code while *signal_name* is blocked.
:param gobject: The object to block the signal on.
:type gobject: :py:class:`GObject.Object`
:param str signal_name: The name of th... |
This is a context manager that can be used with the 'with' statement
to execute a block of code while *signal_name* is blocked.
:param gobject: The object to block the signal on.
:type gobject: :py:class:`GObject.Object`
:param str signal_name: The name of the signal to block.
| gobject_signal_blocked | python | rsmusllp/king-phisher | king_phisher/client/gui_utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/gui_utilities.py | BSD-3-Clause |
def gobject_signal_accumulator(test=None):
"""
Create an accumulator function for use with GObject signals. All return
values will be collected and returned in a list. If provided, *test* is a
callback that will be called with two arguments, the return value from the
handler and the list of accumulated return valu... |
Create an accumulator function for use with GObject signals. All return
values will be collected and returned in a list. If provided, *test* is a
callback that will be called with two arguments, the return value from the
handler and the list of accumulated return values.
.. code-block:: python
stop = test(re... | gobject_signal_accumulator | python | rsmusllp/king-phisher | king_phisher/client/gui_utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/gui_utilities.py | BSD-3-Clause |
def gtk_calendar_get_pydate(gtk_calendar):
"""
Get the Python date from a :py:class:`Gtk.Calendar` instance. If the day
in *gtk_calendar* is not within the valid range for the specified month, it
will be rounded to the closest value (i.e. 0 for unset will become 1 etc.).
:param gtk_calendar: The calendar to get t... |
Get the Python date from a :py:class:`Gtk.Calendar` instance. If the day
in *gtk_calendar* is not within the valid range for the specified month, it
will be rounded to the closest value (i.e. 0 for unset will become 1 etc.).
:param gtk_calendar: The calendar to get the date from.
:type gtk_calendar: :py:class:`G... | gtk_calendar_get_pydate | python | rsmusllp/king-phisher | king_phisher/client/gui_utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/gui_utilities.py | BSD-3-Clause |
def gtk_combobox_get_active_cell(combobox, column=None):
"""
Get the active value from a GTK combobox and it's respective model. If
nothing is selected, ``None`` is returned.
.. versionadded:: 1.14.0
:param combobox: The combobox to retrieve the active model value for.
:param int column: The column ID to retrie... |
Get the active value from a GTK combobox and it's respective model. If
nothing is selected, ``None`` is returned.
.. versionadded:: 1.14.0
:param combobox: The combobox to retrieve the active model value for.
:param int column: The column ID to retrieve from the selected row. If not
specified, the combobox's ... | gtk_combobox_get_active_cell | python | rsmusllp/king-phisher | king_phisher/client/gui_utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/gui_utilities.py | BSD-3-Clause |
def gtk_combobox_get_active_row(combobox):
"""
Get the active row from a GTK combobox and it's respective model. If
nothing is selected, ``None`` is returned.
.. versionadded:: 1.14.0
:param combobox: The combobox to retrieve the active model row for.
:return: The selected model row.
"""
active = combobox.get... |
Get the active row from a GTK combobox and it's respective model. If
nothing is selected, ``None`` is returned.
.. versionadded:: 1.14.0
:param combobox: The combobox to retrieve the active model row for.
:return: The selected model row.
| gtk_combobox_get_active_row | python | rsmusllp/king-phisher | king_phisher/client/gui_utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/gui_utilities.py | BSD-3-Clause |
def gtk_combobox_get_entry_text(combobox):
"""
Get the text from a combobox's entry widget.
.. versionadded:: 1.14.0
:param combobox: The combobox to retrieve the entry text for.
:return: The value of the entry text.
:rtype: str
"""
if not combobox.get_has_entry():
raise ValueError('the specified combobox d... |
Get the text from a combobox's entry widget.
.. versionadded:: 1.14.0
:param combobox: The combobox to retrieve the entry text for.
:return: The value of the entry text.
:rtype: str
| gtk_combobox_get_entry_text | python | rsmusllp/king-phisher | king_phisher/client/gui_utilities.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/client/gui_utilities.py | BSD-3-Clause |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.