redlof worm cure
When RedLof worm was wrecking havoc on my files, and NAV was deleting all my data, i wrote a small utility that removes infected portions from infected files...
Unfortunately, i knew only Java at that time, so sorry if this program sucks.. but it does its job perfectly..
Unfortunately, i knew only Java at that time, so sorry if this program sucks.. but it does its job perfectly..
/** Cure for HTML.Redlof.A virus
* Copyright (C) Anurag
*/
import java.io.*;
import java.util.*;
public class redlof
{
public static void main(String args[])
{
System.out.println("Virus Repair tool <HTML.Redlof.A>\n");
if (args.length==0)
{
System.out.println("Usage : java redlof [directory]");
System.exit(0);
}
String loc=args[0];
System.out.println("\n\n ****** Initializing Virus Remover ****** ");
System.out.println("Searching : "+loc);
redlof virus=new redlof();
virus.scanFiles(new File(loc),new Vector(),"htm");
virus.scanFiles(new File(loc),new Vector(),"html");
virus.scanFiles(new File(loc),new Vector(),"asp");
}
public void scanFiles(File f, Vector htmlList, String fileExtn)
{
if (f.isDirectory())
{
String[] list = f.list();
if (list != null)
{
for (int i = 0; i < list.length; i++)
{
scanFiles(new File(f, list[i]), htmlList,fileExtn);
}
}
}
else
{
if (f.getName().toLowerCase().endsWith(fileExtn))
{
htmlList.addElement(f.getAbsolutePath());
openfile(f.getAbsolutePath());
}
}
}
void openfile(String filename)
{
System.out.print("Scanning file : "+filename);
String content="";
byte b[];
long nob;
try
{
RandomAccessFile raf=new RandomAccessFile(filename,"rw");
nob=raf.length();
if(nob<11519)
return ;
b=new byte[(int)nob];
System.out.println(" ## Size = "+nob);
raf.seek(0);
raf.read(b);
content=(new String(b));
checkinfected(content,filename);
raf.close();
}
catch(Exception e)
{
}
}
void checkinfected(String src,String filename)
{
int infected=src.indexOf("vbscript:KJ_start()");
if (infected==-1)
{
return;
}
else
{
cure(filename);
}
}
void cure(String filename)
{
System.out.println("Repairing file : "+filename);
byte b[];
long nob;
try
{
RandomAccessFile raf=new RandomAccessFile(filename,"rw");
nob=raf.length();
b=new byte[(int)nob];
raf.setLength(raf.length()-11516);
raf.close();
}
catch(Exception e)
{
}
}
}

