1#!/bin/sh 2# 3# WWWOFFLE - World Wide Web Offline Explorer - Version 2.9. 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,99,2000,01,02,03,05,06 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 15exec perl -x $0 16 17exit 1 18 19#!perl 20 21%commands=( 22 "Online","-online", 23 "Fetch","-fetch", 24 "Offline","-offline", 25 "In Autodial Mode","-autodial", 26 "Re-Reading Configuration File","-config", 27 "Dumping Configuration File","-dump", 28 "Purge","-purge", 29 "Status","-status", 30 "Kill","-kill" 31 ); 32 33%modes=( 34 "-spool","S", 35 "-fetch","F", 36 "-real","R", 37 "-autodial","A" 38 ); 39 40%statuses=( 41 "Internal Page","I", 42 "Cached Page Used","C", 43 "New Page","N", 44 "Forced Reload","F", 45 "Modified on Server","M", 46 "Unmodified on Server","U", 47 "Not Cached","X" 48 ); 49 50@piddata=(); 51 52print "# Mode : F=Fetch, R=Online (Real), S=Offline (Spool), A=Autodial,\n"; 53print "# W=WWWOFFLE Command, T=Timestamp, X=Error Condition\n"; 54print "#\n"; 55print "# Status: C=Cached version used, N=New page, F=Forced refresh, I=Internal,\n"; 56print "# M=Modified on server, U=Unmodified on server, X=Not cached\n"; 57print "# +z=Compressed transfer, +c=Chunked transfer.\n"; 58print "#\n"; 59print "# Mode Status\n"; 60print "# ---- ------\n"; 61print "# / ,---' Server Bytes Client Bytes\n"; 62print "#/ / Hostname Username Read Writ Read Writ Details\n"; 63print "# ### ---------------- -------- -------- ---- ---- -------- -------\n"; 64 65while(<STDIN>) 66 { 67 if(/^wwwoffled\[([0-9]+)\]/ || /wwwoffled\[([0-9]+)\]:/) 68 { 69 if(/Timestamp: ([a-zA-Z0-9 :]+)/) 70 { 71 &PrintLine(mode => "T", string => $1); 72 } 73 elsif(/WWWOFFLE (Online|Fetch|Offline|In Autodial Mode|Re-Reading Configuration File|Dumping Configuration File|Purge|Kill)\./) 74 { 75 &PrintLine(mode => "W", host => $host, string => "WWWOFFLE $commands{$1}"); 76 } 77 elsif(/WWWOFFLE (Incorrect Password|Not a command|Unknown control command)/) 78 { 79 &PrintLine(mode => "X", host => $host, string => "WWWOFFLE Bad Connection($1)"); 80 } 81 elsif(/HTTPS? Proxy connection from host ([^ ]+) /) 82 { 83 $host=$1; 84 } 85 elsif(/(HTTPS?) Proxy connection rejected from host ([^ ]+) /) 86 { 87 &PrintLine(mode => "X", host => $2, string => "$1 Proxy Host Connection Rejected"); 88 } 89 elsif(/WWWOFFLE Connection from host ([^ ]+) /) 90 { 91 $host=$1; 92 } 93 elsif(/WWWOFFLE Connection rejected from host ([^ ]+) /) 94 { 95 &PrintLine(mode => "X", host => $1, string => "WWWOFFLE Connection Rejected"); 96 } 97 elsif(/Forked wwwoffles (-[a-z]+) .pid=([0-9]+)/) 98 { 99 $pid=$2; 100 $mode=$modes{$1}; 101 $host="" if($mode eq "F"); 102 103 ${$piddata[$pid]}{mode}=$mode; 104 ${$piddata[$pid]}{host}=$host; 105 } 106 elsif(/Child wwwoffles (exited|terminated) with status ([0-9]+) .pid=([0-9]+)/) 107 { 108 $pid=$3; 109 110 &PrintLine(%{$piddata[$pid]}); 111 112 undef %{$piddata[$pid]}; 113 } 114 } 115 elsif(/^wwwoffles\[([0-9]+)\]/ || /wwwoffles\[([0-9]+)\]:/) 116 { 117 $pid=$1; 118 119 if(/: (URL|SSL[^=]*)=\'([^\']+)/) 120 { 121 $url=$2; 122 if($1 =~ "SSL") {$url.=" (SSL)";} 123 ${$piddata[$pid]}{string}=$url; 124 ${$piddata[$pid]}{status}="I"; 125 } 126 elsif(/: Cache Access Status=\'([^\']+)/) 127 { 128 ${$piddata[$pid]}{status}=$statuses{$1}; 129 } 130 elsif(/: Server has used .Content-Encoding:/) 131 { 132 ${$piddata[$pid]}{compress}="z"; 133 } 134 elsif(/: Server has used .Transfer-Encoding:/) 135 { 136 ${$piddata[$pid]}{chunked}="c"; 137 } 138 elsif(/: Server bytes; ([0-9]+) Read, ([0-9]+) Written./) 139 { 140 ${$piddata[$pid]}{server_rd}=$1; 141 ${$piddata[$pid]}{server_wr}=$2; 142 } 143 elsif(/: Client bytes; ([0-9]+) Read, ([0-9]+) Written./) 144 { 145 ${$piddata[$pid]}{client_rd}=$1; 146 ${$piddata[$pid]}{client_wr}=$2; 147 } 148 elsif(/HTTP Proxy connection from user '([^ ]+)'/) 149 { 150 ${$piddata[$pid]}{user}=$1; 151 } 152 elsif(/No more outgoing requests/) 153 { 154 ${$piddata[$pid]}{mode}="W"; 155 ${$piddata[$pid]}{string}="WWWOFFLE fetch finished"; 156 } 157 elsif(/HTTP Proxy connection rejected from unauthenticated user/) 158 { 159 ${$piddata[$pid]}{mode}="X"; 160 ${$piddata[$pid]}{string}="HTTP Proxy User Connection Rejected"; 161 } 162 elsif(/(Cannot open temporary spool file|Could not parse HTTP request|The requested method '[^']+' is not supported)/) 163 { 164 ${$piddata[$pid]}{mode}="X"; 165 ${$piddata[$pid]}{string}="WWWOFFLE Error($1)"; 166 } 167 } 168 } 169 170# 171# Print a line 172# 173 174sub PrintLine 175 { 176 my(%params)=@_; 177 178# foreach $key (keys %params) 179# { 180# print "KEY=$key VALUE=$params{$key}\n"; 181# } 182 183 foreach $variable (mode,status,compress,chunked,host,user,server_wr,server_rd,client_wr,client_rd,string) 184 { 185 next if($params{$variable}); 186 $params{$variable}='-'; 187 $params{$variable}='' if($variable eq compress || $variable eq chunked); 188 } 189 190 printf("%1s %1s%-2s %16s %8s %8s %4s %4s %8s %s\n", 191 $params{mode},$params{status},$params{compress}.$params{chunked}, 192 $params{host},$params{user}, 193 $params{server_rd},$params{server_wr},$params{client_rd},$params{client_wr}, 194 $params{string}); 195 } 196