From 82e0de422b3591030855c7d6b9e3232a4ce1c9a7 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Tue, 27 Sep 2022 23:56:25 -0700 Subject: [PATCH] Add export_bitlocker.py script --- scripts/export_bitlocker.py | 11 +++++++++++ scripts/wk/os/win.py | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 scripts/export_bitlocker.py 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/os/win.py b/scripts/wk/os/win.py index 331d75a4..187289ad 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') 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 = [