[Python][自己写的杀病毒脚本]

来源:互联网 发布:php 获取pathinfo 编辑:程序博客网 时间:2024/06/06 10:55

电脑里的HTML都插入了一段VB病毒代码..只能自己手动清除了..发现Python确实好用

import osimport re;Root = ["H:"];for root in Root:    for rt, dirs, files in os.walk(root):        for f in files:            fname = os.path.splitext(f)            if fname[1]=='.html' :                 fileString=rt+'\\'+f                print(fileString)                htmlfile=open(fileString,"r+");                Filecontent=htmlfile.read();                Filecontent=str(Filecontent);                NewFilecontent=re.sub("<SCRIPT Language=VBScript>[\s\S]*","",Filecontent);                htmlfile.close();                htmlfile=open(fileString,"w+");                htmlfile.write(NewFilecontent);                htmlfile.close();
0 0