httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Jones" <b...@fccj.org>
Subject Re: http protocol tracing?
Date Wed, 08 Sep 1999 00:07:23 GMT
> On Fri, Sep 03, 1999 at 02:26:41PM -0600, BIXBY,MARK HP-Cupertino,ex1" wrote:
>> Is there anything I can turn on within Apache that will log the http
>> protocol between the server and the browser?  Or do I have to add my own
>> code to do this?
>
> There is no such code in Apache itself (that I know of). Try netcat,
> at <ftp://coast.cs.purdue.edu/pub/tools/unix/netcat/nc110.tgz>. It has
> the ability to act as an intermediary between clients and servers on a
> TCP connection, logging the data that go through.


Here is something I've been playing with - Lincoln Stein wrote it originally
(I believe this fragment is his own code. I am not sure anymore as I have
been making my own changes.)  You should be able to add just about any other
protocol stuff.  Note you need tcpdump (or snoop) already setup...


#!/usr/bin/perl

$LIMIT = shift || 5000000;

$|=1;
open (STDIN,"/usr/sbin/tcpdump -lnx -s 1024 dst port 80|");
while (<>) {
    if (/^\S/) {
        last unless $LIMIT--;
        while ($packet=~/(GET|POST|WWW-Authenticate|Authorization).+/g)  {
            print "$client -> $host\t$&\n";
        }
        undef $client; undef $host; undef $packet;
        ($client,$host) = /(\d+\.\d+\.\d+\.\d+).+ > (\d+\.\d+\.\d+\.\d+)/
            if /P \d+:\d+\((\d+)\)/ && $1 > 0;
    }
    next unless $client && $host;
    s/\s+//;
    s/([0-9a-f]{2})\s?/chr(hex($1))/eg;
    tr/\x1F-\x7E\r\n//cd;
    $packet .= $_;
}



Just goes to show how easy it is to watch HTTP (and similar protocols.)

Enjoy!
-Sneex-  :]

Mime
View raw message