Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
spelling
Source Link
B14D3
  • 5.3k
  • 16
  • 69
  • 85

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:

  1. filename with virus

    filename with virus

  2. string, which marks virus begin string

    string, which marks virus begin string

  3. 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 

i 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) 

you should give:

  1. filename with virus
  2. string, which marks virus begin string
  3. string, which marks virus end

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 befire using.

use i in this way:

python cleaner.py index.html js/jquery.js 

I 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) 

You should give:

  1. filename with virus

  2. string, which marks virus begin string

  3. 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.

Please test it, and backup before using.

Use it in this way:

python cleaner.py index.html js/jquery.js 
Source Link

i 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) 

you should give:

  1. filename with virus
  2. string, which marks virus begin string
  3. string, which marks virus end

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 befire using.

use i in this way:

python cleaner.py index.html js/jquery.js