python - PermissionError:[Errno 13] 权限被拒绝:'C:\\Windows\\System32\\catroot2\\edb.log'
问题描述
我试图扫描我的 system32 目录,但出现错误。任何人之前遇到过这个问题或任何解决方案?下面是错误。
PermissionError: [Errno 13] Permission denied: 'C:\\Windows\\System32\\catroot2\\edb.log'
下面是我的编码:
import hashlib
import os.path
import os
def md5(fname):
hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(2 ** 20), b""):
hash_md5.update(chunk)
return hash_md5.hexdigest()
viruslist = open('C:/FYP/SecuCOM2022/virusshare.md5.txt','rt')
virusinside = [l.rstrip() for l in viruslist]
def get_all_abs_paths(rootdir):
paths = list()
virus="detected"
novirus="clear"
for dirpath,_,filenames in os.walk(rootdir):
for f in filenames:
paths.append(os.path.abspath(os.path.join(dirpath, f)))
for filename in paths:
print(filename, md5(filename))
if md5(filename) in virusinside:
print(virus)
os.remove(filename)
else:
print(novirus)
filenames = get_all_abs_paths('C:\Windows\System32\catroot2')
解决方案
推荐阅读
- c# - asp DataGrid 不显示按钮行
- angular - 在组件之间交换时如何防止表单数据丢失(不刷新)?
- curl - 将多个 curl 请求导入 Postman
- csv - 从 csv 文件读取和使用值
- c# - WPF DataGrid - 如何在新添加的行上自动设置 EditMode?
- sql - 如何根据它们是否可用(非 Null)或不可用(Null)在 Oracle/SQL 中动态获取值年
- python - 计算图像中的单元格数
- datetime - Flask Appbuilder - 从 created_on,changed_on 减少小数
- xcode - 沙盒 MacOS 命令行工具
- typescript - 为什么我得到带有 jwks-rsa 模块的 webpackMissingModule?