home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / c / cops_104.zip / cops_104 / bug.chk < prev    next >
Text File  |  1992-03-10  |  4KB  |  129 lines

  1. #!/bin/sh
  2. #
  3. #  bug.chk [arch]
  4. #
  5. #   This uses publically available (available via anon-ftp from 
  6. # cert.sei.cmu.edu) data to determine if a security bug is present.  It
  7. # checks the date of the program in question against the cert advisory
  8. # date, and, if it is older than that, it flags it as a potential
  9. # bug/vulnerability.
  10. #
  11. #  Right now, it either uses your argument as an archetecture type, or
  12. # tries to figure out what kind of platform you're running
  13. # on, and then looks at the bugs known for your host, in a file named
  14. # "bug.chk.arch_type".
  15. #
  16. ECHO=/bin/echo
  17. TEST=/bin/test
  18. GREP=/bin/grep
  19. LS=/bin/ls
  20. LS_OPTS="-slagL"
  21. AWK=/bin/awk
  22. SH=/bin/sh
  23. DATE=/bin/date
  24.  
  25. # the bug comparison module; current vs. bug date
  26. BUG="$AWK -f ./bug_cmp"
  27.  
  28. # Do you decend from 4.3 BSD?
  29. bsd43=yes
  30. platform="./platform"
  31.  
  32. if $TEST ! -f ./bug_cmp ; then
  33.     $ECHO "Must have bug compare module, ./bug_cmp, to run..."
  34.     exit 2
  35.     fi
  36.  
  37. # what is the date?  We just need the month and year...
  38. # Format: Fri Feb  7 14:16:55 PST 1992
  39. real_date=`$DATE | $AWK '{print $2, $NF}'`
  40.  
  41. # what kind of machine are we on?
  42. #
  43. if $TEST "$1" != "" ; then
  44.     host_type=$1
  45. else
  46.     host_type=`$platform`
  47.     fi
  48.  
  49. #
  50. #  Do a few (old) generic checks, then go to machine specific drek...
  51. #
  52.  
  53. #
  54. # Generic sendmail problem -- worm used this...
  55. sendmail="/usr/lib/sendmail"
  56. fix_date="1 Dec 1988"
  57. cert_advis="CA-88:01"
  58. if $TEST -f "$sendmail" ; then
  59.     cur_date=`$LS $LS_OPTS $sendmail | $AWK '{print $8, $7, $9}'`
  60.     $ECHO $sendmail $fix_date $cur_date $cert_advis $real_date | $BUG
  61.     fi
  62.  
  63. #
  64. #   If running BSD based stuff, check login, fingerd, and ftpd,
  65. # plus the more recent rdist hole.
  66. login="/bin/login"
  67. all_locations="/etc /bin /usr/bin /usr/etc /usr/ucb"
  68. if $TEST "$bsd43" -eq "yes" -a -f "$login" ; then
  69.     fix_date="21 Dec 1988"
  70.     cert_advis="CA-89:01"
  71.     cur_date=`$LS $LS_OPTS $login | $AWK '{print $8, $7, $9}'`
  72.     $ECHO $login $fix_date $cur_date $cert_advis $real_date | $BUG
  73.     for location in $all_locations ; do
  74.         # have to check for sun's naming schema also...
  75.         if $TEST -f "$location/ftpd" ; then
  76.             ftp="$location/ftpd"
  77.         elif $TEST -f "$location/in.ftpd" ; then
  78.             ftp="$location/in.ftpd"
  79.             fi
  80.         if $TEST -f "$location/fingerd" ; then
  81.             finger="$location/fingerd"
  82.         elif $TEST -f "$location/in.fingerd" ; then
  83.             finger="$location/in.fingerd"
  84.             fi
  85.         if $TEST -f "$location/rdist" ; then
  86.             rdist="$location/rdist"
  87.             fi
  88.         done
  89.     cur_date=`$LS $LS_OPTS $ftp | $AWK '{print $8, $7, $9}'`
  90.     $ECHO $ftp $fix_date $cur_date $cert_advis $real_date | $BUG
  91.     cur_date=`$LS $LS_OPTS $finger | $AWK '{print $8, $7, $9}'`
  92.     $ECHO $finger $fix_date $cur_date $cert_advis $real_date | $BUG
  93.  
  94.     #
  95.     # rdist is special
  96.     #
  97.     # These vendors are *not* affected: Amdahl, AT&T System V,
  98.     # Data General DG/UX for AViiON Systems, Sequent Computer Systems
  99.     # (note they will begin to ship rdist in February 1992, but
  100.     # it will be the corrected version)
  101.     #
  102.     fix_date="22 Oct 1991"
  103.     #   Sun put out another one after that date... you probably want
  104.     # this date instead...
  105.     fix_date="23 Oct 1991"
  106.  
  107.     cert_advis="CA-91:20"
  108.     cur_date=`$LS $LS_OPTS $rdist | $AWK '{print $8, $7, $9}'`
  109.     $ECHO $rdist $fix_date $cur_date $cert_advis $real_date | $BUG
  110.     fi
  111.  
  112. # host specific ones....
  113. if $TEST -n "$host_type" ; then
  114.     if $TEST -f "./bug.chk.$host_type" ; then
  115.         $SH ./bug.chk.$host_type $real_date
  116.     else
  117.         # check to see if I'm a sun...
  118.         $ECHO $host_type | $GREP "sun" > /dev/null
  119.         if $TEST $? -eq "0" ; then
  120.             ./bug.chk.sun $real_date
  121.         else
  122.             :
  123.             # $ECHO Bug list for $host_type not found...
  124.             fi
  125.         fi
  126.     fi
  127.  
  128. # finis
  129.