-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8972e79
Showing
8 changed files
with
290 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Windows Registry Editor Version 5.00 | ||
|
||
; hi - @z_h_ on discord | ||
|
||
|
||
|
||
[-HKEY_CLASSES_ROOT\*\shell\Force_Delete] | ||
[-HKEY_CLASSES_ROOT\*\shell\runas] | ||
|
||
[HKEY_CLASSES_ROOT\*\shell\Force_Delete] | ||
@="Force Delete" | ||
"Extended"=- | ||
"HasLUAShield"="" | ||
"NoWorkingDirectory"="" | ||
"NeverDefault"="" | ||
|
||
[HKEY_CLASSES_ROOT\*\shell\Force_Delete\command] | ||
@="powershell -windowstyle hidden -command \"Start-Process \\\"C:/path/to/your/Force_Delete.exe\\\" -ArgumentList '\\\"%1\\\"' -Verb runAs\"" | ||
"IsolatedCommand"= "powershell -windowstyle hidden -command \"Start-Process \\\"C:/path/to/your/Force_Delete.exe\\\" -ArgumentList '\\\"%1\\\"' -Verb runAs\"" | ||
|
||
|
||
[HKEY_CLASSES_ROOT\Directory\shell\Force_Delete] | ||
@="Force Delete" | ||
"Extended"=- | ||
"HasLUAShield"="" | ||
"NoWorkingDirectory"="" | ||
"Position"="middle" | ||
|
||
[HKEY_CLASSES_ROOT\Directory\shell\Force_Delete\command] | ||
@="powershell -windowstyle hidden -command \"Start-Process \\\"C:/path/to/your/Force_Delete.exe\\\" -ArgumentList '\\\"%1\\\"' -Verb runAs\"" | ||
"IsolatedCommand"= "powershell -windowstyle hidden -command \"Start-Process \\\"C:/path/to/your/Force_Delete.exe\\\" -ArgumentList '\\\"%1\\\"' -Verb runAs\"" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Windows Registry Editor Version 5.00 | ||
|
||
; hi - @z_h_ on discord | ||
|
||
|
||
|
||
[-HKEY_CLASSES_ROOT\*\shell\Force_Delete] | ||
[-HKEY_CLASSES_ROOT\*\shell\runas] | ||
|
||
[HKEY_CLASSES_ROOT\*\shell\Force_Delete] | ||
@="Force Delete" | ||
"Extended"=- | ||
"HasLUAShield"="" | ||
"NoWorkingDirectory"="" | ||
"NeverDefault"="" | ||
|
||
[HKEY_CLASSES_ROOT\*\shell\Force_Delete\command] | ||
@="powershell -windowstyle hidden -command \"Start-Process \\\"C:/path/to/your/Force_Delete.exe\\\" -ArgumentList '\\\"%1\\\"' -Verb runAs\"" | ||
"IsolatedCommand"= "powershell -windowstyle hidden -command \"Start-Process \\\"C:/path/to/your/Force_Delete.exe\\\" -ArgumentList '\\\"%1\\\"' -Verb runAs\"" | ||
|
||
|
||
[HKEY_CLASSES_ROOT\Directory\shell\Force_Delete] | ||
@="Force Delete" | ||
"Extended"=- | ||
"HasLUAShield"="" | ||
"NoWorkingDirectory"="" | ||
"Position"="middle" | ||
|
||
[HKEY_CLASSES_ROOT\Directory\shell\Force_Delete\command] | ||
@="powershell -windowstyle hidden -command \"Start-Process \\\"C:/path/to/your/Force_Delete.exe\\\" -ArgumentList '\\\"%1\\\"' -Verb runAs\"" | ||
"IsolatedCommand"= "powershell -windowstyle hidden -command \"Start-Process \\\"C:/path/to/your/Force_Delete.exe\\\" -ArgumentList '\\\"%1\\\"' -Verb runAs\"" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import os, subprocess, ctypes, signal, sys | ||
|
||
|
||
def is_admin(): | ||
try: | ||
return ctypes.windll.shell32.IsUserAnAdmin() | ||
except: | ||
return False | ||
|
||
|
||
def get_admin(): | ||
if '.py' in str(sys.argv): | ||
python = True | ||
else: | ||
python = False | ||
|
||
if not python: | ||
if is_admin(): | ||
# Code of your program here | ||
pass | ||
#print("Congrats, you're running me with admin huh?") | ||
else: | ||
# Re-run the program with admin rights | ||
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1) | ||
os.kill(os.getpid(), signal.SIGTERM) | ||
|
||
|
||
get_admin() | ||
|
||
# Get the absolute path of your exe | ||
abs_path = os.path.abspath("Force_Delete.exe") | ||
|
||
# Open .reg file and replace placeholder with absolute path | ||
with open('Force_Delete_base.reg', 'r') as file: | ||
filedata = file.read() | ||
# Replace the target string | ||
filedata = filedata.replace(r'C:/path/to/your/Force_Delete.exe', abs_path.replace('\\','/')) | ||
# Write the file out again | ||
with open('Force_Delete.reg', 'w') as f: | ||
f.write(filedata) | ||
|
||
# Now we have the .reg file with the correct path inside. Just need to merge it. | ||
subprocess.call(['regedit', '/s', 'Force_Delete.reg']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import sys, os, psutil, shutil, ctypes, signal, time | ||
|
||
|
||
def is_admin(): | ||
try: | ||
return ctypes.windll.shell32.IsUserAnAdmin() | ||
except: | ||
return False | ||
|
||
|
||
def EXIT(): | ||
print('EXITING') | ||
os.kill(os.getpid(), signal.SIGTERM) | ||
|
||
|
||
if not is_admin(): | ||
print('This script is best ran from an admin powershell instance.') | ||
EXIT() | ||
|
||
|
||
if len(sys.argv) < 2: | ||
print("No file/folder argument found.") | ||
EXIT() | ||
else: | ||
delf = sys.argv[1] | ||
|
||
|
||
def take_ownership(path): | ||
#command = f'takeown /F {path} /R /D Y' | ||
command = f'''powershell -command "Start-Process cmd -ArgumentList '/c takeown /f \\"{path}\\" && icacls \\"{path}\\" /grant *S-1-3-4:F /t /c /l' -Verb runAs"''' | ||
os.system(command) | ||
|
||
|
||
def remove_folder(folder_name): | ||
shutil.rmtree(folder_name) | ||
|
||
|
||
def get_all_files_in_path(path): | ||
drives = [path] | ||
listos = [] | ||
for o in drives: | ||
for root, dirs, files in os.walk(str(o), topdown=True, onerror=None, followlinks=False): | ||
for f in files: | ||
listo = os.path.join(root, f) | ||
listos.append(f"{listo}\n") | ||
return listos | ||
|
||
|
||
procs = [] | ||
for proc in psutil.process_iter(['pid', 'name']): | ||
procs.append(proc) | ||
|
||
|
||
def multikill(kill_procs): | ||
for proc in kill_procs: | ||
try: | ||
os.kill(proc[0], 9) | ||
except: | ||
os.system(f'taskkill /F /IM "{proc[1]}" /T') | ||
|
||
|
||
def delete_file_or_path(file_path): | ||
print(f'Deleting {file_path}') | ||
if os.path.exists(file_path): | ||
take_ownership(file_path) | ||
if os.path.isdir(file_path): | ||
files = get_all_files_in_path(file_path) | ||
else: | ||
files = file_path | ||
|
||
try: | ||
remove_folder(file_path) | ||
except Exception as e: | ||
kill_procs = [] | ||
print(e) | ||
print(f'Failed, finding process') | ||
#if file_path.lower().endswith('.exe'): | ||
print('First pass') | ||
for proc in procs: | ||
try: | ||
if file_path in proc.exe(): | ||
print(f"Found process {proc.pid} ({proc.name()}) accessing {file_path}.") | ||
kill_procs.append([proc.pid, proc.name()]) | ||
except (psutil.NoSuchProcess, psutil.AccessDenied): | ||
pass | ||
multikill(kill_procs) | ||
try: | ||
remove_folder(file_path) | ||
except: | ||
pass | ||
time.sleep(0.1) | ||
try: | ||
remove_folder(file_path) | ||
except: | ||
print('Second pass') | ||
|
||
for proc in procs: | ||
try: | ||
for item in proc.open_files(): | ||
# print(item.path) | ||
if file_path in item.path or file_path.replace('\\', '/') in item.path: | ||
print(f"Found process {proc.pid} ({proc.name()}) accessing {file_path}.") | ||
kill_procs.append([proc.pid, proc.name()]) | ||
except (psutil.NoSuchProcess, psutil.AccessDenied): | ||
pass | ||
|
||
#print(f"Killed process {proc[1]} ({proc[1]}).") | ||
print('Finished second pass') | ||
multikill(kill_procs) | ||
remove_folder(file_path) | ||
try: | ||
os.unlink(file_path) | ||
except: | ||
pass | ||
if os.path.exists(file_path): | ||
print('Success! Path removed.') | ||
else: | ||
print('File did not exist') | ||
|
||
|
||
delete_file_or_path(delf) | ||
|
||
#time.sleep(5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Windows Registry Editor Version 5.00 | ||
|
||
; hi - @z_h_ on discord | ||
|
||
|
||
|
||
[-HKEY_CLASSES_ROOT\*\shell\Force_Delete] | ||
[-HKEY_CLASSES_ROOT\*\shell\runas] | ||
|
||
[HKEY_CLASSES_ROOT\*\shell\Force_Delete] | ||
@="Force Delete" | ||
"Extended"=- | ||
"HasLUAShield"="" | ||
"NoWorkingDirectory"="" | ||
"NeverDefault"="" | ||
|
||
[HKEY_CLASSES_ROOT\*\shell\Force_Delete\command] | ||
@="powershell -windowstyle hidden -command \"Start-Process \\\"C:/path/to/your/Force_Delete.exe\\\" -ArgumentList '\\\"%1\\\"' -Verb runAs\"" | ||
"IsolatedCommand"= "powershell -windowstyle hidden -command \"Start-Process \\\"C:/path/to/your/Force_Delete.exe\\\" -ArgumentList '\\\"%1\\\"' -Verb runAs\"" | ||
|
||
|
||
[HKEY_CLASSES_ROOT\Directory\shell\Force_Delete] | ||
@="Force Delete" | ||
"Extended"=- | ||
"HasLUAShield"="" | ||
"NoWorkingDirectory"="" | ||
"Position"="middle" | ||
|
||
[HKEY_CLASSES_ROOT\Directory\shell\Force_Delete\command] | ||
@="powershell -windowstyle hidden -command \"Start-Process \\\"C:/path/to/your/Force_Delete.exe\\\" -ArgumentList '\\\"%1\\\"' -Verb runAs\"" | ||
"IsolatedCommand"= "powershell -windowstyle hidden -command \"Start-Process \\\"C:/path/to/your/Force_Delete.exe\\\" -ArgumentList '\\\"%1\\\"' -Verb runAs\"" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Windows Registry Editor Version 5.00 | ||
|
||
; hi - @z_h_ on discord | ||
|
||
|
||
|
||
[-HKEY_CLASSES_ROOT\*\shell\Force_Delete] | ||
[-HKEY_CLASSES_ROOT\*\shell\runas] | ||
|
||
[HKEY_CLASSES_ROOT\*\shell\Force_Delete] | ||
@="Force Delete" | ||
"Extended"=- | ||
"HasLUAShield"="" | ||
"NoWorkingDirectory"="" | ||
"NeverDefault"="" | ||
|
||
[HKEY_CLASSES_ROOT\*\shell\Force_Delete\command] | ||
@="powershell -windowstyle hidden -command \"Start-Process \\\"C:/path/to/your/Force_Delete.exe\\\" -ArgumentList '\\\"%1\\\"' -Verb runAs\"" | ||
"IsolatedCommand"= "powershell -windowstyle hidden -command \"Start-Process \\\"C:/path/to/your/Force_Delete.exe\\\" -ArgumentList '\\\"%1\\\"' -Verb runAs\"" | ||
|
||
|
||
[HKEY_CLASSES_ROOT\Directory\shell\Force_Delete] | ||
@="Force Delete" | ||
"Extended"=- | ||
"HasLUAShield"="" | ||
"NoWorkingDirectory"="" | ||
"Position"="middle" | ||
|
||
[HKEY_CLASSES_ROOT\Directory\shell\Force_Delete\command] | ||
@="powershell -windowstyle hidden -command \"Start-Process \\\"C:/path/to/your/Force_Delete.exe\\\" -ArgumentList '\\\"%1\\\"' -Verb runAs\"" | ||
"IsolatedCommand"= "powershell -windowstyle hidden -command \"Start-Process \\\"C:/path/to/your/Force_Delete.exe\\\" -ArgumentList '\\\"%1\\\"' -Verb runAs\"" |