Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Help Me Please For Antivirus Coding Problem In C (http://www.go4expert.com/forums/help-antivirus-coding-c-t7284/)

dragosam 13Nov2007 22:10

Help Me Please For Antivirus Coding Problem In C
 
please help i have developed an antivirus programme code in c language

which fights for ashar virus whos details are


Ashar virus is also known as paralyse virus

Its charachteristic features are :

1) It comes as “(c) Brain “ or ( c) ashar”

Where ( c ) stands for copyright in the volume label

of affected disk.

2) it resides in the boot record and is entirely a memory

Resident programme occupying 3 to4 kilobytes
i am attching its source code

please help me it shows many errors when i run it

please help me as soon as possible i have to submit that programme code

latest by 15 nov 2007

please make it working by correcting it and you can post it to my email id

dragokartik@yahoo.co.in
CODE IS AS FOLLOWS


Code:

#include<dos.h>
#include<dir.h>
#include<string.h>
void main()

{

  int virus_found,more;

  virus_found=RAM_Test();

  if(virus_found)
  {

    Reset_INT13();

    clean_Disk('F')  ;

  }

  while(1)
  {
    printf("\n\nMore diskette to clean ?  Y/N");

    more=toupper(getch());

    while(more!='Y' &&more!='N')
        more=toupper(getch());

    if(more=='N') exit(0);
      clean_Disk(more);

  }
  }

  /* End of program */

  /* Routine to check Ram for virus */

  RAM_Test()
{
  unsigned int vseg,voff;

  void interrupt(*v)(void);

  printf("\n\n RAM checking____");

  v=getvect(109);
  vseg=FP_SEG(v);
  voff=FP_OFF(v);
  if(vseg!=0x0 && voff=0x0)
  {
    printf("virus detected :-");
    putch(7);return(1);
    }
    else
    {
    printf("ok\n\n");
    putch(7);putch(7);return(0);
    }
}
    /*end of routine ram test*/

  /*ROUTINE TO RESETINT 13H*/
 Reset_INT13()
{
    unsigned int vseg,voff;

    void interrupt(*v)(void);
    v=getvect(109);
    vseg=FP_SEG(v);voff=FP_OFF(v);
    poke(0,76,voff);poke(0,78,vseg);
    printf("disabled\n");
}
  /*end of routine Reset_INT13*/

  /*Routine to clean diskette*/

 clean_Disk(next)
 char next;
{
 clean_Boot_sector(next);
 clean_Data_Area();
 change_Label();
}
/* end of routine clean disk*/

clean_Boot_sector(next_disk)
char next_disk;
{
 int ans,i,True;
 static void *buf[512];
 char virus[6],ashar[]="ashar",brain[]="Brain";
 if(next_disk=='F')
 True=1;
 else True=0;
 while(True)
 {
  printf("\ninsert dos diskettein drive A____WAITING\n");
  ans=getch();
  ans=absread(0,1,0,buf);
  virus=ashar;
  ans=chkboot(buf,&virus);
  virus=brain;
  ans=ans&&chkboot(buf,&virus);
  if(!ans)
  {
    printf("\nBoot sector infected with virus\n") ;
  }
  else
  break;
 }
 printf("\n insert infected disk in drive A_________ waiting\n\n\n");
 ans=getch();
 ans=abswrite(0,1,0,buf);
 if(ans)
 printf("\n unable to clean disk\n");
}

/*end of routine clean boot record*/

/*subroutine to check virus*/
 /*boot routine*/
 chkboot(str,name)
 char str[512],name[6];
 {
  int i,k;
  for(i=0,k=0;i<512;i++)
  if(str[i]==name[k])
  {
    k++;
    if(k==5)
    return(0);
    else
    continue;
  }
  else
  k=0;
  return(1);
  }

  /*end of sub routine chk boot*/

  /*routine to clean virus*/
  /* executive routine*/

  clean_Data_Area()
{
  int i,j;
  float rj;
  unsigned int fat_off,fat_dmp;
  unsigned dmp_sav;
  unsigned char fatbuf[1024],b1,b2;
  absread(0,2,1,fatbuf);j=0;

  for(i=2;i<355;i++)
  {
    rj=1.5*i;
    fat_off=rj;
    b2=fatbuf[fat_off+1];
    b1=fatbuf[fat_off];
    fat_dmp=b2;
    fat_dmp=fat_dmp<<8;
    fat_dmp=fat_dmp+b1;
    dmp_sav=fat_dmp;
    if(rj==fat_off)
    fat_dmp=fat_dmp&0xffff;
    else fat_dmp=fat_dmp>>4;
    fat_dmp=fat_dmp<<4;
    fat_dmp=fat_dmp>>4;
    if(fat_dmp==0x0ff7)
    {
      j++;
      if(rj==fat_off)
      dmp_sav=dmp_sav&0xf000;
      else
      dmp_sav=dmp_sav&0x000f;
      b2=(dmp_sav&0xff00)>>8;
      b1=dmp_sav&0x00ff;
      fatbuf[fat_off]=b1;
      fatbuf[fat_off+1]=b2;
    }
    }
    if(j)
    {
      abswrite(0,2,1,fatbuf);
      printf("disk cleaned \n\n");
    }
}

    /*End of routine clean_data_Area*/

    /*routine to change volume label */

  change_Label()
{
  unsigned char buf[512],volb1[11];
  int i,llen,lblpos,sno=5;
  struct ffblk blk;
  i=findfirst("*.*",&blk,0x08);
  if(!i)
  {
  absread(0,1,sno,buf);
  lblpos=findlbl(buf);
  while(!lblpos){ sno++;absread(0,1,sno,buf);
                  lblpos=lblpos-0x0b;
                  for(i=0;i<0x0b;i++)
                  volb1[i]=buf[lblpos+i];
                  volb1[i]=0x0b;
                  printf("volume label is %s \n",volb1);
                  }
  }
  else
  printf("volume label not defined\n");
  printf("enter new label (char):");
  scanf("%s",volb1);
  if(!i)
  {
    llen=strlen(volb1);
    for(i=0;i<=llen;i++,lblpos++)
    buf[lblpos]=volb1[i];
    for(;i<0x0b;i++,lblpos++)
    buf[lblpos]=' ';
    abswrite(0,1,sno,buf);
  }else
  {
    i=_creat(volb1,0x08);
    close(i);
  }
}
 findlbl(source)
 unsigned char source[512];
 {
  int ofset=0x0b;
  while(ofset<512){
  if(source[ofset]==0x28)
  return(ofset);
  ofset=ofset+0x020;
  }
  return(0);
 }

/* End of routine change _label*/



All times are GMT +5.5. The time now is 09:47.