BaSs_HaXoR

DisableWinTracking (python) (MY FAV)

Jun 21st, 2018 (edited)
1,033
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 25.01 KB | None | 0 0
  1. ##########################################################################################
  2. #                                                                                        #
  3. #                    https://github.com/10se1ucgo/DisableWinTracking                     #
  4. #         EXE DL HERE: https://github.com/10se1ucgo/DisableWinTracking/releases/         #
  5. #                                                                                        #
  6. ##########################################################################################
  7.  
  8. # Copyright (C) 10se1ucgo 2015-2016
  9. #
  10. # This file is part of DisableWinTracking.
  11. #
  12. # DisableWinTracking is free software: you can redistribute it and/or modify
  13. # it under the terms of the GNU General Public License as published by
  14. # the Free Software Foundation, either version 3 of the License, or
  15. # (at your option) any later version.
  16. #
  17. # DisableWinTracking is distributed in the hope that it will be useful,
  18. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. # GNU General Public License for more details.
  21. #
  22. # You should have received a copy of the GNU General Public License
  23. # along with DisableWinTracking.  If not, see <http://www.gnu.org/licenses/>.
  24. import logging
  25. import sys
  26. import io
  27. import platform
  28. import traceback
  29. import webbrowser
  30. from ctypes import windll
  31.  
  32. import wx
  33. from wx.lib.itemspicker import ItemsPicker, IP_SORT_SELECTED, IP_SORT_CHOICES, IP_REMOVE_FROM_CHOICES
  34.  
  35. import dwt_about
  36. import dwt_util
  37.  
  38. class RedirectText(io.StringIO):
  39.     def __init__(self, console, old_stdout):
  40.         super(RedirectText, self).__init__()
  41.  
  42.         self.out = console
  43.         self.old_out = old_stdout
  44.  
  45.     def write(self, string):
  46.         # Oh my god this is the DUMBEST THING I've ever done. (Keeping a reference to the old stdout)
  47.         self.old_out.write(string)
  48.         self.out.WriteText(string)
  49.  
  50.  
  51. class ConsoleDialog(wx.Dialog):
  52.     def __init__(self, old_stdout):
  53.         wx.Dialog.__init__(self, parent=wx.GetApp().TopWindow, title="Console Output", size=(500, 200),
  54.                            style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
  55.  
  56.         console_box = wx.TextCtrl(self, style=wx.TE_MULTILINE | wx.TE_READONLY)
  57.         sys.stdout = RedirectText(console_box, old_stdout)
  58.  
  59.         top_sizer = wx.BoxSizer(wx.VERTICAL)
  60.         console_sizer = wx.BoxSizer(wx.VERTICAL)
  61.         button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL)
  62.  
  63.         report_button = wx.FindWindowById(wx.ID_CANCEL, self)
  64.         report_button.SetLabel("Report an issue")
  65.  
  66.         console_sizer.Add(console_box, 1, wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ALIGN_TOP, 5)
  67.  
  68.         top_sizer.Add(console_sizer, 1, wx.ALL | wx.EXPAND, 5)
  69.         top_sizer.Add(button_sizer, 0, wx.ALL | wx.ALIGN_LEFT, 5)
  70.  
  71.         self.Bind(wx.EVT_CLOSE, handler=lambda x: sys.exit(0))
  72.         self.Bind(wx.EVT_BUTTON, handler=lambda x: sys.exit(0), id=wx.ID_OK)
  73.         self.Bind(wx.EVT_BUTTON, source=report_button, handler=self.submit_issue)
  74.         self.SetSizer(top_sizer)
  75.  
  76.     def submit_issue(self, event):
  77.         webbrowser.open_new_tab("https://github.com/10se1ucgo/DisableWinTracking/issues/new")
  78.  
  79.  
  80. class MainFrame(wx.Frame):
  81.     def __init__(self):
  82.         super(MainFrame, self).__init__(parent=wx.GetApp().GetTopWindow(), title="Disable Windows 10 Tracking",
  83.                                         size=(415, 245))
  84.         self.SetMinSize(self.GetSize())
  85.         panel = MainPanel(self)
  86.  
  87.         file_menu = wx.Menu()
  88.         settings = file_menu.Append(wx.ID_SETUP, "&Settings", "DWT settings")
  89.  
  90.         help_menu = wx.Menu()
  91.         about = help_menu.Append(wx.ID_ABOUT, "&About", "About DWT")
  92.         licenses = help_menu.Append(wx.ID_ANY, "&Licenses", "Open-source licenses")
  93.  
  94.         menu_bar = wx.MenuBar()
  95.         menu_bar.Append(file_menu, "&File")
  96.         menu_bar.Append(help_menu, "&Help")
  97.         self.SetMenuBar(menu_bar)
  98.  
  99.         check_elevated()
  100.  
  101.         self.SetIcon(wx.Icon(sys.executable, wx.BITMAP_TYPE_ICO))
  102.         self.Bind(wx.EVT_MENU, lambda x: dwt_about.about_dialog(self), about)
  103.         self.Bind(wx.EVT_MENU, panel.settings, settings)
  104.         self.Bind(wx.EVT_MENU, lambda x: dwt_about.Licenses(self), licenses)
  105.         self.Layout()
  106.  
  107.  
  108. class MainPanel(wx.Panel):
  109.     def __init__(self, parent):
  110.         super(MainPanel, self).__init__(parent)
  111.  
  112.         self.parent = parent
  113.         self.picked_normal = []
  114.         self.picked_extra = []
  115.         self.picked_ips = []
  116.  
  117.         self.service_check = wx.CheckBox(self, label="Services")
  118.         self.service_check.SetToolTip("Disables or deletes tracking services. Choose option in 'Services Method'")
  119.  
  120.         self.diagtrack_check = wx.CheckBox(self, label="Clear DiagTrack log")
  121.         self.diagtrack_check.SetToolTip("Clears Dianostic Tracking log and prevents modification to it. "
  122.                                         "Cannot be undone automatically.")
  123.  
  124.         # Telemetry checkbox
  125.         self.telemetry_check = wx.CheckBox(self, label="Telemetry")
  126.         self.telemetry_check.SetToolTip("Sets 'AllowTelemetry' to 0. "
  127.                                         "On non-Enterprise OS editions, requires HOSTS file modification.")
  128.  
  129.         # HOSTS file checkbox
  130.         self.host_check = wx.CheckBox(self, label="Block tracking domains")
  131.         self.host_check.SetToolTip("Adds known tracking domains to HOSTS file. Required to disable Telemetry")
  132.  
  133.         # Extra HOSTS checkbox
  134.         self.extra_host_check = wx.CheckBox(self, label="Block even more tracking domains")
  135.         self.extra_host_check.SetToolTip("For the paranoid. Adds extra domains to the HOSTS file.\n"
  136.                                          "May cause issues with Skype, Dr. Watson, Hotmail and/or Error Reporting.")
  137.  
  138.         # IP block checkbox
  139.         self.ip_check = wx.CheckBox(self, label="Block tracking IP addresses")
  140.         self.ip_check.SetToolTip("Blocks known tracking IP addresses with Windows Firewall.")
  141.  
  142.         # Windows Privacy Regs (Policy Manager)
  143.         self.defender_check = wx.CheckBox(self, label="Windows Defender collection")
  144.         #self.defender_check.SetToolTip("Modifies registry to prevent Defender collection")
  145.         #Disable defender option until a solution is found.
  146.         self.defender_check.SetToolTip("Disable due to limitation set by windows kernel.")
  147.         self.defender_check.Enable(False)
  148.  
  149.         # WifiSense checkbox
  150.         self.wifisense_check = wx.CheckBox(self, label="WifiSense")
  151.  
  152.         # OneDrive uninstall checkbox
  153.         self.onedrive_check = wx.CheckBox(self, label="Uninstall OneDrive")
  154.         self.onedrive_check.SetToolTip("Uninstalls OneDrive from your computer and removes it from Explorer.")
  155.  
  156.         self.service_rad = wx.RadioBox(self, label="Service Method", choices=("Disable", "Delete"))
  157.         self.service_rad.SetItemToolTip(item=0, text="Simply disables the services. This can be undone.")
  158.         self.service_rad.SetItemToolTip(item=1, text="Deletes the services completely. This can't be undone.")
  159.  
  160.         self.mode_rad = wx.RadioBox(self, label="Mode", choices=("Privacy", "Revert"))
  161.         self.mode_rad.SetItemToolTip(item=0, text="Applies the selected settings.")
  162.         self.mode_rad.SetItemToolTip(item=1, text="Reverts the selected settings.")
  163.  
  164.         go_button = wx.Button(self, label="Go!")
  165.  
  166.         #Temporarily removed due to issues with not being able to restore apps properly
  167.         #This was honestly beyond the scope of the project to begin with and shouldn't have been implemented
  168.  
  169.  
  170.         '''self.app_box = wx.StaticBoxSizer(wx.VERTICAL, self, "Built-in Apps")
  171.         stat_box = self.app_box.GetStaticBox()
  172.         top_app_sizer = wx.BoxSizer(wx.HORIZONTAL)
  173.         button_app_sizer = wx.BoxSizer(wx.HORIZONTAL)
  174.         left_app_sizer = wx.BoxSizer(wx.VERTICAL)
  175.         middle_app_sizer = wx.BoxSizer(wx.VERTICAL)
  176.         right_app_sizer = wx.BoxSizer(wx.VERTICAL)
  177.  
  178.         # wx.CheckBox(app_box.GetStaticBox(), label="Name", name="search_name")
  179.  
  180.         wx.CheckBox(stat_box, label="3D Builder", name="3dbuilder")
  181.         wx.CheckBox(stat_box, label="Alarms && Clocks", name="windowsalarms")
  182.         wx.CheckBox(stat_box, label="Calendar and Mail", name="windowscommunicationsapps")
  183.         wx.CheckBox(stat_box, label="Camera", name="windowscamera")
  184.         wx.CheckBox(stat_box, label="Drawboard PDF", name="drawboardpdf")
  185.         wx.CheckBox(stat_box, label="Feedback Hub", name="windowsfeedbackhub")
  186.         wx.CheckBox(stat_box, label="Food && Drink", name="bingfoodanddrink")
  187.         wx.CheckBox(stat_box, label="Get Office App", name="officehub")
  188.         wx.CheckBox(stat_box, label="Get Skype App", name="skypeapp")
  189.         wx.CheckBox(stat_box, label="Get Started App", name="getstarted")
  190.         wx.CheckBox(stat_box, label="Groove Music", name="zunemusic")
  191.         wx.CheckBox(stat_box, label="Health && Fitness", name="binghealthandfitness")
  192.         wx.CheckBox(stat_box, label="Maps", name="windowsmaps")
  193.         wx.CheckBox(stat_box, label="Messaging", name="messaging")
  194.         wx.CheckBox(stat_box, label="Money", name="bingfinance")
  195.         wx.CheckBox(stat_box, label="Movies && TV", name="zunevideo")
  196.         wx.CheckBox(stat_box, label="News", name="bingnews")
  197.         wx.CheckBox(stat_box, label="OneNote App", name="onenote")
  198.         wx.CheckBox(stat_box, label="People", name="people")
  199.         wx.CheckBox(stat_box, label="Phone Companion", name="windowsphone")
  200.         wx.CheckBox(stat_box, label="Photos", name="photos")
  201.         wx.CheckBox(stat_box, label="Reader", name="reader")
  202.         wx.CheckBox(stat_box, label="Reading List", name="windowsreadinglist")
  203.         wx.CheckBox(stat_box, label="Solitaire Collection", name="solitairecollection")
  204.         wx.CheckBox(stat_box, label="Sports", name="bingsports")
  205.         wx.CheckBox(stat_box, label="Sticky Notes", name="microsoftstickynotes")
  206.         wx.CheckBox(stat_box, label="Sway App", name="sway")
  207.         wx.CheckBox(stat_box, label="Travel", name="bingtravel")
  208.         wx.CheckBox(stat_box, label="Voice Recorder", name="soundrecorder")
  209.         wx.CheckBox(stat_box, label="Weather", name="bingweather")
  210.         wx.CheckBox(stat_box, label="Xbox", name="xboxapp")
  211.         remove_app_button = wx.Button(stat_box, label="Remove selected apps")
  212.         select_all_check = wx.CheckBox(stat_box, label="Select all")
  213.  
  214.         sorted_list = sorted(stat_box.GetChildren(), key=lambda x: x.GetLabel())
  215.         for index, item in enumerate([x for x in sorted_list if isinstance(x, wx.CheckBox) and x != select_all_check]):
  216.             n = len(sorted_list) // 3
  217.             if index <= n:
  218.                 left_app_sizer.Add(item, 1, wx.ALL, 1)
  219.             elif index <= n * 2:
  220.                 middle_app_sizer.Add(item, 1, wx.ALL, 1)
  221.             else:
  222.                 right_app_sizer.Add(item, 1, wx.ALL, 1)
  223.  
  224.         top_app_sizer.Add(left_app_sizer, 1, wx.ALL, 1)
  225.         top_app_sizer.Add(middle_app_sizer, 1, wx.ALL, 1)
  226.         top_app_sizer.Add(right_app_sizer, 1, wx.ALL, 1)
  227.         button_app_sizer.Add(remove_app_button, 0, wx.ALL, 1)
  228.         button_app_sizer.Add(select_all_check, 1, wx.ALL, 5)
  229.         self.app_box.Add(top_app_sizer)
  230.         self.app_box.Add(button_app_sizer)'''
  231.  
  232.         top_sizer = wx.BoxSizer(wx.VERTICAL)
  233.         top_row_sizer = wx.BoxSizer(wx.HORIZONTAL)
  234.         check_sizer = wx.BoxSizer(wx.VERTICAL)
  235.         rad_sizer = wx.BoxSizer(wx.VERTICAL)
  236.  
  237.         top_sizer.Add(top_row_sizer, 0, wx.ALL, 5)
  238.         #top_sizer.Add(self.app_box, 0, wx.ALL, 5)
  239.         top_row_sizer.Add(check_sizer, 0, wx.ALL)
  240.         top_row_sizer.Add(rad_sizer, 0, wx.ALL)
  241.         rad_sizer.Add(self.service_rad, 0, wx.ALL, 10)
  242.         rad_sizer.Add(go_button, 0, wx.ALL ^ wx.BOTTOM | wx.ALIGN_CENTER, 10)
  243.         rad_sizer.Add(self.mode_rad, 0, wx.ALL, 10)
  244.         check_sizer.Add(self.service_check, 0, wx.ALL, 1)
  245.         check_sizer.Add(self.diagtrack_check, 0, wx.ALL, 1)
  246.         check_sizer.Add(self.telemetry_check, 0, wx.ALL, 1)
  247.         check_sizer.Add(self.host_check, 0, wx.ALL, 1)
  248.         check_sizer.Add(self.extra_host_check, 0, wx.ALL, 1)
  249.         check_sizer.Add(self.ip_check, 0, wx.ALL, 1)
  250.         check_sizer.Add(self.defender_check, 0, wx.ALL, 1)
  251.         check_sizer.Add(self.wifisense_check, 0, wx.ALL, 1)
  252.         check_sizer.Add(self.onedrive_check, 0, wx.ALL, 1)
  253.  
  254.         #self.Bind(wx.EVT_CHECKBOX, handler=self.select_all_apps, source=select_all_check)
  255.         self.Bind(wx.EVT_CHECKBOX, handler=self.ip_warn, source=self.ip_check)
  256.         self.Bind(wx.EVT_CHECKBOX, handler=self.hosts_warn, source=self.extra_host_check)
  257.         #self.Bind(wx.EVT_BUTTON, handler=self.remove_apps, source=remove_app_button)
  258.         self.Bind(wx.EVT_BUTTON, handler=self.go, source=go_button)
  259.  
  260.         self.SetSizer(top_sizer)
  261.  
  262.     def select_all_apps(self, event):
  263.         # Iters through all children of the wxStaticBox of the wxStaticBoxSizer and checks/un checks all wxCheckBoxes.
  264.         for child in self.app_box.GetStaticBox().GetChildren():
  265.             if isinstance(child, wx.CheckBox):
  266.                 child.SetValue(event.IsChecked())
  267.            
  268.     def ip_warn(self, event):
  269.         # Warn users about the potential side effects of the IP blocking firewall rules
  270.         if event.IsChecked():
  271.             warn = wx.MessageDialog(parent=self,
  272.                                     message="This option could potentially disable Microsoft Licensing traffic and thus "
  273.                                             "certain games and apps may cease to work, such as, Forza, or Gears of War.",
  274.                                     caption="Attention!", style=wx.YES_NO | wx.ICON_EXCLAMATION)
  275.  
  276.             if warn.ShowModal() == wx.ID_NO:
  277.                 event.GetEventObject().SetValue(False)
  278.  
  279.             warn.Destroy()
  280.  
  281.     def hosts_warn(self, event):
  282.         # Warn users about the potential side effects of the extra hosts mod.
  283.         if event.IsChecked():
  284.             warn = wx.MessageDialog(parent=self,
  285.                                     message="This option could potentially disable one or more of the following "
  286.                                             "services:\n\nSkype, Hotmail, Dr. Watson and/or Error Reporting. Continue?",
  287.                                     caption="Attention!", style=wx.YES_NO | wx.ICON_EXCLAMATION)
  288.  
  289.             if warn.ShowModal() == wx.ID_NO:
  290.                 event.GetEventObject().SetValue(False)
  291.  
  292.             warn.Destroy()
  293.  
  294.     def go(self, event):
  295.         if not all((self.picked_ips, self.picked_extra, self.picked_normal)):
  296.             self.settings(event=None)
  297.  
  298.         undo = bool(self.mode_rad.GetSelection())
  299.  
  300.         if self.ip_check.IsChecked():
  301.             dwt_util.ip_block(self.picked_ips, undo=undo)
  302.         if self.diagtrack_check.IsChecked():
  303.             dwt_util.clear_diagtrack()
  304.         if self.service_check.IsChecked():
  305.             if self.service_rad.GetSize():
  306.                 dwt_util.delete_service("dmwappushsvc")
  307.                 dwt_util.delete_service("DiagTrack")
  308.             else:
  309.                 dwt_util.disable_service("dmwappushsvc")
  310.                 dwt_util.disable_service("DiagTrack")
  311.             dwt_util.services(undo=undo)
  312.         if self.telemetry_check.IsChecked():
  313.             dwt_util.telemetry(undo=undo)
  314.         if self.host_check.IsChecked():
  315.             dwt_util.host_file(self.picked_normal, undo=undo)
  316.         if self.extra_host_check.IsChecked():
  317.             dwt_util.host_file(self.picked_extra, undo=undo)
  318.         if self.defender_check.IsChecked():
  319.             dwt_util.defender(undo=undo)
  320.         if self.wifisense_check.IsChecked():
  321.             dwt_util.wifisense(undo=undo)
  322.         if self.onedrive_check.IsChecked():
  323.             dwt_util.onedrive(undo=undo)
  324.         logger.info("Done. It's recommended that you reboot as soon as possible for the full effect.")
  325.         logger.info(("If you feel something didn't work properly, please press the 'Report an issue'"
  326.                       " button and follow the directions"))
  327.         console.Center()
  328.         console.Show()
  329.  
  330.     def remove_apps(self, event):
  331.         children = [child for child in self.app_box.GetStaticBox().GetChildren() if child.GetName() != "check"]
  332.         app_list = [child.GetName() for child in children if isinstance(child, wx.CheckBox) and child.IsChecked()]
  333.         dwt_util.app_manager(app_list, undo=False)
  334.  
  335.     def settings(self, event, silent=False):
  336.         if silent == False:
  337.             dialog = wx.Dialog(parent=self, title="Settings", style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
  338.             sizer = wx.BoxSizer(wx.VERTICAL)
  339.            
  340.         normal_domains = (
  341.             'a-0001.a-msedge.net', 'a-0002.a-msedge.net', 'a-0003.a-msedge.net', 'a-0004.a-msedge.net',
  342.             'a-0005.a-msedge.net', 'a-0006.a-msedge.net', 'a-0007.a-msedge.net', 'a-0008.a-msedge.net',
  343.             'a-0009.a-msedge.net', 'a-msedge.net', 'a.ads1.msn.com', 'a.ads2.msads.net', 'a.ads2.msn.com',
  344.             'a.rad.msn.com', 'ac3.msn.com', 'ad.doubleclick.net', 'adnexus.net', 'adnxs.com', 'ads.msn.com',
  345.             'ads1.msads.net', 'ads1.msn.com', 'aidps.atdmt.com', 'aka-cdn-ns.adtech.de',
  346.             'az361816.vo.msecnd.net', 'az512334.vo.msecnd.net', 'b.ads1.msn.com', 'b.ads2.msads.net',
  347.             'b.rad.msn.com', 'bs.serving-sys.com', 'c.atdmt.com', 'c.msn.com', 'cdn.atdmt.com',
  348.             'cds26.ams9.msecn.net', 'choice.microsoft.com', 'choice.microsoft.com.nsatc.net',
  349.             'compatexchange.cloudapp.net', 'corp.sts.microsoft.com', 'corpext.msitadfs.glbdns2.microsoft.com',
  350.             'cs1.wpc.v0cdn.net', 'db3aqu.atdmt.com', 'df.telemetry.microsoft.com',
  351.             'diagnostics.support.microsoft.com', 'ec.atdmt.com', 'feedback.microsoft-hohm.com',
  352.             'feedback.search.microsoft.com', 'feedback.windows.com', 'flex.msn.com', 'g.msn.com', 'h1.msn.com',
  353.             'i1.services.social.microsoft.com', 'i1.services.social.microsoft.com.nsatc.net',
  354.             'lb1.www.ms.akadns.net', 'live.rads.msn.com', 'm.adnxs.com', 'msedge.net', 'msftncsi.com',
  355.             'msnbot-65-55-108-23.search.msn.com', 'msntest.serving-sys.com', 'oca.telemetry.microsoft.com',
  356.             'oca.telemetry.microsoft.com.nsatc.net', 'pre.footprintpredict.com', 'preview.msn.com',
  357.             'rad.live.com', 'rad.msn.com', 'redir.metaservices.microsoft.com',
  358.             'reports.wes.df.telemetry.microsoft.com', 'schemas.microsoft.akadns.net',
  359.             'secure.adnxs.com', 'secure.flashtalking.com', 'services.wes.df.telemetry.microsoft.com',
  360.             'settings-sandbox.data.microsoft.com', 'settings-win.data.microsoft.com',
  361.             'sls.update.microsoft.com.akadns.net', 'sqm.df.telemetry.microsoft.com',
  362.             'sqm.telemetry.microsoft.com', 'sqm.telemetry.microsoft.com.nsatc.net', 'ssw.live.com',
  363.             'static.2mdn.net', 'statsfe1.ws.microsoft.com', 'statsfe2.ws.microsoft.com',
  364.             'telecommand.telemetry.microsoft.com', 'telecommand.telemetry.microsoft.com.nsatc.net',
  365.             'telemetry.appex.bing.net', 'telemetry.microsoft.com', 'telemetry.urs.microsoft.com',
  366.             'v10.vortex-win.data.microsoft.com', 'vortex-bn2.metron.live.com.nsatc.net',
  367.             'vortex-cy2.metron.live.com.nsatc.net', 'vortex-sandbox.data.microsoft.com',
  368.             'vortex-win.data.metron.live.com.nsatc.net', 'vortex-win.data.microsoft.com',
  369.             'vortex.data.glbdns2.microsoft.com', 'vortex.data.microsoft.com', 'watson.live.com',
  370.             'web.vortex.data.microsoft.com', 'www.msftncsi.com'
  371.         )
  372.  
  373.         extra_domains = (
  374.             'fe2.update.microsoft.com.akadns.net', 's0.2mdn.net', 'statsfe2.update.microsoft.com.akadns.net',
  375.             'survey.watson.microsoft.com', 'view.atdmt.com', 'watson.microsoft.com',
  376.             'watson.ppe.telemetry.microsoft.com', 'watson.telemetry.microsoft.com',
  377.             'watson.telemetry.microsoft.com.nsatc.net', 'wes.df.telemetry.microsoft.com', 'ui.skype.com',
  378.             'pricelist.skype.com', 'apps.skype.com', 'm.hotmail.com', 's.gateway.messenger.live.com'
  379.         )
  380.  
  381.         ip_addresses = (
  382.             '2.22.61.43', '2.22.61.66', '65.39.117.230', '65.55.108.23', '23.218.212.69', '134.170.30.202',
  383.             '137.116.81.24', '157.56.106.189', '204.79.197.200', '65.52.108.33', '64.4.54.254'
  384.         )
  385.  
  386.         normal_domain_picker = ItemsPicker(dialog, choices=[], selectedLabel="Domains to be blocked",
  387.                                            ipStyle=IP_SORT_SELECTED | IP_SORT_CHOICES | IP_REMOVE_FROM_CHOICES)
  388.         if self.picked_normal:
  389.             normal_domain_picker.SetSelections(self.picked_normal)
  390.             normal_domain_picker.SetItems([domain for domain in normal_domains if domain not in self.picked_normal])
  391.         else:
  392.             normal_domain_picker.SetSelections(normal_domains)
  393.  
  394.         extra_domain_picker = ItemsPicker(dialog, choices=[], selectedLabel="Extra domains to be blocked",
  395.                                           ipStyle=IP_SORT_SELECTED | IP_SORT_CHOICES | IP_REMOVE_FROM_CHOICES)
  396.         if self.picked_extra:
  397.             extra_domain_picker.SetSelections(self.picked_extra)
  398.             extra_domain_picker.SetItems([domain for domain in extra_domains if domain not in self.picked_extra])
  399.         else:
  400.             extra_domain_picker.SetSelections(extra_domains)
  401.  
  402.         ip_picker = ItemsPicker(dialog, choices=[], selectedLabel="IP addresses to be blocked",
  403.                                 ipStyle=IP_SORT_SELECTED | IP_SORT_CHOICES | IP_REMOVE_FROM_CHOICES)
  404.         if self.picked_ips:
  405.             ip_picker.SetSelections(self.picked_ips)
  406.             ip_picker.SetItems([ip for ip in ip_addresses if ip not in self.picked_ips])
  407.         else:
  408.             ip_picker.SetSelections(ip_addresses)
  409.  
  410.         if silent == False:
  411.             sizer.Add(normal_domain_picker, 0, wx.EXPAND)
  412.             sizer.Add(extra_domain_picker, 0, wx.EXPAND)
  413.             sizer.Add(ip_picker, 0, wx.EXPAND)
  414.             if event is not None:
  415.                 dialog.SetSizerAndFit(sizer)
  416.                 dialog.Center()
  417.                 dialog.ShowModal()
  418.             dialog.Destroy()
  419.            
  420.         self.picked_normal = normal_domain_picker.GetSelections()
  421.         self.picked_extra = extra_domain_picker.GetSelections()
  422.         self.picked_ips = ip_picker.GetSelections()
  423.        
  424.        
  425. def setup_logging():
  426.     global logger
  427.     logger = logging.getLogger('dwt')
  428.     logger.setLevel(logging.DEBUG)
  429.  
  430.     formatter = logging.Formatter(fmt='%(asctime)s %(levelname)s: %(message)s', datefmt='%H:%M:%S')
  431.  
  432.     stdout_log = logging.StreamHandler(sys.stdout)
  433.     stdout_log.setLevel(logging.DEBUG)
  434.     stdout_log.setFormatter(formatter)
  435.     logger.addHandler(stdout_log)
  436.  
  437.     try:
  438.         file_log = logging.FileHandler(filename='dwt.log')
  439.         file_log.setLevel(logging.DEBUG)
  440.         file_log.setFormatter(formatter)
  441.         logger.addHandler(file_log)
  442.     except (OSError, IOError):
  443.         error_dialog = wx.MessageDialog(parent=wx.GetApp().GetTopWindow(),
  444.                                         message="Could not create log file, errors will not be recorded!",
  445.                                         caption="ERROR!", style=wx.OK | wx.ICON_ERROR)
  446.         error_dialog.ShowModal()
  447.         error_dialog.Destroy()
  448.         logger.exception("Could not create log file.")
  449.  
  450.     logger.info("Python {version} on {platform}".format(version=sys.version, platform=sys.platform))
  451.     logger.info(platform.uname())
  452.     logger.info("DisableWinTracking version {v}".format(v=dwt_about.__version__))
  453.  
  454.  
  455. def exception_hook(error, value, trace):
  456.     error_message = ''.join(traceback.format_exception(error, value, trace))
  457.     logger.critical(error_message)
  458.     error_dialog = wx.MessageDialog(parent=wx.GetApp().GetTopWindow(),
  459.                                     message="An error has occured!\n\n" + error_message,
  460.                                     caption="ERROR!", style=wx.OK | wx.CANCEL | wx.ICON_ERROR)
  461.     error_dialog.SetOKCancelLabels("Ignore", "Quit")
  462.     if error_dialog.ShowModal() == wx.ID_OK:
  463.         error_dialog.Destroy()
  464.     else:
  465.         error_dialog.Destroy()
  466.         sys.exit(1)
  467.  
  468. def check_elevated(silent=False):
  469.     if not bool(windll.advpack.IsNTAdmin(0, None)):
  470.         if silent:
  471.             windll.shell32.ShellExecuteW(None, u"runas", unicode(sys.executable), u"{0} -silent".format(unicode(__file__)), None, 1)
  472.             sys.exit(1)
  473.         else:
  474.             windll.shell32.ShellExecuteW(None, u"runas", unicode(sys.executable), unicode(__file__), None, 1)
  475.         sys.exit(1)
  476.    
  477. def silent():
  478.  
  479.     setup_logging()
  480.     check_elevated(True)
  481.  
  482.     dwt_util.clear_diagtrack()
  483.     dwt_util.disable_service("dmwappushsvc")
  484.     dwt_util.disable_service("DiagTrack")
  485.     dwt_util.services(0)
  486.     dwt_util.telemetry(0)
  487.     #dwt_util.defender(0)
  488.     dwt_util.wifisense(0)
  489.     dwt_util.onedrive(0)
  490.    
  491.     logger.info("COMPLETE")
  492.        
  493. if __name__ == '__main__':
  494.     if '-silent' in sys.argv:
  495.         silent()
  496.         sys.exit(0)
  497.            
  498.     wx_app = wx.App()
  499.     frame = MainFrame()
  500.     console = ConsoleDialog(sys.stdout)
  501.     setup_logging()
  502.     sys.excepthook = exception_hook
  503.     dwt_about.update_check(None)
  504.     frame.Show()
  505.     wx_app.MainLoop()
  506. # example of output:
  507. # 04:17:32 INFO: Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] on win32
  508. # 04:17:32 INFO: ('Windows', 'USERNAME', '10', '10.0.16299', 'AMD64', 'AMD64 Family 21 Model 1 Stepping 2, AuthenticAMD')
  509. # 04:17:32 INFO: DisableWinTracking version 3.2.1
  510. # 04:19:02 INFO: IP Blocker: The IP 134.170.30.202 was successfully blocked.
  511. # 04:19:02 INFO: IP Blocker: The IP 137.116.81.24 was successfully blocked.
  512. # 04:19:03 INFO: IP Blocker: The IP 157.56.106.189 was successfully blocked.
  513. # 04:19:03 INFO: IP Blocker: The IP 2.22.61.43 was successfully blocked.
  514. # 04:19:03 INFO: IP Blocker: The IP 2.22.61.66 was successfully blocked.
  515. # 04:19:04 INFO: IP Blocker: The IP 204.79.197.200 was successfully blocked.
  516. # 04:19:04 INFO: IP Blocker: The IP 23.218.212.69 was successfully blocked.
  517. # 04:19:05 INFO: IP Blocker: The IP 64.4.54.254 was successfully blocked.
  518. # 04:19:05 INFO: IP Blocker: The IP 65.39.117.230 was successfully blocked.
  519. # 04:19:05 INFO: IP Blocker: The IP 65.52.108.33 was successfully blocked.
  520. # 04:19:06 INFO: IP Blocker: The IP 65.55.108.23 was successfully blocked.
  521. # 04:19:06 INFO: DiagTrack: Successfully deleted service 'DiagTrack'
  522. # 04:19:06 INFO: DiagTrack: Completed Part 1/3
  523. # 04:19:06 INFO: DiagTrack: Successfully deleted service 'dmwappushservice'
  524. # 04:19:06 INFO: DiagTrack: Completed Part 2/3
  525. # 04:19:06 INFO: DiagTrack: Successfully erased tracking log.
  526. # 04:19:06 INFO: DiagTrack: Completed Part 3/3
  527. # 04:19:06 INFO: DiagTrack: Completed successfully, without errors.
  528. # 04:19:07 INFO: Registry: Successfully modified dmwappushsvc key.
  529. # 04:19:07 INFO: Registry: Successfully modified DiagTrack key.
  530. # 04:19:07 INFO: Registry: Successfully modified AllowTelemetry key.
  531. # 04:19:08 INFO: Registry: Successfully modified WifiSense Open-ness key.
  532. # 04:19:08 INFO: Registry: Successfully modified WifiSense Credential Share key.
  533. # 04:19:08 INFO: Registry: Successfully modified ListPin key.
  534. # 04:19:08 INFO: Registry: Successfully modified ListPin64Bit key.
  535. # 04:19:08 INFO: Registry: Successfully modified FileSync key.
  536. # 04:20:12 INFO: OneDrive: unable to uninstall. Exited with code: 0 - ('', '')
  537. # 04:20:12 INFO: Done. It's recommended that you reboot as soon as possible for the full effect.
  538. # 04:20:12 INFO: If you feel something didn't work properly, please press the 'Report an issue' button and follow the  directions
  539. #
  540. #
  541. #
Add Comment
Please, Sign In to add comment