Module refinery.lib.scripts.win32const
Default Windows environment variables and programs for script emulation.
Expand source code Browse git
"""
Default Windows environment variables and programs for script emulation.
"""
from __future__ import annotations
from uuid import uuid4
DEFAULT_ENVIRONMENT_TEMPLATE = {
'AllUsersProfile' : r'C:\ProgramData',
'AppData' : r'C:\Users\{u}\AppData\Roaming',
'CommonProgramFiles' : r'C:\Program Files\Common Files',
'CommonProgramFiles(x86)' : r'C:\Program Files (x86)\Common Files',
'CommonProgramW6432' : r'C:\Program Files\Common Files',
'ComputerName' : r'{h}',
'ComSpec' : r'C:\WINDOWS\system32\cmd.exe',
'DriverData' : r'C:\Windows\System32\Drivers\DriverData',
'HomeDrive' : r'C:',
'HomePath' : r'\Users\{u}',
'LocalAppData' : r'C:\Users\{u}\AppData\Local',
'LogonServer' : r'\\{h}',
'NumberOfProcessors' : r'16',
'OneDrive' : r'C:\Users\{u}\OneDrive',
'OS' : r'Windows_NT',
'Path' : ';'.join(
[
'C:\\Windows\\System32',
'C:\\Windows',
'C:\\Windows\\System32\\Wbem',
'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\',
'C:\\Windows\\System32\\OpenSSH\\',
'C:\\Program Files\\dotnet\\',
]
),
'PathExt' : r'.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC',
'ProcessorArchitecture' : r'AMD64',
'ProcessorIdentifier' : r'Intel64 Family 6 Model 158 Stepping 10, GenuineIntel',
'ProcessorLevel' : r'6',
'ProcessorRevision' : r'99ff',
'ProgramData' : r'C:\ProgramData',
'ProgramFiles' : r'C:\Program Files',
'ProgramFiles(x86)' : r'C:\Program Files (x86)',
'ProgramW6432' : r'C:\Program Files',
'Public' : r'C:\Users\Public',
'SessionName' : r'Console',
'SystemDrive' : r'C:',
'SystemRoot' : r'C:\WINDOWS',
'Temp' : r'C:\Users\{u}\AppData\Local\Temp',
'Tmp' : r'C:\Users\{u}\AppData\Local\Temp',
'UserDomain' : r'{h}',
'UserDomainRoamingProfile' : r'{h}',
'UserName' : r'{u}',
'UserProfile' : r'C:\Users\{u}',
'WinDir' : r'C:\WINDOWS',
}
DEFAULT_PROGRAMS: dict[str, tuple[str, ...]] = {
'C:\\Windows\\System32': (
'ARP.EXE',
'at.exe',
'AtBroker.exe',
'attrib.exe',
'bcdedit.exe',
'bitsadmin.exe',
'cacls.exe',
'certutil.exe',
'CHCP.COM',
'chkdsk.exe',
'chkntfs.exe',
'choice.exe',
'cipher.exe',
'clip.exe',
'cmd.exe',
'cmstp.exe',
'comp.exe',
'compact.exe',
'conhost.exe',
'control.exe',
'convert.exe',
'cscript.exe',
'curl.exe',
'defrag.exe',
'diskpart.exe',
'diskshadow.exe',
'doskey.exe',
'driverquery.exe',
'esentutl.exe',
'expand.exe',
'extrac32.exe',
'fc.exe',
'find.exe',
'findstr.exe',
'fodhelper.exe',
'forfiles.exe',
'format.com',
'fsutil.exe',
'ftp.exe',
'gpresult.exe',
'HOSTNAME.EXE',
'icacls.exe',
'ipconfig.exe',
'label.exe',
'logoff.exe',
'makecab.exe',
'mavinject.exe',
'mode.com',
'more.com',
'mountvol.exe',
'msg.exe',
'mshta.exe',
'msiexec.exe',
'mstsc.exe',
'net.exe',
'net1.exe',
'netsh.exe',
'NETSTAT.EXE',
'notepad.exe',
'nslookup.exe',
'odbcconf.exe',
'openfiles.exe',
'PATHPING.EXE',
'PING.EXE',
'PresentationHost.exe',
'print.exe',
'recover.exe',
'reg.exe',
'regsvr32.exe',
'replace.exe',
'robocopy.exe',
'ROUTE.EXE',
'rundll32.exe',
'sc.exe',
'schtasks.exe',
'sdclt.exe',
'setx.exe',
'shutdown.exe',
'sort.exe',
'subst.exe',
'SyncAppvPublishingServer.exe',
'systeminfo.exe',
'tar.exe',
'taskkill.exe',
'tasklist.exe',
'timeout.exe',
'TRACERT.EXE',
'tree.com',
'vssadmin.exe',
'wbadmin.exe',
'where.exe',
'whoami.exe',
'winrm.cmd',
'winrs.exe',
'wscript.exe',
'xcopy.exe',
),
'C:\\Windows': (
'explorer.exe',
'HelpPane.exe',
'hh.exe',
'notepad.exe',
'regedit.exe',
'splwow64.exe',
'write.exe',
),
'C:\\Windows\\System32\\Wbem': (
'mofcomp.exe',
'WMIC.exe',
'WmiPrvSE.exe',
),
'C:\\Windows\\System32\\WindowsPowerShell\\v1.0': (
'powershell.exe',
'powershell_ise.exe',
),
'C:\\Windows\\System32\\OpenSSH': (
'scp.exe',
'sftp.exe',
'ssh-add.exe',
'ssh-agent.exe',
'ssh-keygen.exe',
'ssh-keyscan.exe',
'ssh.exe',
),
}
"""
The programs that a default Windows installation keeps in the folders on its search path, by
folder, in the casing Windows shows them. The table is not exhaustive: it holds the programs that
scripts commonly run and is extended as needed.
"""
def make_win32_environment(
username: str = 'Administrator',
hostname: str | None = None,
) -> dict[str, str]:
"""
Generate a default Windows environment variable dictionary.
"""
if hostname is None:
hostname = str(uuid4())
return {
key: value.format(h=hostname, u=username)
for key, value in DEFAULT_ENVIRONMENT_TEMPLATE.items()
}
Global variables
var DEFAULT_PROGRAMS-
The programs that a default Windows installation keeps in the folders on its search path, by folder, in the casing Windows shows them. The table is not exhaustive: it holds the programs that scripts commonly run and is extended as needed.
Functions
def make_win32_environment(username='Administrator', hostname=None)-
Generate a default Windows environment variable dictionary.
Expand source code Browse git
def make_win32_environment( username: str = 'Administrator', hostname: str | None = None, ) -> dict[str, str]: """ Generate a default Windows environment variable dictionary. """ if hostname is None: hostname = str(uuid4()) return { key: value.format(h=hostname, u=username) for key, value in DEFAULT_ENVIRONMENT_TEMPLATE.items() }