parent
179748c469
commit
875166b683
6 changed files with 105 additions and 59 deletions
13
scripts/check_av.ps1
Normal file
13
scripts/check_av.ps1
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
# WizardKit: Check Antivirus
|
||||||
|
|
||||||
|
#Requires -Version 3.0
|
||||||
|
if (Test-Path Env:\DEBUG) {
|
||||||
|
Set-PSDebug -Trace 1
|
||||||
|
}
|
||||||
|
$Host.UI.RawUI.WindowTitle = "WizardKit: Check Antivirus"
|
||||||
|
$Host.UI.RawUI.BackgroundColor = "black"
|
||||||
|
$Host.UI.RawUI.ForegroundColor = "white"
|
||||||
|
$ProgressPreference = "SilentlyContinue"
|
||||||
|
|
||||||
|
# Main
|
||||||
|
Get-CimInstance -Namespace "root\SecurityCenter2" -ClassName AntivirusProduct | select displayName,productState | ConvertTo-Json
|
||||||
13
scripts/check_partition_alignment.ps1
Normal file
13
scripts/check_partition_alignment.ps1
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
# WizardKit: Check Partition Alignment
|
||||||
|
|
||||||
|
#Requires -Version 3.0
|
||||||
|
if (Test-Path Env:\DEBUG) {
|
||||||
|
Set-PSDebug -Trace 1
|
||||||
|
}
|
||||||
|
$Host.UI.RawUI.WindowTitle = "WizardKit: Check Partition Alignment"
|
||||||
|
$Host.UI.RawUI.BackgroundColor = "black"
|
||||||
|
$Host.UI.RawUI.ForegroundColor = "white"
|
||||||
|
$ProgressPreference = "SilentlyContinue"
|
||||||
|
|
||||||
|
# Main
|
||||||
|
Get-CimInstance -Query "Select * from Win32_DiskPartition" | select Name,Size,StartingOffset | ConvertTo-Json
|
||||||
13
scripts/disable_password_expiration.ps1
Normal file
13
scripts/disable_password_expiration.ps1
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
# WizardKit: Disable Password Expiration (Local Accounts)
|
||||||
|
|
||||||
|
#Requires -Version 3.0
|
||||||
|
if (Test-Path Env:\DEBUG) {
|
||||||
|
Set-PSDebug -Trace 1
|
||||||
|
}
|
||||||
|
$Host.UI.RawUI.WindowTitle = "Disable Password Expiration"
|
||||||
|
$Host.UI.RawUI.BackgroundColor = "black"
|
||||||
|
$Host.UI.RawUI.ForegroundColor = "white"
|
||||||
|
$ProgressPreference = "SilentlyContinue"
|
||||||
|
|
||||||
|
# Main
|
||||||
|
Get-LocalUser | Set-LocalUser -PasswordNeverExpires $true
|
||||||
|
|
@ -29,6 +29,14 @@ REG_CHROME_UBLOCK_ORIGIN = {
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
REG_WINDOWS_BSOD_MINIDUMPS = {
|
||||||
|
'HKLM': {
|
||||||
|
# Enable small memory dumps
|
||||||
|
r'SYSTEM\CurrentControlSet\Control\CrashControl': (
|
||||||
|
('CrashDumpEnabled', 3, 'DWORD'),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
REG_WINDOWS_EXPLORER = {
|
REG_WINDOWS_EXPLORER = {
|
||||||
'HKLM': {
|
'HKLM': {
|
||||||
# Allow password sign-in for MS accounts
|
# Allow password sign-in for MS accounts
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import logging
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import platform
|
import platform
|
||||||
import re
|
|
||||||
|
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
@ -74,9 +73,6 @@ KNOWN_HIVE_NAMES = {
|
||||||
RAM_OK = 5.5 * 1024**3 # ~6 GiB assuming a bit of shared memory
|
RAM_OK = 5.5 * 1024**3 # ~6 GiB assuming a bit of shared memory
|
||||||
RAM_WARNING = 3.5 * 1024**3 # ~4 GiB assuming a bit of shared memory
|
RAM_WARNING = 3.5 * 1024**3 # ~4 GiB assuming a bit of shared memory
|
||||||
REG_MSISERVER = r'HKLM\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\MSIServer'
|
REG_MSISERVER = r'HKLM\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\MSIServer'
|
||||||
REGEX_4K_ALIGNMENT = re.compile(
|
|
||||||
r'^(?P<description>.*?)\s+(?P<size>\d+)\s+(?P<offset>\d+)',
|
|
||||||
)
|
|
||||||
SLMGR = pathlib.Path(f'{os.environ.get("SYSTEMROOT")}/System32/slmgr.vbs')
|
SLMGR = pathlib.Path(f'{os.environ.get("SYSTEMROOT")}/System32/slmgr.vbs')
|
||||||
SYSTEMDRIVE = os.environ.get('SYSTEMDRIVE')
|
SYSTEMDRIVE = os.environ.get('SYSTEMDRIVE')
|
||||||
|
|
||||||
|
|
@ -169,29 +165,23 @@ def set_timezone(zone) -> None:
|
||||||
# Info Functions
|
# Info Functions
|
||||||
def check_4k_alignment(show_alert=False) -> list[str]:
|
def check_4k_alignment(show_alert=False) -> list[str]:
|
||||||
"""Check if all partitions are 4K aligned, returns list."""
|
"""Check if all partitions are 4K aligned, returns list."""
|
||||||
cmd = ['WMIC', 'partition', 'get', 'Caption,Size,StartingOffset']
|
script_path = find_kit_dir('Scripts').joinpath('check_partition_alignment.ps1')
|
||||||
|
cmd = ['PowerShell', '-ExecutionPolicy', 'Bypass', '-File', script_path]
|
||||||
|
json_data = get_json_from_command(cmd)
|
||||||
report = []
|
report = []
|
||||||
show_alert = False
|
show_alert = False
|
||||||
|
|
||||||
# Check offsets
|
# Check offsets
|
||||||
proc = run_program(cmd)
|
for part in json_data:
|
||||||
for line in proc.stdout.splitlines():
|
if part['StartingOffset'] % 4096 != 0:
|
||||||
line = line.strip()
|
report.append(
|
||||||
if not line or not line.startswith('Disk'):
|
ansi.color_string(
|
||||||
continue
|
f'{part["Name"]}'
|
||||||
match = REGEX_4K_ALIGNMENT.match(line)
|
f' ({bytes_to_string(part["Size"], decimals=1)})'
|
||||||
if not match:
|
,
|
||||||
LOG.error('Failed to parse partition info for: %s', line)
|
'RED'
|
||||||
continue
|
)
|
||||||
if int(match.group('offset')) % 4096 != 0:
|
)
|
||||||
report.append(
|
|
||||||
ansi.color_string(
|
|
||||||
f'{match.group("description")}'
|
|
||||||
f' ({bytes_to_string(match.group("size"), decimals=1)})'
|
|
||||||
,
|
|
||||||
'RED'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Show alert
|
# Show alert
|
||||||
if show_alert:
|
if show_alert:
|
||||||
|
|
@ -203,6 +193,7 @@ def check_4k_alignment(show_alert=False) -> list[str]:
|
||||||
0,
|
0,
|
||||||
ansi.color_string('One or more partitions not 4K aligned', 'YELLOW'),
|
ansi.color_string('One or more partitions not 4K aligned', 'YELLOW'),
|
||||||
)
|
)
|
||||||
|
report.sort()
|
||||||
return report
|
return report
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -224,45 +215,52 @@ def export_bitlocker_info() -> None:
|
||||||
_f.write(f'{proc.stdout}\n\n')
|
_f.write(f'{proc.stdout}\n\n')
|
||||||
|
|
||||||
|
|
||||||
def get_installed_antivirus() -> list[str]:
|
def get_installed_antivirus() -> dict[str, dict]:
|
||||||
"""Get list of installed antivirus programs, returns list."""
|
"""Get installed antivirus products and their status, returns dict."""
|
||||||
cmd = [
|
script_path = find_kit_dir('Scripts').joinpath('check_av.ps1')
|
||||||
'WMIC', r'/namespace:\\root\SecurityCenter2',
|
cmd = ['PowerShell', '-ExecutionPolicy', 'Bypass', '-File', script_path]
|
||||||
'path', 'AntivirusProduct',
|
json_data = get_json_from_command(cmd)
|
||||||
'get', 'displayName', '/value',
|
products = {}
|
||||||
]
|
|
||||||
products = []
|
|
||||||
report = []
|
|
||||||
|
|
||||||
# Get list of products
|
# Check state and build dict
|
||||||
proc = run_program(cmd)
|
for p in json_data:
|
||||||
for line in proc.stdout.splitlines():
|
name = p['displayName']
|
||||||
line = line.strip()
|
state = p['productState']
|
||||||
if '=' in line:
|
enabled = ((state>>8) & 0x11) in (0x10, 0x11) # middle two hex digits
|
||||||
products.append(line.split('=')[1])
|
outdated = (state & 0x11) != 0x00 # last two hex digits
|
||||||
|
products[name] = {
|
||||||
|
'Enabled': enabled,
|
||||||
|
'Outdated': outdated,
|
||||||
|
'State': state,
|
||||||
|
}
|
||||||
|
return products
|
||||||
|
|
||||||
|
|
||||||
|
def list_installed_antivirus() -> list[str]:
|
||||||
|
"""Get list of installed antivirus programs, returns list."""
|
||||||
|
products = get_installed_antivirus()
|
||||||
|
products_active = []
|
||||||
|
products_inactive = []
|
||||||
|
|
||||||
# Check product(s) status
|
# Check product(s) status
|
||||||
for product in sorted(products):
|
for name, details in products.items():
|
||||||
cmd = [
|
if details['Enabled']:
|
||||||
'WMIC', r'/namespace:\\root\SecurityCenter2',
|
if details['Outdated']:
|
||||||
'path', 'AntivirusProduct',
|
products_active.append(ansi.color_string(f'{name} [OUTDATED]', 'YELLOW'))
|
||||||
'where', f'displayName="{product}"',
|
else:
|
||||||
'get', 'productState', '/value',
|
products_active.append(name)
|
||||||
]
|
|
||||||
proc = run_program(cmd)
|
|
||||||
state = proc.stdout.split('=')[1]
|
|
||||||
state = hex(int(state))
|
|
||||||
if str(state)[3:5] not in ['10', '11']:
|
|
||||||
report.append(ansi.color_string(f'[Disabled] {product}', 'YELLOW'))
|
|
||||||
else:
|
else:
|
||||||
report.append(product)
|
# Disabled
|
||||||
|
products_inactive.append(ansi.color_string(f'[Disabled] {name}', 'YELLOW'))
|
||||||
|
|
||||||
# Final check
|
# Final check
|
||||||
if not report:
|
if not (products_active or products_inactive):
|
||||||
report.append(ansi.color_string('No products detected', 'RED'))
|
products_inactive.append(ansi.color_string('No products detected', 'RED'))
|
||||||
|
|
||||||
# Done
|
# Done
|
||||||
return report
|
products_active.sort()
|
||||||
|
products_inactive.sort()
|
||||||
|
return products_active + products_inactive
|
||||||
|
|
||||||
|
|
||||||
def get_installed_ram(as_list=False, raise_exceptions=False) -> list | str:
|
def get_installed_ram(as_list=False, raise_exceptions=False) -> list | str:
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ from wk.cfg.setup import (
|
||||||
REG_WINDOWS_EXPLORER,
|
REG_WINDOWS_EXPLORER,
|
||||||
REG_OPEN_SHELL_SETTINGS,
|
REG_OPEN_SHELL_SETTINGS,
|
||||||
REG_OPEN_SHELL_LOW_POWER_IDLE,
|
REG_OPEN_SHELL_LOW_POWER_IDLE,
|
||||||
|
REG_WINDOWS_BSOD_MINIDUMPS,
|
||||||
UBLOCK_ORIGIN_URLS,
|
UBLOCK_ORIGIN_URLS,
|
||||||
)
|
)
|
||||||
from wk.exe import kill_procs, run_program, popen_program
|
from wk.exe import kill_procs, run_program, popen_program
|
||||||
|
|
@ -36,7 +37,6 @@ from wk.os.win import (
|
||||||
OS_VERSION,
|
OS_VERSION,
|
||||||
activate_with_bios,
|
activate_with_bios,
|
||||||
check_4k_alignment,
|
check_4k_alignment,
|
||||||
get_installed_antivirus,
|
|
||||||
get_installed_ram,
|
get_installed_ram,
|
||||||
get_os_activation,
|
get_os_activation,
|
||||||
get_os_name,
|
get_os_name,
|
||||||
|
|
@ -45,6 +45,7 @@ from wk.os.win import (
|
||||||
get_volume_usage,
|
get_volume_usage,
|
||||||
is_activated,
|
is_activated,
|
||||||
is_secure_boot_enabled,
|
is_secure_boot_enabled,
|
||||||
|
list_installed_antivirus,
|
||||||
reg_set_value,
|
reg_set_value,
|
||||||
reg_write_settings,
|
reg_write_settings,
|
||||||
stop_service,
|
stop_service,
|
||||||
|
|
@ -520,7 +521,7 @@ def auto_show_4k_alignment_check() -> None:
|
||||||
|
|
||||||
def auto_show_installed_antivirus() -> None:
|
def auto_show_installed_antivirus() -> None:
|
||||||
"""Display installed antivirus."""
|
"""Display installed antivirus."""
|
||||||
TRY_PRINT.run('Virus Protection...', get_installed_antivirus)
|
TRY_PRINT.run('Virus Protection...', list_installed_antivirus)
|
||||||
|
|
||||||
|
|
||||||
def auto_show_installed_ram() -> None:
|
def auto_show_installed_ram() -> None:
|
||||||
|
|
@ -629,14 +630,14 @@ def disable_chrome_notifications() -> None:
|
||||||
|
|
||||||
def disable_password_expiration() -> None:
|
def disable_password_expiration() -> None:
|
||||||
"""Disable password expiration for all users."""
|
"""Disable password expiration for all users."""
|
||||||
cmd = ['wmic', 'UserAccount', 'set', 'PasswordExpires=False']
|
script_path = find_kit_dir('Scripts').joinpath('disable_password_expiration.ps1')
|
||||||
|
cmd = ['PowerShell', '-ExecutionPolicy', 'Bypass', '-File', script_path]
|
||||||
run_program(cmd)
|
run_program(cmd)
|
||||||
|
|
||||||
|
|
||||||
def enable_bsod_minidumps() -> None:
|
def enable_bsod_minidumps() -> None:
|
||||||
"""Enable saving minidumps during BSoDs."""
|
"""Enable saving minidumps during BSoDs."""
|
||||||
cmd = ['wmic', 'RECOVEROS', 'set', 'DebugInfoType', '=', '3']
|
reg_write_settings(REG_WINDOWS_BSOD_MINIDUMPS)
|
||||||
run_program(cmd)
|
|
||||||
|
|
||||||
|
|
||||||
def enable_ublock_origin() -> None:
|
def enable_ublock_origin() -> None:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue