Added d7II Cleanup sections
* Renamed d7_firefox_fix.py to post_d7.py * This will include all items that need to be run outside d7II
This commit is contained in:
parent
edb82df4d3
commit
9c1c8b90be
2 changed files with 75 additions and 4 deletions
|
|
@ -68,6 +68,73 @@ def cleanup_cbs(dest_folder):
|
||||||
r'{}\CbsPersist*'.format(temp_folder)]
|
r'{}\CbsPersist*'.format(temp_folder)]
|
||||||
run_program(cmd)
|
run_program(cmd)
|
||||||
|
|
||||||
|
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_temp = r'{}\Temp'.format(d7_path)
|
||||||
|
|
||||||
|
# Logs & Reports
|
||||||
|
if os.path.exists(d7_reports):
|
||||||
|
for entry in os.scandir(d7_reports):
|
||||||
|
r = re.match(r'(\d+)-(\d+)-(\d+)', entry.name)
|
||||||
|
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(
|
||||||
|
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):
|
||||||
|
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 = 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(
|
||||||
|
log_dest=log_dest,
|
||||||
|
name=m_entry.name)
|
||||||
|
dest_path = non_clobber_rename(dest_path)
|
||||||
|
shutil.move(entry.path, dest_path)
|
||||||
|
|
||||||
|
# Remove folder if empty
|
||||||
|
try:
|
||||||
|
os.rmdir(entry.path)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Temp items
|
||||||
|
if os.path.exists(d7_path):
|
||||||
|
if os.path.exists(d7_temp):
|
||||||
|
shutil.rmtree(d7_temp)
|
||||||
|
try:
|
||||||
|
os.rmdir(d7_path)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
def cleanup_desktop():
|
def cleanup_desktop():
|
||||||
"""Move known backup files and reports into the ClientDir."""
|
"""Move known backup files and reports into the ClientDir."""
|
||||||
dest_folder = r'{ProgBackupDir}\{Date}\Desktop'.format(**global_vars)
|
dest_folder = r'{ProgBackupDir}\{Date}\Desktop'.format(**global_vars)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# Wizard Kit: Install uBlock Origin for Firefox
|
# Wizard Kit: Post-d7II items
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
@ -10,16 +10,15 @@ from functions.browsers import *
|
||||||
from functions.cleanup import *
|
from functions.cleanup import *
|
||||||
from functions.setup import *
|
from functions.setup import *
|
||||||
init_global_vars()
|
init_global_vars()
|
||||||
os.system('title {}: User Checklist Tool'.format(KIT_NAME_FULL))
|
os.system('title {}: Post-d7II Work'.format(KIT_NAME_FULL))
|
||||||
global_vars['LogFile'] = r'{LogDir}\User Checklist ({USERNAME}).log'.format(
|
global_vars['LogFile'] = r'{LogDir}\User Checklist ({USERNAME}).log'.format(
|
||||||
**global_vars, **global_vars['Env'])
|
**global_vars, **global_vars['Env'])
|
||||||
D7_MODE = 'd7mode' in sys.argv
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
try:
|
try:
|
||||||
stay_awake()
|
stay_awake()
|
||||||
clear_screen()
|
clear_screen()
|
||||||
print_info('{}: Firefox Fix for d7\n'.format(KIT_NAME_FULL))
|
print_info('{}: Post-d7II Work\n'.format(KIT_NAME_FULL))
|
||||||
other_results = {
|
other_results = {
|
||||||
'Warning': {
|
'Warning': {
|
||||||
'NotInstalledError': 'Not installed',
|
'NotInstalledError': 'Not installed',
|
||||||
|
|
@ -34,6 +33,11 @@ if __name__ == '__main__':
|
||||||
print_info('Installing uBlock Origin')
|
print_info('Installing uBlock Origin')
|
||||||
install_adblock(just_firefox=True)
|
install_adblock(just_firefox=True)
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
print_info('Cleanup')
|
||||||
|
try_and_print(message='d7II...',
|
||||||
|
function=cleanup_d7ii, cs='Done')
|
||||||
|
|
||||||
# Done
|
# Done
|
||||||
print_standard('\nDone.')
|
print_standard('\nDone.')
|
||||||
pause('Press Enter to exit...')
|
pause('Press Enter to exit...')
|
||||||
Loading…
Reference in a new issue