-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRMArtifacts.py
66 lines (58 loc) · 3.11 KB
/
RMArtifacts.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
#Simple Script to Remove Windows Artifacts
import winreg
from os import chmod,getlogin
from sys import platform
from ctypes import windll
import stat
from shutil import rmtree
from subprocess import run
class RE:
def __init__(self):
print("""
____ __ ___ ___ __ _ ____ __
/ __ \/ |/ / / | _____/ /_(_) __/___ ______/ /______
/ /_/ / /|_/ / / /| | / ___/ __/ / /_/ __ `/ ___/ __/ ___/
/ _, _/ / / / / ___ |/ / / /_/ / __/ /_/ / /__/ /_(__ )
/_/ |_/_/ /_/____/_/ |_/_/ \__/_/_/ \__,_/\___/\__/____/
/_____/
""")
directroyPrefetch = "C:\\Windows\\Prefetch\\"
directoryHistroy = "C:\\Users\\"+getlogin()+"\\AppData\\Local\\Microsoft\\Windows\\History"
if windll.shell32.IsUserAnAdmin():
if platform != "win32":
exit()
else:
#Disable Prefetch From Registry
regPath = "SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters"
connect = winreg.ConnectRegistry(None,winreg.HKEY_LOCAL_MACHINE)
Prefetch= winreg.OpenKey(connect,regPath,0,winreg.KEY_ALL_ACCESS)
winreg.SetValueEx(Prefetch,"EnablePrefetcher",0,winreg.REG_DWORD,0)
winreg.SetValueEx(Prefetch,"EnableSuperfetch",0,winreg.REG_DWORD,0)
winreg.CloseKey(connect)
winreg.CloseKey(Prefetch)
run(["powershell", "Set-Service -Name 'SysMain' -Status stopped -StartupType disabled"], capture_output=True)
print("[+] Disable Prefetch From Registry")
try:
chmod(directroyPrefetch, 0o777)
rmtree(directroyPrefetch, ignore_errors=True)
print("[+] PreFetch Directory Deleted Successfully")
except:
print("[+] PreFetch Directory Already Deleted Successfully")
#Disable Recent Files Opend From Registry
regPathRecent = "SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer"
connect = winreg.ConnectRegistry(None,winreg.HKEY_LOCAL_MACHINE)
Recent = winreg.OpenKey(connect,regPathRecent,0,winreg.KEY_ALL_ACCESS)
winreg.SetValueEx(Recent,"NoRecentDocsHistory",0,winreg.REG_DWORD,1)
print("[+] Disable History And Recent Files From Registry")
try:
chmod(directoryHistroy, 0o777)
rmtree(directoryHistroy, ignore_errors=True)
run(["powershell", "Clear-RecycleBin -Force"], capture_output=True)
print("[+] History Directory Deleted Successfully")
print("[+] Recent Directory Deleted Successfully")
except:
print("[+] History Directory Already Deleted Successfully")
print("[+] Recent Directory Deleted Successfully")
else:
print("Please Run As Administrator")
ob = RE()