windows.base_objects

This Model Component provides some base objects that are often needed for Windows Model Components. Notably, this provides PowershellScheduleEntry which helps run PowerShell scripts on a VM.

The following VM resources are provided with this model component:

  1. add_remote_desktop_user.bat - Adds a user to the Remote Desktop Users group.

  2. autologon.ps1 - Configures autologon for a specified user.

  3. change_password.ps1 - Changes the password for a specified user.

  4. check_email.ps1 - Checks email using the EWS Managed API.

  5. cleanup.ps1 - Cleans up files in the C:\\launch directory (which are put there by FIREWHEEL).

  6. configure_ips.ps1 - Configures IP addresses on the Windows host.

  7. create_smb_share.ps1 - Creates an SMB share on the Windows host.

  8. disable_smbv1.ps1 - Disables SMBv1 on the Windows host.

  9. enable_file_sharing.ps1 - Enables file sharing on the Windows host.

  10. enable_rdp.ps1 - Enables Remote Desktop Protocol (RDP) on the Windows host.

  11. grant_smb_access.ps1 - Grants access to an SMB share on the Windows host.

  12. manage_network_share.ps1 - Manages a network share on the Windows host.

  13. rearm_windows.ps1 - Rearms the Windows activation.

  14. remove_autologon.ps1 - Removes autologon configuration from the Windows host.

  15. run_smb_gen.ps1 - Registers and modifies a scheduled task to generate SMB traffic.

  16. run_task.ps1 - Starts a scheduled task.

  17. set_hostname.ps1 - Sets the hostname of the Windows host.

  18. smb_traffic_gen.ps1 - Generates SMB traffic on the Windows host.

  19. wget.ps1 - Downloads a file using wget on the Windows host.

Model Component Dependencies:

Available Objects

class windows.base_objects.PowershellScheduleEntry(start_time, powershell_script, arguments=None, batch=False)[source]

Bases: ScheduleEntry

This class creates a Powershell Schedule Entry. This helps run Powershell scripts on various versions of Windows.

__annotate_func__ = None
__annotations_cache__ = {}
__firstlineno__ = 381
__init__(start_time, powershell_script, arguments=None, batch=False)[source]

Initialization for a PowershellScheduleEntry.

Parameters:
  • start_time (int) – The time at which to run the script.

  • powershell_script (str) – The name of the PowerShell script to run.

  • arguments (str or list, optional) – Any arguments to provide to the script. Default is None.

  • batch (bool) – Whether or not the default shell is batch and needs to be wrapped to run as PowerShell. Default is False.

Raises:

TypeError – If the arguments are not a string nor a list.

__static_attributes__ = ()
add_dynamic_content(target_filename, content, ps_parameter=None)[source]

Adds dynamic content to the PowerShell schedule entry.

Parameters:
  • target_filename (str) – The target filename for the content.

  • content (str) – The content to add.

  • ps_parameter (str, optional) – The PowerShell parameter for the content. Default is None.

class windows.base_objects.WindowsHost(*args, **kwargs)[source]

Bases: object

This class provides functionality that is common to most Windows hosts, regardless of the version.

__annotate_func__ = None
__annotations_cache__ = {}
__firstlineno__ = 8
__init__(*args, **kwargs)
__static_attributes__ = ('name', 'type', 'windows_domain')
add_ews()[source]

Adds the EWS Managed API to the Windows host.

add_remote_desktop_user(start_time, username)[source]

Adds a user to the Remote Desktop Users group on the Windows host.

Parameters:
  • start_time (int) – The time at which to run the script.

  • username (str) – The username to add.

add_sysinternals(start_time)[source]

Adds Sysinternals tools to the Windows host.

Parameters:

start_time (int) – The time at which to run the script.

autologon(start_time, username, password, domain=None)[source]

Configures autologon for the Windows host.

Parameters:
  • start_time (int) – The time at which to run the script.

  • username (str) – The username for autologon.

  • password (str) – The password for autologon.

  • domain (str, optional) – The domain for autologon. Default is None.

change_password(start_time, username, password)[source]

Changes the password for a user on the Windows host.

Parameters:
  • start_time (int) – The time at which to run the script.

  • username (str) – The username for which to change the password.

  • password (str) – The new password.

check_email(username, password, domain, mailbox, smtp, click_rate, trusted_sender)[source]

Checks email using the Exchange Web Service (EWS) Managed API.

Parameters:
  • username (str) – The username for email access.

  • password (str) – The password for email access.

  • domain (str) – The domain for email access.

  • mailbox (str) – The mailbox to check.

  • smtp (str) – The SMTP server address.

  • click_rate (int) – The click rate for email checking.

  • trusted_sender (str) – The trusted sender address.

cleanup(start_time=1)[source]

Cleans up the Windows host.

Parameters:

start_time (int) – The time at which to run the script. Default is 1.

configure_ips(start_time=-200)[source]

Configures IP addresses on the Windows host.

Parameters:

start_time (int) – The time at which to run the script. Default is -200.

Returns:

True if IP addresses were configured, False otherwise.

Return type:

bool

create_smb_share(start_time, name, path, caching_mode, folder_enumeration_mode, full_access)[source]

Creates a Server Message Block (SMB) share on the Windows host.

Parameters:
  • start_time (int) – The time at which to run the script.

  • name (str) – The name of the SMB share.

  • path (str) – The path of the SMB share.

  • caching_mode (str) – The caching mode for the SMB share.

  • folder_enumeration_mode (str) – The folder enumeration mode for the SMB share.

  • full_access (str) – The full access permissions for the SMB share.

disable_smbv1(start_time=-99)[source]

Disables SMBv1 on the Windows host.

Parameters:

start_time (int) – The time at which to run the script. Default is -99.

enable_file_sharing(start_time=-10)[source]

Enables file sharing on the Windows host.

Parameters:

start_time (int) – The time at which to run the script. Default is -10.

enable_rdp(start_time)[source]

Enables Remote Desktop Protocol (RDP) on the Windows host.

Parameters:

start_time (int) – The time at which to run the script.

grant_smb_access(start_time, name, account)[source]

Grants access to an SMB share on the Windows host.

Parameters:
  • start_time (int) – The time at which to run the script.

  • name (str) – The name of the SMB share.

  • account (str) – The account to grant access to.

join_domain(domain_id, domain_name, dns=None)[source]

Joins the Windows host to a domain.

Parameters:
  • domain_id (str) – The domain ID.

  • domain_name (str) – The domain name.

  • dns (str, optional) – The DNS server address. Default is None.

manage_network_share(start_time, share, max_files)[source]

Manages a network share on the Windows host.

Parameters:
  • start_time (int) – The time at which to run the script.

  • share (str) – The network share to manage.

  • max_files (int) – The maximum number of files to manage.

rearm_windows(start_time=-1000)[source]

Rearms the Windows activation.

Parameters:

start_time (int) – The time at which to run the script. Default is -1000.

remove_autologon(start_time)[source]

Removes autologon configuration from the Windows host.

Parameters:

start_time (int) – The time at which to run the script.

run_powershell(start_time, script_name, arguments=None)[source]

Creates a PowershellScheduleEntry.

Parameters:
  • start_time (int) – The time at which to run the script.

  • script_name (str) – The name of the PowerShell script to run.

  • arguments (str or list, optional) – Any arguments to provide to the script. Default is None.

Returns:

The created PowerShell schedule entry.

Return type:

PowershellScheduleEntry

set_hostname(start_time=-250)[source]

Sets the hostname of the Windows host.

Parameters:

start_time (int) – The time at which to run the script. Default is -250.

smb_traffic_gen(start_time, share, username, password)[source]

Generates SMB traffic on the Windows host.

Parameters:
  • start_time (int) – The time at which to run the script.

  • share (str) – The SMB share to use.

  • username (str) – The username for SMB access.

  • password (str) – The password for SMB access.

sysprep(start_time=-10000)[source]

Runs the Sysprep tool on the Windows host.

Parameters:

start_time (int) – The time at which to run the script. Default is -10000.

wget(start_time, address, href_filter=None)[source]

Downloads a file using wget on the Windows host.

Parameters:
  • start_time (int) – The time at which to run the script.

  • address (str) – The URL to download.

  • href_filter (str, optional) – A filter for the href attribute. Default is None.