home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / WWIVMODS / MODSUNKN.ZIP / VIRUSCHK.MOD < prev    next >
Text File  |  1992-01-21  |  9KB  |  260 lines

  1. /***************************************************************************
  2.   MOD: Virus Checker
  3.   Description: Check for virus on remote upload or ask to check on local upload
  4.                uses the archive formats you have specified in INIT.EXE.
  5.  
  6.   Author: Captain Learjet
  7.   Modified: Enigma #9 @9973
  8.             Rejean F #1 @5499
  9.  
  10.   Comments: Enigma's release had two slight problems in the test_upload
  11.             function:
  12.                first:  it wasn't clearing the temp dir when checking
  13.                        multiple files.
  14.                second: de-archiving was not possible since the string
  15.                        passed to to run_external wasn't set up properly.
  16.  
  17.             Both are now corrected.
  18.   Requirements: You must have McAffe's SCAN.EXE and all de-archiver in your
  19.                 path somewhere.
  20.  
  21.                                                        Rejean F
  22.                                                        #1 @5499
  23. ***************************************************************************/
  24.  
  25. ***********************
  26.  
  27.         STEP 1
  28.  
  29. Back-up your source!
  30.  
  31. ***********************
  32.  
  33.         STEP 2
  34.  
  35. In BBS.C add the following:
  36.  
  37.   if (strcmp(s,"/O")==0)                          = Existing
  38.     if (countdwn()==1)                            = Existing
  39.       hangup=1;                                   = Existing
  40.   if ((strcmp(s,"/?")==0) && (dcs()))             = Existing
  41.     printmenu(8);                                 = Existing
  42.   if (strcmp(s,"/V")==0)                          + ADD
  43.     virus_check();                                + ADD
  44.   if ((strcmp(s,"UPLOADALL")==0) && (dcs())) {    = Existing
  45.     i1=0;
  46.  
  47. ***********************
  48.  
  49.        STEP 3
  50.  
  51. **-- NOTE: In step 3 and 4, the sprintf function might not be exactly as
  52.            represented. Also, in step 3, the pl function is probably
  53.            different in your source.
  54.  
  55.  
  56. In XFER.C add the following:
  57.  
  58.   ++status.uptoday;                             = Existing
  59.   save_status();                                = Existing
  60.   sprintf(s,"+%s uploaded in %s",               = Existing
  61.           u.filename,directories[dn].name);     = Existing
  62.   sysoplog(s);                                  = Existing
  63.   nl();                                         = Existing
  64.   if(!incom){                                   + ADD
  65.     prt(5,"Test this file? ");                  + ADD
  66.     if(yn())                                    + ADD
  67.       test_upload(u.filename);                  + ADD
  68.   }else                                         + ADD
  69.     test_upload(u.filename);                    + ADD
  70.   nl();                                         = Existing
  71.   pl("File uploaded.");                         = Existing
  72.  
  73.  
  74. At the end of the file (after the last line) add:
  75.  
  76. #include "VIRUSCHK.C"
  77.  
  78. ***********************
  79.  
  80.         STEP 4
  81.  
  82. In XFEROVL.C add the following:
  83.  
  84.     SETREC(0);                                  = Existing
  85.     write(dlf,(void *)&u1,sizeof(uploadsrec));  = Existing
  86.     ++status.uptoday;                           = Existing
  87.     save_status();                              = Existing
  88.     sprintf(s,"+%s uploaded in %s",             = Existing
  89.             u.filename,d.name);                 = Existing
  90.     sysoplog(s);                                = Existing
  91.     if(!incom){                                 + ADD
  92.       prt(5,"Test this file? ");                + ADD
  93.       if(yn())                                  + ADD
  94.         test_upload(u.filename)                 + ADD
  95.     }else                                       + ADD
  96.       test_upload(u.filename);                  + ADD
  97.   }                                             = Existing
  98.   return(1);                                    = Existing
  99. }                                               = Existing
  100.  
  101. ***********************
  102.        
  103.        STEP 5
  104.  
  105. In FCNS.H add these two declaration in the XFER.C section:
  106.  
  107. void virus_check(void);
  108. void test_upload(char *s);
  109.  
  110. ***********************
  111.  
  112.         STEP 6
  113.          
  114. Create those two files in your gfiles directory:
  115.  
  116. VIRUSOK.TXT  - Will be added to arc files that pass the test
  117. VIRUSBAD.TXT - Will be added to arc files that fail the test
  118.  
  119. ***********************
  120.  
  121.         STEP 7
  122.  
  123. Save the two following functions as VIRUSCHK.C
  124.  
  125. --------------------------------CUT HERE-------------------------------------
  126.  
  127. void virus_check(void)
  128. {
  129.   char s[81];
  130.  
  131.   nl();
  132.   prt(2,"Archive to Scan: ");
  133.   mpl(12);
  134.   input(s,12);
  135.   if (!strchr(s,'.'))
  136.     strcat(s,".*");
  137.   test_upload(s);
  138.   topscreen();
  139. }
  140.  
  141.  
  142. void test_upload(char *s)
  143. {
  144.   char s1[81],s2[81],s3[81],s4[81],s5[81];
  145.   int i,i1,i2,type=0,abort=0,next=0,ext;
  146.   uploadsrec u;
  147.  
  148.   remove_from_temp("*.*",syscfg.tempdir,0);
  149.   align(s);
  150.   dliscan();
  151.  
  152.   i=recno(s);
  153.   do {
  154.     if (i>0) {
  155.       SETREC(i);
  156.       read(dlf,(void *)&u,sizeof(uploadsrec));
  157.       for(i2=0; i2<4; i2++)         /*** determine type and assign to ext ***/
  158.       if (!strcmp(u.filename+9,syscfg.arcs[i2].extension)) {
  159.         sprintf(s1,"%s%s",directories[udir[curdir].subnum].path,
  160.                 stripfn(u.filename));
  161.         ext=i2;
  162.         type=1;
  163.       }
  164.       if ((!strcmp(u.filename+9,"EXE")) || (!strcmp(u.filename+9,"COM")))
  165.       type=4;
  166.       if (type) {
  167.         sprintf(s1,"%s%s",directories[udir[curdir].subnum].path,
  168.         stripfn(u.filename));
  169.         if (exist(s1)) {
  170.           nl();
  171.           ansic(2);
  172.           sprintf(s2,"Scanning %s for viruses... ",u.filename);
  173.           nl();
  174.           prt(3,"Please wait.....");nl();
  175.           if (type<4) {     /*** if archived extract and check for virii ***/
  176.             strcpy(s4,syscfg.arcs[ext].arce);    /* This part modified   */
  177.             strcpy(s5,syscfg.tempdir);           /* for proper operation */
  178.             stuff_in(s2,s4,s1,s5,"","","");      /* of PKUNZIP           */
  179.             run_external(s2);
  180.             sprintf(s3,"SCAN /nomem %s",syscfg.tempdir);
  181.             i1=run_external1(s3);
  182.             remove_from_temp("*.*",syscfg.tempdir,0);
  183.           } else {          /*** else just check for virii ***/
  184.             sprintf(s2,"SCAN /nomem %s",s1),
  185.             i1=run_external1(s2);
  186.           }
  187.           prt(2,u.filename);
  188.           if (i1==1) {
  189.             pl(" \a\a\0036FAILED \0030the virus test!");
  190.             nl();
  191.    sprintf(s2,"%s \0036FAILED \0030the virus test. Please delete the file!",
  192.            u.filename); 
  193.             ssm(1,0,s2); 
  194.             sysoplog(s2); 
  195.           } else {
  196.             pl(" \0035PASSED \0032the virus test.");
  197.             sprintf(s2,"%s \0035PASSED \0030the virus test.",u.filename);
  198.             ssm(1,0,s2);
  199.             sysoplog(s2);
  200.             nl();
  201.           }
  202. /*════════ delete area between lines to skip adding file comments ═════════*/
  203. /*** will add file VIRUSOK.TXT to an archive that passed the virii scan ***
  204.  *** will add file VIRUSBAD.TXT to an archive that failed the virii scan ***/
  205.  
  206.   /*** if ARJ archive add comment ***/
  207.           if (!strcmp(u.filename+9,"ARJ")) {
  208.             if (i1==1)
  209.                sprintf(s1,"ARJ C %s%s -z%sVIRUSBAD.TXT",
  210.                     directories[udir[curdir].subnum].path,
  211.                     stripfn(u.filename),syscfg.gfilesdir);
  212.             else
  213.                sprintf(s1,"ARJ C %s%s -z%sVIRUSOK.TXT",
  214.                directories[udir[curdir].subnum].path,
  215.                stripfn(u.filename),syscfg.gfilesdir);
  216.             sprintf(s3,"Adding comment to %s",u.filename);
  217.             prt(2,s3);
  218.             nl();
  219.             run_external(s1);
  220.           }
  221.   /*** end add comment to ARJ ***/
  222.  
  223.   /*** if ZIP archive add comment ***/
  224.  
  225.           if (!strcmp(u.filename+9,"ZIP")) {
  226.              if (i1==1)
  227.                sprintf(s1,"PKZIP -Z %s%s < %sVIRUSBAD.TXT",
  228.                     directories[udir[curdir].subnum].path,
  229.                     stripfn(u.filename), syscfg.gfilesdir);
  230.              else
  231.                sprintf(s1,"PKZIP -Z %s%s < %sVIRUSOK.TXT",
  232.                     directories[udir[curdir].subnum].path,
  233.                     stripfn(u.filename), syscfg.gfilesdir);
  234.              sprintf(s3,"Adding comment to %s",u.filename);
  235.              prt(2,s3);
  236.              nl();
  237.              run_external(s1);
  238.           }
  239.  
  240.   /*** end add comment to ZIP ***/
  241. /*════════════════════════ end adding file comments ════════════════════════*/
  242.         }
  243.         checka(&abort,&next);
  244.       }
  245.     }
  246.     i=nrecno(s,i);
  247.   } while ((i>0) && (!hangup) && (!abort));
  248.   closedl();
  249.   remove_from_temp("*.*",syscfg.tempdir,0);
  250. }
  251.  
  252. --------------------------------CUT HERE-------------------------------------
  253.  
  254. That's it, all that is left now is to recompile the whole thing.  Hope you
  255. won't have problems with this mod.
  256.  
  257.  
  258. RejeanF
  259.  
  260. #1 @5499