Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/10se1ucgo/DisableWinTracking.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Galkin <leks.molecul@gmail.com>2019-01-31 00:46:33 +0300
committerAlexey Galkin <leks.molecul@gmail.com>2019-01-31 00:46:33 +0300
commit498fc9cf8d896286d77a0963568b6b1c7bba2c1f (patch)
tree861d0d487994df5a90f549fabce39936d06839c3
parentdcec2d191c5fee1632d79912430ffec84a90ded6 (diff)
Resolve conflicts and remove fixes for code stylingpr/410
-rw-r--r--README.md1
-rw-r--r--dwt.py253
-rw-r--r--dwt_about.py11
-rw-r--r--dwt_util.py263
4 files changed, 255 insertions, 273 deletions
diff --git a/README.md b/README.md
index 3f188fd..56fde40 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,7 @@ A tool that I created to use some of the known methods of disabling tracking in
<!-- ![screenshot](http://i.imgur.com/WINUxAj.png) -->
![screenshot](http://i.imgur.com/Yu8WEHN.png)
+
## CYRILLIC LANGUAGES WARNING
## ПРЕДУПРЕЖДЕНИЕ ДЛЯ КИРИЛЛИЧЕСКИХ ЯЗЫКОВ
diff --git a/dwt.py b/dwt.py
index 1ebfd1f..03f22b0 100644
--- a/dwt.py
+++ b/dwt.py
@@ -28,54 +28,54 @@ from wx.lib.itemspicker import ItemsPicker, IP_SORT_SELECTED, IP_SORT_CHOICES, I
import dwt_about
import dwt_util
-
class RedirectText(io.StringIO):
- def __init__(self, cli, old_stdout):
- super(RedirectText, self).__init__()
+ def __init__(self, console, old_stdout):
+ super(RedirectText, self).__init__()
- self.out = cli
- self.old_out = old_stdout
+ self.out = console
+ self.old_out = old_stdout
- def write(self, string):
- # Oh my god this is the DUMBEST THING I've ever done. (Keeping a reference to the old stdout)
- self.old_out.write(string)
- self.out.WriteText(string)
+ def write(self, string):
+ # Oh my god this is the DUMBEST THING I've ever done. (Keeping a reference to the old stdout)
+ self.old_out.write(string)
+ self.out.WriteText(string)
class ConsoleDialog(wx.Dialog):
- def __init__(self, old_stdout):
- wx.Dialog.__init__(
- self, parent=wx.GetApp().TopWindow, title="Console Output", size=(500, 200),
- style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
+ def __init__(self, old_stdout):
+ wx.Dialog.__init__(self, parent=wx.GetApp().TopWindow, title="Console Output", size=(500, 200),
+ style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
- console_box = wx.TextCtrl(self, style=wx.TE_MULTILINE | wx.TE_READONLY)
- sys.stdout = RedirectText(console_box, old_stdout)
+ console_box = wx.TextCtrl(self, style=wx.TE_MULTILINE | wx.TE_READONLY)
+ sys.stdout = RedirectText(console_box, old_stdout)
- top_sizer = wx.BoxSizer(wx.VERTICAL)
- console_sizer = wx.BoxSizer(wx.VERTICAL)
- button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL)
+ top_sizer = wx.BoxSizer(wx.VERTICAL)
+ console_sizer = wx.BoxSizer(wx.VERTICAL)
+ button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL)
- report_button = wx.FindWindowById(wx.ID_CANCEL, self)
- report_button.SetLabel("Report an issue")
+ report_button = wx.FindWindowById(wx.ID_CANCEL, self)
+ report_button.SetLabel("Report an issue")
- console_sizer.Add(console_box, 1, wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ALIGN_TOP, 5)
+ console_sizer.Add(console_box, 1, wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ALIGN_TOP, 5)
- top_sizer.Add(console_sizer, 1, wx.ALL | wx.EXPAND, 5)
- top_sizer.Add(button_sizer, 0, wx.ALL | wx.ALIGN_LEFT, 5)
+ top_sizer.Add(console_sizer, 1, wx.ALL | wx.EXPAND, 5)
+ top_sizer.Add(button_sizer, 0, wx.ALL | wx.ALIGN_LEFT, 5)
- self.Bind(wx.EVT_CLOSE, handler=lambda x: sys.exit(0))
- self.Bind(wx.EVT_BUTTON, handler=lambda x: sys.exit(0), id=wx.ID_OK)
- self.Bind(wx.EVT_BUTTON, source=report_button, handler=self.submit_issue)
- self.SetSizer(top_sizer)
+ self.Bind(wx.EVT_CLOSE, handler=lambda x: sys.exit(0))
+ self.Bind(wx.EVT_BUTTON, handler=lambda x: sys.exit(0), id=wx.ID_OK)
+ self.Bind(wx.EVT_BUTTON, source=report_button, handler=self.submit_issue)
+ self.SetSizer(top_sizer)
- def submit_issue(self, event):
- webbrowser.open_new_tab("https://github.com/10se1ucgo/DisableWinTracking/issues/new")
+ def submit_issue(self, event):
+ webbrowser.open_new_tab("https://github.com/10se1ucgo/DisableWinTracking/issues/new")
class MainFrame(wx.Frame):
def __init__(self):
- super(MainFrame, self).__init__(
- parent=wx.GetApp().GetTopWindow(), title="Disable Windows 10 Tracking", size=(415, 245))
+ super(MainFrame, self).__init__(parent=wx.GetApp().GetTopWindow(), \
+ title="Disable Windows 10 Tracking", \
+ size=(415,245))
+
self.SetMinSize(self.GetSize())
panel = MainPanel(self)
@@ -113,13 +113,13 @@ class MainPanel(wx.Panel):
self.service_check.SetToolTip("Disables or deletes tracking services. Choose option in 'Services Method'")
self.diagtrack_check = wx.CheckBox(self, label="Clear DiagTrack log")
- self.diagtrack_check.SetToolTip(
- "Clears Dianostic Tracking log and prevents modification to it. Cannot be undone automatically.")
+ self.diagtrack_check.SetToolTip("Clears Dianostic Tracking log and prevents modification to it. "
+ "Cannot be undone automatically.")
# Telemetry checkbox
self.telemetry_check = wx.CheckBox(self, label="Telemetry")
- self.telemetry_check.SetToolTip(
- "Sets 'AllowTelemetry' to 0. On non-Enterprise OS editions, requires HOSTS file modification.")
+ self.telemetry_check.SetToolTip("Sets 'AllowTelemetry' to 0. "
+ "On non-Enterprise OS editions, requires HOSTS file modification.")
# HOSTS file checkbox
self.host_check = wx.CheckBox(self, label="Block tracking domains")
@@ -127,9 +127,8 @@ class MainPanel(wx.Panel):
# Extra HOSTS checkbox
self.extra_host_check = wx.CheckBox(self, label="Block even more tracking domains")
- self.extra_host_check.SetToolTip(
- "For the paranoid. Adds extra domains to the HOSTS file.\n"
- "May cause issues with Skype, Dr. Watson, Hotmail and/or Error Reporting.")
+ self.extra_host_check.SetToolTip("For the paranoid. Adds extra domains to the HOSTS file.\n"
+ "May cause issues with Skype, Dr. Watson, Hotmail and/or Error Reporting.")
# IP block checkbox
self.ip_check = wx.CheckBox(self, label="Block tracking IP addresses")
@@ -137,8 +136,8 @@ class MainPanel(wx.Panel):
# Windows Privacy Regs (Policy Manager)
self.defender_check = wx.CheckBox(self, label="Windows Defender collection")
- # self.defender_check.SetToolTip("Modifies registry to prevent Defender collection")
- # Disable defender option until a solution is found.
+ #self.defender_check.SetToolTip("Modifies registry to prevent Defender collection")
+ #Disable defender option until a solution is found.
self.defender_check.SetToolTip("Disable due to limitation set by windows kernel.")
self.defender_check.Enable(False)
@@ -163,8 +162,9 @@ class MainPanel(wx.Panel):
go_button = wx.Button(self, label="Go!")
- # Temporarily removed due to issues with not being able to restore apps properly
- # This was honestly beyond the scope of the project to begin with and shouldn't have been implemented
+ #Temporarily removed due to issues with not being able to restore apps properly
+ #This was honestly beyond the scope of the project to begin with and shouldn't have been implemented
+
'''self.app_box = wx.StaticBoxSizer(wx.VERTICAL, self, "Built-in Apps")
stat_box = self.app_box.GetStaticBox()
@@ -234,7 +234,7 @@ class MainPanel(wx.Panel):
rad_sizer = wx.BoxSizer(wx.VERTICAL)
top_sizer.Add(top_row_sizer, 0, wx.ALL, 5)
- # top_sizer.Add(self.app_box, 0, wx.ALL, 5)
+ #top_sizer.Add(self.app_box, 0, wx.ALL, 5)
top_row_sizer.Add(check_sizer, 0, wx.ALL)
top_row_sizer.Add(rad_sizer, 0, wx.ALL)
rad_sizer.Add(self.service_rad, 0, wx.ALL, 10)
@@ -249,12 +249,12 @@ class MainPanel(wx.Panel):
check_sizer.Add(self.defender_check, 0, wx.ALL, 1)
check_sizer.Add(self.wifisense_check, 0, wx.ALL, 1)
check_sizer.Add(self.onedrive_check, 0, wx.ALL, 1)
- check_sizer.Add(self.dvr_check, 0, wx.ALL, 1)
+ check_sizer.Add(self.dvr_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.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.remove_apps, source=remove_app_button)
self.Bind(wx.EVT_BUTTON, handler=self.go, source=go_button)
self.SetSizer(top_sizer)
@@ -264,15 +264,14 @@ class MainPanel(wx.Panel):
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)
+ 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)
@@ -282,10 +281,10 @@ class MainPanel(wx.Panel):
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, caption="Attention!", style=wx.YES_NO | wx.ICON_EXCLAMATION,
- message="""This option could potentially disable one or more of the following services:
- \n\nSkype, Hotmail, Dr. Watson and/or Error Reporting. Continue?""")
+ 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)
@@ -325,22 +324,21 @@ class MainPanel(wx.Panel):
if self.dvr_check.IsChecked():
dwt_util.dvr(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")
+ 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):
+ 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_flag=False):
- if not silent_flag:
+ 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',
@@ -387,37 +385,31 @@ class MainPanel(wx.Panel):
'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)
-
+ normal_domain_picker = ItemsPicker(dialog, choices=[], selectedLabel="Domains to be blocked",
+ 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])
else:
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)
-
+ extra_domain_picker = ItemsPicker(dialog, choices=[], selectedLabel="Extra domains to be blocked",
+ 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])
else:
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)
-
+ ip_picker = ItemsPicker(dialog, choices=[], selectedLabel="IP addresses to be blocked",
+ 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])
else:
ip_picker.SetSelections(ip_addresses)
- if not silent_flag:
+ if silent == False:
sizer.Add(normal_domain_picker, 0, wx.EXPAND)
sizer.Add(extra_domain_picker, 0, wx.EXPAND)
sizer.Add(ip_picker, 0, wx.EXPAND)
@@ -426,70 +418,64 @@ class MainPanel(wx.Panel):
dialog.Center()
dialog.ShowModal()
dialog.Destroy()
-
+
self.picked_normal = normal_domain_picker.GetSelections()
self.picked_extra = extra_domain_picker.GetSelections()
self.picked_ips = ip_picker.GetSelections()
-
-
+
+
def setup_logging():
- global logger
- logger = logging.getLogger('dwt')
- logger.setLevel(logging.DEBUG)
-
- formatter = logging.Formatter(fmt='%(asctime)s %(levelname)s: %(message)s', datefmt='%H:%M:%S')
-
- stdout_log = logging.StreamHandler(sys.stdout)
- stdout_log.setLevel(logging.DEBUG)
- stdout_log.setFormatter(formatter)
- logger.addHandler(stdout_log)
-
- try:
- file_log = logging.FileHandler(filename='dwt.log')
- file_log.setLevel(logging.DEBUG)
- file_log.setFormatter(formatter)
- logger.addHandler(file_log)
- except (OSError, IOError):
- error_dialog = wx.MessageDialog(
- parent=wx.GetApp().GetTopWindow(),
- message="Could not create log file, errors will not be recorded!",
- caption="ERROR!", style=wx.OK | wx.ICON_ERROR)
- error_dialog.ShowModal()
- error_dialog.Destroy()
- logger.exception("Could not create log file.")
-
- logger.info("Python {version} on {platform}".format(version=sys.version, platform=sys.platform))
- logger.info(platform.uname())
- logger.info("DisableWinTracking version {v}".format(v=dwt_about.__version__))
+ global logger
+ logger = logging.getLogger('dwt')
+ logger.setLevel(logging.DEBUG)
+
+ formatter = logging.Formatter(fmt='%(asctime)s %(levelname)s: %(message)s', datefmt='%H:%M:%S')
+
+ stdout_log = logging.StreamHandler(sys.stdout)
+ stdout_log.setLevel(logging.DEBUG)
+ stdout_log.setFormatter(formatter)
+ logger.addHandler(stdout_log)
+
+ try:
+ file_log = logging.FileHandler(filename='dwt.log')
+ file_log.setLevel(logging.DEBUG)
+ file_log.setFormatter(formatter)
+ logger.addHandler(file_log)
+ except (OSError, IOError):
+ error_dialog = wx.MessageDialog(parent=wx.GetApp().GetTopWindow(),
+ message="Could not create log file, errors will not be recorded!",
+ caption="ERROR!", style=wx.OK | wx.ICON_ERROR)
+ error_dialog.ShowModal()
+ error_dialog.Destroy()
+ logger.exception("Could not create log file.")
+
+ logger.info("Python {version} on {platform}".format(version=sys.version, platform=sys.platform))
+ logger.info(platform.uname())
+ logger.info("DisableWinTracking version {v}".format(v=dwt_about.__version__))
def exception_hook(error, value, trace):
- error_message = ''.join(traceback.format_exception(error, value, trace))
- logger.critical(error_message)
- error_dialog = wx.MessageDialog(
- parent=wx.GetApp().GetTopWindow(),
- message="An error has occured!\n\n" + error_message,
- caption="ERROR!", style=wx.OK | wx.CANCEL | wx.ICON_ERROR)
- error_dialog.SetOKCancelLabels("Ignore", "Quit")
- if error_dialog.ShowModal() == wx.ID_OK:
- error_dialog.Destroy()
- else:
- error_dialog.Destroy()
- sys.exit(1)
-
-
-def check_elevated(silent_flag=False):
+ error_message = ''.join(traceback.format_exception(error, value, trace))
+ logger.critical(error_message)
+ error_dialog = wx.MessageDialog(parent=wx.GetApp().GetTopWindow(),
+ message="An error has occured!\n\n" + error_message,
+ caption="ERROR!", style=wx.OK | wx.CANCEL | wx.ICON_ERROR)
+ error_dialog.SetOKCancelLabels("Ignore", "Quit")
+ if error_dialog.ShowModal() == wx.ID_OK:
+ error_dialog.Destroy()
+ else:
+ error_dialog.Destroy()
+ sys.exit(1)
+
+def check_elevated(silent=False):
if not bool(windll.advpack.IsNTAdmin(0, None)):
- if silent_flag:
- windll.shell32.ShellExecuteW(
- None, u"runas", unicode(sys.executable), u"{0} -silent".format(unicode(__file__)), None, 1)
+ if silent:
+ windll.shell32.ShellExecuteW(None, u"runas", unicode(sys.executable), u"{0} -silent".format(unicode(__file__)), None, 1)
sys.exit(1)
else:
- windll.shell32.ShellExecuteW(
- None, u"runas", unicode(sys.executable), unicode(__file__), None, 1)
+ windll.shell32.ShellExecuteW(None, u"runas", unicode(sys.executable), unicode(__file__), None, 1)
sys.exit(1)
-
-
+
def silent():
setup_logging()
@@ -500,18 +486,17 @@ def silent():
dwt_util.disable_service("DiagTrack")
dwt_util.services(0)
dwt_util.telemetry(0)
- # dwt_util.defender(0)
+ #dwt_util.defender(0)
dwt_util.wifisense(0)
dwt_util.onedrive(0)
-
+
logger.info("COMPLETE")
-
-
+
if __name__ == '__main__':
if '-silent' in sys.argv:
silent()
sys.exit(0)
-
+
wx_app = wx.App()
frame = MainFrame()
console = ConsoleDialog(sys.stdout)
diff --git a/dwt_about.py b/dwt_about.py
index fe1dd45..afff940 100644
--- a/dwt_about.py
+++ b/dwt_about.py
@@ -16,6 +16,7 @@
# along with DisableWinTracking. If not, see <http://www.gnu.org/licenses/>.
# dwt.py will become cluttered enough :^)
+import datetime
import cgi
import json
import urllib2
@@ -26,12 +27,12 @@ import wx
import wx.adv
import wx.lib.scrolledpanel as sp
-__version__ = "3.2.1"
-
+__version__ = "3.2.2"
+year = datetime.date.today().year
def about_dialog(parent):
license_text = """
- Copyright (C) 10se1ucgo 2015-2016
+ Copyright (C) 10se1ucgo 2015-{year}
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -44,12 +45,12 @@ def about_dialog(parent):
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>."""
+ along with this program. If not, see <http://www.gnu.org/licenses/>.""".format(year=year)
about_info = wx.adv.AboutDialogInfo()
about_info.SetName("Disable Windows 10 Tracking")
about_info.SetVersion("v{v}".format(v=__version__))
- about_info.SetCopyright("Copyright (C) 10se1ucgo 2015-2016")
+ about_info.SetCopyright("Copyright (C) 10se1ucgo 2015-{year}".format(year=year))
about_info.SetDescription("A tool to disable tracking in Windows 10")
about_info.SetWebSite("https://github.com/10se1ucgo/DisableWinTracking", "GitHub repository")
about_info.AddDeveloper("10se1ucgo")
diff --git a/dwt_util.py b/dwt_util.py
index 29d637a..607236b 100644
--- a/dwt_util.py
+++ b/dwt_util.py
@@ -66,12 +66,13 @@ class CalledProcessError(Exception):
def is_64bit():
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
+ 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.")
- exit(0)
+ 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):
@@ -83,100 +84,93 @@ def ip_block(ip_list, undo):
try:
subprocess_handler(shlex.split(cmd))
- logger.info(
- "IP Blocker: The IP {ip} was successfully {act}.".format(ip=ip, act='unblocked' if undo else 'blocked'))
+ logger.info("IP Blocker: The IP {ip} was successfully {act}.".format(ip=ip, act='unblocked' if undo else 'blocked'))
except CalledProcessError as e:
logger.exception("IP Blocker: Failed to {act} IP {ip}".format(act='unblock' if undo else 'block', ip=ip))
logger.critical("IP Blocker: Error output:\n" + e.stdout.decode('ascii', 'replace'))
def clear_diagtrack():
- file_path = os.path.join(
- os.environ['SYSTEMDRIVE'],
- '\\ProgramData\\Microsoft\\Diagnosis\\ETLLogs\\AutoLogger\\AutoLogger-Diagtrack-Listener.etl')
-
- cmds = [
- 'sc delete DiagTrack',
- 'sc delete dmwappushservice',
- 'echo "" > "{file}"'.format(file=file_path)
- ]
-
- i = 0
- failed = False
- for cmd in cmds:
- i += 1
- service = split(cmd, 'sc delete ')
-
- output = subprocess_handler(cmd)
- if output[0] in [0, 1060, 1072]:
- 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]))
- if output[0] == 1072:
- logger.info(
- "DiagTrack: {0} service marked for deletion. "
- "This is OK, make sure you reboot your machine!".format(service[1]))
-
- logger.info("DiagTrack: Completed Part {0}/{1}".format(i, len(cmds)))
- else:
- logger.info("{0}".format(output[0]))
- failed = True
- logger.exception("DiagTrack: Failed Part {0}/{1}".format(i, len(cmds)))
- logger.critical("DiagTrack: Error code: {0} - {1}".format(output[0], output[1]))
-
- if failed:
- logger.info("DiagTrack: Complete. Errors were recorded.")
- else:
- logger.info("DiagTrack: Completed successfully, without errors.")
-
- '''
- This is an ORDERED dictionary. It will always run in order, not subject to the devastation
- of a standard dictionary, so no worries.
- '''
-
- # temporarily removing this code in favor of something that actually works
- '''
- cmds = OrderedDict()
- cmds["takeown /f {0}".format(file)]="Take Ownership"
- cmds["icacls {0} /grant administrators:F".format(file)]="Grant Admin Privilege"
- cmds["icacls {0} /inheritance:r /deny SYSTEM:F /grant Administrators:F".format(file)]="Deny System Privilege"
-
- i = 0
-
- for x, y in cmds.iteritems():
- i += 1
-
- if i == 3:
- try:
- open(file, 'w').close()
- logger.info("DiagTrack: Cleared AutoLogger-Diagtrack-Listener.etl")
- except:
- logger.exception("DiagTrack: Couldn't open AutoLogger-Diagtrack-Listener.etl for writing")
-
- p = subprocess.Popen(x, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
- output = p.communicate()
- logger.info("DiagTrack: {0} of AutoLogger-Diagtrack-Listener.etl was successful".format(y))
-
- if p.returncode:
- logger.exception(p.returncode.decode())
-
- if i == 3:
- logger.info("DiagTrack: Successfully cleared and locked DiagTrack log.")
- '''
-
+ file = os.path.join(os.environ['SYSTEMDRIVE'], ('\\ProgramData\\Microsoft\\Diagnosis\\ETLLogs\\AutoLogger\\AutoLogger-Diagtrack-Listener.etl'))
+
+ cmds = ['sc delete DiagTrack',
+ 'sc delete dmwappushservice',
+ 'echo "" > "{file}"'.format(file=file)]
+
+ i = 0
+ failed = False
+ for cmd in cmds:
+ i += 1
+ service = split(cmd, 'sc delete ')
+
+
+ output = subprocess_handler(cmd)
+ if output[0] in [0, 1060, 1072]:
+ 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]))
+ if output[0] == 1072:
+ logger.info("DiagTrack: {0} service marked for deletion. This is OK, make sure you reboot your machine!".format(service[1]))
+
+ logger.info("DiagTrack: Completed Part {0}/{1}".format(i, len(cmds)))
+ else:
+ logger.info("{0}".format(output[0]))
+ failed = True
+ logger.exception("DiagTrack: Failed Part {0}/{1}".format(i, len(cmds)))
+ logger.critical("DiagTrack: Error code: {0} - {1}".format(output[0],output[1]))
+
+ if failed:
+ logger.info("DiagTrack: Complete. Errors were recorded.")
+ else:
+ logger.info("DiagTrack: Completed successfully, without errors.")
+
+ '''
+ This is an ORDERED dictionary. It will always run in order, not subject to the devastation
+ of a standard dictionary, so no worries.
+ '''
+
+ #temporarily removing this code in favor of something that actually works
+ '''
+ cmds = OrderedDict()
+ cmds["takeown /f {0}".format(file)]="Take Ownership"
+ cmds["icacls {0} /grant administrators:F".format(file)]="Grant Admin Privilege"
+ cmds["icacls {0} /inheritance:r /deny SYSTEM:F /grant Administrators:F".format(file)]="Deny System Privilege"
+
+ i = 0
+
+ for x, y in cmds.iteritems():
+ i += 1
+
+ if i == 3:
+ try:
+ open(file, 'w').close()
+ logger.info("DiagTrack: Cleared AutoLogger-Diagtrack-Listener.etl")
+ except:
+ logger.exception("DiagTrack: Couldn't open AutoLogger-Diagtrack-Listener.etl for writing")
+
+ p = subprocess.Popen(x, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
+ output = p.communicate()
+ logger.info("DiagTrack: {0} of AutoLogger-Diagtrack-Listener.etl was successful".format(y))
+
+ if p.returncode:
+ logger.exception(p.returncode.decode())
+
+ if i == 3:
+ logger.info("DiagTrack: Successfully cleared and locked DiagTrack log.")
+ '''
def delete_service(service):
try:
win32serviceutil.RemoveService(service)
- logger.info("Services: Successfully removed service '{service}'".format(service=service))
+ logger.info("Services: Succesfully removed service '{service}'".format(service=service))
except pywintypes.error as e:
- errors = (winerror.ERROR_SERVICE_DOES_NOT_EXIST, winerror.ERROR_SERVICE_NOT_ACTIVE)
+ errors = (winerror.ERROR_SERVICE_DOES_NOT_EXIST, \
+ winerror.ERROR_SERVICE_NOT_ACTIVE, \
+ winerror.ERROR_SERVICE_MARKED_FOR_DELETE)
if not any(error == e.winerror for error in errors):
logger.exception("Services: Failed to remove service '{service}'".format(service=service))
@@ -184,7 +178,7 @@ def delete_service(service):
def disable_service(service):
try:
win32serviceutil.StopService(service)
- logger.info("Services: Successfully stopped service '{service}'".format(service=service))
+ logger.info("Services: Succesfully stopped service '{service}'".format(service=service))
except pywintypes.error as e:
errors = (winerror.ERROR_SERVICE_DOES_NOT_EXIST, winerror.ERROR_SERVICE_NOT_ACTIVE)
if not any(error == e.winerror for error in errors):
@@ -241,46 +235,48 @@ def wifisense(undo):
def onedrive(undo):
- 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]))
-
+ 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))
+
+ #Adding check if exe is there to help weed out issue submissions
+ #from users who have somehow previously removed the binary
+ if os.path.isfile(onedrive_setup):
+ cmd = "{bin} /{action}".format(bin=onedrive_setup, action=action)
+
+ output = subprocess_handler(cmd)
+ if output[0] == -2147219813:
+ 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]))
+ else:
+ logger.info("OneDrive: Binary doesn't exist. Unable to {action}. Do not send a report for this.".format(action=action))
def set_registry(keys):
mask = winreg.KEY_WOW64_64KEY | winreg.KEY_ALL_ACCESS if is_64bit() else winreg.KEY_ALL_ACCESS
@@ -342,10 +338,10 @@ def app_manager(apps, undo):
def subprocess_handler(cmd):
- p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, shell=True)
- output = p.communicate()
-
- return [p.returncode, output]
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, shell=True)
+ output = p.communicate()
+
+ return [p.returncode, output]
# Old reinstall code, does not work:
# if reinstall:
@@ -359,7 +355,6 @@ def subprocess_handler(cmd):
# except (WindowsError, IOError):
# print "App management: Could not re-install all apps"
-
def dvr(undo):
game_dvr_enabled = allow_game_dvr = 0
action = "disabled"