audit-usage.pl
上传用户:seven77cht
上传日期:2007-01-04
资源大小:486k
文件大小:4k
源码类别:

浏览器

开发平台:

Unix_Linux

  1. #!/bin/sh
  2. #
  3. # WWWOFFLE - World Wide Web Offline Explorer - Version 2.3.
  4. #
  5. # A Perl script to get audit information from the standard error output.
  6. #
  7. # Written by Andrew M. Bishop
  8. #
  9. # This file Copyright 1998 Andrew M. Bishop
  10. # It may be distributed under the GNU Public License, version 2, or
  11. # any higher version.  See section COPYING of the GNU Public license
  12. # for conditions under which this file may be redistributed.
  13. #
  14. exec perl -x $0
  15. exit 1
  16. #!perl
  17. %commands=("Online","-online",
  18.            "Fetch","-fetch",
  19.            "Offline","-offline",
  20.            "In Autodial Mode","-autodial",
  21.            "Re-Reading Configuration File","-config",
  22.            "Purge","-purge",
  23.            "Kill","-kill");
  24. %modes=("-spool","S",
  25.         "-fetch","F",
  26.         "-real","R",
  27.         "-autodial","A");
  28. $time='';
  29. %host=();
  30. %user=();
  31. %ip=();
  32. %mode=();
  33. $url='';
  34. while(<STDIN>)
  35.   {
  36.    if(/^wwwoffled.([0-9]+)/)
  37.        {
  38.         $pid=$1;
  39.         if(/Timestamp: ([a-zA-Z0-9 :]+)/)
  40.             {
  41.              $time=$1;
  42.              printf("T %sn",$time);
  43.             }
  44.         elsif(/HTTP Proxy connection from host ([^ ]+) .([0-9.]+)/)
  45.             {
  46.              $host=$1;
  47.              $ip=$2;
  48.             }
  49.         elsif(/HTTP Proxy connection rejected from host ([^ ]+) .([0-9.]+)/)
  50.             {
  51.              printf("X %16s %12s %8s HTTP Proxy Host Connection Rejectedn",$1,$2,"");
  52.             }
  53.         elsif(/WWWOFFLE Connection from host ([^ ]+) .([0-9.]+)/)
  54.             {
  55.              $host=$1;
  56.              $ip=$2;
  57.             }
  58.         elsif(/WWWOFFLE Connection rejected from host ([^ ]+) .([0-9.]+)/)
  59.             {
  60.              printf("X %16s %12s %8s WWWOFFLE Connection Rejectedn",$1,$2,"");
  61.             }
  62.         elsif(/Forked wwwoffles (-[a-z]+) .pid=([0-9]+)/)
  63.             {
  64.              $mode=$modes{$1};
  65.              if($mode eq "F")
  66.                  {
  67.                   $host='';
  68.                   $ip='';
  69.                  }
  70.              if($url{$2}) # The wwwoffles output was before the wwwoffled output.
  71.                  {
  72.                   $url=$url{$2}; $url{$2}='';
  73.                   $user=$user{$2}; $user{$2}='';
  74.                   printf("%1s %16s %12s %8s %sn",$mode,$host,$ip,$user,$url);
  75.                  }
  76.              else # The wwwoffled output is before the wwwoffles output.
  77.                  {
  78.                   $host{$2}=$host;
  79.                   $ip{$2}=$ip;
  80.                   $mode{$2}=$mode;
  81.                  }
  82.             }
  83.         elsif(/WWWOFFLE (Online|Fetch|Offline|In Autodial Mode|Re-Reading Configuration File|Purge|Kill)./)
  84.             {
  85.              $command=$commands{$1};
  86.              printf("W %16s %12s %8s WWWOFFLE %sn",$host,$ip,"",$command);
  87.             }
  88.         elsif(/WWWOFFLE (Incorrect Password|Not a command|Unknown control command)/)
  89.             {
  90.              printf("X %16s %12s %8s WWWOFFLE Bad Connection (%s)n",$host,$ip,"",$1);
  91.             }
  92.        }
  93.    elsif(/^wwwoffles.([0-9]+)/)
  94.        {
  95.         $pid=$1;
  96.         if(/: (URL|SSL)='([^']+)/)
  97.             {
  98.              if($1 eq "SSL") {$url="$2 (SSL)";}
  99.              if($1 eq "URL") {$url=$2;}
  100.              if($mode{$pid}) # The wwwoffled output was before the wwwoffles output.
  101.                  {
  102.                   $host=$host{$pid}; $host{$pid}='';
  103.                   $ip=$ip{$pid}; $ip{$pid}='';
  104.                   $mode=$mode{$pid}; $mode{$pid}='';
  105.                   $user=$user{$pid}; $user{$pid}='';
  106.                   printf("%1s %16s %12s %8s %sn",$mode,$host,$ip,$user,$url);
  107.                  }
  108.              else # The wwwoffles output is before the wwwoffled output.
  109.                  {
  110.                   $url{$pid}=$url;
  111.                  }
  112.             }
  113.         elsif(/HTTP Proxy connection from user '([^ ]+)'/)
  114.             {
  115.              $user{$pid}=$1;
  116.             }
  117.         elsif(/HTTP Proxy connection rejected from unauthenticated user/)
  118.             {
  119.              $host=$host{$pid}; $host{$pid}='';
  120.              $ip=$ip{$pid}; $ip{$pid}='';
  121.              $mode=$mode{$pid}; $mode{$pid}='';
  122.              printf("X %16s %12s %8s HTTP Proxy User Connection Rejectedn",$host,$ip,"");
  123.             }
  124.        }
  125.   }