首页 > 解决方案 > 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')

标签: pythonhashdirectorymd5

解决方案


推荐阅读