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 / carp / carp next >
Text File  |  1992-03-10  |  4KB  |  111 lines

  1. #!/bin/sh
  2. #
  3. #  Useage: carp [-x] report_or_cops_dir
  4. #
  5. # -x emits a result file that can be used with the X-previewer
  6. #
  7. #  Carp is a data analysis tool for cops output, primarily designed
  8. # for use analyzing a cops directory tree full of cops output (presumably
  9. # from a network of data.)  It looks in the cops main directory (by
  10. # default) and finds all subdirectories (and hence hostnames) containing
  11. # cops reports (they are named something like "1992_Dec_31".)  It then
  12. # runs two subprograms; a report analyzer ("carp.anlz") and a table
  13. # generator ("carp.table".)  The final output will look something like:
  14. # hostname      rep date     crn dev ftp grp hme is pass msc pwd rc  rot usr
  15. # ===========================================================================
  16. # neuromancer  1992_Jan_27  | 1 |   | 2 |   | 1 | 2 |   |   | 2 | 2 | 2 |   |
  17. # sun          1992_Jan_26  |   |   | 2 | 2 | 1 | 2 |   |   | 2 | 2 |   | 1 |
  18. # death        1992_Jan_15  |   |   |   | 2 | 1 | 2 |   |   |   |   | 0 |   |
  19. #
  20. #  The date is the date the cops report was created, the other headers
  21. # correspond to the various checks that cops runs; "cron.chk", "ftp.chk",
  22. # etc.  The number refers to the severity of the most serious warning
  23. # from that host on that particular check:
  24. #
  25. # 0 == a problem that, if exploited, can gain root access for an intruder
  26. # 1 == a serious security problem, such as a guessed password.
  27. # 2 == a possibly serious security problem, but one that is difficult
  28. #      to analyze via a mere program.  Look at the problems in question,
  29. #      and decide for yourself.
  30. # Blanks mean that no problem was found (*not* that no problem exists!)
  31. #  If the -x flag was used, the pathname to the report file is printed
  32. # after the corresponding report line for the host.
  33. #
  34. #  All of these numbers are in the carp.anlz program; they can be modified
  35. # to best suit your needs... and, of course, you should look at the actual
  36. # cops report for more information on the specific problems encountered.
  37. #
  38. #  TO ADD NEW CHECKS -- just add a column in the echo near the bottom;
  39. # bug.chk is used (commented out) as an example.  Note you'll also have
  40. # to add stuff to "carp.table" -- see comments there, too...
  41. #
  42. # Basic stuff:
  43. AWK=/bin/awk
  44. FIND=/bin/find
  45. SORT=/bin/sort
  46. LS=/bin/ls
  47. ECHO=/bin/echo
  48. TEST=/bin/test
  49.  
  50. # other progs, files:
  51. generator="./carp.anlz"
  52. tabler="./carp.table"
  53.  
  54. if $TEST ! -s $generator -a ! -s $tabler ; then
  55.     echo Can\'t find $tabler and/or $generator...
  56.     exit 1
  57.     fi
  58.  
  59. # arg stuff:
  60. # more arg stuff:
  61. if $TEST $# -eq 0 ; then
  62.         echo Usage: $0 [-x] directory
  63.         exit 2
  64.         fi
  65.  
  66. while $TEST $# != 0
  67.         do      case "$1" in
  68.         -x)     x=yes ; shift ;;
  69.         *)      report_dir=$report_dir" "$1 ; shift ;;
  70.         esac
  71.         done
  72.  
  73. for dir in $report_dir ; do
  74.     if $TEST ! -d $dir ; then
  75.         echo $dir is not a directory...
  76.         exit 3
  77.         fi
  78.     done
  79.  
  80. #  find the most recent targets on all the machines...
  81. # a two step process; one, get the dirs the report files live in,
  82. # two, get the most recent one.
  83. targets=`$FIND $report_dir -name '[0-9][0-9][0-9][0-9]_[A-Z][a-z][a-z]_[0-9]*' \
  84.     -exec dirname {} \; | $SORT -u`
  85.  
  86. for dir in $targets ; do
  87.     all_reports=`$LS -t $dir/[0-9][0-9][0-9][0-9]_[A-Z][a-z][a-z]_[0-9]* \
  88.         | $AWK 'NR == 1'`" "$all_reports
  89.     done
  90.  
  91. # echo all the reports are: $all_reports
  92. $ECHO "COPS warning summary"
  93. $ECHO
  94. #
  95. #  Default headers... must think of a better way.  A potential additional
  96. # field might be bug.chk; to add, just add a column in the echo...
  97. #
  98. $ECHO "hostname      rep date     crn dev ftp grp hme is pass msc pwd rc root usr kng"
  99. $ECHO "==============================================================================="
  100.  
  101. for report in $all_reports ; do
  102.     # extra X info for the x-program...
  103.     if $TEST "$x" = "yes" ; then
  104.         echo $report
  105.         fi
  106.     $AWK -f $generator $report | $AWK -f $tabler 
  107.     done
  108.  
  109. # done
  110.