forked from NoMod-Programming/DyKnow-Bypass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkillDyKnow.py
66 lines (58 loc) · 2.48 KB
/
killDyKnow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import ctypes
import time
import os
helperDll = ctypes.CDLL("DyKnowSupport.dll")
def killProcess(executable):
# 'executable' must be bytes
return helperDll.killProcessByName(ctypes.create_string_buffer(executable))
def allProcesses():
allProcesses = ((ctypes.c_char * 255) * 255)()
helperDll.getProcesses(allProcesses)
yield from (x.value for x in allProcesses if x.value)
def getDyKnowExes():
allExes = set()
for folderName, folders, files in os.walk(r"C:\Program Files\DyKnow"):
allExes.update(x.encode("utf-8") for x in files if x.endswith(".exe"))
return allExes
#def getLANDeskExes():
# allExes = set()
# for folderName, folders, files in os.walk(r"C:\Program Files (x86)\LANDesk\LDClient"):
# allExes.update(x.encode("utf-8") for x in files if x.endswith(".exe"))
# return allExes
#def getSophosExes():
# allExes = set()
# for folderName, folders, files in os.walk(r"C:\Program Files (x86)\Sophos"):
# allExes.update(x.encode("utf-8") for x in files if x.endswith(".exe"))
# return allExes
protectedProcesses = []
customBlacklist = [
# b'ALMon.exe', # Sophos Endpoint Security and Control
# b'proxyhost.exe', # Seems suspicious
# b'LDISCN32.EXE', #Inventory scan
# b'RouterNT.exe', #
# b'MSASCuiL.exe', # Windows Defender notification icon
# b'TabTip32.exe', # Touch Keyboard and Handwriting Panel Helper
# b'TabTip.exe', # Touch Keyboard and Handwriting Panel
# b'tposd.exe', # On screen display drawer
# #b'LPlatSvc.exe', # Lenovo Platform Service
]
if __name__ == '__main__':
print("Starting main loop!")
while True:
processes = list(allProcesses())
#new.update(x for x in lastProcesses if x not in curr) # Get killed processes
blacklisted = getDyKnowExes()
#blacklisted.update(getLANDeskExes())
#blacklisted.update(getSophosExes())
blacklisted.update(customBlacklist)
for proc in blacklisted:
# Kill processes
if proc in processes and proc not in protectedProcesses:
res = killProcess(proc)
if res == 0:
print("Killed {}!".format(proc))
else:
# Error killing process? Must be a permissions issue; log it
print("Error killing process \"{}\". {}".format(proc, ctypes.WinError(res) ))
protectedProcesses.append(proc)
time.sleep(0.05)