Updated diags.py

This commit is contained in:
2Shirt 2018-11-23 18:10:50 -07:00
parent 1839edf84d
commit 7f37bc8802
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -38,7 +38,7 @@ def check_connection():
else: else:
abort() abort()
def check_secure_boot_status(): def check_secure_boot_status(show_alert=False):
"""Checks UEFI Secure Boot status via PowerShell.""" """Checks UEFI Secure Boot status via PowerShell."""
boot_mode = get_boot_mode() boot_mode = get_boot_mode()
cmd = ['PowerShell', '-Command', 'Confirm-SecureBootUEFI'] cmd = ['PowerShell', '-Command', 'Confirm-SecureBootUEFI']
@ -51,18 +51,30 @@ def check_secure_boot_status():
# It's on, do nothing # It's on, do nothing
return return
elif 'False' in out: elif 'False' in out:
if show_alert:
show_alert_box('Secure Boot DISABLED')
raise SecureBootDisabledError raise SecureBootDisabledError
else: else:
if show_alert:
show_alert_box('Secure Boot status UNKNOWN')
raise SecureBootUnknownError raise SecureBootUnknownError
else: else:
if boot_mode != 'UEFI': if boot_mode != 'UEFI':
if (show_alert and
global_vars['OS']['Version'] in ('8', '8.1', '10')):
# OS supports Secure Boot
show_alert_box('Secure Boot DISABLED\n\nOS installed LEGACY')
raise OSInstalledLegacyError raise OSInstalledLegacyError
else: else:
# Check error message # Check error message
err = result.stderr.decode() err = result.stderr.decode()
if 'Cmdlet not supported' in err: if 'Cmdlet not supported' in err:
if show_alert:
show_alert_box('Secure Boot UNAVAILABLE?')
raise SecureBootNotAvailError raise SecureBootNotAvailError
else: else:
if show_alert:
show_alert_box('Secure Boot ERROR')
raise GenericError raise GenericError
def get_boot_mode(): def get_boot_mode():
@ -123,7 +135,8 @@ def run_xmplay():
r'{BinDir}\XMPlay\music.7z'.format(**global_vars)] r'{BinDir}\XMPlay\music.7z'.format(**global_vars)]
# Unmute audio first # Unmute audio first
run_nircmd(['mutesysvolume', '0']) extract_item('NirCmd', silent=True)
run_nircmd('mutesysvolume', '0')
# Open XMPlay # Open XMPlay
popen_program(cmd) popen_program(cmd)
@ -134,7 +147,7 @@ def run_hitmanpro():
cmd = [ cmd = [
global_vars['Tools']['HitmanPro'], global_vars['Tools']['HitmanPro'],
'/quiet', '/noinstall', '/noupload', '/quiet', '/noinstall', '/noupload',
r'/log={LogDir}\hitman.xml'.format(**global_vars)] r'/log={LogDir}\Tools\HitmanPro.txt'.format(**global_vars)]
popen_program(cmd) popen_program(cmd)
def run_process_killer(): def run_process_killer():
@ -152,23 +165,25 @@ def run_rkill():
extract_item('RKill', silent=True) extract_item('RKill', silent=True)
cmd = [ cmd = [
global_vars['Tools']['RKill'], global_vars['Tools']['RKill'],
'-l', r'{LogDir}\RKill.log'.format(**global_vars), '-s', '-l', r'{LogDir}\Tools\RKill.log'.format(**global_vars),
'-new_console:n', '-new_console:s33V'] '-new_console:n', '-new_console:s33V']
run_program(cmd, check=False) run_program(cmd, check=False)
wait_for_process('RKill') wait_for_process('RKill')
kill_process('notepad.exe')
# RKill cleanup # RKill cleanup
desktop_path = r'{USERPROFILE}\Desktop'.format(**global_vars['Env']) desktop_path = r'{USERPROFILE}\Desktop'.format(**global_vars['Env'])
if os.path.exists(desktop_path): if os.path.exists(desktop_path):
for item in os.scandir(desktop_path): for item in os.scandir(desktop_path):
if re.search(r'^RKill', item.name, re.IGNORECASE): if re.search(r'^RKill', item.name, re.IGNORECASE):
dest = re.sub(r'^(.*)\.', '\1_{Date-Time}.'.format( dest = r'{LogDir}\Tools\{name}'.format(
**global_vars), item.name)
dest = r'{ClientDir}\Info\{name}'.format(
name=dest, **global_vars) name=dest, **global_vars)
dest = non_clobber_rename(dest) dest = non_clobber_rename(dest)
shutil.move(item.path, dest) shutil.move(item.path, dest)
def show_alert_box(message, title='Wizard Kit Warning'):
"""Show Windows alert box with message."""
message_box = ctypes.windll.user32.MessageBoxW
message_box(None, message, title, 0x00001030)
if __name__ == '__main__': if __name__ == '__main__':
print("This file is not meant to be called directly.") print("This file is not meant to be called directly.")