Lloyd
02-08-2007, 04:37 PM
My mail server IP was blacklisted by hotmail! This post tells you how it happened and how I managed to work around it.
HOW IT HAPPENED
I run a small e-business, and back on Jan. 13-14 a "contact us" perl CGI script of mine with a security hole was exploited by a web bot to send spam to hotmail addresses.
I knew this script was insecure, and wasn't using it, but it (and the html form that called it) got copied to my Rimuhosting server from my old shared hosting server. During the migration of files the CGI script's permissions accidentally got set executable (700).
I realized the problem on the morning of the 14th, when I saw the bounces from non-existent email addresses in my inbox. I detained the exploited script immediately. The event lasted about 12 hours, I believe.
On Jan 31, 2 weeks after the event, MSN Hotmail blacklisted my IP. There was no warning or contact from MSN.
Suddenly my mail server could not delivery email to hotmail addresses. It seems that about 1/3 or more of my customers use hotmail! Order acknowledgements, e-invoices, and requests to be included on my mailing list all bounced. :(
I filled out an MSN online contact form to report delivery trouble. In subsequent correspondence I explained the problem, and in an email on Monday (Feb. 5) they promised to remove the block as soon as I explained what I am doing to prevent future exploits. They assume the problem is a Windows virus, and they assume I am running Windows Server, even though I specified on the original contact form that I run a Linux mail server. They even offered me a free Windows virus scan! :)
I gave them details on the exploit on Monday, but they have not responded, and my IP is still blacklisted.
THE WORKAROUND
Before I got in contact with MSN I was already working on a temporary fix. Suppose MSN drags their feet for weeks and leaves my IP blacklisted?
What I did was to write a perl mailing script that uses my gmail account to send email to hotmail addresses (only).
Gmail uses TLS encryption. On CPAN (http://www.cpan.org) I found a module to allow TLS (encrypted) data transfer. (Net::SMTP::TLS). If you know any perl the code will be obvious. ($to_ holds the recipient email address. 'emailmessage' must include the mail headers and the body. This code does not construct the actual email.)
if ($msnhack and $to_ =~ /\@hotmail\./)
{
use Net::SMTP::TLS;
my %smtpopts;
my $server= 'smtp.gmail.com';
$smtpopts{'Hello'}= 'carao.org';
$smtpopts{'Port'}= 587;
$smtpopts{'User'}= 'username@gmail.com';
$smtpopts{'Password'}= 'yourgmailpassword';
$smtpopts{'Timeout'}= 10;
my $smtp = Net::SMTP::TLS->new($server,%smtpopts);
$smtp->mail('senderemailaddress');
$smtp->to($to_);
$smtp->data;
$smtp->datasend('emailmessage');
$smtp->dataend;
$smtp->quit;
}
else
{
<code to send email using your own mail server>
}
Note that you should use a gmail server only as a temporary workaround, for personal email only (never for mailing list mailings). Gmail offers a generous and excellent service; don't abuse it. If your system needs to send a large volume of email to hotmail addresses, this is not for you.
Conclusion: Don't leave exploitable scripts on your server! It is not enough to set the permissions 600. Better to remove such files completely.
HOW IT HAPPENED
I run a small e-business, and back on Jan. 13-14 a "contact us" perl CGI script of mine with a security hole was exploited by a web bot to send spam to hotmail addresses.
I knew this script was insecure, and wasn't using it, but it (and the html form that called it) got copied to my Rimuhosting server from my old shared hosting server. During the migration of files the CGI script's permissions accidentally got set executable (700).
I realized the problem on the morning of the 14th, when I saw the bounces from non-existent email addresses in my inbox. I detained the exploited script immediately. The event lasted about 12 hours, I believe.
On Jan 31, 2 weeks after the event, MSN Hotmail blacklisted my IP. There was no warning or contact from MSN.
Suddenly my mail server could not delivery email to hotmail addresses. It seems that about 1/3 or more of my customers use hotmail! Order acknowledgements, e-invoices, and requests to be included on my mailing list all bounced. :(
I filled out an MSN online contact form to report delivery trouble. In subsequent correspondence I explained the problem, and in an email on Monday (Feb. 5) they promised to remove the block as soon as I explained what I am doing to prevent future exploits. They assume the problem is a Windows virus, and they assume I am running Windows Server, even though I specified on the original contact form that I run a Linux mail server. They even offered me a free Windows virus scan! :)
I gave them details on the exploit on Monday, but they have not responded, and my IP is still blacklisted.
THE WORKAROUND
Before I got in contact with MSN I was already working on a temporary fix. Suppose MSN drags their feet for weeks and leaves my IP blacklisted?
What I did was to write a perl mailing script that uses my gmail account to send email to hotmail addresses (only).
Gmail uses TLS encryption. On CPAN (http://www.cpan.org) I found a module to allow TLS (encrypted) data transfer. (Net::SMTP::TLS). If you know any perl the code will be obvious. ($to_ holds the recipient email address. 'emailmessage' must include the mail headers and the body. This code does not construct the actual email.)
if ($msnhack and $to_ =~ /\@hotmail\./)
{
use Net::SMTP::TLS;
my %smtpopts;
my $server= 'smtp.gmail.com';
$smtpopts{'Hello'}= 'carao.org';
$smtpopts{'Port'}= 587;
$smtpopts{'User'}= 'username@gmail.com';
$smtpopts{'Password'}= 'yourgmailpassword';
$smtpopts{'Timeout'}= 10;
my $smtp = Net::SMTP::TLS->new($server,%smtpopts);
$smtp->mail('senderemailaddress');
$smtp->to($to_);
$smtp->data;
$smtp->datasend('emailmessage');
$smtp->dataend;
$smtp->quit;
}
else
{
<code to send email using your own mail server>
}
Note that you should use a gmail server only as a temporary workaround, for personal email only (never for mailing list mailings). Gmail offers a generous and excellent service; don't abuse it. If your system needs to send a large volume of email to hotmail addresses, this is not for you.
Conclusion: Don't leave exploitable scripts on your server! It is not enough to set the permissions 600. Better to remove such files completely.