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

windows非白名单exe监控并杀死

 需求:孩子在家用电脑上网课,总是悄悄打开游戏或视频软件

方案:指定白名单exe,打开非白名单的就自动被杀死,并记录日志供查看

不知道是否还有更好的结果方案?

import psutil
import time
import logging# 配置日志记录,禁用缓冲
logging.basicConfig(filename='killed_exes.log', level=logging.INFO, format='%(asctime)s - %(message)s', filemode='a',force=True)# 允许访问的EXE名称清单
# allowed_exes = ['notepad++.exe','SgrmBroker.exe', 'TextInputHost.exe', 'ChsIME.exe', 'HPPrintScanDoctorService.exe', 'esif_uf.exe', 'OfficeClickToRun.exe', 'smartscreen.exe', 'dllhost.exe', 'System Idle Process', 'spoolsv.exe', 'wlanext.exe', 'fontdrvhost.exe', 'PhoneExperienceHost.exe', 'FMService64.exe', 'lkads.exe', 'msedgewebview2.exe', 'WmiApSrv.exe', 'LAVService.exe', 'Lenovo.Modern.ImController.exe', 'NisSrv.exe', 'explorer.exe', 'NVDisplay.Container.exe', 'dasHost.exe', 'Lsf.exe', 'System', 'MSOfficePLUSService.exe', 'AggregatorHost.exe', 'ldnews.exe', 'SogouCloud.exe', 'DAX3API.exe', 'usysdiag.exe', 'audiodg.exe', 'tagsrv.exe', 'csrss.exe', 'StartMenuExperienceHost.exe', 'NvTelemetryContainer.exe', 'SecurityHealthService.exe', 'rundll32.exe', 'MemCompression', 'svchost.exe', 'nimxs.exe', 'crashpad_handler.exe', 'IShowServer.exe', 'service.exe', 'sihost.exe', 'chrome.exe', 'MsMpEng.exe', 'dwm.exe', 'pdfServer.exe', 'PdsClientsDaemon.exe', 'LenovoTray.exe', 'Locator.exe', 'DSRHost.exe', 'RtkAudUService64.exe', 'Registry', 'Everything.exe', 'SearchIndexer.exe', 'Lenovo.Modern.ImController.PluginHost.Device.exe', 'lktsrv.exe', 'SecurityHealthSystray.exe', 'IShowSU.exe', 'SunloginClient.exe', 'nidmsrv.exe', 'RuntimeBroker.exe', 'unsecapp.exe', 'LenovoInternetSoftwareFramework.exe', 'python.exe', 'PDFEngine.exe', 'SearchApp.exe', 'ctfmon.exe', 'sqlwriter.exe', 'CastSrv.exe', 'taskhostw.exe', 'WmiPrvSE.exe', 'mDNSResponder.exe', 'niauth_daemon.exe', 'CompPkgSrv.exe', 'LISFService.exe', 'TestStandService.exe', 'LnvSvcFdn.exe', 'MSPCManagerService.exe', 'jhi_service.exe', 'fsnotifier.exe', 'smss.exe', 'conhost.exe', 'MpDefenderCoreService.exe', 'LenovoPcManagerService.exe', 'WUDFHost.exe', 'LockApp.exe', 'MSPCManager.exe', 'services.exe', 'lsass.exe', 'rsSyncSvc.exe', 'pycharm64.exe', 'wininit.exe', 'aDrive.exe', 'winlogon.exe', 'SyncAppServer.exe', 'LMS.exe', 'SogouImeBroker.exe']
allowed_exes = ['LnvSvcFdn.exe', 'services.exe', 'LenovoPcManagerService.exe', 'SogouImeBroker.exe','SyncAppServer.exe', 'Lenovo.Modern.ImController.PluginHost.Device.exe', 'PDFEngine.exe', 'Locator.exe','winlogon.exe', 'SgrmBroker.exe', 'taskhostw.exe', 'Typora.exe', 'nidmsrv.exe', 'DAX3API.exe','WINWORD.EXE', 'CalculatorApp.exe', 'aDrive.exe', '猿辅导.exe', 'SecurityHealthSystray.exe','MSPCManager.exe', 'WmiApSrv.exe', 'SunloginClient.exe', 'WmiPrvSE.exe', 'dwm.exe', 'sqlwriter.exe','SearchIndexer.exe', 'fontdrvhost.exe', 'WUDFHost.exe', 'rundll32.exe', 'smss.exe', 'FMService64.exe','YunDetectService.exe', 'iPDF Viewer.exe', 'wininit.exe', 'tagsrv.exe', 'dllhost.exe', 'NisSrv.exe','CodeSetup-stable-ea1445cc7016315d0f5728f8e8b12a45dc0a7286.tmp', 'MindMaster.exe', 'usysdiag.exe','System', 'iPDFUpg.exe', 'TestStandService.exe', 'Everything.exe', 'StartMenuExperienceHost.exe','nimxs.exe', 'ldnews.exe', 'DSRHost.exe', 'LenovoInternetSoftwareFramework.exe', 'LockApp.exe','wlanext.exe', 'IShowSU.exe', 'csrss.exe', 'LAVService.exe', 'SGTool.exe', 'MsMpEng.exe','Lenovo.Modern.ImController.exe', 'notepad++.exe', 'BaiduNetdiskUnite.exe', 'RtkAudUService64.exe','SearchFilterHost.exe', 'Registry', 'rsSyncSvc.exe', '小猿优课.exe', 'lsass.exe','mmcrashpad_handler64.exe', 'Video.UI.exe', 'PdsClientsDaemon.exe', 'pdfServer.exe', 'sihost.exe','Code.exe', 'OfficeClickToRun.exe', 'explorer.exe', 'svchost.exe', 'WiseOS.exe', 'BaiduNetdisk.exe','WeChatOCR.exe', 'smartscreen.exe', 'CompPkgSrv.exe', 'jhi_service.exe', 'LenovoTray.exe', 'ctfmon.exe','SearchApp.exe', 'Lsf.exe', 'PhoneExperienceHost.exe','CodeSetup-stable-ea1445cc7016315d0f5728f8e8b12a45dc0a7286.exe', 'AggregatorHost.exe', 'wemeetapp.exe','niauth_daemon.exe', 'msedgewebview2.exe', 'SnippingTool.exe', 'dasHost.exe', 'unsecapp.exe','IShowServer.exe', 'baidunetdiskhost.exe', 'lkads.exe', 'WeChat.exe', 'lktsrv.exe','NVDisplay.Container.exe', 'pycharm64.exe', 'audiodg.exe', 'esif_uf.exe', 'System Idle Process','WeChatAppEx.exe', 'SearchProtocolHost.exe', 'MemCompression', 'python.exe', 'plugin_host.exe','MpDefenderCoreService.exe', 'LISFService.exe', 'EXCEL.EXE', 'WeChatUtility.exe','crashpad_handler.exe', 'ai.exe', 'WeChatPlayer.exe', 'fsnotifier.exe', 'TextInputHost.exe','spoolsv.exe', 'splwow64.exe', 'NvTelemetryContainer.exe', 'ChsIME.exe', 'conhost.exe','MSPCManagerService.exe', 'MSOfficePLUSService.exe', 'SogouCloud.exe', 'UserOOBEBroker.exe','HPPrintScanDoctorService.exe', 'RuntimeBroker.exe', 'service.exe', 'FSCapture-动态截图工具.exe','xnnexternal.exe', 'SecurityHealthService.exe', 'ApplicationFrameHost.exe', 'mDNSResponder.exe','sublime_text.exe', 'LMS.exe', 'CastSrv.exe','cmd.exe','wemeetcrashhandler.exe','backgroundTaskHost.exe','WMIC.exe','Appvant.exe']def is_allowed_exe(exe_name):"""检查EXE名称是否在允许访问的清单中"""return exe_name.lower() in [name.lower() for name in allowed_exes]def kill_process(process_name):"""杀死某个进程并记录到日志文件中"""for proc in psutil.process_iter():try:if process_name.lower() == proc.name().lower():proc.kill()logging.info(f"{process_name} killed")print(f"{process_name} 已被杀死")# 手动刷新缓冲区logging.getLogger().handlers[0].flush()except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):passdef monitor_and_kill_unallowed_exes(interval=1):"""监控并杀死不在允许访问清单中的EXE"""while True:for proc in psutil.process_iter():try:exe_name = proc.name()if not is_allowed_exe(exe_name):print(f"{exe_name} 不在允许访问清单中")kill_process(exe_name)except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):passtime.sleep(interval)if __name__ == "__main__":monitor_and_kill_unallowed_exes()

相关文章:

  • 飞时达软件,揭开土方工程师的生活“面纱”
  • 数据库操作语言(DML)
  • jQuery 实例:掌握 JavaScript 库的奥秘
  • 番外篇 | YOLOv8改进之即插即用全维度动态卷积ODConv + 更换Neck网络为GFPN
  • Android adb logcat日志过滤输出
  • 【Windows】Bootstrap Studio(网页设计)软件介绍及安装步骤
  • MySQL之主从同步、分库分表
  • 0704模拟记录
  • 销毁终结者:IT 采购必知:高效数据销毁服务 文件销毁 硬盘销毁 数据销毁 销毁
  • [ruby on rails]rails6.0升级6.1
  • Paragon NTFS与Tuxera NTFS有何区别 Mac NTFS 磁盘读写工具选哪个好
  • 一文解开关于UWB定位技术的认识误区
  • vue模板语法v-html
  • 搜狗输入法产品使用说明
  • 免杀笔记 ---> PE
  • 时间复杂度分析经典问题——最大子序列和
  • CSS进阶篇--用CSS开启硬件加速来提高网站性能
  • express.js的介绍及使用
  • Java 网络编程(2):UDP 的使用
  • Javascript设计模式学习之Observer(观察者)模式
  • SpriteKit 技巧之添加背景图片
  • 阿里中间件开源组件:Sentinel 0.2.0正式发布
  • 测试开发系类之接口自动化测试
  • 初探 Vue 生命周期和钩子函数
  • 从零开始在ubuntu上搭建node开发环境
  • 大整数乘法-表格法
  • 解析 Webpack中import、require、按需加载的执行过程
  • 批量截取pdf文件
  • 设计模式 开闭原则
  • 视频flv转mp4最快的几种方法(就是不用格式工厂)
  • 我的zsh配置, 2019最新方案
  • 我是如何设计 Upload 上传组件的
  • 详解NodeJs流之一
  • 用jquery写贪吃蛇
  • Salesforce和SAP Netweaver里数据库表的元数据设计
  • 继 XDL 之后,阿里妈妈开源大规模分布式图表征学习框架 Euler ...
  • ​如何使用ArcGIS Pro制作渐变河流效果
  • ​油烟净化器电源安全,保障健康餐饮生活
  • #HarmonyOS:软件安装window和mac预览Hello World
  • #Linux(Source Insight安装及工程建立)
  • #window11设置系统变量#
  • (C++)栈的链式存储结构(出栈、入栈、判空、遍历、销毁)(数据结构与算法)
  • (阿里云万网)-域名注册购买实名流程
  • (附源码)ssm跨平台教学系统 毕业设计 280843
  • (经验分享)作为一名普通本科计算机专业学生,我大学四年到底走了多少弯路
  • (七)MySQL是如何将LRU链表的使用性能优化到极致的?
  • (十八)devops持续集成开发——使用docker安装部署jenkins流水线服务
  • (十八)三元表达式和列表解析
  • (转)C#调用WebService 基础
  • (自适应手机端)响应式新闻博客知识类pbootcms网站模板 自媒体运营博客网站源码下载
  • *(长期更新)软考网络工程师学习笔记——Section 22 无线局域网
  • **PHP分步表单提交思路(分页表单提交)
  • ..thread“main“ com.fasterxml.jackson.databind.JsonMappingException: Jackson version is too old 2.3.1
  • .Net 8.0 新的变化
  • .NET NPOI导出Excel详解