fortrace.utility package

Subpackages

Submodules

fortrace.utility.create_volatility_profile module

fortrace.utility.distribution_constants module

class fortrace.utility.distribution_constants.DesktopEnvironmentType(*values)[source]

Bases: Enum

Desktop environment types.

Budgie = 1
Cinnamon = 2
Cutefish = 3
Deepin_Desktop_Environment = 4
Enlightenment = 5
GNOME = 6
KDE_Plasma = 7
LXDE = 8
LXQt = 9
MATE = 10
Sugar = 11
UKUI = 12
Windows_10 = 14
Windows_11 = 15
Xfce = 13
class fortrace.utility.distribution_constants.Distribution(*values)[source]

Bases: Enum

Linux distributions.

ARCH = 3
DEBIAN = 2
OpenSUSE = 4
UBUNTU = 1
class fortrace.utility.distribution_constants.OSType(*values)[source]

Bases: Enum

Operating System types.

LINUX = 2
MACOS = 1
WINDOWS = 3
class fortrace.utility.distribution_constants.PackageManager(*values)[source]

Bases: Enum

Collection of possible package managers.

APT = 1
CHOCO = 9
DNF = 2
DPKG = 3
FINK = 12
HOMEBREW = 13
MACPORTS = 14
NUGET = 10
PACMAN = 4
PORTAGE = 5
RPM = 6
WINGET = 11
YUM = 7
ZYPPER = 8
class fortrace.utility.distribution_constants.ShellType(*values)[source]

Bases: Enum

Shell types.

BASH = 1
POWERSHELL = 3
ZSH = 2

fortrace.utility.exceptions module

ForTrace specific exceptions.

exception fortrace.utility.exceptions.ConfigurationError(*args)[source]

Bases: ForTraceException

Configuration-specific exception

exception fortrace.utility.exceptions.DesktopEnvironmentException(*args)[source]

Bases: ForTraceException

To be thrown from desktop environment, if something unpredicted has happened.

exception fortrace.utility.exceptions.DomainException(*args)[source]

Bases: ForTraceException

To be thrown when something cannot be done with a domain

exception fortrace.utility.exceptions.ForTraceException(*args)[source]

Bases: Exception

Generic ForTrace specific exception, to help differentiate from other exceptions. All other custom exceptions have to inherit this class.

exception fortrace.utility.exceptions.GeneratorException(*args)[source]

Bases: ForTraceException

To be thrown from the Generator

exception fortrace.utility.exceptions.MultiStageAttackException(*args)[source]

Bases: ForTraceException

Multi-stage attack exception, thrown when something is not working during an attack

exception fortrace.utility.exceptions.ServerInteractionException(*args)[source]

Bases: ForTraceException

Server interaction exception, thrown when interaction with server encounters an issue

exception fortrace.utility.exceptions.SetupException(*args)[source]

Bases: ForTraceException

To be thrown if something unexpected happens during a setup process

fortrace.utility.file_generator module

fortrace.utility.logger_helper module

class fortrace.utility.logger_helper.CustomFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]

Bases: Formatter

CustomFormatter, providing colorful output to the console.

FORMATS = {10: '\x1b[38;20m[%(threadName)16s] :: %(asctime)s - %(levelname)-8s - %(message)s\x1b[0m', 20: '\x1b[38;20m[%(threadName)16s] :: %(asctime)s - %(levelname)-8s - %(message)s\x1b[0m', 30: '\x1b[33;20m[%(threadName)16s] :: %(asctime)s - %(levelname)-8s - %(message)s\x1b[0m', 40: '\x1b[31;20m[%(threadName)16s] :: %(asctime)s - %(levelname)-8s - %(message)s\x1b[0m', 50: '\x1b[31;1m[%(threadName)16s] :: %(asctime)s - %(levelname)-8s - %(message)s\x1b[0m'}
bold_red = '\x1b[31;1m'
format(record)[source]

Format the specified record as text.

The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.

grey = '\x1b[38;20m'
log_msg_format = '[%(threadName)16s] :: %(asctime)s - %(levelname)-8s - %(message)s'
red = '\x1b[31;20m'
reset = '\x1b[0m'
yellow = '\x1b[33;20m'
fortrace.utility.logger_helper.setup_logger(name: str) Logger[source]

Create a logger with the specified name.

Please refer to https://docs.python.org/3/howto/logging-cookbook.html for more information. Especially relevant is https://docs.python.org/3/howto/logging-cookbook.html#patterns-to-avoid

Parameters:

name – name of the logger to be created. Should be __name__ in most cases

Returns:

a new logger instance

fortrace.utility.server_setup module

class fortrace.utility.server_setup.LinuxServerSetup(server: VirshDomain, config: dict)[source]

Bases: ServerSetup

Handle Linux server setup.

class fortrace.utility.server_setup.ServerSetup(server: VirshDomain, config: dict)[source]

Bases: ABC

Interface to handle setup of servers participating on the scenario.

setup()[source]

Method to be called from a SimulationMonitor.

Registers all users, sets up all services and stars them.

class fortrace.utility.server_setup.WindowsServerSetup(server: VirshDomain, config: dict)[source]

Bases: ServerSetup

Class to handle Windows Server setup.

fortrace.utility.string_filtering module

fortrace.utility.string_filtering.ansi_escape(string: str) str[source]

Strips all ANSI escape characters of the provided string.

Parameters:

string – string to be stripped of ansi characters

Returns:

stripped string

fortrace.utility.string_filtering.unicode_control_escape(string: str) str[source]

Escape all control characters of a unicode string.

References

https://stackoverflow.com/questions/4324790/removing-control-characters-from-a-string-in-python

Parameters:

string – string to be stripped of unicode control characters

Returns:

stripped string

fortrace.utility.usb_drive module

fortrace.utility.web_scraper module

fortrace.utility.web_scraper.scrape_web_page(url: str | Url, element: Literal['a', 'img']) list[Url][source]

Scrape a web page for all urls behind certain elements.

Parameters:
  • url – the web page to be scraped

  • element – which kind of element links should be scraped from the page

Returns:

list of all urls from the web page (relative ones will be made absolute)

Module contents

A package full of utilities (i.e. ipaddr, macAddr, exceptions..)