Archive for the 'Cron' Category

Goldfish and forged spam

Recently I had the goldfish autoresponder (vacation responses / email auto reply) setup for a user for about one week. Checking their inbox about half way through this time period revealed it having over 47,000 unread messages. What was happening is that spammers were sending email with forged headers. Have you ever received a spam message that apparently has been sent from yourself?

I suppose it can be accomplished via a variety of ways, however I was able to reproduce this particular issue via generating one of these tasty spam mails via the following (all internally of course… I am not a spammer):

telnet smtp.example.com 25

and then issuing these commands:

ehlo workstation.example.com
mail from:<emailuser@example.com>
rcpt to:<emailuser@example.com>
data
From: <emailuser@example.com>
To: <emailuser@example.com>
Subject: testing a loop
Message text
.
quit

Notice the mail is being sent to the user… and from the user…

  1. The server would receive the email addressed to emailuser@example.com
  2. goldfish would parse the message and notice it needed to respond to… emailuser@example.com
  3. The mail was delivered
  4. Rinse, wash, repeat

The source of the message looked something like this:

root@server:/var/local/vmail/example.com/emailuser# cat new/1220557062.P6882Q0M652544.server\,S\=1082
Return-Path: <emailuser@example.com>
Delivered-To: emailuser@example.com
Received: from localhost (localhost [127.0.0.1]) by server.example.com (Postfix) with ESMTP id 923E9185F7 for <emailuser@example.com>; Thu, 4 Sep 2008 15:37:42 -0400 (EDT)
X-Virus-Scanned: Debian amavisd-new at server.example.com
Received: from server.example.com ([127.0.0.1]) by localhost (server.example.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id q3tScOaitRoS for <emailuser@example.com>; Thu, 4 Sep 2008 15:37:42 -0400 (EDT)
Received: from workstation.example.com (workstation.example.com [xx.xxx.xxx.xx]) by server.example.com (Postfix) with ESMTP id B89E1185EB for <emailuser@example.com>; Thu, 4 Sep 2008 15:37:25 -0400 (EDT)
From: <emailuser@example.com>
To: <emailuser@example.com>
Subject: testing a loop

Message-Id: <20080904193728.B89E1185EB@server.example.com>
Date: Thu, 4 Sep 2008 15:37:25 -0400 (EDT)

Message text

and to prevent goldfish from causing havoc on the particular inbox (or mitigating what was already done… and preventing future issues), I added the following PHP:

//strip the line break from $address for checks
$addressCheck = substr($address,0,strlen($address)-1);
if ($addressCheck==$email)
{
        $log->addLine("Email address from autoresponder table is the same as the intended recipient! Not sending the mail!");
        break;
}

just before letting the mail being sent…

mail($address, $subject, $message, $headers);

I love goldfish. It’s like a do it yourself autoresponder! Keep in mind, this code works on Version 002, patch level 1, but could very well not work on any future releases (there have been indications that a newer version is in the works). Maybe I will post a few more tweaks in upcoming posts if the latest stable stays around for much longer.

Posted by Karl Herrick on September 9th, 2008 in PHP, Linux, Cron | 2 Comments »

Autoresponders - a loop

This past week I encountered an interesting situation between two web applications I work with regularly. The first is the goldfish autoresponder for postfix. The second is RT: Request Tracker.

The situation went something like this:

Every five minutes a new ticket was being created in RT because of goldfish’s configuration and cron job being set to run that often. I caught the cycle happening when the incoming queue of tickets had three or four created with their subjects typical of those created by an autoresponder.

Posted by Karl Herrick on August 2nd, 2008 in PHP, Linux, Cron | 2 Comments »

Cron crontab window windowed gui app application

The title shows all of the different terms I was googling for… and what was near impossible to find, I finally found.

Here I am to share share my new found knowledge with you. Do you want to run a windowed application with cron? The basics are that you have to export your display.

Yeah, I read that in other places. But where? I thought to myself… Some said, “IN YOUR CRONTAB FILE” Yeah, okay, whatever that means. I would like some more detail. As they say, the devil is in the details. So, with detailed instructions I continue.

If you have your cron permissions setup properly and run:

crontab -e

you can set a cron job that looks something like:

0,30 * * * * export DISPLAY=:0 && killall skype && sleep 5 && skype

So what does this mean? It means, every 30 minutes, run the following commands:

export DISPLAY=:0
killall skype
sleep 5
skype

Okay, difficult to explain… but basically as I understand it, it means: When you run the cron job, it is in a terminal environment. It cannot find the X Windows display without setting the DISPLAY variable within the command string for the cron job.

So, as a recap, set your display variable within the command string of your cron job. :-)

Posted by Karl Herrick on September 8th, 2006 in Cron, Bash | No Comments »