Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
10se1ucgo committed Aug 4, 2015
1 parent 8d30118 commit 102f1a4
Showing 1 changed file with 31 additions and 11 deletions.
42 changes: 31 additions & 11 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import subprocess
import _winreg
import ctypes
import os

import wx
from wx.lib.wordwrap import wordwrap
Expand Down Expand Up @@ -41,24 +42,30 @@ def __init__(self, parent, title):
self.warn.Destroy()
sys.exit()

self.icon = wx.Icon(r"c:\windows\system32\shell32.dll;315", wx.BITMAP_TYPE_ICO)
self.shell32file = os.path.join(os.environ['WINDIR'], 'System32\\shell32.dll')
self.icon = wx.Icon(self.shell32file + ";315", wx.BITMAP_TYPE_ICO)
self.SetIcon(self.icon)

self.telebox = wx.CheckBox(wxpanel, label="Telemetry", pos=(10, 15))
self.telebox.Bind(wx.EVT_CHECKBOX, self.hostcheck)
self.telebox.SetToolTip(
wx.ToolTip("Set \'AllowTelemetry\' to 0. Requires HOST file modification for full effect"))
self.telebox.Set3StateValue(0)

self.servicebox = wx.CheckBox(wxpanel, label="Services", pos=(10, 30))
self.servicebox.SetToolTip(wx.ToolTip("Enable \'Service Method\' box, select an option"))
self.servicebox.Set3StateValue(0)
self.servicebox.Bind(wx.EVT_CHECKBOX, self.serviceradcheck)

self.diagbox = wx.CheckBox(wxpanel, label="Clear DiagTrack log", pos=(10, 45))
self.diagbox.SetToolTip(wx.ToolTip("Clear DiagTrack log and prevents modification to it."))
self.diagbox.Set3StateValue(0)

self.hostbox = wx.CheckBox(wxpanel, label="Block tracking servers with HOSTS file (Needed for Telemetry)",
self.hostbox = wx.CheckBox(wxpanel, label="Block tracking servers with HOSTS file",
pos=(10, 60))
self.hostbox.SetToolTip(wx.ToolTip("Add known tracking domains to HOSTS file. Required for Telemetry"))
self.hostbox.Set3StateValue(0)

self.servicebox = wx.CheckBox(wxpanel, label="Services", pos=(10, 30))
self.servicebox.Set3StateValue(0)
self.servicebox.Bind(wx.EVT_CHECKBOX, self.serviceradcheck)

self.servicerad = wx.RadioBox(wxpanel, label="Service Method", pos=(135, 10), choices=["Disable", "Delete"])
self.servicerad.Disable()

Expand Down Expand Up @@ -94,21 +101,33 @@ def about(self, event):
def onok(self, event):
if self.telebox.IsChecked():
self.telekeypath = r'SOFTWARE\Policies\Microsoft\Windows\DataCollection' # Path to Telemetry key
self.telekey2path = r'SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\DataCollection' # 2nd path

try:
self.telekey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, self.telekeypath, 0, _winreg.KEY_ALL_ACCESS)
_winreg.SetValueEx(self.telekey, "AllowTelemetry", 0, _winreg.REG_SZ, "0") # Disable Telemetry
_winreg.CloseKey(self.telekey)
print "Telemetry key succesfully modified."
except WindowsError:
print "Unable to modify Telemetry key. Deleted, or is the program not elevated?"
print "Unable to modify Telemetry key. Deleted, or is the program not elevated? Trying another method"

try:
self.telekey2 = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, self.telekey2path, 0,
_winreg.KEY_ALL_ACCESS)
_winreg.SetValueEx(self.telekey2, "AllowTelemetry", 0, _winreg.REG_SZ, "0") # Disable Telemetry
_winreg.CloseKey(self.telekey2)
print "2nd Telemetry key succesfully modified."
except WindowsError:
print "Unable to modify 2nd Telemetry key. Deleted, or is the program not elevated?"

if self.diagbox.IsChecked():
self.logfile = os.path.join(os.environ['SYSTEMDRIVE'],
'\\ProgramData\\Microsoft\\Diagnosis\\ETLLogs\\AutoLogger\\AutoLogger-Diagtrack-Listener.etl')

try:
open('C:\ProgramData\Microsoft\Diagnosis\ETLLogs\AutoLogger\AutoLogger-Diagtrack-Listener.etl',
'w').close() # Clear the AutoLogger file
open(self.logfile).close() # Clear the AutoLogger file
subprocess.Popen(
"echo y|cacls C:\ProgramData\Microsoft\Diagnosis\ETLLogs\AutoLogger\AutoLogger-Diagtrack-Listener.etl /d SYSTEM",
["echo", "y|cacls", self.logfile, "/d", "SYSTEM"],
shell=True) # Prevent modification to file
print "DiagTrack log succesfully cleared and locked."
except IOError:
Expand Down Expand Up @@ -139,9 +158,10 @@ def onok(self, event):
'feedback.microsoft-hohm.com', 'feedback.search.microsoft.com']
self.IP = '0.0.0.0 '
self.MSHosts2 = [self.IP + x for x in self.MSHosts]
self.hostslocation = os.path.join(os.environ['WINDIR'], 'System32\\drivers\\etc\\hosts')

try:
with open('C:\Windows\System32\drivers\etc\hosts', 'ab') as f:
with open(self.hostslocation, 'ab') as f:
f.write('\n' + '\n'.join(self.MSHosts2))
print "Domains successfully appended to HOSTS file."
except WindowsError:
Expand Down

0 comments on commit 102f1a4

Please sign in to comment.