diff --git a/scripts/auto_repairs.py b/scripts/auto_repairs.py index 37684f91..47e32a2c 100644 --- a/scripts/auto_repairs.py +++ b/scripts/auto_repairs.py @@ -13,7 +13,7 @@ import wk # pylint: disable=wrong-import-position class MenuEntry(): # pylint: disable=too-few-public-methods """Simple class to allow cleaner code below.""" - def __init__(self, name, function=None, **kwargs): + def __init__(self, name, function=None, selected=True, **kwargs): self.name = name # Color reboot entries @@ -27,7 +27,7 @@ class MenuEntry(): # Set details self.details = { 'Function': function, - 'Selected': True, + 'Selected': selected, **kwargs, } @@ -78,28 +78,38 @@ BASE_MENUS = { MenuEntry('Malwarebytes (Install)', 'auto_mbam_install'), MenuEntry('Malwarebytes (Run)', 'auto_mbam_run'), MenuEntry('Malwarebytes (Uninstall)', 'auto_mbam_uninstall'), - MenuEntry('IO Bit Uninstaller', 'auto_iobit_uninstaller'), + MenuEntry('UninstallView', 'auto_uninstallview'), MenuEntry('Enable Windows Updates', 'auto_windows_updates_enable'), ), }, 'Options': ( - MenuEntry('Kill Explorer'), + MenuEntry('Kill Explorer', selected=False), MenuEntry('Run RKill'), MenuEntry('Run TDSSKiller (once)'), MenuEntry('Sync Clock'), - MenuEntry('Use Autologon'), + MenuEntry('Use Autologon', selected=False), ), 'Actions': ( + MenuEntry('Load Preset'), MenuEntry('Options'), MenuEntry('Start', Separator=True), MenuEntry('Quit'), ), } - +PRESETS = { + 'Default': { # Will be expanded at runtime using BASE_MENUS + 'Options': ( + 'Run RKill', + 'Run TDSSKiller (once)', + 'Sync Clock', + ), + }, + 'Custom': {}, # Will remain empty at runtime + } if __name__ == '__main__': try: - wk.repairs.win.run_auto_repairs(BASE_MENUS) + wk.repairs.win.run_auto_repairs(BASE_MENUS, PRESETS) except KeyboardInterrupt: wk.std.abort() except SystemExit: diff --git a/scripts/auto_setup.py b/scripts/auto_setup.py index 31ea555a..afd8749e 100644 --- a/scripts/auto_setup.py +++ b/scripts/auto_setup.py @@ -9,83 +9,6 @@ sys.path.append(os.getcwd()) import wk # pylint: disable=wrong-import-position -# STATIC VARIABLES -PRESETS = { - 'Default': {}, # Will be built at runtime using BASE_MENUS - 'Additional User': { - 'Configure System': ( - 'Chrome Notifications', - 'Open Shell', - 'uBlock Origin', - 'Enable BSoD MiniDumps', - 'Enable RegBack', - 'Enable System Restore', - 'Set System Restore Size', - 'Enable Windows Updates', - 'Windows Explorer', - ), - 'Install Software': ( - 'Firefox', # Needed to handle profile upgrade nonsense - ), - 'System Summary': ( - 'Operating System', - 'Windows Activation', - 'Secure Boot', - 'Installed RAM', - 'Storage Status', - 'Virus Protection', - 'Partitions 4K Aligned', - ), - }, - 'Hardware': { - 'Configure System': ( - 'Enable BSoD MiniDumps', - 'Enable RegBack', - 'Enable System Restore', - 'Set System Restore Size', - 'Enable Windows Updates', - ), - 'System Information': ( - 'Backup Registry', - ), - 'System Summary': ( - 'Operating System', - 'Windows Activation', - 'Secure Boot', - 'Installed RAM', - 'Storage Status', - 'Virus Protection', - 'Partitions 4K Aligned', - ), - 'Run Programs': ( - 'Device Manager', - 'HWiNFO Sensors', - 'XMPlay', - ), - }, - 'Verify': { - 'Configure System': ( - 'Enable BSoD MiniDumps', - 'Enable RegBack', - 'Enable System Restore', - 'Set System Restore Size', - 'Enable Windows Updates', - 'Windows Explorer', - ), - 'System Summary': ( - 'Operating System', - 'Windows Activation', - 'Secure Boot', - 'Installed RAM', - 'Storage Status', - 'Virus Protection', - 'Installed Office', - 'Partitions 4K Aligned', - ), - }, - 'Custom': {}, # Will remain empty at runtime - } - # Classes class MenuEntry(): # pylint: disable=too-few-public-methods @@ -162,6 +85,81 @@ BASE_MENUS = { MenuEntry('Quit'), ), } +PRESETS = { + 'Default': {}, # Will be built at runtime using BASE_MENUS + 'Additional User': { + 'Configure System': ( + 'Chrome Notifications', + 'Open Shell', + 'uBlock Origin', + 'Enable BSoD MiniDumps', + 'Enable RegBack', + 'Enable System Restore', + 'Set System Restore Size', + 'Enable Windows Updates', + 'Windows Explorer', + ), + 'Install Software': ( + 'Firefox', # Needed to handle profile upgrade nonsense + ), + 'System Summary': ( + 'Operating System', + 'Windows Activation', + 'Secure Boot', + 'Installed RAM', + 'Storage Status', + 'Virus Protection', + 'Partitions 4K Aligned', + ), + }, + 'Hardware': { + 'Configure System': ( + 'Enable BSoD MiniDumps', + 'Enable RegBack', + 'Enable System Restore', + 'Set System Restore Size', + 'Enable Windows Updates', + ), + 'System Information': ( + 'Backup Registry', + ), + 'System Summary': ( + 'Operating System', + 'Windows Activation', + 'Secure Boot', + 'Installed RAM', + 'Storage Status', + 'Virus Protection', + 'Partitions 4K Aligned', + ), + 'Run Programs': ( + 'Device Manager', + 'HWiNFO Sensors', + 'XMPlay', + ), + }, + 'Verify': { + 'Configure System': ( + 'Enable BSoD MiniDumps', + 'Enable RegBack', + 'Enable System Restore', + 'Set System Restore Size', + 'Enable Windows Updates', + 'Windows Explorer', + ), + 'System Summary': ( + 'Operating System', + 'Windows Activation', + 'Secure Boot', + 'Installed RAM', + 'Storage Status', + 'Virus Protection', + 'Installed Office', + 'Partitions 4K Aligned', + ), + }, + 'Custom': {}, # Will remain empty at runtime + } if __name__ == '__main__': diff --git a/scripts/export_bitlocker.py b/scripts/export_bitlocker.py new file mode 100644 index 00000000..d44ff494 --- /dev/null +++ b/scripts/export_bitlocker.py @@ -0,0 +1,11 @@ +"""WizardKit: Export Bitlocker Tool""" +# vim: sts=2 sw=2 ts=2 + +import os +import sys + +os.chdir(os.path.dirname(os.path.realpath(__file__))) +sys.path.append(os.getcwd()) +import wk # pylint: disable=wrong-import-position + +wk.os.win.export_bitlocker_info() \ No newline at end of file diff --git a/scripts/wk/cfg/hw.py b/scripts/wk/cfg/hw.py index 17a735ee..c957e8f7 100644 --- a/scripts/wk/cfg/hw.py +++ b/scripts/wk/cfg/hw.py @@ -20,6 +20,7 @@ BADBLOCKS_REGEX = re.compile( r'^Pass completed, (\d+) bad blocks found. .(\d+)/(\d+)/(\d+) errors', re.IGNORECASE, ) +BADBLOCKS_RESULTS_REGEX = re.compile(r'^(.*?)\x08.*\x08(.*)') BADBLOCKS_SKIP_REGEX = re.compile(r'^(Checking|\[)', re.IGNORECASE) CPU_CRITICAL_TEMP = 99 CPU_FAILURE_TEMP = 90 diff --git a/scripts/wk/cfg/launchers.py b/scripts/wk/cfg/launchers.py index b9562c86..ca9c6b29 100644 --- a/scripts/wk/cfg/launchers.py +++ b/scripts/wk/cfg/launchers.py @@ -4,13 +4,32 @@ LAUNCHERS = { r'': { # Root Dir - 'Auto Repairs': { + '0) Export BitLocker': { + 'L_TYPE': 'PyScript', + 'L_PATH': 'Scripts', + 'L_ITEM': 'export_bitlocker.py', + 'L_ELEV': 'True', + }, + '1) Auto Repairs': { 'L_TYPE': 'PyScript', 'L_PATH': 'Scripts', 'L_ITEM': 'auto_repairs.py', 'L_ELEV': 'True', }, - 'Auto Setup': { + '2) Windows Updates': { + 'L_TYPE': 'Executable', + 'L_PATH': '.', + 'L_ITEM': 'control', + 'L_ARGS': 'update', + 'L_ELEV': 'True', + }, + '3) Snappy Driver Installer Origin': { + 'L_TYPE': 'Executable', + 'L_PATH': 'SDIO', + 'L_ITEM': 'SDIO.exe', + 'L_ARGS': r'-log_dir "%client_dir%\Logs\Tools"', + }, + '4) Auto Setup': { 'L_TYPE': 'PyScript', 'L_PATH': 'Scripts', 'L_ITEM': 'auto_setup.py', @@ -22,29 +41,68 @@ LAUNCHERS = { 'L_ITEM': 'WinSCP.exe', }, }, - r'Data Recovery': { - 'PhotoRec (CLI)': { + r'Tools': { + 'AIDA64': { 'L_TYPE': 'Executable', - 'L_PATH': 'TestDisk', - 'L_ITEM': 'photorec_win.exe', - 'L_ELEV': 'True', - 'L__CLI': 'True', + 'L_PATH': 'AIDA64', + 'L_ITEM': 'aida64.exe', }, - 'PhotoRec': { + 'Autoruns (with VirusTotal Scan)': { 'L_TYPE': 'Executable', - 'L_PATH': 'TestDisk', - 'L_ITEM': 'qphotorec_win.exe', + 'L_PATH': 'Sysinternals', + 'L_ITEM': 'Autoruns.exe', + 'L_ARGS': '-e', + 'Extra Code': [ + r'reg add HKCU\Software\Sysinternals\AutoRuns /v checkvirustotal /t REG_DWORD /d 1 /f >nul', + r'reg add HKCU\Software\Sysinternals\AutoRuns /v EulaAccepted /t REG_DWORD /d 1 /f >nul', + r'reg add HKCU\Software\Sysinternals\AutoRuns /v shownomicrosoft /t REG_DWORD /d 1 /f >nul', + r'reg add HKCU\Software\Sysinternals\AutoRuns /v shownowindows /t REG_DWORD /d 1 /f >nul', + r'reg add HKCU\Software\Sysinternals\AutoRuns /v showonlyvirustotal /t REG_DWORD /d 1 /f >nul', + r'reg add HKCU\Software\Sysinternals\AutoRuns /v submitvirustotal /t REG_DWORD /d 0 /f >nul', + r'reg add HKCU\Software\Sysinternals\AutoRuns /v verifysignatures /t REG_DWORD /d 1 /f >nul', + r'reg add HKCU\Software\Sysinternals\AutoRuns\SigCheck /v EulaAccepted /t REG_DWORD /d 1 /f >nul', + r'reg add HKCU\Software\Sysinternals\AutoRuns\Streams /v EulaAccepted /t REG_DWORD /d 1 /f >nul', + r'reg add HKCU\Software\Sysinternals\AutoRuns\VirusTotal /v VirusTotalTermsAccepted /t REG_DWORD /d 1 /f >nul', + ], + }, + 'BleachBit': { + 'L_TYPE': 'Executable', + 'L_PATH': 'BleachBit', + 'L_ITEM': 'bleachbit.exe', + }, + 'BlueScreenView': { + 'L_TYPE': 'Executable', + 'L_PATH': 'BlueScreenView', + 'L_ITEM': 'BlueScreenView.exe', + }, + 'ConEmu (as ADMIN)': { + 'L_TYPE': 'Executable', + 'L_PATH': 'ConEmu', + 'L_ITEM': 'ConEmu.exe', 'L_ELEV': 'True', }, - 'TestDisk': { + 'ConEmu': { 'L_TYPE': 'Executable', - 'L_PATH': 'TestDisk', - 'L_ITEM': 'testdisk_win.exe', - 'L_ELEV': 'True', - 'L__CLI': 'True', + 'L_PATH': 'ConEmu', + 'L_ITEM': 'ConEmu.exe', + }, + 'ERUNT': { + 'L_TYPE': 'Executable', + 'L_PATH': 'erunt', + 'L_ITEM': 'ERUNT.EXE', + 'L_ARGS': r'%client_dir%\Backups\Registry\%iso_date% sysreg curuser otherusers', + 'L_ELEV': 'True', + 'Extra Code': [ + r'call "%bin%\Scripts\init_client_dir.cmd" /Logs', + ], + }, + 'Everything': { + 'L_TYPE': 'Executable', + 'L_PATH': 'Everything', + 'L_ITEM': 'Everything.exe', + 'L_ARGS': '-nodb', + 'L_ELEV': 'True', }, - }, - r'Data Transfers': { "Fab's Autobackup Pro": { 'L_TYPE': 'Executable', 'L_PATH': 'AutoBackupPro', @@ -151,57 +209,6 @@ LAUNCHERS = { r'call "%bin%\Scripts\init_client_dir.cmd" /Logs /Transfer', ], }, - 'Mac & Linux Reader': { - 'L_TYPE': 'Executable', - 'L_PATH': 'LinuxReader', - 'L_ITEM': 'LinuxReader.exe', - 'L_ELEV': 'True', - }, - }, - r'Diagnostics': { - 'AIDA64': { - 'L_TYPE': 'Executable', - 'L_PATH': 'AIDA64', - 'L_ITEM': 'aida64.exe', - }, - 'Autoruns (with VirusTotal Scan)': { - 'L_TYPE': 'Executable', - 'L_PATH': 'Sysinternals', - 'L_ITEM': 'Autoruns.exe', - 'L_ARGS': '-e', - 'Extra Code': [ - r'reg add HKCU\Software\Sysinternals\AutoRuns /v checkvirustotal /t REG_DWORD /d 1 /f >nul', - r'reg add HKCU\Software\Sysinternals\AutoRuns /v EulaAccepted /t REG_DWORD /d 1 /f >nul', - r'reg add HKCU\Software\Sysinternals\AutoRuns /v shownomicrosoft /t REG_DWORD /d 1 /f >nul', - r'reg add HKCU\Software\Sysinternals\AutoRuns /v shownowindows /t REG_DWORD /d 1 /f >nul', - r'reg add HKCU\Software\Sysinternals\AutoRuns /v showonlyvirustotal /t REG_DWORD /d 1 /f >nul', - r'reg add HKCU\Software\Sysinternals\AutoRuns /v submitvirustotal /t REG_DWORD /d 0 /f >nul', - r'reg add HKCU\Software\Sysinternals\AutoRuns /v verifysignatures /t REG_DWORD /d 1 /f >nul', - r'reg add HKCU\Software\Sysinternals\AutoRuns\SigCheck /v EulaAccepted /t REG_DWORD /d 1 /f >nul', - r'reg add HKCU\Software\Sysinternals\AutoRuns\Streams /v EulaAccepted /t REG_DWORD /d 1 /f >nul', - r'reg add HKCU\Software\Sysinternals\AutoRuns\VirusTotal /v VirusTotalTermsAccepted /t REG_DWORD /d 1 /f >nul', - ], - }, - 'BleachBit': { - 'L_TYPE': 'Executable', - 'L_PATH': 'BleachBit', - 'L_ITEM': 'bleachbit.exe', - }, - 'BlueScreenView': { - 'L_TYPE': 'Executable', - 'L_PATH': 'BlueScreenView', - 'L_ITEM': 'BlueScreenView.exe', - }, - 'ERUNT': { - 'L_TYPE': 'Executable', - 'L_PATH': 'erunt', - 'L_ITEM': 'ERUNT.EXE', - 'L_ARGS': r'%client_dir%\Backups\Registry\%iso_date% sysreg curuser otherusers', - 'L_ELEV': 'True', - 'Extra Code': [ - r'call "%bin%\Scripts\init_client_dir.cmd" /Logs', - ], - }, 'FurMark': { 'L_TYPE': 'Executable', 'L_PATH': 'FurMark', @@ -231,34 +238,10 @@ LAUNCHERS = { r')', ], }, - 'Prime95': { + 'Mac & Linux Reader': { 'L_TYPE': 'Executable', - 'L_PATH': 'Prime95', - 'L_ITEM': 'prime95.exe', - }, - 'Snappy Driver Installer Origin': { - 'L_TYPE': 'Executable', - 'L_PATH': 'SDIO', - 'L_ITEM': 'SDIO.exe', - }, - }, - r'Misc': { - 'ConEmu (as ADMIN)': { - 'L_TYPE': 'Executable', - 'L_PATH': 'ConEmu', - 'L_ITEM': 'ConEmu.exe', - 'L_ELEV': 'True', - }, - 'ConEmu': { - 'L_TYPE': 'Executable', - 'L_PATH': 'ConEmu', - 'L_ITEM': 'ConEmu.exe', - }, - 'Everything': { - 'L_TYPE': 'Executable', - 'L_PATH': 'Everything', - 'L_ITEM': 'Everything.exe', - 'L_ARGS': '-nodb', + 'L_PATH': 'LinuxReader', + 'L_ITEM': 'LinuxReader.exe', 'L_ELEV': 'True', }, 'Notepad++': { @@ -266,6 +249,11 @@ LAUNCHERS = { 'L_PATH': 'notepadplusplus', 'L_ITEM': 'notepadplusplus.exe', }, + 'Prime95': { + 'L_TYPE': 'Executable', + 'L_PATH': 'Prime95', + 'L_ITEM': 'prime95.exe', + }, 'PuTTY': { 'L_TYPE': 'Executable', 'L_PATH': 'PuTTY', @@ -282,6 +270,12 @@ LAUNCHERS = { 'L_ITEM': 'OOSU10.exe', 'L_ARGS': '1201.cfg', }, + 'UninstallView': { + 'L_TYPE': 'Executable', + 'L_PATH': 'UninstallView', + 'L_ITEM': 'UninstallView.exe', + 'L_ELEV': 'True', + }, 'Windows Repair AIO': { 'L_TYPE': 'Executable', 'L_PATH': 'WinRepairAIO', @@ -333,13 +327,6 @@ LAUNCHERS = { 'L_ARGS': r'"%bin%\XMPlay\music.7z"', }, }, - r'Uninstallers': { - 'IObit Uninstaller': { - 'L_TYPE': 'Executable', - 'L_PATH': 'IObitUninstallerPortable', - 'L_ITEM': 'IObitUninstallerPortable.exe', - }, - }, } diff --git a/scripts/wk/cfg/main.py b/scripts/wk/cfg/main.py index 488fa479..a04783b6 100644 --- a/scripts/wk/cfg/main.py +++ b/scripts/wk/cfg/main.py @@ -14,7 +14,7 @@ ENABLED_UPLOAD_DATA=True ARCHIVE_PASSWORD='Sorted1201' KIT_NAME_FULL='1201-WizardKit' KIT_NAME_SHORT='1201' -SUPPORT_MESSAGE='Please let support know by opening an issue on Gogs' +SUPPORT_MESSAGE='Please let support know by opening an issue on Gitea' # Text Formatting INDENT=4 diff --git a/scripts/wk/cfg/repairs.py b/scripts/wk/cfg/repairs.py index 86c09868..3f36d562 100644 --- a/scripts/wk/cfg/repairs.py +++ b/scripts/wk/cfg/repairs.py @@ -3,7 +3,7 @@ from wk.cfg.main import KIT_NAME_FULL, KIT_NAME_SHORT -AUTO_REPAIR_DELAY_IN_SECONDS = 30 +AUTO_REPAIR_DELAY_IN_SECONDS = 3 AUTO_REPAIR_KEY = fr'Software\{KIT_NAME_FULL}\Auto Repairs' BLEACH_BIT_CLEANERS = ( # Applications diff --git a/scripts/wk/cfg/sources.py b/scripts/wk/cfg/sources.py index 492456cb..ef4f96c8 100644 --- a/scripts/wk/cfg/sources.py +++ b/scripts/wk/cfg/sources.py @@ -34,12 +34,12 @@ SOURCES = { 'VCRedist_2012_x64': 'https://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x64.exe', 'VCRedist_2013_x32': 'https://aka.ms/highdpimfc2013x86enu', 'VCRedist_2013_x64': 'https://aka.ms/highdpimfc2013x64enu', - 'VCRedist_2019_x32': 'https://aka.ms/vs/16/release/vc_redist.x86.exe', - 'VCRedist_2019_x64': 'https://aka.ms/vs/16/release/vc_redist.x64.exe', + 'VCRedist_2022_x32': 'https://aka.ms/vs/17/release/vc_redist.x86.exe', + 'VCRedist_2022_x64': 'https://aka.ms/vs/17/release/vc_redist.x64.exe', # Build Kit - 'AIDA64': 'https://download.aida64.com/aida64engineer660.zip', - 'Adobe Reader DC': 'https://ardownload2.adobe.com/pub/adobe/reader/win/AcrobatDC/2101120039/AcroRdrDC2101120039_en_US.exe', + 'AIDA64': 'https://download.aida64.com/aida64engineer675.zip', + 'Adobe Reader DC': 'https://ardownload2.adobe.com/pub/adobe/reader/win/AcrobatDC/2200220191/AcroRdrDC2200220191_en_US.exe', 'Aria2': 'https://github.com/aria2/aria2/releases/download/release-1.36.0/aria2-1.36.0-win-32bit-build1.zip', 'Autoruns32': 'http://live.sysinternals.com/Autoruns.exe', 'Autoruns64': 'http://live.sysinternals.com/Autoruns64.exe', @@ -47,28 +47,28 @@ SOURCES = { 'BlueScreenView32': 'http://www.nirsoft.net/utils/bluescreenview.zip', 'BlueScreenView64': 'http://www.nirsoft.net/utils/bluescreenview-x64.zip', 'ERUNT': 'http://www.aumha.org/downloads/erunt.zip', - 'Everything32': 'https://www.voidtools.com/Everything-1.4.1.1009.x86.en-US.zip', - 'Everything64': 'https://www.voidtools.com/Everything-1.4.1.1009.x64.en-US.zip', - 'FastCopy': 'https://ftp.vector.co.jp/73/10/2323/FastCopy392_installer.exe', - 'Fluent-Metro': 'https://github.com/bonzibudd/Fluent-Metro/releases/download/v1.5.2/Fluent-Metro_1.5.2.zip', - 'FurMark': 'https://geeks3d.com/dl/get/569', - 'HWiNFO': 'https://www.sac.sk/download/utildiag/hwi_712.zip', - 'IOBit Uninstaller': 'https://portableapps.com/redirect/?a=IObitUninstallerPortable&s=s&d=pa&f=IObitUninstallerPortable_7.5.0.7.paf.exe', - 'LibreOffice32': 'https://download.documentfoundation.org/libreoffice/stable/7.3.0/win/x86/LibreOffice_7.3.0_Win_x86.msi', - 'LibreOffice64': 'https://download.documentfoundation.org/libreoffice/stable/7.3.0/win/x86_64/LibreOffice_7.3.0_Win_x64.msi', + 'Everything32': 'https://www.voidtools.com/Everything-1.4.1.1020.x86.zip', + 'Everything64': 'https://www.voidtools.com/Everything-1.4.1.1020.x64.zip', + 'FastCopy': 'https://ftp.vector.co.jp/75/32/2323/FastCopy4.2.0_installer.exe', + 'Fluent-Metro': 'https://github.com/bonzibudd/Fluent-Metro/releases/download/v1.5.3/Fluent-Metro_1.5.3.zip', + 'FurMark': 'https://geeks3d.com/dl/get/696', + 'HWiNFO': 'https://www.sac.sk/download/utildiag/hwi_730.zip', + 'LibreOffice32': 'https://download.documentfoundation.org/libreoffice/stable/7.3.6/win/x86/LibreOffice_7.3.6_Win_x86.msi', + 'LibreOffice64': 'https://download.documentfoundation.org/libreoffice/stable/7.3.6/win/x86_64/LibreOffice_7.3.6_Win_x64.msi', 'Linux Reader': 'https://www.diskinternals.com/download/Linux_Reader.exe', 'Macs Fan Control': 'https://www.crystalidea.com/downloads/macsfancontrol_setup.exe', 'Neutron': 'http://keir.net/download/neutron.zip', 'Notepad++': 'https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v8.1.9.3/npp.8.1.9.3.portable.minimalist.7z', - 'OpenShell': 'https://github.com/Open-Shell/Open-Shell-Menu/releases/download/v4.4.160/OpenShellSetup_4_4_160.exe', + 'OpenShell': 'https://github.com/Open-Shell/Open-Shell-Menu/releases/download/v4.4.170/OpenShellSetup_4_4_170.exe', 'Prime95': 'https://www.mersenne.org/ftp_root/gimps/p95v307b9.win64.zip', 'PuTTY': 'https://the.earth.li/~sgtatham/putty/latest/w32/putty.zip', - 'SDIO Torrent': 'https://www.snappy-driver-installer.org/downloads/SDIO_Update.torrent', + 'SDIO Torrent': 'https://www.glenn.delahoy.com/downloads/sdio/SDIO_Update.torrent', 'ShutUp10': 'https://dl5.oo-software.com/files/ooshutup10/OOSU10.exe', - 'TestDisk': 'https://www.cgsecurity.org/testdisk-7.2-WIP.win.zip', 'Windows Repair AIO': 'http://www.tweaking.com/files/setups/tweaking.com_windows_repair_aio.zip', 'WinSCP': 'https://sourceforge.net/projects/winscp/files/WinSCP/5.19.5/WinSCP-5.19.5-Portable.zip/download', - 'WizTree': 'https://diskanalyzer.com/files/wiztree_4_07_portable.zip', + 'UninstallView32': 'https://www.nirsoft.net/utils/uninstallview.zip', + 'UninstallView64': 'https://www.nirsoft.net/utils/uninstallview-x64.zip', + 'WizTree': 'https://diskanalyzer.com/files/wiztree_4_10_portable.zip', 'XMPlay': 'https://support.xmplay.com/files/20/xmplay385.zip?v=47090', 'XMPlay 7z': 'https://support.xmplay.com/files/16/xmp-7z.zip?v=800962', 'XMPlay Game': 'https://support.xmplay.com/files/12/xmp-gme.zip?v=515637', diff --git a/scripts/wk/hw/surface_scan.py b/scripts/wk/hw/surface_scan.py index f4913a8a..c5cd5d12 100644 --- a/scripts/wk/hw/surface_scan.py +++ b/scripts/wk/hw/surface_scan.py @@ -8,7 +8,8 @@ from subprocess import STDOUT from wk.cfg.hw import ( BADBLOCKS_LARGE_DISK, BADBLOCKS_REGEX, - BADBLOCKS_SKIP_REGEX, + BADBLOCKS_RESULTS_REGEX, + #BADBLOCKS_SKIP_REGEX, TEST_MODE_BADBLOCKS_LIMIT, ) from wk.exe import run_program @@ -35,6 +36,11 @@ def check_surface_scan_results(test_obj, log_path) -> None: if not line: # Skip continue + + # Clean line by removing backspaces/etc + line = BADBLOCKS_RESULTS_REGEX.sub(r'\1 \2', line) + + # Add to report match = BADBLOCKS_REGEX.search(line) if match: if all(s == '0' for s in match.groups()): diff --git a/scripts/wk/kit/build_win.py b/scripts/wk/kit/build_win.py index bbc345f1..e5d15ea9 100644 --- a/scripts/wk/kit/build_win.py +++ b/scripts/wk/kit/build_win.py @@ -75,10 +75,10 @@ def delete_from_temp(item_path): delete_item(TMP_DIR.joinpath(item_path), force=True, ignore_errors=True) -def download_to_temp(filename, source_url): +def download_to_temp(filename, source_url, referer=None): """Download file to temp dir, returns pathlib.Path.""" out_path = TMP_DIR.joinpath(filename) - download_file(out_path, source_url) + download_file(out_path, source_url, referer=referer) return out_path @@ -209,7 +209,7 @@ def download_fastcopy(): def download_furmark(): """Download FurMark.""" - installer = download_to_temp('FurMark_Setup.exe', SOURCES['FurMark']) + installer = download_to_temp('FurMark_Setup.exe', SOURCES['FurMark'], referer=SOURCES['FurMark']) out_path = BIN_DIR.joinpath('FurMark') tmp_path = TMP_DIR.joinpath('FurMarkInstall') run_program([installer, f'/DIR={tmp_path}', '/SILENT']) @@ -230,21 +230,12 @@ def download_hwinfo(): delete_from_temp('HWiNFO.zip') -def download_iobit_uninstaller(): - """Download IOBit Uninstaller.""" - installer = CBIN_DIR.joinpath('IObitUninstallerPortable.exe') - download_file(installer, SOURCES['IOBit Uninstaller']) - popen_program([installer]) - sleep(1) - wait_for_procs('IObitUninstallerPortable.exe') - delete_item(installer) - - def download_libreoffice(): """Download LibreOffice.""" for arch in 32, 64: out_path = INSTALLERS_DIR.joinpath(f'LibreOffice{arch}.msi') download_file(out_path, SOURCES[f'LibreOffice{arch}']) + sleep(1) def download_linux_reader(): @@ -378,15 +369,19 @@ def download_snappy_driver_installer_origin(): delete_from_temp('fake.7z') -def download_testdisk(): - """Download TestDisk.""" - archive = download_to_temp('testdisk_wip.zip', SOURCES['TestDisk']) - out_path = BIN_DIR.joinpath('TestDisk') - tmp_path = TMP_DIR.joinpath('TestDisk') - extract_archive(archive, tmp_path) - rename_item(tmp_path.joinpath('testdisk-7.2-WIP'), out_path) - delete_from_temp('TestDisk') - delete_from_temp('testdisk_wip.zip') +def download_uninstallview(): + """Download UninstallView.""" + archive_32 = download_to_temp('uninstallview32.zip', SOURCES['UninstallView32']) + archive_64 = download_to_temp('uninstallview64.zip', SOURCES['UninstallView64']) + out_path = BIN_DIR.joinpath('UninstallView') + extract_archive(archive_64, out_path, 'UninstallView.exe') + rename_item( + out_path.joinpath('UninstallView.exe'), + out_path.joinpath('UninstallView64.exe'), + ) + extract_archive(archive_32, out_path) + delete_from_temp('uninstallview32.zip') + delete_from_temp('uninstallview64.zip') def download_windows_repair_aio(): @@ -527,7 +522,6 @@ def build_kit(): try_print.run('FastCopy...', download_fastcopy) try_print.run('FurMark...', download_furmark) try_print.run('HWiNFO...', download_hwinfo) - try_print.run('IOBit Uninstaller...', download_iobit_uninstaller) try_print.run('LibreOffice...', download_libreoffice) try_print.run('Linux Reader...', download_linux_reader) try_print.run('Macs Fan Control...', download_macs_fan_control) @@ -538,9 +532,9 @@ def build_kit(): try_print.run('Prime95...', download_prime95) try_print.run('PuTTY...', download_putty) try_print.run('Snappy Driver Installer...', download_snappy_driver_installer_origin) - try_print.run('TestDisk...', download_testdisk) try_print.run('Windows Repair AIO...', download_windows_repair_aio) try_print.run('WinSCP...', download_winscp) + try_print.run('UninstallView...', download_uninstallview) try_print.run('WizTree...', download_wiztree) try_print.run('XMPlay...', download_xmplay) try_print.run('XMPlay Music...', download_xmplay_music) diff --git a/scripts/wk/kit/tools.py b/scripts/wk/kit/tools.py index 781d14d6..0d59cb81 100644 --- a/scripts/wk/kit/tools.py +++ b/scripts/wk/kit/tools.py @@ -11,7 +11,7 @@ import requests from wk.cfg.main import ARCHIVE_PASSWORD from wk.cfg.sources import DOWNLOAD_FREQUENCY, SOURCES from wk.exe import popen_program, run_program -from wk.std import GenericError +from wk.std import GenericError, sleep # STATIC VARIABLES @@ -30,7 +30,7 @@ CACHED_DIRS = {} # Functions -def download_file(out_path, source_url, as_new=False, overwrite=False): +def download_file(out_path, source_url, as_new=False, overwrite=False, referer=None): """Download a file using requests, returns pathlib.Path.""" out_path = pathlib.Path(out_path).resolve() name = out_path.name @@ -47,12 +47,24 @@ def download_file(out_path, source_url, as_new=False, overwrite=False): # Create destination directory out_path.parent.mkdir(parents=True, exist_ok=True) + # Update headers + headers = HEADERS.copy() + if referer: + headers['referer'] = referer + # Request download with requests.Session() as session: try: - response = session.get(source_url, headers=HEADERS, stream=True) + response = session.get(source_url, allow_redirects=True, headers=headers, stream=True) except requests.RequestException as _err: - download_failed = _err + try: + sleep(1) + response = session.get(source_url, allow_redirects=True, headers=headers, stream=True) + except requests.RequestException as _err2: + download_failed = _err2 + else: + if not response.ok: + download_failed = response else: if not response.ok: download_failed = response diff --git a/scripts/wk/log.py b/scripts/wk/log.py index 505c9475..3a776677 100644 --- a/scripts/wk/log.py +++ b/scripts/wk/log.py @@ -40,7 +40,8 @@ def enable_debug_mode(): def format_log_path( log_dir=None, log_name=None, timestamp=False, - kit=False, tool=False): + kit=False, tool=False, append=False): + # pylint: disable=too-many-arguments """Format path based on args passed, returns pathlib.Path obj.""" log_path = pathlib.Path( f'{log_dir if log_dir else DEFAULT_LOG_DIR}/' @@ -54,7 +55,8 @@ def format_log_path( log_path = log_path.resolve() # Avoid clobbering - log_path = non_clobber_path(log_path) + if not append: + log_path = non_clobber_path(log_path) # Done return log_path @@ -121,10 +123,10 @@ def start(config=None): def update_log_path( - dest_dir=None, dest_name=None, keep_history=True, timestamp=True): + dest_dir=None, dest_name=None, keep_history=True, timestamp=True, append=False): """Moves current log file to new path and updates the root logger.""" root_logger = logging.getLogger() - new_path = format_log_path(dest_dir, dest_name, timestamp=timestamp) + new_path = format_log_path(dest_dir, dest_name, timestamp=timestamp, append=append) old_handler = None old_path = get_root_logger_path() os.makedirs(new_path.parent, exist_ok=True) @@ -147,10 +149,15 @@ def update_log_path( new_handler = logging.FileHandler(new_path, mode='a') new_handler.setFormatter(old_handler.formatter) - # Remove old_handler and log if empty + # Remove old_handler root_logger.removeHandler(old_handler) old_handler.close() - remove_empty_log(old_path) + + # Delete orignal log if needed + if keep_history: + remove_empty_log(old_path) + else: + old_path.unlink() # Add new handler root_logger.addHandler(new_handler) diff --git a/scripts/wk/os/win.py b/scripts/wk/os/win.py index 331d75a4..a7fa6118 100644 --- a/scripts/wk/os/win.py +++ b/scripts/wk/os/win.py @@ -30,6 +30,7 @@ from wk.std import ( GenericWarning, bytes_to_string, color_string, + input_text, sleep, ) @@ -73,6 +74,7 @@ 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 REG_MSISERVER = r'HKLM\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\MSIServer' SLMGR = pathlib.Path(f'{os.environ.get("SYSTEMROOT")}/System32/slmgr.vbs') +SYSTEMDRIVE = os.environ.get('SYSTEMDRIVE') # Activation Functions @@ -166,6 +168,24 @@ def check_4k_alignment(show_alert=False): raise GenericError('One or more partitions are not 4K aligned') +def export_bitlocker_info(): + """Get Bitlocker info and save to the current directory.""" + commands = [ + ['manage-bde', '-status', SYSTEMDRIVE], + ['manage-bde', '-protectors', '-get', SYSTEMDRIVE], + ] + + # Get filename + file_name = input_text(prompt='Enter filename', allow_empty_response=False) + file_path = pathlib.Path(f'../../Bitlocker_{file_name}.txt').resolve() + + # Save info + with open(file_path, 'a', encoding='utf-8') as _f: + for cmd in commands: + proc = run_program(cmd, check=False) + _f.write(f'{proc.stdout}\n\n') + + def get_installed_antivirus(): """Get list of installed antivirus programs, returns list.""" cmd = [ diff --git a/scripts/wk/repairs/win.py b/scripts/wk/repairs/win.py index 388e14c6..9a131594 100644 --- a/scripts/wk/repairs/win.py +++ b/scripts/wk/repairs/win.py @@ -44,7 +44,11 @@ from wk.kit.tools import ( get_tool_path, run_tool, ) -from wk.log import format_log_path, update_log_path +from wk.log import ( + format_log_path, + get_root_logger_path, + update_log_path, + ) from wk.os.win import ( ARCH, OS_VERSION, @@ -91,6 +95,7 @@ GPUPDATE_SUCCESS_STRINGS = ( 'User Policy update has completed successfully.', ) IN_CONEMU = 'ConEmuPID' in os.environ +MENU_PRESETS = Menu() PROGRAMFILES_32 = os.environ.get( 'PROGRAMFILES(X86)', os.environ.get( 'PROGRAMFILES', r'C:\Program Files (x86)', @@ -123,7 +128,7 @@ for error in ('CalledProcessError', 'FileNotFoundError'): # Auto Repairs -def build_menus(base_menus, title): +def build_menus(base_menus, title, presets): """Build menus, returns dict.""" menus = {} menus['Main'] = Menu(title=f'{title}\n{color_string("Main Menu", "GREEN")}') @@ -170,6 +175,22 @@ def build_menus(base_menus, title): sys.modules[__name__], _function, ) + # Update presets + for group, entries in base_menus['Groups'].items(): + presets['Default'][group] = tuple( + entry.name for entry in entries if entry.details['Selected'] + ) + + # Update presets Menu + MENU_PRESETS.title = f'{title}\n{color_string("Load Preset", "GREEN")}' + MENU_PRESETS.add_option('Default') + for name in presets: + MENU_PRESETS.add_option(name) + MENU_PRESETS.add_option('Custom') + MENU_PRESETS.add_action('Main Menu') + MENU_PRESETS.add_action('Quit') + MENU_PRESETS.update() + # Done return menus @@ -244,13 +265,6 @@ def init(menus): """Initialize Auto Repairs.""" session_started = is_session_started() - # Run AVRemover - if not session_started: - TRY_PRINT.run( - 'Run AVRemover...', run_tool, 'AVRemover', 'AVRemover', - download=True, msg_good='DONE', - ) - # Check if autologon is needed if not session_started: if is_autologon_enabled(): @@ -278,6 +292,7 @@ def init(menus): def init_run(options): """Initialize Auto Repairs Run.""" + update_scheduled_task() if options['Kill Explorer']['Selected']: atexit.register(start_explorer) reg_set_value('HKCU', AUTO_REPAIR_KEY, 'Kill Explorer', 1, 'DWORD') @@ -306,6 +321,7 @@ def init_run(options): def init_session(options): """Initialize Auto Repairs session.""" reg_set_value('HKCU', AUTO_REPAIR_KEY, 'SessionStarted', 1, 'DWORD') + reg_set_value('HKCU', AUTO_REPAIR_KEY, 'LogName', get_root_logger_path().stem, 'SZ') # Check timezone zone = get_timezone() @@ -316,19 +332,11 @@ def init_session(options): if zone != WINDOWS_TIME_ZONE and ask(msg): set_timezone(WINDOWS_TIME_ZONE) - # Create logon task for Auto Repairs - cmd = [ - 'schtasks', '/create', '/f', - '/sc', 'ONLOGON', - '/tn', f'{KIT_NAME_FULL}-AutoRepairs', - '/rl', 'HIGHEST', - '/tr', fr'C:\Windows\System32\cmd.exe "/C {sys.executable} {sys.argv[0]}"', - ] - if IN_CONEMU: - cmd[-1] = f'{CONEMU_EXE} -run {sys.executable} {sys.argv[0]}' - run_program(cmd) - # One-time tasks + TRY_PRINT.run( + 'Run AVRemover...', run_tool, 'AVRemover', 'AVRemover', + download=True, msg_good='DONE', + ) if options['Run TDSSKiller (once)']['Selected']: TRY_PRINT.run('Running TDSSKiller...', run_tdsskiller, msg_good='DONE') print('') @@ -365,6 +373,32 @@ def is_session_started(): return session_started +def load_preset(menus, presets, enable_menu_exit=True): + """Load menu settings from preset and ask selection question(s).""" + if not enable_menu_exit: + MENU_PRESETS.actions['Main Menu'].update({'Disabled':True, 'Hidden':True}) + + # Get selection + selection = MENU_PRESETS.simple_select() + + # Exit early + if 'Main Menu' in selection: + return + if 'Quit' in selection: + raise SystemExit + + # Load preset + preset = presets[selection[0]] + for group, menu in menus.items(): + group_enabled = group in preset + for name in menu.options: + value = group_enabled and name in preset[group] + menu.options[name]['Selected'] = value + + # Re-enable Main Menu action if disabled + MENU_PRESETS.actions['Main Menu'].update({'Disabled':False, 'Hidden':False}) + + def load_settings(menus): """Load session settings from the registry.""" for group, menu in menus.items(): @@ -374,9 +408,9 @@ def load_settings(menus): menu.options[name].update(get_entry_settings(group, name)) -def run_auto_repairs(base_menus): +def run_auto_repairs(base_menus, presets): """Run Auto Repairs.""" - update_log_path(dest_name='Auto Repairs', timestamp=True) + set_log_path() title = f'{KIT_NAME_FULL}: Auto Repairs' clear_screen() set_title(title) @@ -385,7 +419,10 @@ def run_auto_repairs(base_menus): # Generate menus print_standard('Initializing...') - menus = build_menus(base_menus, title) + menus = build_menus(base_menus, title, presets) + + # Get repair preset + load_preset(menus, presets, enable_menu_exit=False) # Init try: @@ -397,7 +434,7 @@ def run_auto_repairs(base_menus): # Show Menu if session_started is None or not session_started: try: - show_main_menu(base_menus, menus) + show_main_menu(base_menus, menus, presets, title) except SystemExit: if ask('End session?'): end_session(menus) @@ -518,13 +555,26 @@ def save_settings(group, name, result=None, **kwargs): reg_set_value('HKCU', key_path, value_name, data, data_type) -def show_main_menu(base_menus, menus): +def set_log_path(): + """Set log name using defaults or the saved registry value.""" + try: + log_path = reg_read_value('HKCU', AUTO_REPAIR_KEY, 'LogName') + except FileNotFoundError: + # Ignore and use default values + update_log_path(dest_name='Auto Repairs', timestamp=True) + else: + update_log_path(dest_name=log_path, keep_history=False, timestamp=False, append=True) + + +def show_main_menu(base_menus, menus, presets, title): """Show main menu and handle actions.""" while True: update_main_menu(menus) selection = menus['Main'].simple_select(update=False) if selection[0] in base_menus['Groups'] or selection[0] == 'Options': show_sub_menu(menus[selection[0]]) + if selection[0] == 'Load Preset': + load_preset(menus, presets, title) elif 'Start' in selection: break elif 'Quit' in selection: @@ -580,6 +630,20 @@ def update_main_menu(menus): menus['Main'].options[name]['Display Name'] = display_name +def update_scheduled_task(): + """Create (or update) scheduled task to start repairs.""" + cmd = [ + 'schtasks', '/create', '/f', + '/sc', 'ONLOGON', + '/tn', f'{KIT_NAME_FULL}-AutoRepairs', + '/rl', 'HIGHEST', + '/tr', fr'C:\Windows\System32\cmd.exe "/C {sys.executable} {sys.argv[0]}"', + ] + if IN_CONEMU: + cmd[-1] = f'{CONEMU_EXE} -run {sys.executable} {sys.argv[0]}' + run_program(cmd) + + # Auto Repairs: Wrapper Functions def auto_adwcleaner(group, name): """Run AdwCleaner scan. @@ -737,14 +801,6 @@ def auto_hitmanpro(group, name): save_settings(group, name, result=result) -def auto_iobit_uninstaller(group, name): - """Run IO Bit Uninstaller scan.""" - result = TRY_PRINT.run( - 'IO Bit Uninstaller...', run_iobit_uninstaller, msg_good='DONE', - ) - save_settings(group, name, result=result) - - def auto_kvrt(group, name): """Run KVRT scan.""" result = TRY_PRINT.run('KVRT...', run_kvrt, msg_good='DONE') @@ -871,6 +927,14 @@ def auto_system_restore_set_size(group, name): save_settings(group, name, result=result) +def auto_uninstallview(group, name): + """Run UninstallView.""" + result = TRY_PRINT.run( + 'UninstallView...', run_uninstallview, msg_good='DONE', + ) + save_settings(group, name, result=result) + + def auto_windows_updates_disable(group, name): """Disable Windows Updates.""" result = TRY_PRINT.run('Disable Windows Updates...', disable_windows_updates) @@ -1146,11 +1210,6 @@ def run_hitmanpro(): proc.wait() -def run_iobit_uninstaller(): - """Run IO Bit Uninstaller.""" - run_tool('IObitUninstallerPortable', 'IObitUninstallerPortable', cbin=True) - - def run_kvrt(): """Run KVRT scan.""" log_path = format_log_path(log_name='KVRT', timestamp=True, tool=True) @@ -1690,6 +1749,11 @@ def run_sfc_scan(): raise OSError +def run_uninstallview(): + """Run UninstallView.""" + run_tool('UninstallView', 'UninstallView') + + def set_system_restore_size(size=8): """Set System Restore size.""" cmd = [ diff --git a/scripts/wk/setup/win.py b/scripts/wk/setup/win.py index 3bd8bcc8..02574707 100644 --- a/scripts/wk/setup/win.py +++ b/scripts/wk/setup/win.py @@ -913,7 +913,7 @@ def install_software_bundle(): def install_vcredists(): """Install latest supported Visual C++ runtimes.""" - for year in (2012, 2013, 2019): + for year in (2012, 2013, 2022): cmd_args = ['/install', '/passive', '/norestart'] if year == 2012: cmd_args.pop(0)