Help me defeat the spammers!
December 4, 2006 9:58 AM
Subscribe
Is this a spammer trying to circumvent my website "contact" button?
Due to assloads of spam, I recently switched email addresses and switched from offering my email address on my website (as an image, which got harvested anyway) to a form that passes the message to a simple PHP script.
This morning I saw three emails. This was the content (yes, complete with garbage shown here; identifying features removed):
_____________________________________________
up to 10 added solution can be called ham water added . inally, ham and water product refers [random hex/numbers] > Reply-To: cure Content-Transfer-Encoding: quoted-printable Content-Type: text/html Subject: by the end of uly bcc: [scum]@dogdayinmw.com up to 10 added solution can be called ham water added . inally, ham and water product refers [random numbers] Date: Mon, 04 Dec 2006 04:12:39 -0800 Subject: [INQUIRY] [nonsenseaccount@[mydomain].com [nonsenseaccount]@[mydomain].com
_____________________________________________
Is this an attempt to get a bounce back to him with a real address? I'm assuming the exploit didn't work, as I haven't seen any real bounces in my inbox.
In one of the variations I saw this in the Subject field: "Content-Transfer-Encoding: 7bit Content-Type: text/html Subject: use bcc: [spammer]@orangesundof.com".
I don't know if anyone here has PHP experience but here's the script I'm using (HTML stripped out so as not to confuse MeFi). If anyone sees any exploitation issues please let me know.
_______________________________
$to = "[our address]";
$username = $_POST['cc1'];
$email = $_POST['cc2'];
$subject = "[INQUIRY] " . $_POST['cc3'];
$message = stripslashes($_POST['cc4']);
if ( ($username == "") || ($email == "") || ($subject == "") || ($message == "") ) {
echo(" Could not send message... required fields were left blank. ");
die(); }
$headers = "From: \"" . $username . "\" < . $email .> \r\n" .
"Reply-To: " . $email . "\r\n" .
"Date: ".date("r"). "\r\n" .
"Subject: " . $subject ;
mail( $to, $subject, $message, $headers );
echo ("Thanks, we will reply to your message within about 24 to 48 hours.");
_______________________________
>
posted by zek to computers & internet (9 comments total)
Note that if the submitter sends you information that has, say, embedded carriage returns/linefeeds in it, they can add extra headers to your email, such as CC: or BCC: headers. What if the submitted $_POST['cc2'] variable looked like this:
bob@example.com>[carriagereturn][linefeed]
BCC: alan@aol.com, bob@aol.com, charlie@aol.com, dave@aol.com...... zanzibar@aol.com
Wouldn't your script then cheerfully send mail to you, BCC:ed to every one of those people? Wouldn't your script spam them, in other words?
The exploiter is perhaps messing it up slightly. After all, he doesn't know exactly how your script is written, so he has to try a few different things. But that's what he's trying.
You need to do a lot more to those $_POST fields that you receive from the user before you can trust them enough to use them in constructing an email.
posted by jellicle at 10:19 AM on December 4, 2006