[Python][自己寫的殺病毒指令碼]
阿新 • • 發佈:2019-01-10
電腦裡的HTML都插入了一段VB病毒程式碼..只能自己手動清除了..發現Python確實好用
import os import 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();