parent
7e17a93d42
commit
85e7813539
3 changed files with 85 additions and 16 deletions
|
|
@ -64,12 +64,24 @@ class NotInstalledError(Exception):
|
||||||
class NoProfilesError(Exception):
|
class NoProfilesError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class OSInstalledLegacyError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
class PathNotFoundError(Exception):
|
class PathNotFoundError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class UnsupportedOSError(Exception):
|
class UnsupportedOSError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class SecureBootDisabledError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class SecureBootNotAvailError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class SecureBootUnknownError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
# General functions
|
# General functions
|
||||||
def abort():
|
def abort():
|
||||||
"""Abort script."""
|
"""Abort script."""
|
||||||
|
|
@ -271,7 +283,7 @@ def human_readable_size(size, decimals=0):
|
||||||
units = 'Kb'
|
units = 'Kb'
|
||||||
else:
|
else:
|
||||||
units = ' b'
|
units = ' b'
|
||||||
|
|
||||||
# Return
|
# Return
|
||||||
return '{size:>{width}.{decimals}f} {units}'.format(
|
return '{size:>{width}.{decimals}f} {units}'.format(
|
||||||
size=size, width=width, decimals=decimals, units=units)
|
size=size, width=width, decimals=decimals, units=units)
|
||||||
|
|
@ -462,7 +474,7 @@ def run_program(cmd, args=[], check=True, pipe=True, shell=False):
|
||||||
|
|
||||||
def set_title(title='~Some Title~'):
|
def set_title(title='~Some Title~'):
|
||||||
"""Set title.
|
"""Set title.
|
||||||
|
|
||||||
Used for window title and menu titles."""
|
Used for window title and menu titles."""
|
||||||
global_vars['Title'] = title
|
global_vars['Title'] = title
|
||||||
os.system('title {}'.format(title))
|
os.system('title {}'.format(title))
|
||||||
|
|
@ -566,7 +578,7 @@ def try_and_print(message='Trying...',
|
||||||
|
|
||||||
def upload_crash_details():
|
def upload_crash_details():
|
||||||
"""Upload log and runtime data to the CRASH_SERVER.
|
"""Upload log and runtime data to the CRASH_SERVER.
|
||||||
|
|
||||||
Intended for uploading to a public Nextcloud share."""
|
Intended for uploading to a public Nextcloud share."""
|
||||||
if not ENABLED_UPLOAD_DATA:
|
if not ENABLED_UPLOAD_DATA:
|
||||||
raise GenericError
|
raise GenericError
|
||||||
|
|
@ -648,7 +660,7 @@ def init_global_vars():
|
||||||
def check_os():
|
def check_os():
|
||||||
"""Set OS specific variables."""
|
"""Set OS specific variables."""
|
||||||
tmp = {}
|
tmp = {}
|
||||||
|
|
||||||
# Query registry
|
# Query registry
|
||||||
path = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion'
|
path = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion'
|
||||||
with winreg.OpenKey(HKLM, path) as key:
|
with winreg.OpenKey(HKLM, path) as key:
|
||||||
|
|
@ -697,7 +709,7 @@ def check_os():
|
||||||
tmp['DisplayName'] = '{} x{}'.format(tmp['Name'], tmp['Arch'])
|
tmp['DisplayName'] = '{} x{}'.format(tmp['Name'], tmp['Arch'])
|
||||||
if tmp['Notes']:
|
if tmp['Notes']:
|
||||||
tmp['DisplayName'] += ' ({})'.format(tmp['Notes'])
|
tmp['DisplayName'] += ' ({})'.format(tmp['Notes'])
|
||||||
|
|
||||||
global_vars['OS'] = tmp
|
global_vars['OS'] = tmp
|
||||||
|
|
||||||
def check_tools():
|
def check_tools():
|
||||||
|
|
@ -714,7 +726,7 @@ def check_tools():
|
||||||
|
|
||||||
def clean_env_vars():
|
def clean_env_vars():
|
||||||
"""Remove conflicting global_vars and env variables.
|
"""Remove conflicting global_vars and env variables.
|
||||||
|
|
||||||
This fixes an issue where both global_vars and
|
This fixes an issue where both global_vars and
|
||||||
global_vars['Env'] are expanded at the same time."""
|
global_vars['Env'] are expanded at the same time."""
|
||||||
for key in global_vars.keys():
|
for key in global_vars.keys():
|
||||||
|
|
@ -768,7 +780,7 @@ def set_common_vars():
|
||||||
|
|
||||||
def set_linux_vars():
|
def set_linux_vars():
|
||||||
"""Set common variables in a Linux environment.
|
"""Set common variables in a Linux environment.
|
||||||
|
|
||||||
These assume we're running under a WK-Linux build."""
|
These assume we're running under a WK-Linux build."""
|
||||||
result = run_program(['mktemp', '-d'])
|
result = run_program(['mktemp', '-d'])
|
||||||
global_vars['TmpDir'] = result.stdout.decode().strip()
|
global_vars['TmpDir'] = result.stdout.decode().strip()
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
# Wizard Kit: Functions - Diagnostics
|
# Wizard Kit: Functions - Diagnostics
|
||||||
|
|
||||||
|
import ctypes
|
||||||
|
|
||||||
from functions.common import *
|
from functions.common import *
|
||||||
|
|
||||||
# STATIC VARIABLES
|
# STATIC VARIABLES
|
||||||
|
|
@ -30,12 +32,59 @@ def check_connection():
|
||||||
result = try_and_print(message='Ping test...', function=ping, cs='OK')
|
result = try_and_print(message='Ping test...', function=ping, cs='OK')
|
||||||
if result['CS']:
|
if result['CS']:
|
||||||
break
|
break
|
||||||
|
if not ask('ERROR: System appears offline, try again?'):
|
||||||
|
if ask('Continue anyway?'):
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
abort()
|
||||||
|
|
||||||
|
def check_secure_boot_status():
|
||||||
|
"""Checks UEFI Secure Boot status via PowerShell."""
|
||||||
|
boot_mode = get_boot_mode()
|
||||||
|
cmd = ['PowerShell', '-Command', 'Confirm-SecureBootUEFI']
|
||||||
|
result = run_program(cmd, check=False)
|
||||||
|
|
||||||
|
# Check results
|
||||||
|
if result.returncode == 0:
|
||||||
|
out = result.stdout.decode()
|
||||||
|
if 'True' in out:
|
||||||
|
# It's on, do nothing
|
||||||
|
return
|
||||||
|
elif 'False' in out:
|
||||||
|
raise SecureBootDisabledError
|
||||||
else:
|
else:
|
||||||
if not ask('ERROR: System appears offline, try again?'):
|
raise SecureBootUnknownError
|
||||||
if ask('Continue anyway?'):
|
else:
|
||||||
break
|
if boot_mode != 'UEFI':
|
||||||
else:
|
raise OSInstalledLegacyError
|
||||||
abort()
|
else:
|
||||||
|
# Check error message
|
||||||
|
err = result.stderr.decode()
|
||||||
|
if 'Cmdlet not supported' in err:
|
||||||
|
raise SecureBootNotAvailError
|
||||||
|
else:
|
||||||
|
raise GenericError
|
||||||
|
|
||||||
|
def get_boot_mode():
|
||||||
|
"""Check if Windows is booted in UEFI or Legacy mode, returns str."""
|
||||||
|
kernel = ctypes.windll.kernel32
|
||||||
|
firmware_type = ctypes.c_uint()
|
||||||
|
|
||||||
|
# Get value from kernel32 API
|
||||||
|
try:
|
||||||
|
kernel.GetFirmwareType(ctypes.byref(firmware_type))
|
||||||
|
except:
|
||||||
|
# Just set to zero
|
||||||
|
firmware_type = ctypes.c_uint(0)
|
||||||
|
|
||||||
|
# Set return value
|
||||||
|
type_str = 'Unknown'
|
||||||
|
if firmware_type.value == 1:
|
||||||
|
type_str = 'Legacy'
|
||||||
|
elif firmware_type.value == 2:
|
||||||
|
type_str = 'UEFI'
|
||||||
|
|
||||||
|
return type_str
|
||||||
|
|
||||||
def run_autoruns():
|
def run_autoruns():
|
||||||
"""Run AutoRuns in the background with VirusTotal checks enabled."""
|
"""Run AutoRuns in the background with VirusTotal checks enabled."""
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,17 @@ if __name__ == '__main__':
|
||||||
ticket_number = get_ticket_number()
|
ticket_number = get_ticket_number()
|
||||||
other_results = {
|
other_results = {
|
||||||
'Error': {
|
'Error': {
|
||||||
'CalledProcessError': 'Unknown Error',
|
'BIOSKeyNotFoundError': 'BIOS key not found',
|
||||||
'BIOSKeyNotFoundError': 'BIOS key not found',
|
'CalledProcessError': 'Unknown Error',
|
||||||
'FileNotFoundError': 'File not found',
|
'FileNotFoundError': 'File not found',
|
||||||
|
'GenericError': 'Unknown Error',
|
||||||
|
'SecureBootDisabledError': 'Disabled',
|
||||||
},
|
},
|
||||||
'Warning': {}}
|
'Warning': {
|
||||||
|
'OSInstalledLegacyError': 'OS installed Legacy',
|
||||||
|
'SecureBootNotAvailError': 'Not available',
|
||||||
|
'SecureBootUnknownError': 'Unknown',
|
||||||
|
}}
|
||||||
if ENABLED_TICKET_NUMBERS:
|
if ENABLED_TICKET_NUMBERS:
|
||||||
print_info('Starting System Checklist for Ticket #{}\n'.format(
|
print_info('Starting System Checklist for Ticket #{}\n'.format(
|
||||||
ticket_number))
|
ticket_number))
|
||||||
|
|
@ -76,6 +82,8 @@ if __name__ == '__main__':
|
||||||
try_and_print(message='BIOS Activation:',
|
try_and_print(message='BIOS Activation:',
|
||||||
function=activate_with_bios,
|
function=activate_with_bios,
|
||||||
other_results=other_results)
|
other_results=other_results)
|
||||||
|
try_and_print(message='Secure Boot Status:',
|
||||||
|
function=check_secure_boot_status, other_results=other_results)
|
||||||
try_and_print(message='Installed RAM:',
|
try_and_print(message='Installed RAM:',
|
||||||
function=show_installed_ram, ns='Unknown', silent_function=False)
|
function=show_installed_ram, ns='Unknown', silent_function=False)
|
||||||
show_free_space()
|
show_free_space()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue