iI wrote such script, it could be useful.
#!/usr/bin/env python import os import sys for infile in sys.argv[1:]: print infile filetmp=infile+'.tmp' BEGIN='<!--2d3965-->' END='<!--/2d3965-->' f = open(infile, 'r') ftmp = open(filetmp, 'w') skip=False for line in f: if BEGIN in line: #print line.partition(BEGIN)[0] ftmp.write(line.partition(BEGIN)[0]) skip=True if END in line: #print line.partition(END)[2] ftmp.write(line.partition(END)[2]) skip=False else: if not skip: ftmp.write(line) #you can add save restrictions here os.rename(filetmp, infile) youYou should give:
- filename with virus
filename with virus
- string, which marks virus begin string
string, which marks virus begin string
- string, which marks virus end
string, which marks virus end
Don't forget to change permissions back, if file requires it. btw, I think, it's appliable only for text files.
and, not forget to change permissions back, if file requires it. btw, I think, its appliable only for text files.
Please test it, and backup befirebefore using.
use iUse it in this way:
python cleaner.py index.html js/jquery.js