digital adj. Having digits.     peer n. A comrade; a companion; a fellow; an associate. a.k.a. GEEKED    
   
Recent Articles
Mount JFFS2 Image
Saturday, October 25, 2008
Ottawa Linux Symposium 2008
Sunday, July 27, 2008
Here are some pictures from the 2008 Linux Symposium.
Linux Symposium 2008
Sunday, July 20, 2008
I'll be attending the Linux Symposium this year.
Clay Shirky: Institutions vs. collaboration
Monday, July 14, 2008
This is a rather interesting talk that takes some very foundational ideas from open source software development, P2P networks, and social networking and implies that these paradigms can apply to a lot more.
Fremont Street
Sunday, July 29, 2007
Remote Control Dragonfly
Sunday, July 29, 2007
Videos
Sunday, July 29, 2007
Assortment of videos.
Honda CBR F4 Carburetor Cleaning
Monday, July 23, 2007
Details on how to clean F4 carburetors.

Never mistake knowledge for wisdom. One helps you make a living; the other helps you make a life.
- Sandra Carey

Projects-Misc Scripts-Perl Script...

Perl Script to Test for Open Mail Relays

Thursday, July 29, 2004 by digitalpeer, updated Wednesday, August 18, 2004

Open relays are bad. You shouldn't never run one and your server will be killed if you do by spammers.

As a warning, while this will detect most normal relays, it does not test for vulnerabilities and unknown reactions that some mail servers may have that allow them to exploited as a mail relay. http://www.abuse.net is pretty good at detecting these things. I can personally speak for software like a fully patched Microsoft Exchange 5.5 server which is absolutely horrible at handling mail trying to be relayed.
#!/usr/bin/perl -w

use IO::Socket::INET;
my $SOCKET = IO::Socket::INET->new(
        PeerAddr => "mailserverhost",
        PeerPort => 25,
        Proto   => 'tcp') || die "Error in create socket!";

$SOCKET->autoflush= 0;

# Suck down the greeting and discard it
my $RESPONSE = <$SOCKET>;
print $RESPONSE;

print "HELO server";
print $SOCKET "HELO server";
$RESPONSE = <$SOCKET>;
print $RESPONSE;

print "RSET";
print $SOCKET "RSET";
$RESPONSE = <$SOCKET>;
print $RESPONSE;

print "MAIL FROM:<spamtest@somedomain.com>";
print $SOCKET "MAIL FROM:<spamtest@somedomain.com>";
$RESPONSE = <$SOCKET>;
print $RESPONSE;


print "RCPT TO:<to@domain.com>";
print $SOCKET "RCPT TO:<to@domain.com>";
$RESPONSE = <$SOCKET>;
print $RESPONSE;

# goodbye
print $SOCKET "QUIT";
# eat any response
$RESPONSE = <$SOCKET>;
print $RESPONSE;
# kill socket
close($SOCKET);

This script can basically be used to automate doing something like telneting to a server to test it's ability to deny an unauthorized relay.

If you are looking for a better solution, the Grinch is a more developed perl script.
External Links Summary
Grinch - an open mail relay checker [www.zonque.org]

Submit Comment to This Article - Be the first!
Please post a comment if you have something to add, find something wrong, or would like more information on the topic at hand. Do not use the comment form to contact the author about unrelated concerns!

Name: Email (optional):
Enter verification number here: