UK Webmaster Talk - Online Marketing - SEO


 

Please review for security

This is a discussion on Please review for security within the Php and MySQL forums, part of the Programming / Scripting / Coding category; Hi, I have a simple form that posts to this PHP script. PHP Code: <? $to  =  "my.specified.email@my.domain.ext" ; $subject  ...


Go Back   UK Webmaster Talk - Online Marketing - SEO > Website Design & Development > Programming / Scripting / Coding > Php and MySQL

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Notices

Reply

 

LinkBack Thread Tools Display Modes
Old 28-08-2005, 11:59   #1 (permalink)
Super Moderator
 
Join Date: Mar 2005
Location: Herts, UK
Posts: 1,030
iTrader: 1 / 100%
monaghan is a jewel in the rough
Default Please review for security

Hi,

I have a simple form that posts to this PHP script.

PHP Code:
<?

$to 
"my.specified.email@my.domain.ext";
$subject "Web Enquiry from $customer_name";
$message "Customer: $customer_name \r\nEmail: $customer_email\r\n Originating
Website: $originator\r\n $enquiry"
;
mail($to,$subject,$message);
header("Location: " $ret_url);

?>
I have recently had a few emails with a CC: that suggest they appear from my server. Is there any obvious way to hack into this script or obvious error ?
monaghan is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 03-09-2005, 09:42   #2 (permalink)
WMT Sponsor
 
Join Date: Jan 2005
Location: Mobile, AL
Posts: 38
iTrader: 0 / 0%
TDHCentral is on a distinguished road
Send a message via MSN to TDHCentral Send a message via Yahoo to TDHCentral
Default

If this is a contact form i have had same problem with someone trying to hack mine. I got this from my biz partner and who is a host:

Try this:

//form spammer $email
$mystring=$firstname;
$mystring.=$lastname;
$mystring.=$email;
$mystring.=$comments;
$findme = 'MIME-Version: 1.0';
$pos = strpos($mystring, $findme);
if ($pos == true) exit;

You may have to adjust the variables to your form. They usually try each field and are trying to insert header information in the email that would allow them to send spam via your contact form.

This form has the variables firstname, lastname, email address, and comments that can be filled in. I used the $firstname=$_POST['firstname'] to get the post.

I then wanted to put everything in 1 variable from all the posted variables and used '.=' after firstname to add to the variable.

It seems that MIME-Version: 1.0 was in all the attempts and isn't somehthing someone would normally post in a contact message so the last 2 lines search for that in the posted variables and if it finds it, simply exits without doing anything else. You can replace the MIME- with something else if you want, but, be sure to copy and replace it exactly from the email you've been receiving and make sure that it is going to be in all the batches of emails you recieve, not just one batch IE the boundary for a message would be different for each batch so that would be a bad string to use.
******

He's just been using this for 2 days or so..so the jury is still out. However, he's great host and good programmer. At least it's something you could try as I will.

I'll let ya know how it goes.
TDHCentral is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 03-09-2005, 20:32   #3 (permalink)
Super Moderator
 
Join Date: Mar 2005
Location: Herts, UK
Posts: 1,030
iTrader: 1 / 100%
monaghan is a jewel in the rough
Default

Bl***y spammers

I've put some filtering into the php to bail out if it finds bits related to an email header, not difficult to do, just a pain.
monaghan is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
review, security

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
security precautions when building an application? benf Php and MySQL 1 07-03-2007 20:43
Novice user security FrozenDice Website Reviews 8 14-07-2005 11:14


All times are GMT +1. The time now is 18:24.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
UK Webmaster Forum © WebmasterTalk.co.uk | Design by Forbairt

Ad Management by RedTyger

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41