diff options
author | Dee Jayh <ruined1@gmail.com> | 2018-01-16 11:49:40 +0300 |
---|---|---|
committer | Dee Jayh <ruined1@gmail.com> | 2018-01-16 11:49:46 +0300 |
commit | ba75d2489da37e603223de576457e6d60ec29b3a (patch) | |
tree | e47f8a2d829da3e328201dc9c6ff9b3290df3f0c | |
parent | d297f7d2f868352c5d6bbd3f8707cfa1e2a13e2d (diff) |
v3.2.0v3.2.0
-Fixed OneDrive Uninstaller
-Allowed more complete resolutions for subprocess_handler
-Added ip_warn for IP blocking option to warn of potential Microsoft licensing issues
-Applied more complete handler to DiagTrack option
-rw-r--r-- | dwt.py | 222 | ||||
-rw-r--r-- | dwt_about.py | 2 | ||||
-rw-r--r-- | dwt_util.py | 91 |
3 files changed, 181 insertions, 134 deletions
@@ -99,7 +99,7 @@ class MainFrame(wx.Frame): class MainPanel(wx.Panel): - def __init__(self, parent): + def __init__(self, parent): super(MainPanel, self).__init__(parent) self.parent = parent @@ -245,125 +245,139 @@ class MainPanel(wx.Panel): check_sizer.Add(self.onedrive_check, 0, wx.ALL, 1) #self.Bind(wx.EVT_CHECKBOX, handler=self.select_all_apps, source=select_all_check) + self.Bind(wx.EVT_CHECKBOX, handler=self.ip_warn, source=self.ip_check) self.Bind(wx.EVT_CHECKBOX, handler=self.hosts_warn, source=self.extra_host_check) #self.Bind(wx.EVT_BUTTON, handler=self.remove_apps, source=remove_app_button) self.Bind(wx.EVT_BUTTON, handler=self.go, source=go_button) self.SetSizer(top_sizer) - def select_all_apps(self, event): - # Iters through all children of the wxStaticBox of the wxStaticBoxSizer and checks/un checks all wxCheckBoxes. - for child in self.app_box.GetStaticBox().GetChildren(): - if isinstance(child, wx.CheckBox): - child.SetValue(event.IsChecked()) - - def hosts_warn(self, event): - # Warn users about the potential side effects of the extra hosts mod. - if event.IsChecked(): - warn = wx.MessageDialog(parent=self, - message="This option could potentially disable one or more of the following " - "services:\n\nSkype, Hotmail, Dr. Watson and/or Error Reporting. Continue?", - caption="Attention!", style=wx.YES_NO | wx.ICON_EXCLAMATION) - - if warn.ShowModal() == wx.ID_NO: - event.GetEventObject().SetValue(False) - - warn.Destroy() - - def go(self, event): - if not all((self.picked_ips, self.picked_extra, self.picked_normal)): - self.settings(event=None) - - undo = bool(self.mode_rad.GetSelection()) - - if self.ip_check.IsChecked(): - dwt_util.ip_block(self.picked_ips, undo=undo) - if self.diagtrack_check.IsChecked(): - dwt_util.clear_diagtrack() - if self.service_check.IsChecked(): - if self.service_rad.GetSize(): - dwt_util.delete_service("dmwappushsvc") - dwt_util.delete_service("DiagTrack") - else: - dwt_util.disable_service("dmwappushsvc") - dwt_util.disable_service("DiagTrack") - dwt_util.services(undo=undo) - if self.telemetry_check.IsChecked(): - dwt_util.telemetry(undo=undo) - if self.host_check.IsChecked(): - dwt_util.host_file(self.picked_normal, undo=undo) - if self.extra_host_check.IsChecked(): - dwt_util.host_file(self.picked_extra, undo=undo) - if self.defender_check.IsChecked(): - dwt_util.defender(undo=undo) - if self.wifisense_check.IsChecked(): - dwt_util.wifisense(undo=undo) - if self.onedrive_check.IsChecked(): - dwt_util.onedrive(undo=undo) - logger.info("Done. It's recommended that you reboot as soon as possible for the full effect.") - logger.info(("If you feel something didn't work properly, please press the 'Report an issue'" - " button and follow the directions")) - console.Center() - console.Show() - - def remove_apps(self, event): - children = [child for child in self.app_box.GetStaticBox().GetChildren() if child.GetName() != "check"] - app_list = [child.GetName() for child in children if isinstance(child, wx.CheckBox) and child.IsChecked()] - dwt_util.app_manager(app_list, undo=False) - - def settings(self, event, silent=False): + def select_all_apps(self, event): + # Iters through all children of the wxStaticBox of the wxStaticBoxSizer and checks/un checks all wxCheckBoxes. + for child in self.app_box.GetStaticBox().GetChildren(): + if isinstance(child, wx.CheckBox): + child.SetValue(event.IsChecked()) + + def ip_warn(self, event): + # Warn users about the potential side effects of the IP blocking firewall rules + if event.IsChecked(): + warn = wx.MessageDialog(parent=self, + message="This option could potentially disable Microsoft Licensing traffic and thus " + "certain games and apps may cease to work, such as, Forza, or Gears of War.", + caption="Attention!", style=wx.YES_NO | wx.ICON_EXCLAMATION) + + if warn.ShowModal() == wx.ID_NO: + event.GetEventObject().SetValue(False) + + warn.Destroy() + + def hosts_warn(self, event): + # Warn users about the potential side effects of the extra hosts mod. + if event.IsChecked(): + warn = wx.MessageDialog(parent=self, + message="This option could potentially disable one or more of the following " + "services:\n\nSkype, Hotmail, Dr. Watson and/or Error Reporting. Continue?", + caption="Attention!", style=wx.YES_NO | wx.ICON_EXCLAMATION) + + if warn.ShowModal() == wx.ID_NO: + event.GetEventObject().SetValue(False) + + warn.Destroy() + + def go(self, event): + if not all((self.picked_ips, self.picked_extra, self.picked_normal)): + self.settings(event=None) + + undo = bool(self.mode_rad.GetSelection()) + + if self.ip_check.IsChecked(): + dwt_util.ip_block(self.picked_ips, undo=undo) + if self.diagtrack_check.IsChecked(): + dwt_util.clear_diagtrack() + if self.service_check.IsChecked(): + if self.service_rad.GetSize(): + dwt_util.delete_service("dmwappushsvc") + dwt_util.delete_service("DiagTrack") + else: + dwt_util.disable_service("dmwappushsvc") + dwt_util.disable_service("DiagTrack") + dwt_util.services(undo=undo) + if self.telemetry_check.IsChecked(): + dwt_util.telemetry(undo=undo) + if self.host_check.IsChecked(): + dwt_util.host_file(self.picked_normal, undo=undo) + if self.extra_host_check.IsChecked(): + dwt_util.host_file(self.picked_extra, undo=undo) + if self.defender_check.IsChecked(): + dwt_util.defender(undo=undo) + if self.wifisense_check.IsChecked(): + dwt_util.wifisense(undo=undo) + if self.onedrive_check.IsChecked(): + dwt_util.onedrive(undo=undo) + logger.info("Done. It's recommended that you reboot as soon as possible for the full effect.") + logger.info(("If you feel something didn't work properly, please press the 'Report an issue'" + " button and follow the directions")) + console.Center() + console.Show() + + def remove_apps(self, event): + children = [child for child in self.app_box.GetStaticBox().GetChildren() if child.GetName() != "check"] + app_list = [child.GetName() for child in children if isinstance(child, wx.CheckBox) and child.IsChecked()] + dwt_util.app_manager(app_list, undo=False) + + def settings(self, event, silent=False): if silent == False: dialog = wx.Dialog(parent=self, title="Settings", style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) sizer = wx.BoxSizer(wx.VERTICAL) normal_domains = ( - 'a-0001.a-msedge.net', 'a-0002.a-msedge.net', 'a-0003.a-msedge.net', 'a-0004.a-msedge.net', - 'a-0005.a-msedge.net', 'a-0006.a-msedge.net', 'a-0007.a-msedge.net', 'a-0008.a-msedge.net', - 'a-0009.a-msedge.net', 'a-msedge.net', 'a.ads1.msn.com', 'a.ads2.msads.net', 'a.ads2.msn.com', - 'a.rad.msn.com', 'ac3.msn.com', 'ad.doubleclick.net', 'adnexus.net', 'adnxs.com', 'ads.msn.com', - 'ads1.msads.net', 'ads1.msn.com', 'aidps.atdmt.com', 'aka-cdn-ns.adtech.de', - 'az361816.vo.msecnd.net', 'az512334.vo.msecnd.net', 'b.ads1.msn.com', 'b.ads2.msads.net', - 'b.rad.msn.com', 'bs.serving-sys.com', 'c.atdmt.com', 'c.msn.com', 'cdn.atdmt.com', - 'cds26.ams9.msecn.net', 'choice.microsoft.com', 'choice.microsoft.com.nsatc.net', - 'compatexchange.cloudapp.net', 'corp.sts.microsoft.com', 'corpext.msitadfs.glbdns2.microsoft.com', - 'cs1.wpc.v0cdn.net', 'db3aqu.atdmt.com', 'df.telemetry.microsoft.com', - 'diagnostics.support.microsoft.com', 'ec.atdmt.com', 'feedback.microsoft-hohm.com', - 'feedback.search.microsoft.com', 'feedback.windows.com', 'flex.msn.com', 'g.msn.com', 'h1.msn.com', - 'i1.services.social.microsoft.com', 'i1.services.social.microsoft.com.nsatc.net', - 'lb1.www.ms.akadns.net', 'live.rads.msn.com', 'm.adnxs.com', 'msedge.net', 'msftncsi.com', - 'msnbot-65-55-108-23.search.msn.com', 'msntest.serving-sys.com', 'oca.telemetry.microsoft.com', - 'oca.telemetry.microsoft.com.nsatc.net', 'pre.footprintpredict.com', 'preview.msn.com', - 'rad.live.com', 'rad.msn.com', 'redir.metaservices.microsoft.com', - 'reports.wes.df.telemetry.microsoft.com', 'schemas.microsoft.akadns.net', - 'secure.adnxs.com', 'secure.flashtalking.com', 'services.wes.df.telemetry.microsoft.com', - 'settings-sandbox.data.microsoft.com', 'settings-win.data.microsoft.com', - 'sls.update.microsoft.com.akadns.net', 'sqm.df.telemetry.microsoft.com', - 'sqm.telemetry.microsoft.com', 'sqm.telemetry.microsoft.com.nsatc.net', 'ssw.live.com', - 'static.2mdn.net', 'statsfe1.ws.microsoft.com', 'statsfe2.ws.microsoft.com', - 'telecommand.telemetry.microsoft.com', 'telecommand.telemetry.microsoft.com.nsatc.net', - 'telemetry.appex.bing.net', 'telemetry.microsoft.com', 'telemetry.urs.microsoft.com', - 'v10.vortex-win.data.microsoft.com', 'vortex-bn2.metron.live.com.nsatc.net', - 'vortex-cy2.metron.live.com.nsatc.net', 'vortex-sandbox.data.microsoft.com', - 'vortex-win.data.metron.live.com.nsatc.net', 'vortex-win.data.microsoft.com', - 'vortex.data.glbdns2.microsoft.com', 'vortex.data.microsoft.com', 'watson.live.com', - 'web.vortex.data.microsoft.com', 'www.msftncsi.com' + 'a-0001.a-msedge.net', 'a-0002.a-msedge.net', 'a-0003.a-msedge.net', 'a-0004.a-msedge.net', + 'a-0005.a-msedge.net', 'a-0006.a-msedge.net', 'a-0007.a-msedge.net', 'a-0008.a-msedge.net', + 'a-0009.a-msedge.net', 'a-msedge.net', 'a.ads1.msn.com', 'a.ads2.msads.net', 'a.ads2.msn.com', + 'a.rad.msn.com', 'ac3.msn.com', 'ad.doubleclick.net', 'adnexus.net', 'adnxs.com', 'ads.msn.com', + 'ads1.msads.net', 'ads1.msn.com', 'aidps.atdmt.com', 'aka-cdn-ns.adtech.de', + 'az361816.vo.msecnd.net', 'az512334.vo.msecnd.net', 'b.ads1.msn.com', 'b.ads2.msads.net', + 'b.rad.msn.com', 'bs.serving-sys.com', 'c.atdmt.com', 'c.msn.com', 'cdn.atdmt.com', + 'cds26.ams9.msecn.net', 'choice.microsoft.com', 'choice.microsoft.com.nsatc.net', + 'compatexchange.cloudapp.net', 'corp.sts.microsoft.com', 'corpext.msitadfs.glbdns2.microsoft.com', + 'cs1.wpc.v0cdn.net', 'db3aqu.atdmt.com', 'df.telemetry.microsoft.com', + 'diagnostics.support.microsoft.com', 'ec.atdmt.com', 'feedback.microsoft-hohm.com', + 'feedback.search.microsoft.com', 'feedback.windows.com', 'flex.msn.com', 'g.msn.com', 'h1.msn.com', + 'i1.services.social.microsoft.com', 'i1.services.social.microsoft.com.nsatc.net', + 'lb1.www.ms.akadns.net', 'live.rads.msn.com', 'm.adnxs.com', 'msedge.net', 'msftncsi.com', + 'msnbot-65-55-108-23.search.msn.com', 'msntest.serving-sys.com', 'oca.telemetry.microsoft.com', + 'oca.telemetry.microsoft.com.nsatc.net', 'pre.footprintpredict.com', 'preview.msn.com', + 'rad.live.com', 'rad.msn.com', 'redir.metaservices.microsoft.com', + 'reports.wes.df.telemetry.microsoft.com', 'schemas.microsoft.akadns.net', + 'secure.adnxs.com', 'secure.flashtalking.com', 'services.wes.df.telemetry.microsoft.com', + 'settings-sandbox.data.microsoft.com', 'settings-win.data.microsoft.com', + 'sls.update.microsoft.com.akadns.net', 'sqm.df.telemetry.microsoft.com', + 'sqm.telemetry.microsoft.com', 'sqm.telemetry.microsoft.com.nsatc.net', 'ssw.live.com', + 'static.2mdn.net', 'statsfe1.ws.microsoft.com', 'statsfe2.ws.microsoft.com', + 'telecommand.telemetry.microsoft.com', 'telecommand.telemetry.microsoft.com.nsatc.net', + 'telemetry.appex.bing.net', 'telemetry.microsoft.com', 'telemetry.urs.microsoft.com', + 'v10.vortex-win.data.microsoft.com', 'vortex-bn2.metron.live.com.nsatc.net', + 'vortex-cy2.metron.live.com.nsatc.net', 'vortex-sandbox.data.microsoft.com', + 'vortex-win.data.metron.live.com.nsatc.net', 'vortex-win.data.microsoft.com', + 'vortex.data.glbdns2.microsoft.com', 'vortex.data.microsoft.com', 'watson.live.com', + 'web.vortex.data.microsoft.com', 'www.msftncsi.com' ) extra_domains = ( - 'fe2.update.microsoft.com.akadns.net', 's0.2mdn.net', 'statsfe2.update.microsoft.com.akadns.net', - 'survey.watson.microsoft.com', 'view.atdmt.com', 'watson.microsoft.com', - 'watson.ppe.telemetry.microsoft.com', 'watson.telemetry.microsoft.com', - 'watson.telemetry.microsoft.com.nsatc.net', 'wes.df.telemetry.microsoft.com', 'ui.skype.com', - 'pricelist.skype.com', 'apps.skype.com', 'm.hotmail.com', 's.gateway.messenger.live.com' - ) + 'fe2.update.microsoft.com.akadns.net', 's0.2mdn.net', 'statsfe2.update.microsoft.com.akadns.net', + 'survey.watson.microsoft.com', 'view.atdmt.com', 'watson.microsoft.com', + 'watson.ppe.telemetry.microsoft.com', 'watson.telemetry.microsoft.com', + 'watson.telemetry.microsoft.com.nsatc.net', 'wes.df.telemetry.microsoft.com', 'ui.skype.com', + 'pricelist.skype.com', 'apps.skype.com', 'm.hotmail.com', 's.gateway.messenger.live.com' + ) ip_addresses = ( - '2.22.61.43', '2.22.61.66', '65.39.117.230', '65.55.108.23', '23.218.212.69', '134.170.30.202', - '137.116.81.24', '157.56.106.189', '204.79.197.200', '65.52.108.33', '64.4.54.254' - ) + '2.22.61.43', '2.22.61.66', '65.39.117.230', '65.55.108.23', '23.218.212.69', '134.170.30.202', + '137.116.81.24', '157.56.106.189', '204.79.197.200', '65.52.108.33', '64.4.54.254' + ) normal_domain_picker = ItemsPicker(dialog, choices=[], selectedLabel="Domains to be blocked", - ipStyle=IP_SORT_SELECTED | IP_SORT_CHOICES | IP_REMOVE_FROM_CHOICES) + ipStyle=IP_SORT_SELECTED | IP_SORT_CHOICES | IP_REMOVE_FROM_CHOICES) if self.picked_normal: normal_domain_picker.SetSelections(self.picked_normal) normal_domain_picker.SetItems([domain for domain in normal_domains if domain not in self.picked_normal]) @@ -371,7 +385,7 @@ class MainPanel(wx.Panel): normal_domain_picker.SetSelections(normal_domains) extra_domain_picker = ItemsPicker(dialog, choices=[], selectedLabel="Extra domains to be blocked", - ipStyle=IP_SORT_SELECTED | IP_SORT_CHOICES | IP_REMOVE_FROM_CHOICES) + ipStyle=IP_SORT_SELECTED | IP_SORT_CHOICES | IP_REMOVE_FROM_CHOICES) if self.picked_extra: extra_domain_picker.SetSelections(self.picked_extra) extra_domain_picker.SetItems([domain for domain in extra_domains if domain not in self.picked_extra]) @@ -379,7 +393,7 @@ class MainPanel(wx.Panel): extra_domain_picker.SetSelections(extra_domains) ip_picker = ItemsPicker(dialog, choices=[], selectedLabel="IP addresses to be blocked", - ipStyle=IP_SORT_SELECTED | IP_SORT_CHOICES | IP_REMOVE_FROM_CHOICES) + ipStyle=IP_SORT_SELECTED | IP_SORT_CHOICES | IP_REMOVE_FROM_CHOICES) if self.picked_ips: ip_picker.SetSelections(self.picked_ips) ip_picker.SetItems([ip for ip in ip_addresses if ip not in self.picked_ips]) diff --git a/dwt_about.py b/dwt_about.py index bf13d63..4e8337d 100644 --- a/dwt_about.py +++ b/dwt_about.py @@ -26,7 +26,7 @@ import wx import wx.adv import wx.lib.scrolledpanel as sp -__version__ = "3.1.3" +__version__ = "3.2.0" def about_dialog(parent): diff --git a/dwt_util.py b/dwt_util.py index 65d53e9..656f80b 100644 --- a/dwt_util.py +++ b/dwt_util.py @@ -20,6 +20,7 @@ import platform from collections import OrderedDict import pywintypes import shutil +from string import split import subprocess import tempfile import _winreg as winreg @@ -64,8 +65,14 @@ class CalledProcessError(Exception): def is_64bit(): - # Detect if OS is 64bit - return True if "64" in platform.machine() else False + if os.name == 'nt': + output = subprocess.check_output(['wmic', 'os', 'get', 'OSArchitecture']) + os_arch = output.split()[1] + return True if os_arch == '64-bit' else False + else: + logger.critical("This was only meant to be run on Windows-based system. Specifically, Windows 10.") + os._exit(0) + return os_arch def ip_block(ip_list, undo): @@ -94,13 +101,25 @@ def clear_diagtrack(): failed = False for cmd in cmds: i += 1 - try: - subprocess_handler(shlex.split(cmd)) + service = split(cmd, 'sc delete ') + + + output = subprocess_handler(cmd) + if output[0] in [0, 1060]: + if output[0] == 0: + if len(service) > 1: + logger.info("DiagTrack: Successfully deleted service '{0}'".format(service[1])) + else: + logger.info("DiagTrack: Successfully erased tracking log.") + if output[0] == 1060: + logger.info("DiagTrack: {0} service doesn't exist. This is OK, you likely removed it already.".format(service[1])) + logger.info("DiagTrack: Completed Part {0}/{1}".format(i, len(cmds))) - except CalledProcessError as e: + else: + logger.info("{0}".format(output[0])) failed = True logger.exception("DiagTrack: Failed Part {0}/{1}".format(i, len(cmds))) - logger.critical("DiagTrack: Error output:\n" + e.stdout.decode('ascii', 'replace')) + logger.critical("DiagTrack: Error code: {0} - {1}".format(output[0],output[1])) if failed: logger.info("DiagTrack: Complete. Errors were recorded.") @@ -212,27 +231,42 @@ def wifisense(undo): def onedrive(undo): - file_sync_value = int(undo) - list_pin_value = int(not undo) - action = "install" if undo else "uninstall" - onedrive_keys = {'FileSync': [winreg.HKEY_LOCAL_MACHINE, - r'SOFTWARE\Policies\Microsoft\Windows\OneDrive', - 'DisableFileSyncNGSC', winreg.REG_DWORD, file_sync_value], - - 'ListPin': [winreg.HKEY_CLASSES_ROOT, - r'CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}', - 'System.IsPinnedToNameSpaceTree', winreg.REG_DWORD, list_pin_value]} - - set_registry(onedrive_keys) - - system = "SysWOW64" if is_64bit() else "System32" - onedrive_setup = os.path.join(os.environ['SYSTEMROOT'], "{system}/OneDriveSetup.exe".format(system=system)) - cmd = "{bin} /{action}".format(bin=onedrive_setup, action=action) - try: - subprocess.call(shlex.split(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) - logger.info("OneDrive: successfully {action}ed".format(action=action)) - except (WindowsError, IOError): - logger.info("OneDrive: unable to {action}".format(action=action)) + file_sync_value = int(undo) + list_pin_value = int(not undo) + action = "install" if undo else "uninstall" + + if is_64bit(): + onedrive_keys = {'FileSync': [winreg.HKEY_LOCAL_MACHINE, + r'SOFTWARE\Policies\Microsoft\Windows\OneDrive', + 'DisableFileSyncNGSC', winreg.REG_DWORD, file_sync_value], + + 'ListPin': [winreg.HKEY_CLASSES_ROOT, + r'CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}', + 'System.IsPinnedToNameSpaceTree', winreg.REG_DWORD, list_pin_value], + + 'ListPin64Bit': [winreg.HKEY_CLASSES_ROOT, + r'Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}', + 'System.IsPinnedToNameSpaceTree', winreg.REG_DWORD, list_pin_value]} + else: + onedrive_keys = {'FileSync': [winreg.HKEY_LOCAL_MACHINE, + r'SOFTWARE\Policies\Microsoft\Windows\OneDrive', + 'DisableFileSyncNGSC', winreg.REG_DWORD, file_sync_value], + + 'ListPin': [winreg.HKEY_CLASSES_ROOT, + r'CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}', + 'System.IsPinnedToNameSpaceTree', winreg.REG_DWORD, list_pin_value]} + + set_registry(onedrive_keys) + + system = "SysWOW64" if is_64bit() else "System32" + onedrive_setup = os.path.join(os.environ['SYSTEMROOT'], "{system}\\OneDriveSetup.exe".format(system=system)) + cmd = "{bin} /{action}".format(bin=onedrive_setup, action=action) + + output = subprocess_handler(cmd) + if output[0] == -2147219823: + logger.info("OneDrive: successfully {action}ed".format(action=action)) + else: + logger.info("OneDrive: unable to {action}. Exited with code: {code} - {message}".format(action=action, code=output[0], message=output[1])) def set_registry(keys): @@ -298,8 +332,7 @@ def subprocess_handler(cmd): p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, shell=True) output = p.communicate() - if p.returncode: - return p.returncode + return [p.returncode, output] # Old reinstall code, does not work: # if reinstall: |