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:
author10se1ucgo <hammaadu1@gmail.com>2016-03-19 19:48:40 +0300
committer10se1ucgo <hammaadu1@gmail.com>2016-03-19 20:17:03 +0300
commit143990be2bd3b0c720f431dc297f5f3b7c2ece39 (patch)
tree1f9638776eabd4a17d3ef75e23158c4aae7d2610
parent6f533ffab4245ab327e962bceef322ecc0511ca7 (diff)
Rewrite! Closes #153, #147, #146, #124
Changes: Everything rewritten! Many things borrowed from my other program, pyjam. Split Windows Defender and WifiSense into two options GUI should now scale properly (hopefully) Everything is less terrible! Code is somewhat cleaner! Fixed DiagTrack service Split everything into 3 files: - dwt.py: Entry file, contains GUI and logging stuff - dwt_util.py: Contains functions for disabling the tracking - dwt_about.py: Contains the about and licenses dialog. Have fun!
-rw-r--r--.gitignore8
-rw-r--r--LICENSE13
-rw-r--r--README.md61
-rw-r--r--dwt.py426
-rw-r--r--dwt_about.py160
-rw-r--r--dwt_util.py231
-rw-r--r--run.py679
7 files changed, 849 insertions, 729 deletions
diff --git a/.gitignore b/.gitignore
index f075898..a8a69ca 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,8 +14,8 @@ dist/
*.sublime-workspace
# Log
-DisableWinTracking.log
+dwt.log
-# Ruined1 Stuff
-setup.py
-tester.py \ No newline at end of file
+# Other
+getapps.py
+getreleases.py
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index db02244..0000000
--- a/LICENSE
+++ /dev/null
@@ -1,13 +0,0 @@
-Copyright 2015 10se1ucgo
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License. \ No newline at end of file
diff --git a/README.md b/README.md
index 2728dcb..9a85192 100644
--- a/README.md
+++ b/README.md
@@ -1,18 +1,10 @@
-Currently being re-written, [see issue #153](https://github.com/10se1ucgo/DisableWinTracking/issues/153)
-
-~~No longer being developed, [see issue #147](https://github.com/10se1ucgo/DisableWinTracking/issues/147).~~
-
-~~This may no longer thoroughly disable all tracking, as some services have been added or have had their names changed. [See Issue #124.](https://github.com/10se1ucgo/DisableWinTracking/issues/124)~~
-
# DisableWinTracking
-![Main frame image](http://i.imgur.com/4iDf3Gb.png)
-
A tool that I created to use some of the known methods of disabling tracking in Windows 10.
-## DOWNLOAD!!
+## DOWNLOAD
-[DOWNLOAD EXE HERE!!](https://github.com/10se1ucgo/DisableWinTracking/releases/)
+[DOWNLOAD EXE HERE](https://github.com/10se1ucgo/DisableWinTracking/releases/)
## How to Use
@@ -20,12 +12,12 @@ You can either:
A. [Run the binary uploaded to the Release tab as an Administrator and select which options you'd like](https://github.com/10se1ucgo/DisableWinTracking/releases/)
-B. Install Python and the dependencies listed below and run the script from an elevated (`admin`) command prompt and select which options you'd like
+B. Install Python and the dependencies listed below and run the script from an elevated command prompt and select which options you'd like
## Dependencies
This is only to run the script from source, [download the exe here](https://github.com/10se1ucgo/DisableWinTracking/releases/)
-* [Python 2.7](https://www.python.org/download/releases/2.7/) (or 3 with 2to3.py or something)
-* [wxPython](http://wxpython.org/download.php)
+* Tested on Python 3
+* [wxPython](http://wxpython.org/download.php) -- GUI (Tested with wxPython=Phoenix)
* [PyWin32](http://sourceforge.net/projects/pywin32/files/pywin32/)
* Windows 10 (Duh)
@@ -51,22 +43,22 @@ Action:
#### HOSTS
-Append known tracking domains to the `HOSTS` file located in `C:\Windows\System32\drivers\etc`
-To add these domains to the `HOSTS` file using another tool, it is available in raw form at https://gist.github.com/10se1ucgo/fcb774d781a66ea9d31f
+Append known tracking domains to the `HOSTS` file located in `C:\Windows\System32\drivers\etc`
#### IP Blocking
Blocks known tracking IPs with the Windows Firewall. The rules are named TrackingIPX, replacing X with the IP numbers.
-#### Windows Defender / WifiSense
+#### Windows Defender
-Set disabled value to keys in registry for things such as:
-- Windows Defender
- - Automatic Sample Submission
- - Delivery Optimization Download Mode
-- WifiSense
- - Credential Share
- - Open-ness
+Disables the following:
+- Automatic Sample Submission
+- Delivery Optimization Download Mode
+
+#### WifiSense
+Disables the following:
+- Credential Share
+- Open-ness
#### OneDrive
@@ -83,16 +75,19 @@ Selecting the "Delete" choice will completely delete the tracking services.
## License
-Copyright 2015 10se1ucgo
+```
+Copyright (C) 10se1ucgo 2016
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
+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
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
- http://www.apache.org/licenses/LICENSE-2.0
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+```
diff --git a/dwt.py b/dwt.py
new file mode 100644
index 0000000..1963672
--- /dev/null
+++ b/dwt.py
@@ -0,0 +1,426 @@
+# Copyright (C) 10se1ucgo 2015-2016
+#
+# This file is part of DisableWinTracking.
+#
+# DisableWinTracking is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# DisableWinTracking is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with DisableWinTracking. If not, see <http://www.gnu.org/licenses/>.
+import os
+import logging
+import sys
+import io
+import platform
+import traceback
+from ctypes import windll
+
+import wx
+from wx.lib.itemspicker import ItemsPicker, IP_SORT_SELECTED, IP_SORT_CHOICES, IP_REMOVE_FROM_CHOICES
+
+import dwt_about
+import dwt_util
+
+
+class RedirectText(io.StringIO):
+ def __init__(self, console, old_stdout):
+ super(RedirectText, self).__init__()
+
+ 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)
+
+
+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)
+
+ 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)
+
+ 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)
+
+ 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)
+
+ def submit_issue(self, event):
+ os.startfile("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, 450))
+ self.SetMinSize(self.GetSize())
+ panel = MainPanel(self)
+
+ file_menu = wx.Menu()
+ settings = file_menu.Append(wx.ID_SETUP, "&Settings", "DWT settings")
+
+ help_menu = wx.Menu()
+ about = help_menu.Append(wx.ID_ABOUT, "&About", "About DWT")
+ licenses = help_menu.Append(wx.ID_ANY, "&Licenses", "Open-source licenses")
+
+ menu_bar = wx.MenuBar()
+ menu_bar.Append(file_menu, "&File")
+ menu_bar.Append(help_menu, "&Help")
+ self.SetMenuBar(menu_bar)
+
+ if bool(windll.advpack.IsNTAdmin(0, None)):
+ warn = wx.MessageDialog(parent=self,
+ message="Program requires elevation, please run it as an administrator.",
+ caption="ERROR!", style=wx.OK | wx.ICON_WARNING)
+ warn.ShowModal()
+ warn.Destroy()
+ sys.exit(1)
+
+ self.SetIcon(wx.Icon(sys.executable, wx.BITMAP_TYPE_ICO))
+ self.Bind(wx.EVT_MENU, lambda x: dwt_about.about_dialog(self), about)
+ self.Bind(wx.EVT_MENU, panel.settings, settings)
+ self.Bind(wx.EVT_MENU, lambda x: dwt_about.Licenses(self), licenses)
+
+
+class MainPanel(wx.Panel):
+ def __init__(self, parent):
+ super(MainPanel, self).__init__(parent)
+
+ self.parent = parent
+ self.picked_normal = []
+ self.picked_extra = []
+ self.picked_ips = []
+
+ self.service_check = wx.CheckBox(self, label="Services")
+ 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.")
+
+ # 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.")
+
+ # HOSTS file checkbox
+ self.host_check = wx.CheckBox(self, label="Block tracking domains")
+ self.host_check.SetToolTip("Adds known tracking domains to HOSTS file. Required to disable Telemetry")
+
+ # 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.")
+
+ # IP block checkbox
+ self.ip_check = wx.CheckBox(self, label="Block tracking IP addresses")
+ self.ip_check.SetToolTip("Blocks known tracking IP addresses with Windows Firewall.")
+
+ # 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")
+
+ # WifiSense checkbox
+ self.wifisense_check = wx.CheckBox(self, label="WifiSense")
+
+ # OneDrive uninstall checkbox
+ self.onedrive_check = wx.CheckBox(self, label="Uninstall OneDrive")
+ self.onedrive_check.SetToolTip("Uninstalls OneDrive from your computer and removes it from Explorer.")
+
+ self.service_rad = wx.RadioBox(self, label="Service Method", choices=("Disable", "Delete"))
+ self.service_rad.SetItemToolTip(item=0, text="Simply disables the services. This can be undone.")
+ self.service_rad.SetItemToolTip(item=1, text="Deletes the services completely. This can't be undone.")
+
+ self.mode_rad = wx.RadioBox(self, label="Mode", choices=("Privacy", "Revert"))
+ self.mode_rad.SetItemToolTip(item=0, text="Applies the selected settings.")
+ self.mode_rad.SetItemToolTip(item=1, text="Reverts the selected settings.")
+
+ go_button = wx.Button(self, label="Go!")
+
+ self.app_box = wx.StaticBoxSizer(wx.VERTICAL, self, "Built-in Apps")
+ stat_box = self.app_box.GetStaticBox
+ top_app_sizer = wx.BoxSizer(wx.HORIZONTAL)
+ button_app_sizer = wx.BoxSizer(wx.HORIZONTAL)
+ left_app_sizer = wx.BoxSizer(wx.VERTICAL)
+ middle_app_sizer = wx.BoxSizer(wx.VERTICAL)
+ right_app_sizer = wx.BoxSizer(wx.VERTICAL)
+
+ # wx.CheckBox(app_box.GetStaticBox(), label="Name", name="search_name")
+ wx.CheckBox(stat_box(), label="3D Builder", name="3dbuilder")
+ wx.CheckBox(stat_box(), label="Calender and Mail", name="windowscommunicationsapps")
+ wx.CheckBox(stat_box(), label="Camera", name="windowscamera")
+ wx.CheckBox(stat_box(), label="Get Office App", name="officehub")
+ wx.CheckBox(stat_box(), label="Get Skype App", name="skypeapp")
+ wx.CheckBox(stat_box(), label="Get Started App", name="getstarted")
+ wx.CheckBox(stat_box(), label="Groove Music", name="zunemusic")
+ wx.CheckBox(stat_box(), label="Maps", name="windowsmaps")
+ wx.CheckBox(stat_box(), label="Solitaire Collection", name="solitairecollection")
+ wx.CheckBox(stat_box(), label="Money", name="bingfinance")
+ wx.CheckBox(stat_box(), label="Movies && TV", name="zunevideo")
+ wx.CheckBox(stat_box(), label="News", name="bingnews")
+ wx.CheckBox(stat_box(), label="OneNote App", name="onenote")
+ wx.CheckBox(stat_box(), label="People", name="people")
+ wx.CheckBox(stat_box(), label="Phone Companion", name="windowsphone")
+ wx.CheckBox(stat_box(), label="Photos", name="photos")
+ wx.CheckBox(stat_box(), label="Sports", name="bingsports")
+ wx.CheckBox(stat_box(), label="Voice Recorder", name="soundrecorder")
+ wx.CheckBox(stat_box(), label="Weather", name="bingweather")
+ wx.CheckBox(stat_box(), label="Xbox", name="xboxapp")
+ remove_app_button = wx.Button(stat_box(), label="Remove selected apps")
+ select_all_check = wx.CheckBox(stat_box(), label="Select all")
+
+ sorted_list = sorted(stat_box().GetChildren(), key=lambda x: x.GetLabel())
+ for index, item in enumerate([x for x in sorted_list if isinstance(x, wx.CheckBox) and x != select_all_check]):
+ n = len(sorted_list) // 3
+ if index <= n:
+ left_app_sizer.Add(item, 1, wx.ALL, 1)
+ elif index <= n * 2:
+ middle_app_sizer.Add(item, 1, wx.ALL, 1)
+ else:
+ right_app_sizer.Add(item, 1, wx.ALL, 1)
+
+ top_app_sizer.Add(left_app_sizer, 1, wx.ALL, 1)
+ top_app_sizer.Add(middle_app_sizer, 1, wx.ALL, 1)
+ top_app_sizer.Add(right_app_sizer, 1, wx.ALL, 1)
+ button_app_sizer.Add(remove_app_button, 0, wx.ALL, 1)
+ button_app_sizer.Add(select_all_check, 1, wx.ALL, 5)
+ self.app_box.Add(top_app_sizer)
+ self.app_box.Add(button_app_sizer)
+
+ top_sizer = wx.BoxSizer(wx.VERTICAL)
+ top_row_sizer = wx.BoxSizer(wx.HORIZONTAL)
+ check_sizer = wx.BoxSizer(wx.VERTICAL)
+ 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_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)
+ rad_sizer.Add(go_button, 0, wx.ALL ^ wx.BOTTOM | wx.ALIGN_CENTER, 10)
+ rad_sizer.Add(self.mode_rad, 0, wx.ALL, 10)
+ check_sizer.Add(self.service_check, 0, wx.ALL, 1)
+ check_sizer.Add(self.diagtrack_check, 0, wx.ALL, 1)
+ check_sizer.Add(self.telemetry_check, 0, wx.ALL, 1)
+ check_sizer.Add(self.host_check, 0, wx.ALL, 1)
+ check_sizer.Add(self.extra_host_check, 0, wx.ALL, 1)
+ check_sizer.Add(self.ip_check, 0, wx.ALL, 1)
+ 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)
+
+ self.Bind(wx.EVT_CHECKBOX, handler=self.select_all_apps, source=select_all_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)
+ print(self.GetSize())
+
+ 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 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):
+ 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'
+ )
+
+ 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'
+ )
+
+ 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'
+ )
+
+ 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)
+ if self.picked_normal:
+ 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)
+ 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)
+
+ sizer.Add(normal_domain_picker, 0, wx.EXPAND)
+ sizer.Add(extra_domain_picker, 0, wx.EXPAND)
+ sizer.Add(ip_picker, 0, wx.EXPAND)
+ if event is not None:
+ dialog.SetSizerAndFit(sizer)
+ 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__))
+
+
+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)
+
+
+if __name__ == '__main__':
+ wx_app = wx.App()
+ frame = MainFrame()
+ console = ConsoleDialog(sys.stdout)
+ setup_logging()
+ sys.excepthook = exception_hook
+ frame.Show()
+ wx_app.MainLoop()
diff --git a/dwt_about.py b/dwt_about.py
new file mode 100644
index 0000000..1746ff0
--- /dev/null
+++ b/dwt_about.py
@@ -0,0 +1,160 @@
+# Copyright (C) 10se1ucgo 2015-2016
+#
+# This file is part of DisableWinTracking.
+#
+# DisableWinTracking is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# DisableWinTracking is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with DisableWinTracking. If not, see <http://www.gnu.org/licenses/>.
+
+# dwt.py will become cluttered enough :^)
+import wx
+import wx.adv
+import wx.lib.scrolledpanel as sp
+
+__version__ = "3.0"
+
+
+def about_dialog(parent):
+ license_text = """
+ Copyright (C) 10se1ucgo 2015-2016
+
+ 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 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/>."""
+
+ 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.SetDescription("A tool to disable tracking in Windows 10")
+ about_info.SetWebSite("https://github.com/10se1ucgo/DisableWinTracking", "GitHub repository")
+ about_info.AddDeveloper("10se1ucgo")
+ about_info.AddDeveloper("Ruined1")
+ about_info.SetLicense(license_text)
+ wx.adv.AboutBox(about_info, parent)
+
+
+class Licenses(wx.Dialog):
+ def __init__(self, parent):
+ super(Licenses, self).__init__(parent, title="Licenses", style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
+
+ self.scrolled_panel = sp.ScrolledPanel(self)
+
+ mono_font = wx.Font()
+ mono_font.SetFamily(wx.FONTFAMILY_TELETYPE)
+
+ info = wx.StaticText(self.scrolled_panel, label=("DisableWinTracking uses a number of open source software."
+ "The following are the licenses for these software."))
+
+ wxw = wx.StaticText(self.scrolled_panel, label=("DisableWinTracking uses wxWidgets and wxPython. Their license "
+ "is below\nMore info at https://www.wxwidgets.org/about/"))
+ wxw_license = """
+ wxWindows Library Licence, Version 3.1
+ ======================================
+ Copyright (c) 1998-2005 Julian Smart, Robert Roebling et al
+ Everyone is permitted to copy and distribute verbatim copies
+ of this licence document, but changing it is not allowed.
+ WXWINDOWS LIBRARY LICENCE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public Licence as published by
+ the Free Software Foundation; either version 2 of the Licence, or (at your
+ option) any later version.
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
+ Licence for more details.
+ You should have received a copy of the GNU Library General Public Licence
+ along with this software, usually in a file named COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+ Floor, Boston, MA 02110-1301 USA.
+ EXCEPTION NOTICE
+ 1. As a special exception, the copyright holders of this library give
+ permission for additional uses of the text contained in this release of the
+ library as licenced under the wxWindows Library Licence, applying either
+ version 3.1 of the Licence, or (at your option) any later version of the
+ Licence as published by the copyright holders of version 3.1 of the Licence
+ document.
+ 2. The exception is that you may use, copy, link, modify and distribute
+ under your own terms, binary object code versions of works based on the
+ Library.
+ 3. If you copy code from files distributed under the terms of the GNU
+ General Public Licence or the GNU Library General Public Licence into a
+ copy of this library, as this licence permits, the exception does not apply
+ to the code that you add in this way. To avoid misleading anyone as to the
+ status of such modified files, you must delete this exception notice from
+ such code and/or adjust the licensing conditions notice accordingly.
+ 4. If you write modifications of your own for this library, it is your
+ choice whether to permit this exception to apply to your modifications. If
+ you do not wish that, you must delete the exception notice from such code
+ and/or adjust the licensing conditions notice accordingly."""
+ wxw_text = wx.StaticText(self.scrolled_panel, label=wxw_license)
+ wxw_text.SetFont(mono_font)
+
+ pywin = wx.StaticText(self.scrolled_panel, label="DisableWinTracking uses PyWin32. Its license is below.")
+ pywin_license = """
+ Unless stated in the specfic source file, this work is
+ Copyright (c) 1996-2008, Greg Stein and Mark Hammond.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the distribution.
+
+ Neither names of Greg Stein, Mark Hammond nor the name of contributors may be used
+ to endorse or promote products derived from this software without
+ specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
+ IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."""
+ pywin_text = wx.StaticText(self.scrolled_panel, label=pywin_license)
+ pywin_text.SetFont(mono_font)
+
+ self.top_sizer = wx.BoxSizer(wx.VERTICAL)
+ self.scroll_sizer = wx.BoxSizer(wx.VERTICAL)
+
+ self.scroll_sizer.Add(info, 0, wx.ALL, 2)
+ self.scroll_sizer.Add(wxw, 0, wx.ALL, 2)
+ self.scroll_sizer.Add(wxw_text, 0, wx.EXPAND | wx.ALL, 3)
+ self.scroll_sizer.Add(pywin, 0, wx.ALL, 2)
+ self.scroll_sizer.Add(pywin_text, 0, wx.EXPAND | wx.ALL, 3)
+ self.top_sizer.Add(self.scrolled_panel, 1, wx.EXPAND)
+
+ self.SetSizerAndFit(self.top_sizer)
+ self.scrolled_panel.SetSizerAndFit(self.scroll_sizer)
+ self.scrolled_panel.SetupScrolling()
+ self.Show()
diff --git a/dwt_util.py b/dwt_util.py
new file mode 100644
index 0000000..fd404c0
--- /dev/null
+++ b/dwt_util.py
@@ -0,0 +1,231 @@
+# Copyright (C) 10se1ucgo 2015-2016
+#
+# This file is part of DisableWinTracking.
+#
+# DisableWinTracking is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# DisableWinTracking is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with DisableWinTracking. If not, see <http://www.gnu.org/licenses/>.
+import logging
+import os
+import platform
+import pywintypes
+import shutil
+import subprocess
+import tempfile
+import win32serviceutil
+import winerror
+import winreg
+import shlex
+
+logger = logging.getLogger('dwt.util')
+
+
+def is_64bit():
+ # Detect if OS is 64bit
+ return True if "64" in platform.uname().machine else False
+
+
+def ip_block(ip_list, undo):
+ for ip in ip_list:
+ cmd = 'netsh advfirewall firewall {act} rule name="TrackingIP-{ip}"'.format(act='delete' if undo else 'add',
+ ip=ip)
+ if not undo:
+ cmd += ' dir=out protocol=any remoteip="{ip}" profile=any action=block'.format(ip=ip)
+
+ try:
+ subprocess.check_output(shlex.split(cmd), stderr=subprocess.STDOUT)
+ logger.info("IP Blocker: The IP {ip} was successfully blocked.".format(ip=ip))
+ except subprocess.CalledProcessError as e:
+ logger.exception("IP Blocker: Failed to block IP {ip}".format(ip=ip))
+ logger.critical("IP Blocker: Error output:\n" + e.output.decode('ascii', 'replace'))
+
+
+def clear_diagtrack():
+ file = os.path.join(os.environ['SYSTEMDRIVE'], ('/ProgramData/Microsoft/Diagnosis/ETLLogs/AutoLogger/'
+ 'AutoLogger-Diagtrack-Listener.etl'))
+ own_cmd = "takeown /f {file} && icacls {file} /grant administrators:F".format(file=file)
+ lock_cmd = "echo y|cacls {file} /d SYSTEM".format(file=file)
+
+ try:
+ subprocess.check_output(shlex.split(own_cmd), stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ logger.exception("DiagTrack: Failed to clear DiagTrack log -- could not take ownership of file")
+ logger.critical("DiagTrack: Error output:\n" + e.output.decode('ascii', 'replace'))
+ return
+
+ try:
+ open(file, 'w').close()
+ subprocess.call(shlex.split(lock_cmd), stderr=subprocess.STDOUT)
+ logger.info("DiagTrack: Successfully cleared and locked DiagTrack log.")
+ except subprocess.CalledProcessError as e:
+ logger.exception("DiagTrack: Failed to clear DiagTrack log -- could not clear or lock")
+ logger.critical("DiagTrack: Error output:\n" + e.output.decode('ascii', 'replace'))
+
+
+def delete_service(service):
+ try:
+ win32serviceutil.RemoveService(service)
+ logging.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)
+ if not any(error == e[0] for error in errors):
+ logging.exception("Services: Failed to remove service '{service}'".format(service=service))
+
+
+def disable_service(service):
+ try:
+ win32serviceutil.StopService(service)
+ logging.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[0] for error in errors):
+ logging.exception("Services: Failed to stop service '{service}'".format(service=service))
+
+
+def telemetry(undo):
+ value = int(undo)
+ telemetry_keys = {'AllowTelemetry': [winreg.HKEY_LOCAL_MACHINE,
+ r'SOFTWARE\Policies\Microsoft\Windows\DataCollection',
+ "AllowTelemetry", winreg.REG_DWORD, value]}
+ set_registry(telemetry_keys)
+
+
+def services(undo):
+ value = 4 if undo else 3
+ service_keys = {'dmwappushsvc': [winreg.HKEY_LOCAL_MACHINE,
+ r'SYSTEM\\CurrentControlSet\\Services\\dmwappushsvc',
+ 'Start', winreg.REG_DWORD, value],
+
+ 'DiagTrack': [winreg.HKEY_LOCAL_MACHINE,
+ r'SYSTEM\\CurrentControlSet\\Services\\DiagTrack',
+ 'Start', winreg.REG_DWORD, value]}
+ set_registry(service_keys)
+
+
+def defender(undo):
+ value = int(undo)
+ defender_keys = {'Windows Defender Delivery Optimization Download':
+ [winreg.HKEY_LOCAL_MACHINE,
+ r'SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config',
+ 'DODownloadMode', winreg.REG_DWORD, value],
+
+ 'Windows Defender Spynet': [winreg.HKEY_LOCAL_MACHINE,
+ r'SOFTWARE\Microsoft\Windows Defender\Spynet',
+ 'SpyNetReporting', winreg.REG_DWORD, value],
+
+ 'Windows Defender Sample Submission': [winreg.HKEY_LOCAL_MACHINE,
+ r'SOFTWARE\Microsoft\Windows Defender\Spynet',
+ 'SubmitSamplesConsent', winreg.REG_DWORD, value]}
+ set_registry(defender_keys)
+
+
+def wifisense(undo):
+ value = int(undo)
+ wifisense_keys = {'WifiSense Credential Share': [winreg.HKEY_LOCAL_MACHINE,
+ r'SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\features',
+ 'WiFiSenseCredShared', winreg.REG_DWORD, value],
+
+ 'WifiSense Open-ness': [winreg.HKEY_LOCAL_MACHINE,
+ r'SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\features',
+ 'WiFiSenseOpen', winreg.REG_DWORD, value]}
+ set_registry(wifisense_keys)
+
+
+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))
+ logger.info("OneDrive: successfully {action}ed".format(action=action))
+ except (WindowsError, IOError):
+ logger.info("OneDrive: unable to {action}".format(action=action))
+
+
+def set_registry(keys):
+ mask = winreg.KEY_WOW64_64KEY | winreg.KEY_ALL_ACCESS if is_64bit() else winreg.KEY_ALL_ACCESS
+
+ for key_name, values in keys.items():
+ try:
+ key = winreg.CreateKeyEx(values[0], values[1], 0, mask)
+ winreg.SetValueEx(key, values[2], 0, values[3], values[4])
+ winreg.CloseKey(key)
+ logging.info("Registry: Successfully modified {key} key.".format(key=key_name))
+ except OSError:
+ logging.exception("Registry: Unable to mody {key} key.".format(key=key_name))
+
+
+def host_file(entries, undo):
+ null_ip = "0.0.0.0 "
+ nulled_entires = [null_ip + x for x in entries]
+ hosts_path = os.path.join(os.environ['SYSTEMROOT'], 'System32/drivers/etc/hosts')
+
+ if undo:
+ try:
+ with open(hosts_path, 'r') as hosts, tempfile.NamedTemporaryFile(delete=False) as temp:
+ for line in hosts:
+ if not any(domain in line for domain in entries):
+ temp.write(line)
+ temp.close()
+ shutil.move(temp.name, hosts_path)
+ return True
+ except OSError:
+ logging.exception("Hosts: Failed to undo hosts file")
+ else:
+ try:
+ with open(hosts_path, 'a') as f:
+ f.write('\n' + '\n'.join(nulled_entires))
+ return True
+ except (WindowsError, IOError):
+ logging.exception("Hosts: Failed to modify hosts file")
+
+ return False
+
+
+def app_manager(apps, undo):
+ running = []
+ for app in apps:
+ cmd = 'powershell "Get-AppxPackage *{app}*|Remove-AppxPackage"'.format(app=app)
+ try:
+ process = subprocess.Popen(shlex.split(cmd), stderr=subprocess.STDOUT)
+ running.append(process)
+ except OSError:
+ logging.exception("App remover: Failed to remove app '{app}'".format(app=app))
+
+ for process in running:
+ process.wait()
+
+
+# Old reinstall code:
+# if reinstall:
+# # We encode in Base64 because the command is complex and I'm too lazy to escape everything.
+# # It's uncoded format command: "Get-AppxPackage -AllUsers| Foreach {Add-AppxPackage -DisableDevelopmentMode
+# # -Register "$($_.InstallLocation)\AppXManifest.xml"}"
+# encodedcommand = 'Get-AppxPackage -AllUsers | Foreach {Add-AppxPackage -DisableDevelopmentMode # -Register \
+# "$($_.InstallLocation)\AppXManifest.xml"}'
+# try:
+# subprocess.call("powershell -EncodedCommand {0}".format(encodedcommand), shell=True)
+# except (WindowsError, IOError):
+# print "App management: Could not re-install all apps"
diff --git a/run.py b/run.py
deleted file mode 100644
index 236340d..0000000
--- a/run.py
+++ /dev/null
@@ -1,679 +0,0 @@
-#!python2
-
-import ctypes
-import logging
-import os
-import shutil
-import subprocess
-import sys
-import tempfile
-import _winreg
-import win32serviceutil
-import wx
-import wx.lib.wordwrap
-import pywintypes
-from wx.lib.itemspicker import ItemsPicker, IP_SORT_CHOICES, IP_SORT_SELECTED, IP_REMOVE_FROM_CHOICES
-
-vernumber = "v2.5.3" # Version number
-
-# Configure the Logging module
-try:
- logging.basicConfig(filename='DisableWinTracking.log', level=logging.DEBUG,
- format='\n%(asctime)s %(levelname)s: %(message)s', datefmt='%H:%M:%S', filemode='w')
-except (WindowsError, IOError):
- print "Could not create log file."
-
-
-class RedirectText(object):
- def __init__(self, console):
- self.out = console
-
- def write(self, string):
- self.out.WriteText(string)
-
-
-class ConsoleFrame(wx.Dialog):
- def __init__(self):
- wx.Dialog.__init__(self, parent=wx.GetApp().TopWindow, title="Console Output", size=[500, 200],
- style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
-
- panel = wx.Panel(self) # Frame panel
-
- # Redirect console output to TextCtrl box
- self.consolebox = wx.TextCtrl(panel, wx.ID_ANY, style=wx.TE_MULTILINE | wx.TE_READONLY)
-
- self.redirect = RedirectText(self.consolebox)
- sys.stdout = self.redirect
-
- self.issuebutton = wx.Button(panel, wx.ID_ANY, label="Report an issue", pos=(9, 140))
- self.issuebutton.Bind(wx.EVT_BUTTON, self.submitissue)
-
- # Final OK button
- self.okbutton = wx.Button(panel, wx.ID_OK, label="OK", pos=(398, 140))
- self.okbutton.Bind(wx.EVT_BUTTON, self.onok)
-
- consolesizer = wx.BoxSizer(wx.VERTICAL)
- buttonsizer = wx.BoxSizer(wx.HORIZONTAL)
-
- consolesizer.Add(buttonsizer)
- consolesizer.Add(self.consolebox, 1, wx.ALL | wx.EXPAND, 1)
-
- buttonsizer.Add(self.okbutton)
- buttonsizer.Add(self.issuebutton)
-
- panel.SetSizerAndFit(consolesizer)
-
- def onok(self, event):
- sys.exit()
-
- def submitissue(self, event):
- os.startfile("http://bit.ly/DWTIssue")
-
-
-class MainFrame(wx.Frame):
- def __init__(self):
- wx.Frame.__init__(self, parent=None, title='Disable Windows 10 Tracking', size=[375, 345],
- style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER ^ wx.MAXIMIZE_BOX)
-
- panel = wx.Panel(self) # Frame panel
-
- # Test for elevation
- if ctypes.windll.shell32.IsUserAnAdmin() != 0:
- warn = wx.MessageDialog(parent=self,
- message="Program requires elevation, please run it as an administrator",
- caption="ERROR", style=wx.OK | wx.ICON_WARNING)
- warn.ShowModal()
- sys.exit()
-
- # Get icon
- shell32file = os.path.join(os.environ['SYSTEMROOT'], 'System32\\shell32.dll')
- self.SetIcon(wx.Icon(shell32file + ";315", wx.BITMAP_TYPE_ICO))
-
- # Info bar w/ about menu
- menu = wx.Menu()
- aboutitem = menu.Append(wx.ID_ABOUT, "About", "About the application")
- optionsitem = menu.Append(wx.ID_ANY, "Options", "Settings for the application")
-
- menubar = wx.MenuBar()
- menubar.Append(menu, "&Menu")
-
- self.SetMenuBar(menubar)
- self.Bind(wx.EVT_MENU, self.aboutbox, aboutitem)
- self.Bind(wx.EVT_MENU, self.settingsbox, optionsitem)
-
- # Service checkbox
- self.servicebox = wx.CheckBox(panel, label="&Services", pos=(10, 10))
- self.servicebox.SetToolTip(wx.ToolTip("Disables or Deletes tracking services. Choose option in Service Method"))
- self.Bind(wx.EVT_CHECKBOX, self.serviceradioboxcheck, self.servicebox)
-
- # DiagTrack checkbox
- self.diagtrackbox = wx.CheckBox(panel, label="Clear &DiagTrack log", pos=(10, 25))
- self.diagtrackbox.SetToolTip(wx.ToolTip("Clears Diagnostic Tracking log and prevents modification to it. "
- "This cannot be undone without doing it manually."))
-
- # Telemetry checkbox
- self.telemetrybox = wx.CheckBox(panel, label="&Telemetry", pos=(10, 40))
- self.telemetrybox.SetToolTip(
- wx.ToolTip("Sets \'AllowTelemetry\' to 0. On non-Enterprise OS editions, requires HOSTS file modification"))
- self.Bind(wx.EVT_CHECKBOX, self.telemetryhostcheck, self.telemetrybox)
-
- # HOSTS file checkbox
- self.hostbox = wx.CheckBox(panel, label="&Block tracking domains", pos=(10, 55))
- self.hostbox.SetToolTip(wx.ToolTip("Add known tracking domains to HOSTS file. Required to disable Telemetry"))
-
- # Extra HOSTS checkbox
- self.extrahostbox = wx.CheckBox(panel, label="Block &even more tracking domains", pos=(10, 70))
- self.extrahostbox.SetToolTip(wx.ToolTip("For the paranoid. Adds extra domains to the HOSTS file. \
- May disable Skype, Dr. Watson, Hotmail and/or Error Reporting"))
- self.Bind(wx.EVT_CHECKBOX, self.extrahosthostcheck, self.extrahostbox)
-
- # IP block checkbox
- self.ipbox = wx.CheckBox(panel, label="Block tracking &IP addresses", pos=(10, 85))
- self.ipbox.SetToolTip(wx.ToolTip("Blocks known tracking IP addresses with Windows Firewall."))
-
- # Windows Privacy Regs (Policy Manager)
- self.wdwsbox = wx.CheckBox(panel, label="Windows Defender/WifiSense data collection", pos=(10, 100))
- self.wdwsbox.SetToolTip(wx.ToolTip("Modifies registry to prevent Defender/WifiSense data collection"))
-
- # OneDrive uninstall checkbox
- self.onedrivedbox = wx.CheckBox(panel, label="Uninstall &OneDrive", pos=(10, 115))
- self.onedrivedbox.SetToolTip(wx.ToolTip("Uninstalls OneDrive from your computer and removes it from Explorer."))
-
- # App static box
- self.appbox = wx.StaticBox(panel, label="Built-in Apps", pos=(10, 130), size=(351, 160))
-
- self.builderbox = wx.CheckBox(self.appbox, label="&3D Builder", pos=(10, 15))
- self.calmailbox = wx.CheckBox(self.appbox, label="C&alender && Mail", pos=(10, 30))
- self.camerabox = wx.CheckBox(self.appbox, label="&Camera", pos=(10, 45))
- self.officebox = wx.CheckBox(self.appbox, label="Get &Office App", pos=(10, 60))
- self.skypebox = wx.CheckBox(self.appbox, label="Get S&kype App", pos=(10, 75))
- self.startbox = wx.CheckBox(self.appbox, label="Get S&tarted App", pos=(10, 90))
- self.groovebox = wx.CheckBox(self.appbox, label="&Groove Music", pos=(10, 105))
- self.mapbox = wx.CheckBox(self.appbox, label="&Maps", pos=(120, 15))
- self.mscbox = wx.CheckBox(self.appbox, label="Microso&ft Solitaire Collection", pos=(120, 105))
- self.moneybox = wx.CheckBox(self.appbox, label="Mone&y", pos=(120, 30))
- self.movietvbox = wx.CheckBox(self.appbox, label="Movies && T&V", pos=(120, 45))
- self.newsbox = wx.CheckBox(self.appbox, label="&News", pos=(120, 60))
- self.onenotebox = wx.CheckBox(self.appbox, label="OneNote Ap&p", pos=(120, 75))
- self.peoplebox = wx.CheckBox(self.appbox, label="P&eople", pos=(120, 90))
- self.phonebox = wx.CheckBox(self.appbox, label="Phone Compan&ion", pos=(225, 15))
- self.photosbox = wx.CheckBox(self.appbox, label="P&hotos", pos=(225, 30))
- self.sportsbox = wx.CheckBox(self.appbox, label="&Sports", pos=(225, 45))
- self.voicebox = wx.CheckBox(self.appbox, label="Voice &Recorder", pos=(225, 60))
- self.weatherbox = wx.CheckBox(self.appbox, label="&Weather", pos=(225, 75))
- self.xbonebox = wx.CheckBox(self.appbox, label="&Xbox", pos=(225, 90))
-
- self.selectapps = wx.CheckBox(self.appbox, label="Select all apps", pos=(246, 0), style=wx.ALIGN_RIGHT)
- self.Bind(wx.EVT_CHECKBOX, self.selectallapps, self.selectapps)
-
- self.removeappbut = wx.Button(self.appbox, wx.ID_ANY, label="Uninstall selected apps", pos=(10, 125))
- self.removeappbut.SetToolTip(wx.ToolTip("Uninstalls all of the selected apps. Can take a lot of time."))
- self.Bind(wx.EVT_BUTTON, self.uninstapps, self.removeappbut)
-
- self.reinstappbut = wx.Button(self.appbox, wx.ID_ANY, label="Reinstall original apps", pos=(205, 125))
- self.reinstappbut.SetToolTip(wx.ToolTip("Reinstalls ALL of the default apps. Takes a lot of time."))
- self.Bind(wx.EVT_BUTTON, self.reinstapps, self.reinstappbut)
-
- # Service radio box
- self.serviceradbox = wx.RadioBox(panel, label="Service Method", pos=(135, 5), choices=("Disable", "Delete"))
- self.serviceradbox.Disable()
- self.serviceradbox.SetItemToolTip(0, "Simply disables the services. This can be undone.")
- self.serviceradbox.SetItemToolTip(1, "Deletes the services completely. This can't be undone.")
-
- # Go button
- self.gobutton = wx.Button(panel, wx.ID_ANY, label="Go!", pos=(275, 25))
- self.Bind(wx.EVT_BUTTON, self.go, self.gobutton)
-
- self.goradbox = wx.RadioBox(panel, label="Mode", pos=(284, 50),
- choices=("Privacy", "Revert"), style=wx.RA_SPECIFY_ROWS)
-
- self.goradbox.SetItemToolTip(0, "Using the selected settings, applies privacy.")
- self.goradbox.SetItemToolTip(1, "Reverts everything selected to it's original form")
-
- # Center and show the window
- self.Centre()
- self.Show()
-
- def serviceradioboxcheck(self, event):
- # Enables serviceradbox if the service box is ticked
- self.serviceradbox.Enable(self.servicebox.IsChecked())
-
- def telemetryhostcheck(self, event):
- # Automatically checks the domain block when the telemetry box is checked.
- self.hostbox.SetValue(self.telemetrybox.IsChecked())
-
- def extrahosthostcheck(self, event):
- # Warn users about the potential side effects of the extra hosts mod.
- hostwarn = wx.MessageDialog(parent=self,
- message="This option could potentially prevent you from using one or more of the "
- "following services:\n\nSkype, Hotmail, Dr. Watson, Error Reporting.\n\n Continue?",
- caption="Attention!", style=wx.YES_NO | wx.ICON_EXCLAMATION)
-
- if self.extrahostbox.GetValue() == 1:
- if hostwarn.ShowModal() == wx.ID_NO:
- self.extrahostbox.SetValue(0)
-
- hostwarn.Destroy()
-
- def selectallapps(self, event):
- # Iters through all children of the app static box and checks them except for the last 3.
- # (buttons and the select all checkbox)
- for checkbox in list(self.appbox.GetChildren())[:-3]:
- checkbox.SetValue(self.selectapps.IsChecked())
-
- def aboutbox(self, event):
- # About dialog
-
- licensetext = "Copyright 2015 10se1ucgo\r\n\r\nLicensed under the Apache License, Version 2.0 " \
- "(the \"License\");\r\nyou may not use this file except in compliance with the License." \
- "\r\nYou may obtain a copy of the License at\r\n\r\n " \
- " http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nUnless required by applicable law or " \
- "agreed to in writing, software\r\ndistributed under the License is distributed on an " \
- "\"AS IS\" BASIS,\r\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied." \
- "\r\nSee the License for the specific language governing permissions and\r\nlimitations under " \
- "the License."
-
- aboutpg = wx.AboutDialogInfo()
- aboutpg.Name = "Disable Windows 10 Tracking"
- aboutpg.Version = vernumber
- aboutpg.Copyright = "(c) 2015 10se1ucgo"
- aboutpg.Description = "A tool to disable nasty tracking in Windows 10"
- aboutpg.WebSite = ("https://github.com/10se1ucgo/DisableWinTracking", "GitHub Project Page")
- aboutpg.License = wx.lib.wordwrap.wordwrap(licensetext, 500, wx.ClientDC(self))
- aboutpg.Developers = ["10se1ucgo and Ruined1 on GitHub"]
- wx.AboutBox(aboutpg)
-
- def settingsbox(self, event):
- # Settings dialog
- settingsdialog = wx.Dialog(wx.GetApp().TopWindow, wx.ID_ANY, "Settings")
-
- boxsizer = wx.BoxSizer(wx.VERTICAL)
-
- normallist = ('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',
- 'schemas.microsoft.akadns.net ', 'secure.adnxs.com', 'secure.flashtalking.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', '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',
- 'vortex-bn2.metron.live.com.nsatc.net', 'vortex-cy2.metron.live.com.nsatc.net',
- 'vortex-sandbox.data.microsoft.com', 'vortex-win.data.microsoft.com',
- 'vortex.data.microsoft.com', 'watson.live.com', 'www.msftncsi.com', 'ssw.live.com',
- 'reports.wes.df.telemetry.microsoft.com', 'services.wes.df.telemetry.microsoft.com',
- 'web.vortex.data.microsoft.com', 'vortex-win.data.metron.live.com.nsatc.net',
- 'v10.vortex-win.data.microsoft.com', 'vortex-cy2.metron.live.com.nsatc.net',
- 'vortex.data.glbdns2.microsoft.com', 'vortex-win.data.microsoft.com',
- 'vortex.data.microsoft.com')
-
- extralist = ('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')
-
- self.normalpicker = ItemsPicker(settingsdialog, id=wx.ID_ANY, choices=[], selectedLabel="Domains to be blocked",
- ipStyle=IP_SORT_SELECTED | IP_SORT_CHOICES | IP_REMOVE_FROM_CHOICES)
- self.normalpicker.SetSelections(normallist)
-
- self.extrapicker = ItemsPicker(settingsdialog, id=wx.ID_ANY, choices=[],
- selectedLabel="Extra domains to be blocked",
- ipStyle=IP_SORT_SELECTED | IP_SORT_CHOICES | IP_REMOVE_FROM_CHOICES)
- self.extrapicker.SetSelections(extralist)
-
- iplist = ('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')
-
- self.ippicker = ItemsPicker(settingsdialog, id=wx.ID_ANY, choices=[],
- selectedLabel="IP addresses to be blocked",
- ipStyle=IP_SORT_SELECTED | IP_SORT_CHOICES | IP_REMOVE_FROM_CHOICES)
-
- self.ippicker.SetToolTip(wx.ToolTip("Hello"))
-
- self.ippicker.SetSelections(iplist)
-
- boxsizer.Add(self.normalpicker, 0, wx.ALL | wx.TOP, 10)
- boxsizer.Add(self.extrapicker, 0, wx.ALL | wx.CENTER | wx.EXPAND, 10)
- boxsizer.Add(self.ippicker, 0, wx.ALL | wx.BOTTOM | wx.EXPAND, 10)
-
- settingsdialog.SetSizerAndFit(boxsizer)
-
- if event is not None:
- settingsdialog.Center()
- settingsdialog.ShowModal()
-
- def go(self, event):
- self.settingsbox(None) # Call the settings box to get the settings values
- if self.goradbox.GetSelection() == 1: # if mode is revert
- mode = "Revert"
- startval = 3
- telemetryval = 1
- undo = True
- val = 1
- filesyncval = 0
- installerfunc = "install"
- else:
- mode = "Privacy"
- startval = 4
- telemetryval = 0
- undo = False
- val = 0
- filesyncval = 1
- installerfunc = "uninstall"
- self.cluttercontrol()
- if self.diagtrackbox.IsChecked():
- logging.info("DiagTrack box ticked")
- cleardiagtracklog()
- if self.servicebox.IsChecked():
- if self.serviceradbox.Selection == 0:
- logging.info("Service disable option ticked")
- disableservice(service='dmwappushsvc')
- disableservice(service='Diagnostics Tracking Service')
- elif self.serviceradbox.Selection == 1:
- logging.info("Service delete option ticked")
- deleteservice(service='dmwappushsvc')
- deleteservice(service='Diagnostics Tracking Service')
-
- logging.info("DisableWinTracking Version: {0}".format(vernumber))
- logging.info("Mode: {0}".format(mode))
- if self.servicebox.IsChecked():
- modifyserviceregs(startval=startval)
- if self.telemetrybox.IsChecked():
- logging.info("Telemetry box ticked")
- modifytelemetryregs(telemetryval=telemetryval)
- if self.hostbox.IsChecked():
- self.settingsbox(None)
- logging.info("Host box ticked")
- modifyhostfile(undo=undo, domainlist=self.normalpicker.GetSelections(), name="Domain block")
- if self.extrahostbox.IsChecked():
- logging.info("Extra host box ticked")
- modifyhostfile(undo=undo, domainlist=self.extrapicker.GetSelections(), name="Extra domain block")
- if self.ipbox.IsChecked():
- logging.info("IP block box ticked")
- blockips(iplist=self.ippicker.GetSelections(), undo=undo)
- if self.wdwsbox.IsChecked():
- logging.info("Policy Manager box ticked")
- stopdefendwifi(val=val)
- if self.onedrivedbox.IsChecked():
- logging.info("OneDrive box ticked")
- modifyonedrive(installerfunc=installerfunc, filesyncval=filesyncval)
- self.console.Show() # Show console output window after the code is run
- self.console.Center() # Center console window
- print "Done. It's recommended that you reboot as soon as possible for the full effect."
- print "If you feel something didn't work properly, please press the 'Report an issue' \
- button and follow the directions"
-
- def uninstapps(self, event):
- uninstalllist = []
- logging.info("DisableWinTracking Version: {0}".format(vernumber))
-
- if self.builderbox.IsChecked():
- uninstalllist.append('3dbuilder')
- if self.calmailbox.IsChecked():
- uninstalllist.append('windowscommunicationsapps')
- if self.camerabox.IsChecked():
- uninstalllist.append('windowscamera')
- if self.officebox.IsChecked():
- uninstalllist.append('officehub')
- if self.skypebox.IsChecked():
- uninstalllist.append('skypeapp')
- if self.startbox.IsChecked():
- uninstalllist.append('getstarted')
- if self.groovebox.IsChecked():
- uninstalllist.append('zunemusic')
- if self.mapbox.IsChecked():
- uninstalllist.append('windowsmaps')
- if self.mscbox.IsChecked():
- uninstalllist.append('solitairecollection')
- if self.moneybox.IsChecked():
- uninstalllist.append('bingfinance')
- if self.movietvbox.IsChecked():
- uninstalllist.append('zunevideo')
- if self.newsbox.IsChecked():
- uninstalllist.append('bingnews')
- if self.onenotebox.IsChecked():
- uninstalllist.append('onenote')
- if self.peoplebox.IsChecked():
- uninstalllist.append('people')
- if self.phonebox.IsChecked():
- uninstalllist.append('windowsphone')
- if self.photosbox.IsChecked():
- uninstalllist.append('photos')
- if self.sportsbox.IsChecked():
- uninstalllist.append('bingsports')
- if self.voicebox.IsChecked():
- uninstalllist.append('soundrecorder')
- if self.weatherbox.IsChecked():
- uninstalllist.append('bingweather')
- if self.xbonebox.IsChecked():
- uninstalllist.append('xboxapp')
-
- if uninstalllist: # Check if at least one app is selected
- apppackage(reinstall=False, applist=uninstalllist)
- self.console.Show() # Show console output window after the code is run
- self.console.Center() # Center console window
-
- def reinstapps(self, event):
- apppackage(reinstall=True, applist=['thisshouldntevenbepassed'])
-
- def cluttercontrol(self):
- logging.info("Performing clutter control")
- if self.hostbox.IsChecked():
- modifyhostfile(undo=True, domainlist=self.normalpicker.GetSelections(), name="Clutter control")
- if self.extrahostbox.IsChecked():
- modifyhostfile(undo=True, domainlist=self.extrapicker.GetSelections(), name="Extra domain clutter control")
- if self.ipbox.IsChecked():
- blockips(undo=True)
- self.console.consolebox.Clear()
-
-
-def osis64bit():
- # Detect if OS is 64bit
- if os.environ['PROCESSOR_ARCHITEW6432'].endswith('64'):
- return True
- else:
- return False
-
-
-def blockips(iplist, undo):
- if not undo:
- try:
- for ip in iplist:
- subprocess.call("netsh advfirewall firewall add rule name=""TrackingIP{0}"" dir=out"
- " protocol=any remoteip=""{0}"" profile=any action=block".format(ip), shell=True)
- print "IP Blocking: {0} successfully blocked.".format(ip)
- except (WindowsError, IOError):
- logging.exception("IP Blocking: One or more were unable to be blocked.")
- print "IP Blocking: One or more were unable to be blocked."
-
- elif undo:
- try:
- for ip in iplist:
- subprocess.call("netsh advfirewall firewall delete rule name=""TrackingIP{0}""".format(ip), shell=True)
- print "IP Blocking: {0} successfully unblocked.".format(ip)
- except (WindowsError, IOError):
- logging.exception("IP Blocking: One or more were unable to be unblocked.")
- print "IP Blocking: One or more were unable to be unblocked."
-
-
-def cleardiagtracklog():
- logfile = os.path.join(os.environ['SYSTEMDRIVE'], '\\ProgramData\\Microsoft\\Diagnosis\\ETLLogs\\AutoLogger\\'
- 'AutoLogger-Diagtrack-Listener.etl')
-
- disableservice('Diagnostics Tracking Service')
-
- try:
- subprocess.call("takeown /f {0} && icacls {0} /grant administrators:F".format(logfile), shell=True)
- open(logfile, 'w').close() # Clear the AutoLogger file
- subprocess.call("echo y|cacls {0} /d SYSTEM".format(logfile), shell=True) # Prevent modification to file
- print "DiagTrack Log: successfully cleared and locked."
- except (WindowsError, IOError):
- logging.exception("DiagTrack Log: Unable to clear/lock.")
- print "DiagTrack Log: Unable to clear/lock"
-
-
-def deleteservice(service):
- try:
- win32serviceutil.RemoveService(service) # Delete service
- print "Services: {0} successfully deleted.".format(service)
- except pywintypes.error as e:
- errors = (1060, 1062)
- if not any(error == e[0] for error in errors):
- logging.exception("Services: {0} unable to be deleted.".format(service))
- print "Services: {0} unable to be deleted.".format(service)
-
-
-def disableservice(service):
- try:
- win32serviceutil.StopService(service) # Disable service
- print "Services: {0} successfully stopped.".format(service)
- except pywintypes.error as e:
- errors = (1060, 1062) # 1060: Does not exist. 1062: Not started.
- if not any(error == e[0] for error in errors):
- logging.exception("Services: {0} unable to be stopped.".format(service))
- print "Services: {0} unable to be stopped.".format(service)
-
-
-def modifytelemetryregs(telemetryval):
- # Telemetry regkey paths
- telemetrydict = {'AllowTelemetry': [_winreg.HKEY_LOCAL_MACHINE,
- r'SOFTWARE\Policies\Microsoft\Windows\DataCollection',
- "AllowTelemetry", _winreg.REG_DWORD, telemetryval]}
-
- modifyregistry(regdict=telemetrydict, name="Telemetry")
-
-
-def modifyserviceregs(startval):
- # Service regkey paths
- servicesdict = {'dmwappushsvc': [_winreg.HKEY_LOCAL_MACHINE,
- r'SYSTEM\\CurrentControlSet\\Services\\dmwappushsvc',
- 'Start', _winreg.REG_DWORD, startval],
-
- 'DiagTrack': [_winreg.HKEY_LOCAL_MACHINE,
- r'SYSTEM\\CurrentControlSet\\Services\\DiagTrack',
- 'Start', _winreg.REG_DWORD, startval]}
-
- modifyregistry(regdict=servicesdict, name="Services")
-
-
-def stopdefendwifi(defendersenseval):
- # Windows Defender and WifiSense keys
- wdwfsdict = {'Windows Defender Delivery Optimization Download':
- [_winreg.HKEY_LOCAL_MACHINE,
- r'SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config',
- 'DODownloadMode', _winreg.REG_DWORD, defendersenseval],
-
- 'WifiSense Credential Share': [_winreg.HKEY_LOCAL_MACHINE,
- r'SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\features',
- 'WiFiSenseCredShared', _winreg.REG_DWORD, defendersenseval],
-
- 'WifiSense Open-ness': [_winreg.HKEY_LOCAL_MACHINE,
- r'SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\features',
- 'WiFiSenseOpen', _winreg.REG_DWORD, defendersenseval],
-
- 'Windows Defender Spynet': [_winreg.HKEY_LOCAL_MACHINE,
- r'SOFTWARE\Microsoft\Windows Defender\Spynet',
- 'SpyNetReporting', _winreg.REG_DWORD, defendersenseval],
-
- 'Windows Defender Sample Submission': [_winreg.HKEY_LOCAL_MACHINE,
- r'SOFTWARE\Microsoft\Windows Defender\Spynet',
- 'SubmitSamplesConsent', _winreg.REG_DWORD, defendersenseval]}
-
- modifyregistry(wdwfsdict, name="WifiSense/Defender")
-
-
-def modifyonedrive(installerfunc, filesyncval):
- # The two key values are opposites, so we have to flip them.
- if filesyncval == 0:
- pinval = 1
- else:
- pinval = 0
-
- # OneDrive shellext regkey paths
- ngscdict = {'FileSync': [_winreg.HKEY_LOCAL_MACHINE,
- r'SOFTWARE\Policies\Microsoft\Windows\OneDrive',
- 'DisableFileSyncNGSC', _winreg.REG_DWORD, filesyncval],
-
- 'ListPin': [_winreg.HKEY_CLASSES_ROOT,
- r'CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}',
- 'System.IsPinnedToNameSpaceTree', _winreg.REG_DWORD, pinval]}
-
- modifyregistry(regdict=ngscdict, name="OneDrive")
-
- if osis64bit():
- onedrivesetup = os.path.join(os.environ['SYSTEMROOT'], "SysWOW64/OneDriveSetup.exe")
- else:
- onedrivesetup = os.path.join(os.environ['SYSTEMROOT'], "System32/OneDriveSetup.exe")
-
- try:
- subprocess.call("{0} /{1}".format(onedrivesetup, installerfunc), shell=True)
- print "OneDrive: successfully {0}ed.".format(installerfunc)
- except (WindowsError, IOError):
- logging.exception("OneDrive: Unable to {0}.".format(installerfunc))
- print "OneDrive: Unable to {0}.".format(installerfunc)
-
-
-def modifyregistry(regdict, name):
- # Modifies registry keys from a dictionary
- # FORMAT: regdict = {"Name": [_winreg.HKEY, r'regkeypath', 'regkey', _winreg.REG_(DWORD/SZ/etc.), keyvalue]}
- # keyvalue = String, only if REG_SZ.
-
- if osis64bit():
- accessmask = _winreg.KEY_WOW64_64KEY + _winreg.KEY_ALL_ACCESS
- else:
- accessmask = _winreg.KEY_ALL_ACCESS
-
- for title, registry in regdict.viewitems():
- try:
- # Using CreateKeyEx, which will open or create a key as necessary
- modreg = _winreg.CreateKeyEx(registry[0], registry[1], 0, accessmask)
- _winreg.SetValueEx(modreg, registry[2], 0, registry[3], registry[4])
- _winreg.CloseKey(modreg)
- print "{1}: {0} key successfully modified.".format(title, name)
- except (WindowsError, IOError):
- logging.exception("Registry: Unable to modify {0} key.".format(title, name))
- print "{1}: Unable to modify {0} key.".format(title, name)
-
-
-def modifyhostfile(undo, domainlist, name):
- # Modifies the hosts file with a list
- # FORMAT: domainlist = ['www.example.com', 'www.etc.com']
- # undo: Specifies whether or not to remove the lines from the host file or append them
- # name: Name displayed in error/completion message.
-
- nullip = "0.0.0.0 " # IP to route domains to
-
- # Domains with 0.0.0.0 added to the beginning of each.
- nulledlist = [nullip + x for x in domainlist]
-
- hostspath = os.path.join(os.environ['SYSTEMROOT'], 'System32\\drivers\\etc\\hosts')
- subprocess.call("takeown /f {0} && icacls {0} /grant administrators:F".format(hostspath), shell=True)
-
- if not undo:
- try:
- with open(hostspath, 'ab') as f:
- f.write('\r\n' + '\r\n'.join(nulledlist))
- print "{0}: Domains successfully appended.".format(name)
- except (WindowsError, IOError):
- logging.exception("{0}: Could not append domains".format(name))
- print "{0}: Could not append domains".format(name)
-
- elif undo:
- try:
- with open(hostspath, 'r') as hostfile, tempfile.NamedTemporaryFile(delete=False) as temphosts:
- for line in hostfile:
- if not any(domain in line for domain in domainlist):
- temphosts.write(line)
- temphosts.close()
- shutil.move(temphosts.name, hostspath)
- print "{0}: Domains successfully removed.".format(name)
- except (WindowsError, IOError):
- logging.exception("{0}: Could not remove domains.".format(name))
- print "{0}: Could not remove domains.".format(name)
-
-
-def apppackage(reinstall, applist):
- if not reinstall:
- for app in applist:
- try:
- p = subprocess.Popen("powershell \"Get-AppxPackage *{0}*|Remove-AppxPackage\"".format(app), shell=True)
- print "App management: Handled {0} successfully"
- except (WindowsError, IOError):
- print "App management: Could not uninstall {0}".format(app)
-
- p.communicate() # Workaround for console window opening prematurely
-
- if reinstall:
- # We encode in Base64 because the command is complex and I'm too lazy to escape everything.
- # It's uncoded format command: "Get-AppxPackage -AllUsers| Foreach {Add-AppxPackage -DisableDevelopmentMode
- # -Register "$($_.InstallLocation)\AppXManifest.xml"}"
- encodedcommand = 'Get-AppxPackage -AllUsers | Foreach {Add-AppxPackage -DisableDevelopmentMode # -Register \
- "$($_.InstallLocation)\AppXManifest.xml"}'
- try:
- subprocess.call("powershell -EncodedCommand {0}".format(encodedcommand), shell=True)
- except (WindowsError, IOError):
- print "App management: Could not re-install all apps"
-
-
-if __name__ == '__main__':
- wxwindow = wx.App(False)
- frame = MainFrame() # Create Window
- wxwindow.MainLoop()