Perl tip of the day (was Re: Wellington Perlmongers)

Don Jones don at gamma.net.nz
Tue Oct 8 03:37:45 CDT 2002


Peirs 

exactly what problem where you trying to solve that prompted you to write a
Perl based HTTP proxy? I did have a look at your site - i think you mentioned
something about SSL.

Talking of http proxys, content filtering is all the rage these days, I have
inplemented squidguard on squid before (dont remember if its perl or not) and
have recently looked into snapgear firewalls which have content filtering from
cerberian -generally this stuff tends to be written in perl (eg spamassassin
and various conercial products that ride ontpo of it like perlmx and
spamassassin.com)

So - the question - are there any open source http content filters out there?

Personaly I dont like the idea much, but there seems to be a big market for
them - and in New Zealand at least the 90% answer seems to be web marshal, and
mail marshal - are there any perl based alternatves

I wonder what extras and ihugs virus filters are - I would think they run on
unix - any ideas?

btw heres some code I did last friday in response to a post on the NZNOG
mailing list - it checks banners for nz isps MTAs, it should be easy to modify
to test if the MTA allows forged from addresses which was what the origional
post was about but i didnt add that - too spammer friendly.

any constructive criticism appreciated (code not email style :)

usage ./banner.pl nz_ips.txt

#!/usr/bin/perl -w

use strict;
use Net::Telnet;
use Net::DNS;

my $isps = shift;

open (ISPS, "<$isps")	or die "can't open $isps: $!";

while (<ISPS>) {
	chomp;
	print "-------------------------------------------------------\n";
	print "ISP = $_\n";
	
	my $res = new Net::DNS::Resolver;
        my @mx = mx($res, $_);
        if (@mx) {
                foreach my $rr (@mx) {
                        print $rr->preference, " ", $rr->exchange, "\n";
                	
	
			my $telnet = new Net::Telnet ( 	Timeout=>30,
                            				Port=>25,
                            				Errmode=>'die');
			$telnet->open($rr->exchange,);
			$telnet->waitfor('/220/');
			$telnet->print('helo just-testing.org');
 			(my $output)=$telnet->waitfor('/250/');
			$telnet->print('quit');

			print "Banner: $output";
		}
        }
        else {
                print "can't find MX records for $_: ", $res->errorstring,
"\n";        }

Sorry about the rambling post - im drinking beer as I write ;)

Don
 

> Excellent - altho I don't ( fortunately ) have the problem of using
> win32. :-)
> 
> I have written a couple of articles lately, and attended OSCON so
> perhaps people might be intereseted in such subjects as Perl based HTTP
> proxies, embedding Perl in Daemons, and Perl and SAP R/3.
> My blitherings are at:
> http://www.piersharding.com.
> 
> Cheers.
> 
> On Wed, Sep 25, 2002 at 09:43:03PM +1200, Grant McLean wrote:
> > Hi Piers
> > 
> > Just to let you know we're not all ignoring you.  I couldn't reply
> > straight away since I was writing Tcl code :-(
> > 
> > I'm all in favour of a bit more 'banter' on the list.  What would 
> > you like to talk about?
> > 
> > Perhaps since no one is asking questions, I could kick off with an
> > unsolicited answer...
> > 
> > 
> > Today's message is brought to you be the command line argument '-l'.
> > 
> > The problem: 
> >   I want to extract a list of subroutine names from a Perl .pm file.
> > 
> > The solution:
> > 
> >   perl -n -e '/^\s*sub\s+(\w+)/ && print "$1\n"' filenames
> > 
> > Unfortunately, although that works nicely on Unix, it doesn't work
> > on Windows.  At least not with the standard Windows command shell
> > which only recognises double quotes.  One alternative is to use 
> > the 'qq' double quoting operator:
> > 
> >   perl -n -e "/^\s*sub\s+(\w+)/ && print qq($1\n)" filenames
> > 
> > But my tip of the day is to dispense with the quotes and use the
> > '-l' option to append a linefeed onto every print:
> > 
> >   perl -nle "/^\s*sub\s+(\w+)/ && print $1" filenames
> > 
> > Which is less typing too.
> > 
> > Anyone else have a tip?
> > 
> > Regards
> > Grant
> > 
> > 
> > > -----Original Message-----
> > > From: Piers Harding [mailto:piers at ompa.net]
> > > Subject: Re: Wellington Perlmongers
> > > 
> > > 
> > > Hi Guys - I listen into the melbourne.pm list, and they seem to share
> > > lots of ideas, and regularily publish work/articles etc. to the list.
> > > Are people on this list interested in the same sort of thing, as it
> > > would be good to try and inject some life back into it?
> > > 
> > > Also, as a kiwi overseas, it would be nice to have some 
> > > banter with the
> > > Perl community back home.
> > > 
> > > Cheers.
> > > 
> > > Piers Harding


--
"Intellectual Property" : a tool that the dinosaurs use to make sure
there are no mammals in the future. - Lawrence Lessig




More information about the Wellington-pm mailing list