1.1.14. web_cloner

This module contains the functionality used by the client to clone web pages.

1.1.14.1. Classes

class ClonedResourceDetails[source]

A named tuple which contains details regard a resource that has been cloned.

resource[source]

The web resource that has been cloned.

mime_type[source]

The MIME type that was provided by the server for the cloned resource.

size[source]

The size of the original resource that was provided by the server.

file_name[source]

The path to the file which the resource was written to.

class WebPageCloner(target_url, dest_dir)[source]

Bases: object

This object is used to clone web pages. It will use the WebKit2GTK+ engine and hook signals to detect what remote resources that are loaded from the target URL. These resources are then written to disk. Resources that have a MIME type of text/html have the King Phisher server javascript file patched in..

__init__(target_url, dest_dir)[source]
Parameters:
  • target_url (str) – The URL of the target web page to clone.
  • dest_dir (str) – The path of a directory to write the resources to.
cloned_resources = None[source]

A collections.OrderedDict instance of ClonedResourceDetails keyed by the web resource they describe.

copy_resource_data(resource, data)[source]

Copy the data from a loaded resource to a local file.

Parameters:
  • resource (WebKit2.WebResource) – The resource whose data is being copied.
  • data (bytes, str) – The raw data of the represented resource.
patch_html(data, encoding='utf-8')[source]

Patch the HTML data to include the King Phisher javascript resource. The script tag is inserted just before the closing head tag. If no head tag is present, the data is left unmodified.

Parameters:data (str) – The HTML data to patch.
Returns:The patched HTML data.
Return type:str
resource_is_on_target(resource)[source]

Test whether the resource is on the target system. This tries to match the hostname, scheme and port number of the resource’s URI against the target URI.

Returns:Whether the resource is on the target or not.
Return type:bool
stop_cloning()[source]

Stop the current cloning operation if it is running.

wait()[source]

Wait for the cloning operation to complete and return whether the operation was successful or not.

Returns:True if the operation was successful.
Return type:bool