Java源代码:
在这里插入代码片package KillEndCodes;
import java.io.*;
import java.util.Scanner;
/**
* @Description: 该html病毒特征:打开html文件后,该病毒会在html文件末尾添加111KB的VBScript代码,删除后又会自动生成。
* 病毒代码:
* 解决方法:生成新的文件替换含有VBScript病毒代码的html文件。
* @Author: Java_Enthusiast
* @CreateDate: 2018/10/10 19:39
* @Version: 1.0
*/
public class KillEndCodes {
public static void main(String[] args) throws IOException {
System.out.println("请输入要扫描文件夹的完整路径:");
Scanner sc = new Scanner(System.in);
String f = sc.next();
File file = new File(f);
System.out.println("杀毒文件夹:" + file.getPath());
System.out.println("杀毒开始");
System.out.println("杀毒中,请耐心等待...");
countTime(file);
}
/**
* 计算杀毒花费的时间
*
* @param file
*/
private static void countTime(File file) {
long start = System.currentTimeMillis();
listAllFiles(file);
long end = System.currentTimeMillis();
long total_time = end - start;
System.out.println("杀毒结束");
long hour = total_time / 1000 / 60 / 60;
long minute = total_time / 1000 / 60 - hour * 60;
long second = total_time / 1000 - minute * 60 - hour * 60 * 60;
long millisecond = total_time - second * 1000 - minute * 60 * 1000 - hour * 60 * 60;
System.out.println("总耗时:" + hour + "小时" + minute + "分钟" + second + "秒" + millisecond + "毫秒");
}
/**
* 用新文件替换掉结尾含有病毒代码的文件
*
* @param file
*/
private static void replaceEndCodes(File file) {
try {
File file1 = new File(file.getParent(), file.getName().substring(0, file.getName().indexOf(".html")) + "1.html");
FileInputStream fis = new FileInputStream(file);
FileOutputStream fos = new FileOutputStream(file1);
byte[] bytes = new byte[8192];
int len = 0;
StringBuilder sb = new StringBuilder();
while ((len = fis.read(bytes)) != -1) {
String string = new String(bytes, 0, len);
if (!string.contains("