python病毒 vol.6
2025-06-24 14:28:21
发布于:广东
import tkinter as tk
from tkinter import messagebox
import random
import platform
import subprocess
import os
import time
import threading
import ctypes
from ctypes import wintypes
class Popup:
"""弹窗类,管理弹窗生命周期"""
_all_popups = []
def __init__(self, root, window_id):
self.root = root
self.window_id = window_id
def close(self):
"""关闭弹窗并清理引用"""
if self.root and self.root.winfo_exists():
self.root.destroy()
if 0 <= self.window_id < len(Popup._all_popups):
Popup._all_popups[self.window_id] = None
Popup._all_popups = [p for p in Popup._all_popups if p is not None]
class ScreenInverter:
"""屏幕反色管理器"""
_instance = None
_is_inverted = False
_platform = platform.system()
@staticmethod
def get_instance(root):
if ScreenInverter._instance is None:
ScreenInverter._instance = ScreenInverter(root)
return ScreenInverter._instance
def __init__(self, root):
self.root = root
self._overlay = None
if self._platform == "Windows":
self._user32 = ctypes.windll.user32
class KBDINPUT(ctypes.Structure):
_fields_ = [
("wVk", ctypes.c_ushort),
("wScan", ctypes.c_ushort),
("dwFlags", ctypes.c_ulong),
("time", ctypes.c_ulong),
("dwExtraInfo", ctypes.POINTER(ctypes.c_ulong))
]
class INPUT(ctypes.Structure):
_fields_ = [
("type", ctypes.c_ulong),
("ki", KBDINPUT)
]
self._KBDINPUT = KBDINPUT
self._INPUT = INPUT
self._INPUT_KEYBOARD = 1
self._KEYEVENTF_KEYUP = 2
self._VK_LWIN = 0x5B
self._VK_CONTROL = 0x11
self._VK_I = 0x49
def invert_screen(self, duration_ms):
threading.Thread(target=self._invert_and_restore, args=(duration_ms,), daemon=True).start()
def _invert_and_restore(self, duration_ms):
self._enable_inversion()
time.sleep(duration_ms / 1000.0)
self._disable_inversion()
def _enable_inversion(self):
if self._platform == "Windows":
self._send_key_combo([self._VK_LWIN, self._VK_CONTROL, self._VK_I])
else:
self._fallback_invert()
def _disable_inversion(self):
if self._platform == "Windows":
self._send_key_combo([self._VK_LWIN, self._VK_CONTROL, self._VK_I])
elif self._overlay and self._overlay.winfo_exists():
self._overlay.destroy()
def _send_key_combo(self, vk_codes):
extra_info = ctypes.pointer(ctypes.c_ulong(0))
inputs = []
for vk in vk_codes:
ki = self._KBDINPUT(
wVk=vk,
wScan=0,
dwFlags=0,
time=0,
dwExtraInfo=extra_info
)
inputs.append(self._INPUT(type=self._INPUT_KEYBOARD, ki=ki))
time.sleep(0.1)
for vk in reversed(vk_codes):
ki = self._KBDINPUT(
wVk=vk,
wScan=0,
dwFlags=self._KEYEVENTF_KEYUP,
time=0,
dwExtraInfo=extra_info
)
inputs.append(self._INPUT(type=self._INPUT_KEYBOARD, ki=ki))
time.sleep(0.1)
ctypes_array = (self._INPUT * len(inputs))(*inputs)
self._user32.SendInput(len(inputs), ctypes.byref(ctypes_array), ctypes.sizeof(self._INPUT))
def _fallback_invert(self):
if self._overlay and self._overlay.winfo_exists():
self._overlay.destroy()
self._overlay = tk.Toplevel(self.root)
self._overlay.attributes('-fullscreen', True)
self._overlay.attributes('-alpha', 0.5)
self._overlay.configure(bg='black')
self._overlay.overrideredirect(True)
self._overlay.lift()
self._overlay.attributes('-topmost', True)
def get_screen_info():
"""获取屏幕信息"""
root = tk.Tk()
root.withdraw()
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
root.destroy()
return {"width": screen_width, "height": screen_height}
def lonlat_to_window(lon, lat, win_width, win_height):
"""将经纬度转换为窗口左上角坐标"""
screen = get_screen_info()
scr_center_x, scr_center_y = screen["width"] / 2, screen["height"] / 2
lon_factor = (screen["width"] * 0.8) / 360
lat_factor = (screen["height"] * 0.8) / 720
center_x = scr_center_x + lon * lon_factor
center_y = scr_center_y + lat * lat_factor
left_x = int(center_x - win_width / 2)
top_y = int(center_y - win_height / 2)
left_x = max(10, min(left_x, screen["width"] - win_width - 10))
top_y = max(10, min(top_y, screen["height"] - win_height - 10))
return left_x, top_y
def mgx(x, y, n, message="ERROR", title="系统错误", size="m"):
"""创建弹窗 - 支持自定义尺寸"""
screen = get_screen_info()
root = tk.Toplevel()
root.title(title)
# 根据尺寸参数设置窗口大小
if size == "b": # 屏幕的1/4
win_width = int(screen["width"] / 2)
win_height = int(screen["height"] / 2)
elif size == "o": # 全屏
win_width = screen["width"]
win_height = screen["height"]
root.attributes('-fullscreen', True)
else: # 默认中等尺寸
win_width = int(min(300, screen["width"] * 0.25))
win_height = int(min(180, screen["height"] * 0.2))
left_x, top_y = lonlat_to_window(x, y, win_width, win_height)
if size != "o": # 全屏模式不需要设置geometry
root.geometry(f"{win_width}x{win_height}+{left_x}+{top_y}")
root.attributes("-topmost", True)
root.resizable(False, False)
scale_ratio = min(screen["width"] / 1920, screen["height"] / 1080)
# 根据窗口大小调整字体
base_font_size = 14 if size == "m" else (20 if size == "b" else 28)
err_font = max(10, int(base_font_size * scale_ratio))
btn_font = max(8, int((base_font_size - 4) * scale_ratio))
main_frame = tk.Frame(root, padx=int(15 * scale_ratio), pady=int(15 * scale_ratio))
main_frame.pack(fill="both", expand=True)
msg_label = tk.Label(
main_frame, text=message, font=("SimHei", err_font, "bold"),
fg="#E63946", wraplength=win_width-30 if size != "o" else screen["width"]-60,
justify="center", pady=int(12 * scale_ratio)
)
msg_label.pack(fill="both", expand=True)
if size != "o": # 全屏模式不显示关闭按钮
btn_frame = tk.Frame(main_frame)
btn_frame.pack(pady=int(8 * scale_ratio))
tk.Button(
btn_frame, text="关闭", command=root.destroy,
width=8, height=1, font=("SimHei", btn_font),
bg="#E63946", fg="white", relief=tk.RAISED, bd=2
).pack()
root.protocol("WM_DELETE_WINDOW", root.destroy)
# 确保窗口显示
root.update_idletasks()
root.deiconify()
window_id = len(Popup._all_popups)
popup = Popup(root, window_id)
Popup._all_popups.append(popup)
return root, n
def create_windows11_blue_screen(root, duration=7000):
"""创建更逼真的Windows 11风格蓝屏效果,包含错误代码和详细信息"""
bsod = tk.Toplevel(root)
bsod.attributes('-fullscreen', True)
bsod.configure(bg='#0078D7') # Windows 11 蓝屏颜色
bsod.overrideredirect(True)
bsod.attributes('-topmost', True)
screen_width = bsod.winfo_screenwidth()
screen_height = bsod.winfo_screenheight()
# 创建主框架,添加内边距
main_frame = tk.Frame(bsod, bg='#0078D7')
main_frame.pack(fill="both", expand=True, padx=50, pady=30)
# 错误标题
title_font_size = min(32, int(screen_height / 30))
title_label = tk.Label(
main_frame,
text="CRITICAL_PROCESS_DIED", # 经典蓝屏错误代码
font=("Segoe UI", title_font_size, "bold"),
fg="white",
bg="#0078D7"
)
title_label.pack(pady=(screen_height // 10, 20), anchor="w")
# 错误描述
desc_font_size = min(18, int(screen_width / 100))
desc_label = tk.Label(
main_frame,
text="你的电脑遇到问题,需要重新启动。我们正在收集错误信息,然后为你重新启动。",
font=("Segoe UI", desc_font_size),
fg="white",
bg="#0078D7",
wraplength=screen_width * 0.8,
justify="left"
)
desc_label.pack(pady=10, anchor="w")
# 进度条
progress_frame = tk.Frame(main_frame, bg='#0078D7', height=10)
progress_frame.pack(fill="x", padx=screen_width * 0.1, pady=20, anchor="w")
progress_bar = tk.Canvas(
progress_frame,
bg='#005A9E', # 进度条背景色
highlightthickness=0
)
progress_bar.pack(fill="both", expand=True)
progress_rect = progress_bar.create_rectangle(
0, 0, 0, progress_frame.winfo_reqheight(),
fill='white', # 进度条填充色
outline=''
)
# 错误代码和技术信息
info_font_size = min(14, int(screen_width / 120))
info_text = (
"如果您想了解有关此错误的详细信息,以及可能的解决方法,请访问 "
"https://windows.com/stopcode\n"
"如果致电支持人员,请向他们提供以下信息:\n"
"STOP: 0x000000EF (0x00000000, 0x00000000, 0x00000000, 0x00000000)\n\n"
"CRITICAL_PROCESS_DIED"
)
info_label = tk.Label(
main_frame,
text=info_text,
font=("Consolas", info_font_size), # 使用等宽字体增强真实感
fg="white",
bg="#0078D7",
wraplength=screen_width * 0.9,
justify="left",
anchor="w"
)
info_label.pack(pady=15, anchor="w")
# 底部状态信息
bottom_font_size = min(12, int(screen_width / 140))
bottom_text = (
"正在收集 100% 的系统数据\n"
"完成后将自动重启"
)
bottom_label = tk.Label(
main_frame,
text=bottom_text,
font=("Segoe UI", bottom_font_size),
fg="white",
bg="#0078D7",
justify="left",
anchor="w"
)
bottom_label.pack(pady=10, side="bottom", anchor="sw")
# 更真实的进度条更新(模拟Windows风格)
def update_progress(current_percent=0):
if not bsod.winfo_exists():
return
# 模拟Windows进度条的波动效果
if current_percent < 30:
# 开始阶段进度较慢
progress_speed = random.randint(1, 3)
elif current_percent < 70:
# 中间阶段进度较快
progress_speed = random.randint(2, 5)
else:
# 最后阶段又变慢,模拟完成前的最终检查
progress_speed = random.randint(1, 2)
new_percent = min(current_percent + progress_speed, 100)
# 更新进度条
progress_width = progress_frame.winfo_width() * new_percent / 100
progress_bar.coords(progress_rect, 0, 0, progress_width, progress_frame.winfo_reqheight())
# 更新底部状态文本
if new_percent < 100:
bottom_label.config(text=f"正在收集 {new_percent}% 的系统数据\n完成后将自动重启")
else:
bottom_label.config(text="正在准备重启...")
if new_percent < 100:
# 随机延迟,模拟真实进度更新
delay = random.randint(50, 200)
root.after(delay, update_progress, new_percent)
else:
# 进度完成后延迟一段时间再重启
root.after(2000, close_all_popups_and_quit, root)
# 开始更新进度条
update_progress()
def close_all_popups_and_quit(root):
"""关闭所有弹窗并退出程序"""
# 关闭所有弹窗
for popup in Popup._all_popups[:]:
if popup:
popup.close()
# 关闭屏幕反色(如果启用)
inverter = ScreenInverter.get_instance(root)
if inverter._overlay and inverter._overlay.winfo_exists():
inverter._overlay.destroy()
# 退出主程序
root.quit()
def create_popups_in_batches(popup_data, batch_size=4, index=0, root=None, inverter=None):
"""按批次创建弹窗,每批次显示batch_size个弹窗"""
if index >= len(popup_data):
root.after(1000, lambda: create_windows11_blue_screen(root)) # 使用新的蓝屏函数
return
# 获取当前批次的弹窗数据
batch = popup_data[index:index + batch_size]
# 分离弹窗和命令(如反色)
popups_in_batch = []
commands_in_batch = []
for item in batch:
if isinstance(item, tuple) and len(item) >= 5:
popups_in_batch.append(item)
elif callable(item) and item.__name__ == 'fanse':
commands_in_batch.append(item)
# 执行批次中的命令(如反色)
for cmd in commands_in_batch:
duration = cmd()
inverter.invert_screen(duration)
# 计算当前批次的最大显示时间
max_delay = 0
for item in popups_in_batch:
delay = item[2] # 假设第三个元素是延迟时间
if delay > max_delay:
max_delay = delay
# 批量创建弹窗
def create_batch_popups():
for item in popups_in_batch:
x, y, n, message, title = item[:5]
size = item[5] if len(item) > 5 else "m"
mgx(x, y, n, message, title, size)
root.update_idletasks() # 立即更新UI,确保弹窗同步显示
# 直接调用弹窗创建函数,不使用延迟
create_batch_popups()
# 等待当前批次的弹窗显示完成后,处理下一批次
root.after(max_delay + 300, create_popups_in_batches, popup_data, batch_size, index + batch_size, root, inverter)
def fanse(n):
"""创建反色命令"""
def execute_fanse():
return n
execute_fanse.__name__ = 'fanse'
return execute_fanse
if __name__ == "__main__":
root = tk.Tk()
root.withdraw()
inverter = ScreenInverter.get_instance(root)
# 示例弹窗数据 - 增加显示时间以便观察
popup_data = [
(180, 360, 40, "我的主场!你完了!", "CRITICAL", "o"),
(-180, -360, 50, "ERROR", "系统错误"),
(180, -360, 50, "ERROR", "系统错误"),
(-180, 360, 50, "ERROR", "系统错误"),
(180, 360, 50, "ERROR", "系统错误"),
(-140, -320, 0, "ERROR", "系统错误"),
(140, -320, 0, "ERROR", "系统错误"),
(-140, 320, 0, "ERROR", "系统错误"),
(140, 320, 0, "ERROR", "系统错误"),
(-100, -300, 50, "ERROR", "系统错误"),
(100, -300, 0, "ERROR", "系统错误"),
(-100, 300, 0, "ERROR", "系统错误"),
(100, 300, 0, "ERROR", "系统错误"),
(0, 0, 50, "ERROR", "系统错误"),
(0, 100, 0, "ERROR", "系统错误"),
(0, -100, 0, "ERROR", "系统错误"),
(100, 0, 0, "ERROR", "系统错误"),
(-100, 0, 0, "ERROR", "系统错误"),
(0, 200, 50, "ERROR", "系统错误"),
(0, -200, 0, "ERROR", "系统错误"),
(180, 0, 0, "ERROR", "系统错误"),
(-180, 0, 0, "ERROR", "系统错误"),
(0, 300, 50, "ERROR", "系统错误"),
(0, -300, 0, "ERROR", "系统错误"),
(10, 0, 0, "ERROR", "系统错误"),
(-10, 0, 0, "ERROR", "系统错误"),
(-180, -360, 200, "系统错误", "警告", "m"),
(180, -360, 0, "内存不足", "警告", "b"), # time=0,与下一个同时显示
(-180, 360, 0, "磁盘错误", "警告", "m"), # time=0,与上一个同时显示
(180, 360, 300, "系统崩溃", "CRITICAL", "o"),
(-140, -320, 0, "网络错误", "警告", "m"), # time=0,与下一个同时显示
(140, -320, 0, "程序异常", "警告", "b"), # time=0,与上一个同时显示
(-140, 320, 200, "系统错误", "警告", "m"),
(140, 320, 0, "数据丢失", "ERROR", "o"), # time=0,与下一个同时显示
(-100, -300, 0, "硬件故障", "警告", "m"), # time=0,与上一个同时显示
(100, -300, 200, "系统错误", "警告", "b"),
(-100, 300, 0, "文件损坏", "警告", "m"), # time=0,与下一个同时显示
(100, 300, 0, "驱动程序错误", "警告", "b"), # time=0,与上一个同时显示
(0, 0, 500, "严重系统错误", "CRITICAL", "o"),
*[(random.uniform(-180, 180), random.uniform(-360, 360),
random.choice([0, 50, 100]), "系统错误", "警告", random.choice(["m", "b"])) for _ in range(10)],
fanse(2000),
(-180, -360, 0, "ERROR", "系统错误"), # 显示2秒
(180, -360, 0, "ERROR", "系统错误"),
(-180, 360, 0, "ERROR", "系统错误"),
(180, 360, 0, "ERROR", "系统错误"),
(-140, -320, 20, "ERROR", "系统错误"),
(140, -320, 20, "ERROR", "系统错误"),
(-140, 320, 20, "ERROR", "系统错误"),
(140, 320, 20, "ERROR", "系统错误"),
# 更多弹窗...
(-180, -360, 30, "系统错误", "警告", "m"),
(180, -360, 30, "内存不足", "警告", "b"),
(-180, 360, 30, "磁盘错误", "警告", "m"),
# 随机弹窗
*[(random.uniform(-180, 180), random.uniform(-360, 360),
2000, "系统错误", "警告", random.choice(["m", "b"])) for _ in range(10)],
fanse(2000),
]
# 调用弹窗批处理函数,每4个弹窗一起显示
root.after(100, lambda: create_popups_in_batches(popup_data, 4, 0, root, inverter))
root.mainloop()
只是一个观赏类病毒,不会对电脑造成伤害!
程序会自动退出,可以放心运行
最后有好东西
更新日志
.vol.1 25/6/21 基本引擎
.vol.2 25/6/22 加内容
.vol.3 25/6/22 改bug
.vol.4 25/6/22 还是改bug
.vol.5 25/6/23 加内容
.vol.5 25/6/26 还是加内容
这里空空如也
有帮助,赞一个