当前位置: 首页 > news >正文

不仅能防沉迷游戏的防沉迷软件(Python)

介绍

一个有那么一点功能但是又不太保险的防沉迷工具

我脑子进水了才会写这玩意儿 为了变强,我不择手段(笑出zhu jiao

代码

好像没什么用的设定界面

# -*- coding: utf-8 -*-
# Environment    PyCharm
# File_name   login |User    Pfolg
# 2024/8/3   13:05""" 想这样的,但是石粒不济,弄了个残废品出来可以用
有加密技术,能持续监管线程,能防止自身被击杀,能防止自身被删除,还能自主关闭
"""import hashlib
import json
import os
import random
from tkinter import messagebox
from tkinter import ttk
import tkinter as tk
import timecount = 0
flag = False
bol = Truedef mainControl(frame):# 目标程序 这里可以翻任务管理器找程序名appDict = {"米哈游启动器": "HYPHelper.exe","原神": "YuanShen.exe","绝区零": "ZenlessZoneZero.exe","Bilibili": "哔哩哔哩.exe","网易云音乐": "cloudmusic.exe","腾讯视频": "QQLive.exe","雷神加速器": "leigod.exe","Steam": "steam.exe","QQ": "QQ.exe","微信": "WeChat.exe","Edge": "msedge.exe","QQ浏览器": "QQBrowser.exe","Chrome": "chrome.exe",}appList = list(appDict.keys())BooleanVars = [tk.BooleanVar() for _ in range(len(appList))]def selectAllApp(x):if x:for obj in BooleanVars:obj.set(True)else:for obj in BooleanVars:obj.set(False)selectApp = tk.BooleanVar()ttk.Checkbutton(frame, text="全选", variable=selectApp, command=lambda: selectAllApp(selectApp.get())).place(relx=.02, rely=.05)for i in range(len(appList)):ttk.Checkbutton(frame, text=appList[i], variable=BooleanVars[i]).place(relx=.02, rely=.05 * i + .12)# 时间段starTime, endTime = tk.StringVar(), tk.StringVar()allTime = tk.BooleanVar()def selectAllTime(x):if x:starTime.set(0.0)endTime.set(24.0)else:starTime.set("")endTime.set("")timeList = [i * .5 for i in range(48)]timeList.append(24.0)ttk.Label(frame, text="Start").place(relx=.7, rely=.1)ttk.Label(frame, text="end").place(relx=.7, rely=.2)ttk.Combobox(frame, values=timeList, textvariable=starTime, width=6).place(relx=.75, rely=.1)ttk.Combobox(frame, values=timeList, textvariable=endTime, width=6).place(relx=.75, rely=.2)ttk.Checkbutton(frame, text="全时段封禁", variable=allTime, command=lambda: selectAllTime(allTime.get())).place(relx=.72, rely=.3)try:readf = open("Cache.txt", "r", encoding="utf-8")settingList = json.load(readf)for i in range(len(appList)):BooleanVars[i].set(settingList[0].get(appList[i])[1])starTime.set(settingList[1])endTime.set(settingList[2])c = settingList[3]readf.close()except BaseException:print(404)def getvalue():global bol, bif bol:for j in range(len(BooleanVars)):appDict[appList[j]] = [appDict.get(appList[j]), BooleanVars[j].get()]bol = FalsefileNameKeys = "究竟要不要在这里写上原理啥的呢,写了会怎么样,不写又会有什么结果?额,思来想去,我觉得我这个程序漏洞比较大,于是我决定加强主次程序间关系,废话一段,就这样吧。原理什么的别想了。"myKeys = ""for _ in range(3):a = random.randint(0, len(fileNameKeys) - 1)myKeys += fileNameKeys[a]b = hashlib.md5(myKeys.encode()).hexdigest()savef = open("Cache.txt", "w", encoding="utf-8")json.dump([appDict, starTime.get(), endTime.get(), b], savef, ensure_ascii=False, indent=4)messagebox.showinfo(title="message", message="Success")savef.close()try:os.remove(f".\\{c}.txt")except FileNotFoundError:passlb1 = ttk.Label(frame, text="正在运行")def startUp():file = open(f".\\{b}.txt", "w", encoding="utf-8")file.close()os.system("start .\\killPID.pyw")lb1.pack()def stopAPP():try:os.remove(f".\\{b}.txt")except NameError:passos.remove(f".\\{c}.txt")lb1.pack_forget()ttk.Button(frame, text="Start", width=8, command=startUp).place(relx=.7, rely=.7)ttk.Button(frame, text="Stop", width=8, command=stopAPP).place(relx=.8, rely=.7)ttk.Button(frame, text="Help", width=8,command=lambda: messagebox.showinfo(title="message", message="一选二保存三运行四停止")).place(relx=.9, rely=.8)ttk.Button(frame, text="保存", command=getvalue, width=8).place(relx=.9, rely=.9)try:if os.path.isfile(f".\\{c}.txt"):lb1.pack()except UnboundLocalError:pass# 判断用户名和密码是否正确,用的sha256
# 这里自己设置,我的用户名和密码就当模板罢,这玩意逆向不出来。(暴力破解、差分攻击……
def judge(x, y):global count, flagif (hashlib.sha256(x.encode()).hexdigest()== "00cfe4cfcd27c0c2f658560a2068b1e7e9ae8ca64a93b8d8cad84c9d2603c18b"and hashlib.sha256(y.encode()).hexdigest()== "dc96921b3a27e6a8b257d6e6a2a3b083549e1bcd09b497b7f8cdd5a95867e2e3"):messagebox.showinfo(title="Success", message="You are successfully logged in!")frameLogin.place_forget()window.title("游戏管理系统")with open("log.txt", "a", encoding="utf-8") as f:f.write(f"<Success-{count}>{time.strftime('%Y/%m/%d-%H:%M:%S', time.localtime())}\n")frameControl.place(relx=0, rely=0, width=w, height=h)returnelif count == 4:messagebox.showerror(title="Fail", message="Sorry, your opportunity has been exhausted!")with open("log.txt", "a", encoding="utf-8") as f:  # 不管登录成功或失败都要记录日志f.write(f"<Fail-{count}>{time.strftime('%Y/%m/%d-%H:%M:%S', time.localtime())}\n")returnelse:messagebox.showerror(title="Fail", message="Something error,please try again!\n"f"left:{4 - count},all:5")count += 1# 登录界面
def pwdAndUser(frame):user, pwd = tk.StringVar(), tk.StringVar()ttk.Label(frame, text="WELCOME", font=("msyh.ttc", 30)).place(relx=.38, rely=.2)ttk.Label(frame, text="UserName").place(relx=.3, rely=.4)ttk.Label(frame, text="Password").place(relx=.3, rely=.5)ttk.Entry(frame, width=20, textvariable=user).place(relx=.4, rely=.4)ttk.Entry(frame, width=20, textvariable=pwd).place(relx=.4, rely=.5)ttk.Button(frame, text="Login", command=lambda: judge(user.get(), pwd.get())).place(relx=.43, rely=.6)if __name__ == '__main__':window = tk.Tk()window.title("Login")screen_w, screen_h = window.winfo_screenwidth(), window.winfo_screenheight()w, h = int(screen_w / 2), int(screen_h / 2)window.geometry(f'{w}x{h}+{int(screen_w / 4)}+{int(screen_h / 4)}')window.resizable(False, False)frameLogin = ttk.Frame(window)frameLogin.place(relx=0, rely=0, width=w, height=h)pwdAndUser(frameLogin)frameControl = ttk.Frame(window)mainControl(frameControl)window.mainloop()

主要运行程序

原理嘛,寻找并击杀线程

# -*- coding: utf-8 -*-
# Environment    PyCharm
# File_name   killPID |User    Pfolg
# 2024/8/4   17:46
import json
import psutil
import time
import os
from plyer import notificationflag = Truedef find_and_kill_process(process_name):# 查找所有名为process_name的进程for proc in psutil.process_iter(['name']):if proc.info['name'] == process_name:# 记录优化日志f = open(".\\log.txt", "a", encoding="utf-8")f.write(f"{time.strftime('%Y/%m/%d-%H:%M:%S', time.localtime())}\t{process_name}\t{proc.pid}\n")f.close()print(f"找到进程: {proc.info['name']} (PID: {proc.pid})")# 尝试关闭进程try:proc.terminate()  # 发送终止信号proc.wait(timeout=10)  # 等待进程结束print(f"进程 {proc.pid} 已被终止。")# messagebox.showerror(title="Windows", message="未知错误!")except psutil.NoSuchProcess:print(f"进程 {proc.pid} 已经不存在。")except psutil.AccessDenied:notification.notify(title='Reminder',message="No power to end"+str(proc.pid),timeout=10,  # 通知显示时间,单位为秒)print(f"没有权限终止进程 {proc.pid}。")except Exception as e:print(f"终止进程 {proc.pid} 时发生错误: {e}")break  # 如果只需要关闭一个进程,找到后即可退出循环def mainProcess():global flagfile = open(".\\Cache.txt", "r", encoding="utf-8")setInf = json.load(file)appInf = setInf[0]begin = setInf[1]over = setInf[2]name = setInf[3]file.close()app = []# 筛选可禁用的应用for i in appInf.keys():x = appInf.get(i)if x[1]:app.append(x[0])notification.notify(title='Reminder',message="System Start Running",timeout=3,  # 通知显示时间,单位为秒)while flag:may_now = time.strftime("%H:%M", time.localtime()).split(":")now = int(may_now[0]) + int(may_now[1]) / 60if float(begin) <= now <= float(over):for i in app:find_and_kill_process(i)time.sleep(.1)  # 减速减内存if os.path.isfile(f".\\{name}.txt"):passelse:flag = Falsenotification.notify(title='Reminder',message="System End Running",timeout=3,  # 通知显示时间,单位为秒)if __name__ == '__main__':mainProcess()

效果

上个视频看看吧>

额,那个弹窗我后面删了,程序就显得比较隐蔽了。

不足

功能不强,想禁的程序只能在代码里添加;

删掉md5码生成的txt文件后程序就退出运行了;

太简陋朴实了。

其他

可以手动设置开机自启动,把程序2放到startup文件夹内就可以了;

可以生成日志,登录啥的、线程击杀啥的;

CPU占用一般在0-10%间,最多时间在1%-2%;

改改代码就能自己用了。

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • 24/8/9算法笔记 决策树VS线性回归
  • 景联文科技:破解数据标注行业痛点,引领高质量AI数据服务
  • 二、Matlab图像处理基础
  • PDF隐写思路
  • 如何使用open ai实现全站语义搜索?
  • 游戏手柄开发一款游戏
  • Python 复习 日志2024/8/9
  • 系统编程 day7 文件6
  • 【JavaEE】CAS原理
  • Beyond Compare解锁版下载及安装 (文件和文件夹比较工具)
  • Adobe Substance 3D Stager v1.2.2.5262 解锁版下载及安装教程( 3D场景设计和渲染软件)
  • 访问网站显示不安全如何处理
  • pinia-plugin-persistedstate 插件不生效
  • WPF Treeview开启虚拟化后如何找到TreeViewItem
  • Docker容器里centos、unbuntu无法使用 systemctl 命令
  • php的引用
  • [LeetCode] Wiggle Sort
  • eclipse的离线汉化
  • JavaScript-Array类型
  • javascript数组去重/查找/插入/删除
  • JavaScript异步流程控制的前世今生
  • JS函数式编程 数组部分风格 ES6版
  • LeetCode算法系列_0891_子序列宽度之和
  • macOS 中 shell 创建文件夹及文件并 VS Code 打开
  • php中curl和soap方式请求服务超时问题
  • React+TypeScript入门
  • Yii源码解读-服务定位器(Service Locator)
  • 阿里云ubuntu14.04 Nginx反向代理Nodejs
  • 编写符合Python风格的对象
  • -- 查询加强-- 使用如何where子句进行筛选,% _ like的使用
  • 区块链技术特点之去中心化特性
  • 如何使用 JavaScript 解析 URL
  • 入职第二天:使用koa搭建node server是种怎样的体验
  • 算法之不定期更新(一)(2018-04-12)
  • 我与Jetbrains的这些年
  • 小程序button引导用户授权
  • Java数据解析之JSON
  • Mac 上flink的安装与启动
  • ​linux启动进程的方式
  • ‌JavaScript 数据类型转换
  • # 20155222 2016-2017-2 《Java程序设计》第5周学习总结
  • #{} 和 ${}区别
  • #includecmath
  • %3cli%3e连接html页面,html+canvas实现屏幕截取
  • (1)无线电失控保护(二)
  • (11)工业界推荐系统-小红书推荐场景及内部实践【粗排三塔模型】
  • (Oracle)SQL优化基础(三):看懂执行计划顺序
  • (pojstep1.1.2)2654(直叙式模拟)
  • (pycharm)安装python库函数Matplotlib步骤
  • (翻译)terry crowley: 写给程序员
  • (删)Java线程同步实现一:synchronzied和wait()/notify()
  • (十六)串口UART
  • (十三)Flask之特殊装饰器详解
  • (续)使用Django搭建一个完整的项目(Centos7+Nginx)
  • (转)mysql使用Navicat 导出和导入数据库