pyplugins.actuation.fetch_web module

FetchWeb Plugin (fetch_web.py) for Penguin

This module provides the FetchWeb plugin, which automatically fetches web pages from guest services exposed to the host (typically on ports 80 and 443) via the VPN plugin. It listens for ‘on_bind’ events published by the VPN plugin and attempts to retrieve web content from the corresponding host ports. The plugin is responsible for:

  • Subscribing to VPN ‘on_bind’ events to detect new web services exposed to the host.

  • Enqueuing fetch tasks for HTTP/HTTPS ports (80, 443) and processing them in a worker thread.

  • Fetching web content using wget and logging the response size and entropy.

  • Optionally shutting down the emulation after a successful fetch or after failure, based on arguments.

Arguments

  • outdir (str): Output directory for storing fetched web content.

  • shutdown_after_www (bool, optional): If True, shut down emulation after a successful fetch.

  • shutdown_on_failure (bool, optional): If True, shut down emulation if no responsive servers are found.

Plugin Interface

  • Subscribes to the VPN plugin’s ‘on_bind’ event to trigger web fetches.

  • Does not provide a direct interface for other plugins, but writes fetched content to files in the output directory.

Overall Purpose

The FetchWeb plugin automates the retrieval and analysis of web content from guest services exposed to the host, aiding in service validation and content inspection during emulation.

class pyplugins.actuation.fetch_web.FetchWeb[source]

Bases: Plugin

fetch(guest_ip, host_ip, guest_port, host_port, log_file_name)[source]

Fetch web content from the specified host port and log the response.

Args:

guest_ip (str): Guest IP address. host_ip (str): Host IP address. guest_port (int): Guest port. host_port (int): Host port. log_file_name (str): Path to the file for storing fetched content.

Returns:

bool: True if fetch was successful, False otherwise.

Parameters:
  • guest_ip (str)

  • host_ip (str)

  • guest_port (int)

  • host_port (int)

  • log_file_name (str)

Return type:

bool

fetchweb_on_bind(proto, guest_ip, guest_port, host_port, host_ip, procname)[source]

Handle a new bind event from the VPN plugin and enqueue a fetch task for web ports.

Args:

proto (str): Protocol (e.g., ‘tcp’). guest_ip (str): Guest IP address. guest_port (int): Guest port. host_port (int): Host port mapped to the guest service. host_ip (str): Host IP address. procname (str): Name of the process binding the port.

Parameters:
  • proto (str)

  • guest_ip (str)

  • guest_port (int)

  • host_port (int)

  • host_ip (str)

  • procname (str)

Return type:

None

worker()[source]

Worker thread that processes fetch tasks from the queue.

Return type:

None

pyplugins.actuation.fetch_web.calculate_entropy(buffer)[source]

Calculate the Shannon entropy of a byte buffer.

Args:

buffer (bytes): The data buffer to analyze.

Returns:

float: The calculated entropy value.

Parameters:

buffer (bytes)

Return type:

float