From f9ab36fc7c69d404e840d9805c469ff5c85d7621 Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Sun, 7 Oct 2018 21:04:41 -0600 Subject: [PATCH] Reorganized ClientDir * "ClientDir\Info" renamed to "ClientDir\Logs" * Logs are sorted into subdirs based on the source: * KIT_NAME_FULL: WizardKit logs * d7II: d7II logs * Tools: Logs from tools called by WizardKit or d7II * (no subdir): System information * "ClientDir\Backups" * Switched to "Backups\Source\{Date}" from "Backups\{Date}\Source" --- .bin/Scripts/activate.py | 2 +- .bin/Scripts/borrowed/sensors.py | 54 +++++++++++----------- .bin/Scripts/cbs_fix.py | 9 ++-- .bin/Scripts/check_disk.py | 5 ++- .bin/Scripts/dism.py | 5 ++- .bin/Scripts/functions/activation.py | 2 +- .bin/Scripts/functions/backup.py | 26 +++++------ .bin/Scripts/functions/browsers.py | 16 +++---- .bin/Scripts/functions/cleanup.py | 58 ++++++++++++------------ .bin/Scripts/functions/common.py | 9 ++-- .bin/Scripts/functions/data.py | 36 +++++++-------- .bin/Scripts/functions/ddrescue.py | 4 +- .bin/Scripts/functions/diags.py | 9 ++-- .bin/Scripts/functions/disk.py | 60 ++++++++++++------------- .bin/Scripts/functions/info.py | 11 ++--- .bin/Scripts/functions/network.py | 4 +- .bin/Scripts/functions/product_keys.py | 2 +- .bin/Scripts/functions/repairs.py | 16 +++---- .bin/Scripts/functions/windows_setup.py | 16 +++---- .bin/Scripts/functions/winpe_menus.py | 30 ++++++------- .bin/Scripts/init_client_dir.cmd | 6 +-- .bin/Scripts/install_eset_nod32_av.py | 3 +- .bin/Scripts/install_sw_bundle.py | 5 ++- .bin/Scripts/install_vcredists.py | 7 +-- .bin/Scripts/post_d7.py | 4 +- .bin/Scripts/reset_browsers.py | 4 +- .bin/Scripts/safemode_enter.py | 6 +-- .bin/Scripts/safemode_exit.py | 6 +-- .bin/Scripts/settings/launchers.py | 20 +++++---- .bin/Scripts/settings/windows_builds.py | 6 +-- .bin/Scripts/sfc_scan.py | 5 ++- .bin/Scripts/system_checklist.py | 3 +- .bin/Scripts/system_checklist_hw.py | 3 +- .bin/Scripts/system_diagnostics.py | 4 +- .bin/Scripts/transferred_keys.py | 5 ++- .bin/Scripts/user_checklist.py | 4 +- .bin/Scripts/user_data_transfer.py | 17 +++---- 37 files changed, 244 insertions(+), 238 deletions(-) diff --git a/.bin/Scripts/activate.py b/.bin/Scripts/activate.py index 3555c46a..642e5edd 100644 --- a/.bin/Scripts/activate.py +++ b/.bin/Scripts/activate.py @@ -39,7 +39,7 @@ if __name__ == '__main__': selection = menu_select( '{}: Windows Activation Menu'.format(KIT_NAME_FULL), main_entries=activation_methods, action_entries=actions) - + if (selection.isnumeric()): result = try_and_print( message = activation_methods[int(selection)-1]['Name'], diff --git a/.bin/Scripts/borrowed/sensors.py b/.bin/Scripts/borrowed/sensors.py index 847f2619..39b00a4f 100644 --- a/.bin/Scripts/borrowed/sensors.py +++ b/.bin/Scripts/borrowed/sensors.py @@ -35,7 +35,7 @@ class feature(Structure): _fields_ = [("name", c_char_p), ("number", c_int), ("type", c_int)] - + # sensors_feature_type IN = 0x00 FAN = 0x01 @@ -71,10 +71,10 @@ COMPUTE_MAPPING = 4 def init(cfg_file = None): file = _libc.fopen(cfg_file.encode("utf-8"), "r") if cfg_file is not None else None - + if _hdl.sensors_init(file) != 0: raise Exception("sensors_init failed") - + if file is not None: _libc.fclose(file) @@ -84,10 +84,10 @@ def cleanup(): def parse_chip_name(orig_name): ret = chip_name() err= _hdl.sensors_parse_chip_name(orig_name.encode("utf-8"), byref(ret)) - + if err < 0: raise Exception(strerror(err)) - + return ret def strerror(errnum): @@ -101,10 +101,10 @@ def get_detected_chips(match, nr): @return: (chip, next nr to query) """ _nr = c_int(nr) - + if match is not None: match = byref(match) - + chip = _hdl.sensors_get_detected_chips(match, byref(_nr)) chip = chip.contents if bool(chip) else None return chip, _nr.value @@ -115,10 +115,10 @@ def chip_snprintf_name(chip, buffer_size=200): """ ret = create_string_buffer(buffer_size) err = _hdl.sensors_snprintf_chip_name(ret, buffer_size, byref(chip)) - + if err < 0: raise Exception(strerror(err)) - + return ret.value.decode("utf-8") def do_chip_sets(chip): @@ -128,7 +128,7 @@ def do_chip_sets(chip): err = _hdl.sensors_do_chip_sets(byref(chip)) if err < 0: raise Exception(strerror(err)) - + def get_adapter_name(bus): return _hdl.sensors_get_adapter_name(byref(bus)).decode("utf-8") @@ -177,60 +177,60 @@ class ChipIterator: def __init__(self, match = None): self.match = parse_chip_name(match) if match is not None else None self.nr = 0 - + def __iter__(self): return self - + def __next__(self): chip, self.nr = get_detected_chips(self.match, self.nr) - + if chip is None: raise StopIteration - + return chip - + def __del__(self): if self.match is not None: free_chip_name(self.match) - + def next(self): # python2 compability return self.__next__() - + class FeatureIterator: def __init__(self, chip): self.chip = chip self.nr = 0 - + def __iter__(self): return self - + def __next__(self): feature, self.nr = get_features(self.chip, self.nr) - + if feature is None: raise StopIteration - + return feature def next(self): # python2 compability return self.__next__() - + class SubFeatureIterator: def __init__(self, chip, feature): self.chip = chip self.feature = feature self.nr = 0 - + def __iter__(self): return self - + def __next__(self): subfeature, self.nr = get_all_subfeatures(self.chip, self.feature, self.nr) - + if subfeature is None: raise StopIteration - + return subfeature - + def next(self): # python2 compability return self.__next__() diff --git a/.bin/Scripts/cbs_fix.py b/.bin/Scripts/cbs_fix.py index a3b40a8d..ff619369 100644 --- a/.bin/Scripts/cbs_fix.py +++ b/.bin/Scripts/cbs_fix.py @@ -10,7 +10,8 @@ from functions.cleanup import * from functions.data import * init_global_vars() os.system('title {}: CBS Cleanup'.format(KIT_NAME_FULL)) -global_vars['LogFile'] = r'{LogDir}\CBS Cleanup.log'.format(**global_vars) +global_vars['LogFile'] = r'{LogDir}\{kit_name}\CBS Cleanup.log'.format( + kit_name=KIT_NAME_FULL, **global_vars) if __name__ == '__main__': try: @@ -20,18 +21,18 @@ if __name__ == '__main__': folder_path = r'{}\Backups'.format(KIT_NAME_SHORT) dest = select_destination(folder_path=folder_path, prompt='Which disk are we using for temp data and backup?') - + # Show details print_info('{}: CBS Cleanup Tool\n'.format(KIT_NAME_FULL)) show_data('Backup / Temp path:', dest) print_standard('\n') if (not ask('Proceed with CBS cleanup?')): abort() - + # Run Cleanup try_and_print(message='Running cleanup...', function=cleanup_cbs, cs='Done', dest_folder=dest) - + # Done print_standard('\nDone.') pause("Press Enter to exit...") diff --git a/.bin/Scripts/check_disk.py b/.bin/Scripts/check_disk.py index 734319f0..131e56b5 100644 --- a/.bin/Scripts/check_disk.py +++ b/.bin/Scripts/check_disk.py @@ -9,7 +9,8 @@ sys.path.append(os.getcwd()) from functions.repairs import * init_global_vars() os.system('title {}: Check Disk Tool'.format(KIT_NAME_FULL)) -global_vars['LogFile'] = r'{LogDir}\Check Disk.log'.format(**global_vars) +global_vars['LogFile'] = r'{LogDir}\{kit_name}\Check Disk.log'.format( + kit_name=KIT_NAME_FULL, **global_vars) if __name__ == '__main__': try: @@ -45,7 +46,7 @@ if __name__ == '__main__': cs=cs, other_results=other_results, repair=repair) else: abort() - + # Done print_success('Done.') pause("Press Enter to exit...") diff --git a/.bin/Scripts/dism.py b/.bin/Scripts/dism.py index 1c88e51b..9cb6e7fe 100644 --- a/.bin/Scripts/dism.py +++ b/.bin/Scripts/dism.py @@ -9,7 +9,8 @@ sys.path.append(os.getcwd()) from functions.repairs import * init_global_vars() os.system('title {}: DISM helper Tool'.format(KIT_NAME_FULL)) -global_vars['LogFile'] = r'{LogDir}\DISM helper tool.log'.format(**global_vars) +global_vars['LogFile'] = r'{LogDir}\{kit_name}\DISM Helper.log'.format( + kit_name=KIT_NAME_FULL, **global_vars) if __name__ == '__main__': try: @@ -46,7 +47,7 @@ if __name__ == '__main__': other_results=other_results, repair=repair) else: abort() - + # Done print_success('Done.') pause("Press Enter to exit...") diff --git a/.bin/Scripts/functions/activation.py b/.bin/Scripts/functions/activation.py index f54d1dca..24436418 100644 --- a/.bin/Scripts/functions/activation.py +++ b/.bin/Scripts/functions/activation.py @@ -59,7 +59,7 @@ def windows_is_activated(): ['cscript', '//nologo', SLMGR, '/xpr'], check=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) activation_string = activation_string.stdout.decode() - + return bool(activation_string and 'permanent' in activation_string) if __name__ == '__main__': diff --git a/.bin/Scripts/functions/backup.py b/.bin/Scripts/functions/backup.py index e33cea2c..d872c4d0 100644 --- a/.bin/Scripts/functions/backup.py +++ b/.bin/Scripts/functions/backup.py @@ -16,7 +16,7 @@ def backup_partition(disk, par): """Create a backup image of a partition.""" if par.get('Image Exists', False) or par['Number'] in disk['Bad Partitions']: raise GenericAbort - + cmd = [ global_vars['Tools']['wimlib-imagex'], 'capture', @@ -48,7 +48,7 @@ def get_volume_display_name(mountpoint): serial_number = None max_component_length = None file_system_flags = None - + vol_info = kernel32.GetVolumeInformationW( ctypes.c_wchar_p(mountpoint), vol_name_buffer, @@ -59,16 +59,16 @@ def get_volume_display_name(mountpoint): fs_name_buffer, ctypes.sizeof(fs_name_buffer) ) - + name = '{} "{}"'.format(name, vol_name_buffer.value) except: pass - + return name def prep_disk_for_backup(destination, disk, backup_prefix): """Gather details about the disk and its partitions. - + This includes partitions that can't be backed up, whether backups already exist on the BACKUP_SERVER, partition names/sizes/used space, etc.""" @@ -83,7 +83,7 @@ def prep_disk_for_backup(destination, disk, backup_prefix): if disk['Valid Partitions'] <= 0: print_error('ERROR: No partitions can be backed up for this disk') raise GenericAbort - + # Prep partitions for par in disk['Partitions']: display = '{size} {fs}'.format( @@ -91,7 +91,7 @@ def prep_disk_for_backup(destination, disk, backup_prefix): width = width, size = par['Size'], fs = par['FileSystem']) - + if par['Number'] in disk['Bad Partitions']: # Set display string using partition description & OS type display = '* {display}\t\t{q}{name}{q}\t{desc} ({os})'.format( @@ -120,7 +120,7 @@ def prep_disk_for_backup(destination, disk, backup_prefix): display = '+ {}'.format(display) else: display = ' {}'.format(display) - + # Append rest of Display String for valid/clobber partitions display += ' (Used: {used})\t{q}{name}{q}'.format( used = par['Used Space'], @@ -128,7 +128,7 @@ def prep_disk_for_backup(destination, disk, backup_prefix): name = par['Name']) # For all partitions par['Display String'] = display - + # Set description for bad partitions warnings = '\n' if disk['Bad Partitions']: @@ -148,7 +148,7 @@ def select_backup_destination(auto_select=True): actions = [ {'Name': 'Main Menu', 'Letter': 'M'}, ] - + # Add local disks for d in psutil.disk_partitions(): if re.search(r'^{}'.format(global_vars['Env']['SYSTEMDRIVE']), d.mountpoint, re.IGNORECASE): @@ -161,7 +161,7 @@ def select_backup_destination(auto_select=True): get_volume_display_name(d.mountpoint)), 'Letter': re.sub(r'^(\w):\\.*$', r'\1', d.mountpoint), }) - + # Size check for dest in destinations: if 'IP' in dest: @@ -175,11 +175,11 @@ def select_backup_destination(auto_select=True): if not destinations: print_warning('No backup destinations found.') raise GenericAbort - + # Skip menu? if len(destinations) == 1 and auto_select: return destinations[0] - + selection = menu_select( title = 'Where are we backing up to?', main_entries = destinations, diff --git a/.bin/Scripts/functions/browsers.py b/.bin/Scripts/functions/browsers.py index a17422ef..143d018d 100644 --- a/.bin/Scripts/functions/browsers.py +++ b/.bin/Scripts/functions/browsers.py @@ -137,7 +137,7 @@ def archive_all_users(): if not os.path.exists(source_path): continue source_items = source_path + '*' - archive_path = r'{BackupDir}\Browsers ({USERNAME})'.format( + archive_path = r'{BackupDir}\Browsers ({USERNAME})\{Date}'.format( **global_vars, **fake_env) os.makedirs(archive_path, exist_ok=True) archive_path += r'\{}.7z'.format(b_k) @@ -152,7 +152,7 @@ def archive_all_users(): def archive_browser(name): """Create backup of Browser saved in the BackupDir.""" source = '{}*'.format(browser_data[name]['user_data_path']) - dest = r'{BackupDir}\Browsers ({USERNAME})'.format( + dest = r'{BackupDir}\Browsers ({USERNAME})\{Date}'.format( **global_vars, **global_vars['Env']) archive = r'{}\{}.7z'.format(dest, name) os.makedirs(dest, exist_ok=True) @@ -274,7 +274,7 @@ def get_browser_details(name): profiles.extend( get_mozilla_profiles( search_path=browser['user_data_path'], dev=dev)) - + elif 'Opera' in name: if os.path.exists(browser['user_data_path']): profiles.append( @@ -413,7 +413,7 @@ def install_adblock(indent=8, width=32, just_firefox=False): winreg.QueryValue(HKLM, UBO_EXTRA_CHROME_REG) except FileNotFoundError: urls.append(UBO_EXTRA_CHROME) - + if len(urls) == 0: urls = ['chrome://extensions'] elif 'Opera' in browser: @@ -421,7 +421,7 @@ def install_adblock(indent=8, width=32, just_firefox=False): else: urls.append(UBO_CHROME) urls.append(UBO_EXTRA_CHROME) - + elif browser_data[browser]['base'] == 'mozilla': # Check for system extensions try: @@ -434,11 +434,11 @@ def install_adblock(indent=8, width=32, just_firefox=False): urls = ['about:addons'] else: urls = [UBO_MOZILLA] - + elif browser_data[browser]['base'] == 'ie': urls.append(IE_GALLERY) function=popen_program - + # By using check=False we're skipping any return codes so # it should only fail if the program can't be run # (or can't be found). @@ -461,7 +461,7 @@ def list_homepages(indent=8, width=32): end='', flush=True) print_warning('Not implemented', timestamp=False) continue - + # All other browsers print_info('{indent}{browser:<{width}}'.format( indent=' '*indent, width=width, browser=browser+'...')) diff --git a/.bin/Scripts/functions/cleanup.py b/.bin/Scripts/functions/cleanup.py index 96570b4d..84227b30 100644 --- a/.bin/Scripts/functions/cleanup.py +++ b/.bin/Scripts/functions/cleanup.py @@ -46,7 +46,7 @@ def cleanup_adwcleaner(): # Main folder if os.path.exists(source_path): os.makedirs(global_vars['LogDir'], exist_ok=True) - dest_name = r'{LogDir}\{Date}\AdwCleaner'.format( + dest_name = r'{LogDir}\Tools\AdwCleaner'.format( **global_vars) dest_name = non_clobber_rename(dest_name) shutil.move(source_path, dest_name) @@ -93,7 +93,7 @@ def cleanup_cbs(dest_folder): def cleanup_d7ii(): """Sort d7II logs and remove temp items.""" d7_path = r'{}\d7II'.format(global_vars['ClientDir']) - d7_reports = r'{}_Reports'.format(d7_path) + d7_reports = r'{} Reports'.format(d7_path) d7_temp = r'{}\Temp'.format(d7_path) # Logs & Reports @@ -103,49 +103,46 @@ def cleanup_d7ii(): d7_date = '{}-{:02d}-{:02d}'.format( r.group(1), int(r.group(2)), int(r.group(3))) d7_mlogs = r'{}\Malware Logs'.format(entry.path) - log_dest = r'{SYSTEMDRIVE}\{prefix}\Info\{date}'.format( + log_dest = r'{SYSTEMDRIVE}\{prefix}\Logs\{date}'.format( prefix=KIT_NAME_SHORT, date=d7_date, **global_vars['Env']) - # Remove empty folders - for f in ('Malware Logs', 'Screen Shots'): - try: - os.rmdir(r'{}\{}'.format(entry.path, f)) - except FileNotFoundError: - pass - except OSError: - pass - # Malware Logs if os.path.exists(d7_mlogs): + m_report = 'MalwareScan_Report.txt' for m_entry in os.scandir(d7_mlogs): - prefix = '' - if m_entry.name == 'MalwareScan_Report.txt': - prefix = 'd7II_' - dest_path = r'{log_dest}\{prefix}{name}'.format( - log_dest=log_dest, - prefix=prefix, - name=m_entry.name) + dest_path = r'{}\{}\{}'.format( + log_dest, + 'd7II' if m_entry.name == m_report else 'Tools', + m_entry.name) dest_path = non_clobber_rename(dest_path) shutil.move(entry.path, dest_path) - try: - os.rmdir(d7_mlogs) - except OSError: - pass # Other items for o_entry in os.scandir(entry.path): - dest_path = r'{log_dest}\d7II_{name}'.format( + dest_path = r'{log_dest}\d7II\{name}'.format( log_dest=log_dest, name=m_entry.name) dest_path = non_clobber_rename(dest_path) + + # Just remove empty folders + if o_entry.isdir(): + try: + os.rmdir(o_entry.path) + except OSError: + pass + else: + continue + + # Move item shutil.move(entry.path, dest_path) - # Remove folder if empty + # Remove folder try: os.rmdir(entry.path) except OSError: + # Folder should be empty but whatever pass # Registry Items @@ -167,7 +164,7 @@ def cleanup_d7ii(): def cleanup_desktop(): """Move known backup files and reports into the ClientDir.""" - dest_folder = r'{ProgBackupDir}\{Date}\Desktop'.format(**global_vars) + dest_folder = r'{LogDir}\Tools'.format(**global_vars) os.makedirs(dest_folder, exist_ok=True) desktop_path = r'{USERPROFILE}\Desktop'.format(**global_vars['Env']) @@ -210,12 +207,13 @@ def cleanup_regbackups(): if not os.path.exists(source_path): return + # Make dest folder + dest_dir = r'{BackupDir}\Registry\{Date}'.format(**global_vars) + os.makedirs(dest_dir, exist_ok=True) + # Move to backup folder for entry in os.scandir(source_path): - os.makedirs(global_vars['ProgBackupDir'], exist_ok=True) - dest_path = r'{ProgBackupDir}\{Date}\Registry\{name}'.format( - name=entry.name, - **global_vars) + dest_path = r'{dest}\{name}'.format(dest=dest_dir, name=entry.name) dest_path = non_clobber_rename(dest_path) shutil.move(entry.path, dest_path) diff --git a/.bin/Scripts/functions/common.py b/.bin/Scripts/functions/common.py index 95bcaf7c..d489bbcf 100644 --- a/.bin/Scripts/functions/common.py +++ b/.bin/Scripts/functions/common.py @@ -168,8 +168,7 @@ def exit_script(return_value=0): # Remove dirs (if empty) for dir in ['BackupDir', 'LogDir', 'TmpDir']: try: - dir = global_vars[dir] - os.rmdir(dir) + os.rmdir(global_vars[dir]) except Exception: pass @@ -774,11 +773,9 @@ def set_common_vars(): **global_vars) global_vars['ClientDir'] = r'{SYSTEMDRIVE}\{prefix}'.format( prefix=KIT_NAME_SHORT, **global_vars['Env']) - global_vars['BackupDir'] = r'{ClientDir}\Backups\{Date}'.format( + global_vars['BackupDir'] = r'{ClientDir}\Backups'.format( **global_vars) - global_vars['LogDir'] = r'{ClientDir}\Info\{Date}'.format( - **global_vars) - global_vars['ProgBackupDir'] = r'{ClientDir}\Backups'.format( + global_vars['LogDir'] = r'{ClientDir}\Logs\{Date}'.format( **global_vars) global_vars['QuarantineDir'] = r'{ClientDir}\Quarantine'.format( **global_vars) diff --git a/.bin/Scripts/functions/data.py b/.bin/Scripts/functions/data.py index 7f50610f..26f61645 100644 --- a/.bin/Scripts/functions/data.py +++ b/.bin/Scripts/functions/data.py @@ -126,11 +126,11 @@ def cleanup_transfer(dest_path): if not os.path.exists(dest_path): # Bail if dest_path was empty and removed raise Exception - + # Fix attributes cmd = ['attrib', '-a', '-h', '-r', '-s', dest_path] run_program(cmd, check=False) - + for root, dirs, files in os.walk(dest_path, topdown=False): for name in dirs: # Remove empty directories and junction points @@ -278,7 +278,7 @@ def mount_volumes(all_devices=True, device_path=None, read_write=False): volumes.update({child['name']: child}) for grandchild in child.get('children', []): volumes.update({grandchild['name']: grandchild}) - + # Get list of mounted volumes mounted_volumes = get_mounted_volumes() @@ -357,7 +357,7 @@ def mount_backup_shares(read_write=False): if server['Mounted']: print_warning(mounted_str) continue - + mount_network_share(server, read_write) def mount_network_share(server, read_write=False): @@ -419,12 +419,12 @@ def run_fast_copy(items, dest): """Copy items to dest using FastCopy.""" if not items: raise Exception - + cmd = [global_vars['Tools']['FastCopy'], *FAST_COPY_ARGS] - cmd.append(r'/logfile={}\FastCopy.log'.format(global_vars['LogDir'])) + cmd.append(r'/logfile={LogDir}\Tools\FastCopy.log'.format(**global_vars)) cmd.extend(items) cmd.append('/to={}\\'.format(dest)) - + run_program(cmd) def run_wimextract(source, items, dest): @@ -491,7 +491,7 @@ def list_source_items(source_obj, rel_path=None): def scan_source(source_obj, dest_path, rel_path='', interactive=True): """Scan source for files/folders to transfer, returns list. - + This will scan the root and (recursively) any Windows.old folders.""" selected_items = [] win_olds = [] @@ -568,7 +568,7 @@ def scan_source(source_obj, dest_path, rel_path='', interactive=True): '{}{}{}'.format(dest_path, os.sep, old.name), rel_path=old.name, interactive=False)) - + # Done return selected_items @@ -712,7 +712,7 @@ def select_source(backup_prefix): item.name, # Image file ), 'Source': item}) - + # Check for local sources print_standard('Scanning for local sources...') set_thread_error_mode(silent=True) # Prevents "No disk" popups @@ -752,7 +752,7 @@ def select_source(backup_prefix): ' Local', d.mountpoint, item.name), 'Sort': r'{}{}'.format(d.mountpoint, item.name), 'Source': item}) - + set_thread_error_mode(silent=False) # Return to normal # Build Menu @@ -780,7 +780,7 @@ def select_source(backup_prefix): umount_backup_shares() pause("Press Enter to exit...") exit_script() - + # Sanity check if selected_source.is_file(): # Image-Based @@ -788,7 +788,7 @@ def select_source(backup_prefix): print_error('ERROR: Unsupported image: {}'.format( selected_source.path)) raise GenericError - + # Done return selected_source @@ -796,7 +796,7 @@ def select_volume(title='Select disk', auto_select=True): """Select disk from attached disks. returns dict.""" actions = [{'Name': 'Quit', 'Letter': 'Q'}] disks = [] - + # Build list of disks set_thread_error_mode(silent=True) # Prevents "No disk" popups for d in psutil.disk_partitions(): @@ -817,11 +817,11 @@ def select_volume(title='Select disk', auto_select=True): info['Display Name'] = '{} ({})'.format(info['Name'], free) disks.append(info) set_thread_error_mode(silent=False) # Return to normal - + # Skip menu? if len(disks) == 1 and auto_select: return disks[0] - + # Show menu selection = menu_select(title, main_entries=disks, action_entries=actions) if selection == 'Q': @@ -831,12 +831,12 @@ def select_volume(title='Select disk', auto_select=True): def set_thread_error_mode(silent=True): """Disable or Enable Windows error message dialogs. - + Disable when scanning for disks to avoid popups for empty cardreaders, etc """ # Code borrowed from: https://stackoverflow.com/a/29075319 kernel32 = ctypes.WinDLL('kernel32') - + if silent: kernel32.SetThreadErrorMode(SEM_FAIL, ctypes.byref(SEM_NORMAL)) else: diff --git a/.bin/Scripts/functions/ddrescue.py b/.bin/Scripts/functions/ddrescue.py index a93f88e4..f0770df2 100644 --- a/.bin/Scripts/functions/ddrescue.py +++ b/.bin/Scripts/functions/ddrescue.py @@ -323,7 +323,7 @@ class RecoveryState(): elif not is_writable_filesystem(dest): raise GenericError( 'Destination is mounted read-only, refusing to continue.') - + # Safety checks passed self.block_pairs.append(BlockPair(self.mode, source, dest)) @@ -1081,7 +1081,7 @@ def select_path(skip_device=None): except OSError: raise GenericError( 'Failed to create folder "{}"'.format(s_path)) - + # Create DirObj selected_path = DirObj(s_path) diff --git a/.bin/Scripts/functions/diags.py b/.bin/Scripts/functions/diags.py index c2a0f2b8..e55f5b12 100644 --- a/.bin/Scripts/functions/diags.py +++ b/.bin/Scripts/functions/diags.py @@ -147,7 +147,7 @@ def run_hitmanpro(): cmd = [ global_vars['Tools']['HitmanPro'], '/quiet', '/noinstall', '/noupload', - r'/log={LogDir}\hitman.xml'.format(**global_vars)] + r'/log={LogDir}\Tools\HitmanPro.txt'.format(**global_vars)] popen_program(cmd) def run_process_killer(): @@ -165,20 +165,17 @@ def run_rkill(): extract_item('RKill', silent=True) cmd = [ 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'] run_program(cmd, check=False) wait_for_process('RKill') - kill_process('notepad.exe') # RKill cleanup desktop_path = r'{USERPROFILE}\Desktop'.format(**global_vars['Env']) if os.path.exists(desktop_path): for item in os.scandir(desktop_path): if re.search(r'^RKill', item.name, re.IGNORECASE): - dest = re.sub(r'^(.*)\.', '\1_{Date-Time}.'.format( - **global_vars), item.name) - dest = r'{ClientDir}\Info\{name}'.format( + dest = r'{LogDir}\Tools\{name}'.format( name=dest, **global_vars) dest = non_clobber_rename(dest) shutil.move(item.path, dest) diff --git a/.bin/Scripts/functions/disk.py b/.bin/Scripts/functions/disk.py index 2d7cf0bb..75879ff8 100644 --- a/.bin/Scripts/functions/disk.py +++ b/.bin/Scripts/functions/disk.py @@ -14,13 +14,13 @@ REGEX_DISK_RAW = re.compile(r'Disk ID: 00000000', re.IGNORECASE) def assign_volume_letters(): """Assign a volume letter to all available volumes.""" remove_volume_letters() - + # Write script script = [] for vol in get_volumes(): script.append('select volume {}'.format(vol['Number'])) script.append('assign') - + # Run run_diskpart(script) @@ -35,7 +35,7 @@ def get_boot_mode(): boot_mode = 'UEFI' except: boot_mode = 'Unknown' - + return boot_mode def get_disk_details(disk): @@ -44,7 +44,7 @@ def get_disk_details(disk): script = [ 'select disk {}'.format(disk['Number']), 'detail disk'] - + # Run try: result = run_diskpart(script) @@ -60,13 +60,13 @@ def get_disk_details(disk): tmp = [s.split(':') for s in tmp if ':' in s] # Add key/value pairs to the details variable and return dict details.update({key.strip(): value.strip() for (key, value) in tmp}) - + return details - + def get_disks(): """Get list of attached disks using DiskPart.""" disks = [] - + try: # Run script result = run_diskpart(['list disk']) @@ -79,7 +79,7 @@ def get_disks(): num = tmp[0] size = human_readable_size(tmp[1]) disks.append({'Number': num, 'Size': size}) - + return disks def get_partition_details(disk, partition): @@ -89,7 +89,7 @@ def get_partition_details(disk, partition): 'select disk {}'.format(disk['Number']), 'select partition {}'.format(partition['Number']), 'detail partition'] - + # Diskpart details try: # Run script @@ -111,14 +111,14 @@ def get_partition_details(disk, partition): tmp = [s.split(':') for s in tmp if ':' in s] # Add key/value pairs to the details variable and return dict details.update({key.strip(): value.strip() for (key, value) in tmp}) - + # Get MBR type / GPT GUID for extra details on "Unknown" partitions guid = partition_uids.lookup_guid(details.get('Type')) if guid: details.update({ 'Description': guid.get('Description', '')[:29], 'OS': guid.get('OS', 'Unknown')[:27]}) - + if 'Letter' in details: # Disk usage try: @@ -128,7 +128,7 @@ def get_partition_details(disk, partition): details['Error'] = err.strerror else: details['Used Space'] = human_readable_size(tmp.used) - + # fsutil details cmd = [ 'fsutil', @@ -151,14 +151,14 @@ def get_partition_details(disk, partition): tmp = [s.split(':') for s in tmp if ':' in s] # Add key/value pairs to the details variable and return dict details.update({key.strip(): value.strip() for (key, value) in tmp}) - + # Set Volume Name details['Name'] = details.get('Volume Name', '') - + # Set FileSystem Type if details.get('FileSystem', '') not in ['RAW', 'Unknown']: details['FileSystem'] = details.get('File System Name', 'Unknown') - + return details def get_partitions(disk): @@ -167,7 +167,7 @@ def get_partitions(disk): script = [ 'select disk {}'.format(disk['Number']), 'list partition'] - + try: # Run script result = run_diskpart(script) @@ -181,7 +181,7 @@ def get_partitions(disk): num = tmp[0] size = human_readable_size(tmp[1]) partitions.append({'Number': num, 'Size': size}) - + return partitions def get_table_type(disk): @@ -190,7 +190,7 @@ def get_table_type(disk): script = [ 'select disk {}'.format(disk['Number']), 'uniqueid disk'] - + try: result = run_diskpart(script) except subprocess.CalledProcessError: @@ -203,7 +203,7 @@ def get_table_type(disk): part_type = 'MBR' elif REGEX_DISK_RAW.search(output): part_type = 'RAW' - + return part_type def get_volumes(): @@ -218,7 +218,7 @@ def get_volumes(): output = result.stdout.decode().strip() for tmp in re.findall(r'Volume (\d+)\s+([A-Za-z]?)\s+', output): vols.append({'Number': tmp[0], 'Letter': tmp[1]}) - + return vols def is_bad_partition(par): @@ -229,7 +229,7 @@ def prep_disk_for_formatting(disk=None): """Gather details about the disk and its partitions.""" disk['Format Warnings'] = '\n' width = len(str(len(disk['Partitions']))) - + # Bail early if disk is None: raise Exception('Disk not provided.') @@ -242,7 +242,7 @@ def prep_disk_for_formatting(disk=None): else: if (ask("Setup Windows to use BIOS/Legacy booting?")): disk['Use GPT'] = False - + # Set Display and Warning Strings if len(disk['Partitions']) == 0: disk['Format Warnings'] += 'No partitions found\n' @@ -252,7 +252,7 @@ def prep_disk_for_formatting(disk=None): width = width, size = partition['Size'], fs = partition['FileSystem']) - + if is_bad_partition(partition): # Set display string using partition description & OS type display += '\t\t{q}{name}{q}\t{desc} ({os})'.format( @@ -290,13 +290,13 @@ def remove_volume_letters(keep=None): """Remove all assigned volume letters using DiskPart.""" if not keep: keep = '' - + script = [] for vol in get_volumes(): if vol['Letter'].upper() != keep.upper(): script.append('select volume {}'.format(vol['Number'])) script.append('remove noerr') - + # Run script try: run_diskpart(script) @@ -306,12 +306,12 @@ def remove_volume_letters(keep=None): def run_diskpart(script): """Run DiskPart script.""" tempfile = r'{}\diskpart.script'.format(global_vars['Env']['TMP']) - + # Write script with open(tempfile, 'w') as f: for line in script: f.write('{}\n'.format(line)) - + # Run script cmd = [ r'{}\Windows\System32\diskpart.exe'.format( @@ -335,7 +335,7 @@ def scan_disks(): # Get partition info for disk disk['Partitions'] = get_partitions(disk) - + for partition in disk['Partitions']: # Get partition details partition.update(get_partition_details(disk, partition)) @@ -364,12 +364,12 @@ def select_disk(title='Which disk?', disks=[]): fs = partition['FileSystem']) if partition['Name']: p_name += '\t"{}"'.format(partition['Name']) - + # Show unsupported partition(s) if is_bad_partition(partition): p_name = '{YELLOW}{p_name}{CLEAR}'.format( p_name=p_name, **COLORS) - + display_name += '\n\t\t\t{}'.format(p_name) if not disk['Partitions']: display_name += '\n\t\t\t{}No partitions found.{}'.format( diff --git a/.bin/Scripts/functions/info.py b/.bin/Scripts/functions/info.py index ccf78bfe..7630a766 100644 --- a/.bin/Scripts/functions/info.py +++ b/.bin/Scripts/functions/info.py @@ -68,7 +68,8 @@ def backup_file_list(): def backup_power_plans(): """Export current power plans.""" - os.makedirs(r'{BackupDir}\Power Plans'.format(**global_vars), exist_ok=True) + os.makedirs(r'{BackupDir}\Power Plans\{Date}'.format( + **global_vars), exist_ok=True) plans = run_program(['powercfg', '/L']) plans = plans.stdout.decode().splitlines() plans = [p for p in plans if re.search(r'^Power Scheme', p)] @@ -76,7 +77,7 @@ def backup_power_plans(): guid = re.sub(r'Power Scheme GUID:\s+([0-9a-f\-]+).*', r'\1', p) name = re.sub( r'Power Scheme GUID:\s+[0-9a-f\-]+\s+\(([^\)]+)\).*', r'\1', p) - out = r'{BackupDir}\Power Plans\{name}.pow'.format( + out = r'{BackupDir}\Power Plans\{Date}\{name}.pow'.format( name=name, **global_vars) if not os.path.exists(out): cmd = ['powercfg', '-export', out, guid] @@ -87,7 +88,7 @@ def backup_registry(overwrite=False): extract_item('erunt', silent=True) cmd = [ global_vars['Tools']['ERUNT'], - r'{BackupDir}\Registry'.format(**global_vars), + r'{BackupDir}\Registry\{Date}'.format(**global_vars), 'sysreg', 'curuser', 'otherusers', @@ -374,7 +375,7 @@ def run_bleachbit(cleaners=None, preview=True): """Run BleachBit preview and save log. If preview is True then no files should be deleted.""" - error_path = r'{}\BleachBit.err'.format(global_vars['LogDir']) + error_path = r'{}\Tools\BleachBit.err'.format(global_vars['LogDir']) log_path = error_path.replace('err', 'log') extract_item('BleachBit', silent=True) @@ -473,7 +474,7 @@ def show_os_name(): def show_temp_files_size(): """Show total size of temp files identified by BleachBit.""" size = None - with open(r'{LogDir}\BleachBit.log'.format(**global_vars), 'r') as f: + with open(r'{LogDir}\Tools\BleachBit.log'.format(**global_vars), 'r') as f: for line in f.readlines(): if re.search(r'^disk space to be recovered:', line, re.IGNORECASE): size = re.sub(r'.*: ', '', line.strip()) diff --git a/.bin/Scripts/functions/network.py b/.bin/Scripts/functions/network.py index d040e343..5735c486 100644 --- a/.bin/Scripts/functions/network.py +++ b/.bin/Scripts/functions/network.py @@ -26,7 +26,7 @@ def connect_to_network(): # Bail if currently connected if is_connected(): return - + # WiFi if 'wl' in net_ifs: cmd = [ @@ -37,7 +37,7 @@ def connect_to_network(): message = 'Connecting to {}...'.format(WIFI_SSID), function = run_program, cmd = cmd) - + def is_connected(): """Check for a valid private IP.""" devs = psutil.net_if_addrs() diff --git a/.bin/Scripts/functions/product_keys.py b/.bin/Scripts/functions/product_keys.py index 705f46e9..988d36fd 100644 --- a/.bin/Scripts/functions/product_keys.py +++ b/.bin/Scripts/functions/product_keys.py @@ -39,7 +39,7 @@ def extract_keys(): keys[product] = [] if key not in keys[product]: keys[product].append(key) - + # Done return keys diff --git a/.bin/Scripts/functions/repairs.py b/.bin/Scripts/functions/repairs.py index e4d5e74f..589dccc3 100644 --- a/.bin/Scripts/functions/repairs.py +++ b/.bin/Scripts/functions/repairs.py @@ -24,11 +24,11 @@ def run_chkdsk_scan(): raise GenericError # Save stderr - with open(r'{LogDir}\CHKDSK.err'.format(**global_vars), 'a') as f: + with open(r'{LogDir}\Tools\CHKDSK.err'.format(**global_vars), 'a') as f: for line in out.stderr.decode().splitlines(): f.write(line.strip() + '\n') # Save stdout - with open(r'{LogDir}\CHKDSK.log'.format(**global_vars), 'a') as f: + with open(r'{LogDir}\Tools\CHKDSK.log'.format(**global_vars), 'a') as f: for line in out.stdout.decode().splitlines(): f.write(line.strip() + '\n') @@ -50,7 +50,7 @@ def run_dism(repair=False): cmd = [ 'DISM', '/Online', '/Cleanup-Image', '/RestoreHealth', - r'/LogPath:"{LogDir}\DISM_RestoreHealth.log"'.format( + r'/LogPath:"{LogDir}\Tools\DISM_RestoreHealth.log"'.format( **global_vars), '-new_console:n', '-new_console:s33V'] else: @@ -58,7 +58,7 @@ def run_dism(repair=False): cmd = [ 'DISM', '/Online', '/Cleanup-Image', '/ScanHealth', - r'/LogPath:"{LogDir}\DISM_ScanHealth.log"'.format( + r'/LogPath:"{LogDir}\Tools\DISM_ScanHealth.log"'.format( **global_vars), '-new_console:n', '-new_console:s33V'] run_program(cmd, pipe=False, check=False, shell=True) @@ -67,7 +67,7 @@ def run_dism(repair=False): cmd = [ 'DISM', '/Online', '/Cleanup-Image', '/CheckHealth', - r'/LogPath:"{LogDir}\DISM_CheckHealth.log"'.format(**global_vars)] + r'/LogPath:"{LogDir}\Tools\DISM_CheckHealth.log"'.format(**global_vars)] result = run_program(cmd, shell=True).stdout.decode() # Check result if 'no component store corruption detected' not in result.lower(): @@ -93,11 +93,11 @@ def run_sfc_scan(): '/scannow'] out = run_program(cmd, check=False) # Save stderr - with open(r'{LogDir}\SFC.err'.format(**global_vars), 'a') as f: + with open(r'{LogDir}\Tools\SFC.err'.format(**global_vars), 'a') as f: for line in out.stderr.decode('utf-8', 'ignore').splitlines(): f.write(line.strip() + '\n') # Save stdout - with open(r'{LogDir}\SFC.log'.format(**global_vars), 'a') as f: + with open(r'{LogDir}\Tools\SFC.log'.format(**global_vars), 'a') as f: for line in out.stdout.decode('utf-8', 'ignore').splitlines(): f.write(line.strip() + '\n') # Check result @@ -116,7 +116,7 @@ def run_tdsskiller(): **global_vars), exist_ok=True) cmd = [ global_vars['Tools']['TDSSKiller'], - '-l', r'{LogDir}\TDSSKiller.log'.format(**global_vars), + '-l', r'{LogDir}\Tools\TDSSKiller.log'.format(**global_vars), '-qpath', r'{QuarantineDir}\TDSSKiller'.format(**global_vars), '-accepteula', '-accepteulaksn', '-dcexact', '-tdlfs'] diff --git a/.bin/Scripts/functions/windows_setup.py b/.bin/Scripts/functions/windows_setup.py index cd7f8444..0952e64d 100644 --- a/.bin/Scripts/functions/windows_setup.py +++ b/.bin/Scripts/functions/windows_setup.py @@ -17,7 +17,7 @@ WINDOWS_VERSIONS = [ {'Name': 'Windows 7 Ultimate', 'Image File': 'Win7', 'Image Name': 'Windows 7 ULTIMATE'}, - + {'Name': 'Windows 8.1', 'Image File': 'Win8', 'Image Name': 'Windows 8.1', @@ -25,7 +25,7 @@ WINDOWS_VERSIONS = [ {'Name': 'Windows 8.1 Pro', 'Image File': 'Win8', 'Image Name': 'Windows 8.1 Pro'}, - + {'Name': 'Windows 10 Home', 'Image File': 'Win10', 'Image Name': 'Windows 10 Home', @@ -75,7 +75,7 @@ def find_windows_image(windows_version): image['Glob'] = '--ref="{}*.swm"'.format( image['Path'][:-4]) break - + # Display image to be used (if any) and return if image: print_info('Using image: {}'.format(image['Path'])) @@ -122,7 +122,7 @@ def format_gpt(disk): 'set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"', 'gpt attributes=0x8000000000000001', ] - + # Run run_diskpart(script) @@ -151,7 +151,7 @@ def format_mbr(disk): 'assign letter="T"', 'set id=27', ] - + # Run run_diskpart(script) @@ -197,11 +197,11 @@ def setup_windows_re(windows_version, windows_letter='W', tools_letter='T'): win = r'{}:\Windows'.format(windows_letter) winre = r'{}\System32\Recovery\WinRE.wim'.format(win) dest = r'{}:\Recovery\WindowsRE'.format(tools_letter) - + # Copy WinRE.wim os.makedirs(dest, exist_ok=True) shutil.copy(winre, r'{}\WinRE.wim'.format(dest)) - + # Set location cmd = [ r'{}\System32\ReAgentc.exe'.format(win), @@ -231,7 +231,7 @@ def wim_contains_image(filename, imagename): run_program(cmd) except subprocess.CalledProcessError: return False - + return True if __name__ == '__main__': diff --git a/.bin/Scripts/functions/winpe_menus.py b/.bin/Scripts/functions/winpe_menus.py index 64ffb666..1c732eca 100644 --- a/.bin/Scripts/functions/winpe_menus.py +++ b/.bin/Scripts/functions/winpe_menus.py @@ -90,7 +90,7 @@ def menu_backup(): message = 'Assigning letters...', function = assign_volume_letters, other_results = other_results) - + # Mount backup shares mount_backup_shares(read_write=True) @@ -107,12 +107,12 @@ def menu_backup(): else: print_error('ERROR: No disks found.') raise GenericAbort - + # Select disk to backup disk = select_disk('For which disk are we creating backups?', disks) if not disk: raise GenericAbort - + # "Prep" disk prep_disk_for_backup(destination, disk, backup_prefix) @@ -150,7 +150,7 @@ def menu_backup(): # Ask to proceed if (not ask('Proceed with backup?')): raise GenericAbort - + # Backup partition(s) print_info('\n\nStarting task.\n') for par in disk['Partitions']: @@ -163,7 +163,7 @@ def menu_backup(): if not result['CS'] and not isinstance(result['Error'], GenericAbort): errors = True par['Error'] = result['Error'] - + # Verify backup(s) if disk['Valid Partitions']: print_info('\n\nVerifying backup images(s)\n') @@ -270,7 +270,7 @@ def menu_setup(): # Select the version of Windows to apply windows_version = select_windows_version() - + # Find Windows image # NOTE: Reassign volume letters to ensure all devices are scanned try_and_print( @@ -289,12 +289,12 @@ def menu_setup(): else: print_error('ERROR: No disks found.') raise GenericAbort - + # Select disk to use as the OS disk dest_disk = select_disk('To which disk are we installing Windows?', disks) if not dest_disk: raise GenericAbort - + # "Prep" disk prep_disk_for_formatting(dest_disk) @@ -323,10 +323,10 @@ def menu_setup(): data = par['Display String'], warning = True) print_warning(dest_disk['Format Warnings']) - + if (not ask('Is this correct?')): raise GenericAbort - + # Safety check print_standard('\nSAFETY CHECK') print_warning('All data will be DELETED from the ' @@ -342,7 +342,7 @@ def menu_setup(): function = remove_volume_letters, other_results = other_results, keep=windows_image['Letter']) - + # Assign new letter for local source if necessary if windows_image['Local'] and windows_image['Letter'] in ['S', 'T', 'W']: new_letter = try_and_print( @@ -377,13 +377,13 @@ def menu_setup(): # We need to crash as the disk is in an unknown state print_error('ERROR: Failed to apply image.') raise GenericAbort - + # Create Boot files try_and_print( message = 'Updating boot files...', function = update_boot_partition, other_results = other_results) - + # Setup WinRE try_and_print( message = 'Updating recovery tools...', @@ -392,8 +392,8 @@ def menu_setup(): windows_version = windows_version) # Copy WinPE log(s) - source = r'{}\Info'.format(global_vars['ClientDir']) - dest = r'W:\{}\Info'.format(KIT_NAME_SHORT) + source = r'{}\Logs'.format(global_vars['ClientDir']) + dest = r'W:\{}\Logs\WinPE'.format(KIT_NAME_SHORT) shutil.copytree(source, dest) # Print summary diff --git a/.bin/Scripts/init_client_dir.cmd b/.bin/Scripts/init_client_dir.cmd index 4d73e7ab..073bd4f3 100644 --- a/.bin/Scripts/init_client_dir.cmd +++ b/.bin/Scripts/init_client_dir.cmd @@ -33,7 +33,7 @@ for /f "tokens=* usebackq" %%f in (`findstr KIT_NAME_SHORT "%SETTINGS%"`) do ( set "KIT_NAME_SHORT=!_v:~0,-1!" ) set "client_dir=%systemdrive%\%KIT_NAME_SHORT%" -set "log_dir=%client_dir%\Info\%iso_date%" +set "log_dir=%client_dir%\Logs\%iso_date%" :Flags set _backups= @@ -45,7 +45,7 @@ set _transfer= for %%f in (%*) do ( if /i "%%f" == "/DEBUG" (@echo on) if /i "%%f" == "/Backups" set _backups=True - if /i "%%f" == "/Info" set _info=True + if /i "%%f" == "/Logs" set _logs=True if /i "%%f" == "/Office" set _office=True if /i "%%f" == "/Quarantine" set _quarantine=True if /i "%%f" == "/QuickBooks" set _quickbooks=True @@ -54,7 +54,7 @@ for %%f in (%*) do ( :CreateDirs if defined _backups mkdir "%client_dir%\Backups">nul 2>&1 -if defined _info mkdir "%client_dir%\Info">nul 2>&1 +if defined _logs mkdir "%client_dir%\Logs">nul 2>&1 if defined _office mkdir "%client_dir%\Office">nul 2>&1 if defined _quarantine mkdir "%client_dir%\Quarantine">nul 2>&1 if defined _quickbooks mkdir "%client_dir%\QuickBooks">nul 2>&1 diff --git a/.bin/Scripts/install_eset_nod32_av.py b/.bin/Scripts/install_eset_nod32_av.py index 1bb45d9a..00cf98ec 100644 --- a/.bin/Scripts/install_eset_nod32_av.py +++ b/.bin/Scripts/install_eset_nod32_av.py @@ -9,7 +9,8 @@ sys.path.append(os.getcwd()) from functions.setup import * init_global_vars() os.system('title {}: Install ESET NOD32 AV'.format(KIT_NAME_FULL)) -global_vars['LogFile'] = r'{LogDir}\Install ESET NOD32 AV.log'.format(**global_vars) +global_vars['LogFile'] = r'{LogDir}\{kit_name}\Install ESET NOD32 AV.log'.format( + kit_name=KIT_NAME_FULL, **global_vars) if __name__ == '__main__': try: diff --git a/.bin/Scripts/install_sw_bundle.py b/.bin/Scripts/install_sw_bundle.py index 42757753..a316125e 100644 --- a/.bin/Scripts/install_sw_bundle.py +++ b/.bin/Scripts/install_sw_bundle.py @@ -9,7 +9,8 @@ sys.path.append(os.getcwd()) from functions.setup import * init_global_vars() os.system('title {}: SW Bundle Tool'.format(KIT_NAME_FULL)) -global_vars['LogFile'] = r'{LogDir}\Install SW Bundle.log'.format(**global_vars) +global_vars['LogFile'] = r'{LogDir}\{kit_name}\Install SW Bundle.log'.format( + kit_name=KIT_NAME_FULL, **global_vars) D7_MODE = 'd7mode' in sys.argv if __name__ == '__main__': @@ -35,7 +36,7 @@ if __name__ == '__main__': answer_mse = ask('Install MSE?') else: answer_mse = False - + print_info('Installing Programs') if answer_vcr: install_vcredists() diff --git a/.bin/Scripts/install_vcredists.py b/.bin/Scripts/install_vcredists.py index 4a1f53ea..3207ee6e 100644 --- a/.bin/Scripts/install_vcredists.py +++ b/.bin/Scripts/install_vcredists.py @@ -9,7 +9,8 @@ sys.path.append(os.getcwd()) from functions.setup import * init_global_vars() os.system('title {}: Install Visual C++ Runtimes'.format(KIT_NAME_FULL)) -global_vars['LogFile'] = r'{LogDir}\Install Visual C++ Runtimes.log'.format(**global_vars) +global_vars['LogFile'] = r'{LogDir}\{kit_name}\Install Visual C++ Runtimes.log'.format( + kit_name=KIT_NAME_FULL, **global_vars) if __name__ == '__main__': try: @@ -20,12 +21,12 @@ if __name__ == '__main__': 'Error': { 'CalledProcessError': 'Unknown Error', }} - + if ask('Install Visual C++ Runtimes?'): install_vcredists() else: abort() - + print_standard('\nDone.') exit_script() except SystemExit: diff --git a/.bin/Scripts/post_d7.py b/.bin/Scripts/post_d7.py index 5f47cee7..41250db0 100644 --- a/.bin/Scripts/post_d7.py +++ b/.bin/Scripts/post_d7.py @@ -11,8 +11,8 @@ from functions.cleanup import * from functions.setup import * init_global_vars() os.system('title {}: Post-d7II Work'.format(KIT_NAME_FULL)) -global_vars['LogFile'] = r'{LogDir}\Post-d7II Work.log'.format( - **global_vars, **global_vars['Env']) +global_vars['LogFile'] = r'{LogDir}\{kit_name}\Post-d7II Work.log'.format( + kit_name=KIT_NAME_FULL, **global_vars) if __name__ == '__main__': try: diff --git a/.bin/Scripts/reset_browsers.py b/.bin/Scripts/reset_browsers.py index e47cecbe..88342fb1 100644 --- a/.bin/Scripts/reset_browsers.py +++ b/.bin/Scripts/reset_browsers.py @@ -11,8 +11,8 @@ from functions.cleanup import * from functions.setup import * init_global_vars() os.system('title {}: Browser Reset Tool'.format(KIT_NAME_FULL)) -global_vars['LogFile'] = r'{LogDir}\Browser Reset ({USERNAME}).log'.format( - **global_vars, **global_vars['Env']) +global_vars['LogFile'] = r'{LogDir}\{kit_name}\Browser Reset ({USERNAME}).log'.format( + kit_name=KIT_NAME_FULL, **global_vars, **global_vars['Env']) D7_MODE = 'd7mode' in sys.argv if __name__ == '__main__': diff --git a/.bin/Scripts/safemode_enter.py b/.bin/Scripts/safemode_enter.py index c3213cb9..cce7e28a 100644 --- a/.bin/Scripts/safemode_enter.py +++ b/.bin/Scripts/safemode_enter.py @@ -17,16 +17,16 @@ if __name__ == '__main__': other_results = { 'Error': {'CalledProcessError': 'Unknown Error'}, 'Warning': {}} - + if not ask('Enable booting to SafeMode (with Networking)?'): abort() - + # Configure SafeMode try_and_print(message='Set BCD option...', function=enable_safemode, other_results=other_results) try_and_print(message='Enable MSI in SafeMode...', function=enable_safemode_msi, other_results=other_results) - + # Done print_standard('\nDone.') pause('Press Enter to reboot...') diff --git a/.bin/Scripts/safemode_exit.py b/.bin/Scripts/safemode_exit.py index 1449cff5..af66222e 100644 --- a/.bin/Scripts/safemode_exit.py +++ b/.bin/Scripts/safemode_exit.py @@ -17,16 +17,16 @@ if __name__ == '__main__': other_results = { 'Error': {'CalledProcessError': 'Unknown Error'}, 'Warning': {}} - + if not ask('Disable booting to SafeMode?'): abort() - + # Configure SafeMode try_and_print(message='Remove BCD option...', function=disable_safemode, other_results=other_results) try_and_print(message='Disable MSI in SafeMode...', function=disable_safemode_msi, other_results=other_results) - + # Done print_standard('\nDone.') pause('Press Enter to reboot...') diff --git a/.bin/Scripts/settings/launchers.py b/.bin/Scripts/settings/launchers.py index 71ea189e..fb194764 100644 --- a/.bin/Scripts/settings/launchers.py +++ b/.bin/Scripts/settings/launchers.py @@ -105,7 +105,7 @@ LAUNCHERS = { 'L_PATH': 'FastCopy', 'L_ITEM': 'FastCopy.exe', 'L_ARGS': ( - r' /logfile=%log_dir%\FastCopy.log' + r' /logfile=%log_dir%\Tools\FastCopy.log' r' /cmd=noexist_only' r' /utf8' r' /skip_empty_dir' @@ -145,7 +145,7 @@ LAUNCHERS = { ), 'L_ELEV': 'True', 'Extra Code': [ - r'call "%bin%\Scripts\init_client_dir.cmd" /Info /Transfer', + r'call "%bin%\Scripts\init_client_dir.cmd" /Logs /Transfer', ], }, 'FastCopy': { @@ -153,7 +153,7 @@ LAUNCHERS = { 'L_PATH': 'FastCopy', 'L_ITEM': 'FastCopy.exe', 'L_ARGS': ( - r' /logfile=%log_dir%\FastCopy.log' + r' /logfile=%log_dir%\Tools\FastCopy.log' r' /cmd=noexist_only' r' /utf8' r' /skip_empty_dir' @@ -192,7 +192,7 @@ LAUNCHERS = { r' /to=%client_dir%\Transfer_%iso_date%\ ' ), 'Extra Code': [ - r'call "%bin%\Scripts\init_client_dir.cmd" /Info /Transfer', + r'call "%bin%\Scripts\init_client_dir.cmd" /Logs /Transfer', ], }, 'KVRT': { @@ -302,10 +302,10 @@ LAUNCHERS = { 'L_TYPE': 'Executable', 'L_PATH': 'erunt', 'L_ITEM': 'ERUNT.EXE', - 'L_ARGS': '%client_dir%\Backups\%iso_date%\Registry sysreg curuser otherusers', + 'L_ARGS': '%client_dir%\Backups\Registry\%iso_date% sysreg curuser otherusers', 'L_ELEV': 'True', 'Extra Code': [ - r'call "%bin%\Scripts\init_client_dir.cmd" /Info', + r'call "%bin%\Scripts\init_client_dir.cmd" /Logs', ], }, 'FurMark': { @@ -323,7 +323,7 @@ LAUNCHERS = { 'L_PATH': 'HitmanPro', 'L_ITEM': 'HitmanPro.exe', 'Extra Code': [ - r'call "%bin%\Scripts\init_client_dir.cmd" /Info', + r'call "%bin%\Scripts\init_client_dir.cmd" /Logs', ], }, 'HWiNFO': { @@ -624,8 +624,10 @@ LAUNCHERS = { 'L_TYPE': 'Executable', 'L_PATH': 'RKill', 'L_ITEM': 'RKill.exe', + 'L_ARGS': '-s -l %log_dir%\Tools\RKill.log', + 'L_ELEV': 'True', 'Extra Code': [ - r'call "%bin%\Scripts\init_client_dir.cmd" /Info', + r'call "%bin%\Scripts\init_client_dir.cmd" /Logs', ], }, 'SFC Scan': { @@ -639,7 +641,7 @@ LAUNCHERS = { 'L_PATH': 'TDSSKiller', 'L_ITEM': 'TDSSKiller.exe', 'L_ARGS': ( - r' -l %log_dir%\TDSSKiller.log' + r' -l %log_dir%\Tools\TDSSKiller.log' r' -qpath %q_dir%' r' -accepteula' r' -accepteulaksn' diff --git a/.bin/Scripts/settings/windows_builds.py b/.bin/Scripts/settings/windows_builds.py index bdac8bf4..6c642928 100644 --- a/.bin/Scripts/settings/windows_builds.py +++ b/.bin/Scripts/settings/windows_builds.py @@ -6,16 +6,16 @@ WINDOWS_BUILDS = { '6000': ( 'Vista', 'RTM', 'Longhorn', None, 'unsupported'), '6001': ( 'Vista', 'SP1', 'Longhorn', None, 'unsupported'), '6002': ( 'Vista', 'SP2', 'Longhorn', None, 'unsupported'), - + '7600': ( '7', 'RTM', 'Vienna', None, 'unsupported'), '7601': ( '7', 'SP1', 'Vienna', None, 'outdated'), - + #9199 is a fake build since Win 8 is 6.2.9200 but that collides with Win 8.1 (6.3.9200) '9199': ( '8', 'RTM', None, None, 'unsupported'), '9200': ( '8.1', None, 'Blue', None, 'outdated'), '9600': ( '8.1', None, 'Update', None, None), - + '9841': ( '10', None, 'Threshold 1', None, 'preview build'), '9860': ( '10', None, 'Threshold 1', None, 'preview build'), '9879': ( '10', None, 'Threshold 1', None, 'preview build'), diff --git a/.bin/Scripts/sfc_scan.py b/.bin/Scripts/sfc_scan.py index 81211747..5ef17ae6 100644 --- a/.bin/Scripts/sfc_scan.py +++ b/.bin/Scripts/sfc_scan.py @@ -9,7 +9,8 @@ sys.path.append(os.getcwd()) from functions.repairs import * init_global_vars() os.system('title {}: SFC Tool'.format(KIT_NAME_FULL)) -global_vars['LogFile'] = r'{LogDir}\SFC Tool.log'.format(**global_vars) +global_vars['LogFile'] = r'{LogDir}\{kit_name}\SFC Tool.log'.format( + kit_name=KIT_NAME_FULL, **global_vars) if __name__ == '__main__': try: @@ -28,7 +29,7 @@ if __name__ == '__main__': function=run_sfc_scan, other_results=other_results) else: abort() - + # Done print_standard('\nDone.') pause('Press Enter to exit...') diff --git a/.bin/Scripts/system_checklist.py b/.bin/Scripts/system_checklist.py index bf0e78f2..a2c23529 100644 --- a/.bin/Scripts/system_checklist.py +++ b/.bin/Scripts/system_checklist.py @@ -14,7 +14,8 @@ from functions.product_keys import * from functions.setup import * init_global_vars() os.system('title {}: System Checklist Tool'.format(KIT_NAME_FULL)) -global_vars['LogFile'] = r'{LogDir}\System Checklist.log'.format(**global_vars) +global_vars['LogFile'] = r'{LogDir}\{kit_name}\System Checklist.log'.format( + kit_name=KIT_NAME_FULL, **global_vars) D7_MODE = 'd7mode' in sys.argv if __name__ == '__main__': diff --git a/.bin/Scripts/system_checklist_hw.py b/.bin/Scripts/system_checklist_hw.py index 3e3ae4f1..de0b8ba3 100644 --- a/.bin/Scripts/system_checklist_hw.py +++ b/.bin/Scripts/system_checklist_hw.py @@ -14,7 +14,8 @@ from functions.product_keys import * from functions.setup import * init_global_vars() os.system('title {}: System HW Checklist Tool'.format(KIT_NAME_FULL)) -global_vars['LogFile'] = r'{LogDir}\System HW Checklist.log'.format(**global_vars) +global_vars['LogFile'] = r'{LogDir}\{kit_name}\System HW Checklist.log'.format( + kit_name=KIT_NAME_FULL, **global_vars) if __name__ == '__main__': try: diff --git a/.bin/Scripts/system_diagnostics.py b/.bin/Scripts/system_diagnostics.py index 18a3677f..fb38bfb8 100644 --- a/.bin/Scripts/system_diagnostics.py +++ b/.bin/Scripts/system_diagnostics.py @@ -13,8 +13,8 @@ from functions.product_keys import * from functions.repairs import * init_global_vars() os.system('title {}: System Diagnostics Tool'.format(KIT_NAME_FULL)) -global_vars['LogFile'] = r'{LogDir}\System Diagnostics.log'.format( - **global_vars) +global_vars['LogFile'] = r'{LogDir}\{kit_name}\System Diagnostics.log'.format( + kit_name=KIT_NAME_FULL, **global_vars) D7_MODE = 'd7mode' in sys.argv # Static Variables diff --git a/.bin/Scripts/transferred_keys.py b/.bin/Scripts/transferred_keys.py index 9829207e..8d2976ee 100644 --- a/.bin/Scripts/transferred_keys.py +++ b/.bin/Scripts/transferred_keys.py @@ -9,7 +9,8 @@ sys.path.append(os.getcwd()) from functions.product_keys import * init_global_vars() os.system('title {}: Transferred Key Finder'.format(KIT_NAME_FULL)) -global_vars['LogFile'] = r'{LogDir}\Transferred Keys.log'.format(**global_vars) +global_vars['LogFile'] = r'{LogDir}\{kit_name}\Transferred Keys.log'.format( + kit_name=KIT_NAME_FULL, **global_vars) if __name__ == '__main__': try: @@ -18,7 +19,7 @@ if __name__ == '__main__': print_info('{}: Transferred Key Finder\n'.format(KIT_NAME_FULL)) try_and_print(message='Searching for keys...', function=list_clientdir_keys, print_return=True) - + # Done print_standard('\nDone.') exit_script() diff --git a/.bin/Scripts/user_checklist.py b/.bin/Scripts/user_checklist.py index e71b4e96..8d79d738 100644 --- a/.bin/Scripts/user_checklist.py +++ b/.bin/Scripts/user_checklist.py @@ -11,8 +11,8 @@ from functions.cleanup import * from functions.setup import * init_global_vars() os.system('title {}: User Checklist Tool'.format(KIT_NAME_FULL)) -global_vars['LogFile'] = r'{LogDir}\User Checklist ({USERNAME}).log'.format( - **global_vars, **global_vars['Env']) +global_vars['LogFile'] = r'{LogDir}\{kit_name}\User Checklist ({USERNAME}).log'.format( + kit_name=KIT_NAME_FULL, **global_vars, **global_vars['Env']) D7_MODE = 'd7mode' in sys.argv if __name__ == '__main__': diff --git a/.bin/Scripts/user_data_transfer.py b/.bin/Scripts/user_data_transfer.py index ce572f69..09f47344 100644 --- a/.bin/Scripts/user_data_transfer.py +++ b/.bin/Scripts/user_data_transfer.py @@ -10,7 +10,8 @@ from functions.data import * from functions.repairs import * init_global_vars() os.system('title {}: User Data Transfer Tool'.format(KIT_NAME_FULL)) -global_vars['LogFile'] = r'{LogDir}\User Data Transfer.log'.format(**global_vars) +global_vars['LogFile'] = r'{LogDir}\{kit_name}\User Data Transfer.log'.format( + kit_name=KIT_NAME_FULL, **global_vars) if __name__ == '__main__': try: @@ -18,7 +19,7 @@ if __name__ == '__main__': stay_awake() clear_screen() print_info('{}: User Data Transfer Tool\n'.format(KIT_NAME_FULL)) - + # Get backup name prefix ticket_number = get_ticket_number() if ENABLED_TICKET_NUMBERS: @@ -26,16 +27,16 @@ if __name__ == '__main__': else: backup_prefix = get_simple_string(prompt='Enter backup name prefix') backup_prefix = backup_prefix.replace(' ', '_') - + # Set destination folder_path = r'{}\Transfer'.format(KIT_NAME_SHORT) dest = select_destination(folder_path=folder_path, prompt='Which disk are we transferring to?') - + # Set source items source = select_source(backup_prefix) items = scan_source(source, dest) - + # Transfer clear_screen() print_info('Transfer Details:\n') @@ -43,17 +44,17 @@ if __name__ == '__main__': show_data('Ticket:', ticket_number) show_data('Source:', source.path) show_data('Destination:', dest) - + if (not ask('Proceed with transfer?')): umount_backup_shares() abort() - + print_info('Transferring Data') transfer_source(source, dest, items) try_and_print(message='Removing extra files...', function=cleanup_transfer, cs='Done', dest_path=dest) umount_backup_shares() - + # Done try_and_print(message='Running KVRT...', function=run_kvrt, cs='Started')