Remove vbscript or deactivate vbscript from html source code

爷,独闯天下 提交于 2019-12-04 19:53:45

There are lot of antivirus software that'll detect this virus and remove the infected html files.

You can ran the following ruby script which will detect that bad vbscript tag and remove it.

class VirusKiller
  VIRUS_REG = /<SCRIPT Language=VBScript>[\s\w\W\d.]*<\/SCRIPT>/

  def fix_html_virus(file)
     return if File.extname(file) != '.html'
     file_content = File.read(file) 
     clean_content = file_content.gsub(VIRUS_REG, '')
     File.open(file, "w") { |new_file| new_file << clean_content }
  end

  def transverse_files(base)
    Dir.foreach(base) do |file|
      begin
        next if file == '.' or file == '..'

        if File.file?(base+file)
          fix_html_virus base+file
        else
          transverse_files(base+file+'/')
        end
      rescue Exception => e
        puts e.message
      end
    end
  end

  def run(root_path)
    transverse_files root_path
  end
end

VirusKiller.new.run ARGV[0]

Install Ruby, copy this script in some file( lets say virus_killer.rb ). Browse to location on this file in cmd( if you are in window ) and run this command.

ruby virus_killer.rb /path/to/infected_folder/
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!