WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-17-2007, 06:39 AM
dharrison's Avatar
Moderator
WebProWorld Moderator
 

Join Date: May 2005
Location: Essex, UK
Posts: 1,434
dharrison RepRank 3dharrison RepRank 3
Exclamation HELP! PHP Form being exploited

Please help.

One of my customers have a php form. A couple of weeks ago, he kept getting all these "Mail Delivery Failure" messages. They were all Viagra and horrid stuff like that. He got about 30 of them each evening.

Anyway the random code (part of the PHP form script) was text show I changed it to images and this worked for 2 weeks.

Anyway I got a message just now and it is being exploited again. I am beginning to run out of answers. Can anyone look on Contact U Store Solutions - Online Enquiry form and tell me if they see any obvious vulnerabilities.

Otherwise can anyone recommend another secure form script which should keep the b****rs out.

Any help gratefully received. Any quick help even more gratefully received.

TIA
__________________
Deb Harrison
DVH Design
Essex Web Design | Web Design Blog

Last edited by dharrison : 07-17-2007 at 07:09 AM.
Reply With Quote
  #2 (permalink)  
Old 07-17-2007, 09:09 AM
WebProWorld Veteran
 

Join Date: Aug 2003
Location: Cornwall, UK
Posts: 833
speed RepRank 1
Default Re: HELP! PHP Form being exploited

The way I've got around spam bots (at the moment anyway) is to send all our enquiries through our ticketing system and run the ticketing system over SSL.

Without seeing the PHP running the form it's impossible to tell if they are using OCR to read the characters, or some exploit in the code.

You could change the PHP so that it asks a random maths question or other simple question such as the name of the company or are there pictures of boxes on this page?
__________________
TOLRA Micro Systems Limited US & UK Web Hosting with Continuous Data Protection
Web Directory 2 for 1 Offer : Web Directory Script
Reply With Quote
  #3 (permalink)  
Old 07-17-2007, 09:20 AM
wige's Avatar
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,784
wige RepRank 4wige RepRank 4wige RepRank 4wige RepRank 4
Default Re: HELP! PHP Form being exploited

Other than the addition of captcha, do you have anything specific in the e-mails that narrows it down to a vulnerability in the script itself?

Also, as soon as possible, check the input validation. It looks like the script may be vulnerable to a XSS attack, not related to the e-mail problem but still a bad thing - you can test this by entering the following code in the requirement in detail text area
Code:
</textarea><script>alert()</script><textarea>
To save time I didn't bother entering a message, you do have input validation to prevent SQL injections and I didn't want to waste too much time on exploring this (but fix it). Also, is the site on a shared or dedicated host?
__________________
The best way to learn anything, is to question everything.

Last edited by wige : 07-17-2007 at 09:43 AM.
Reply With Quote
  #4 (permalink)  
Old 07-17-2007, 10:24 AM
WebProWorld Member
 

Join Date: Jan 2005
Posts: 37
joncase RepRank 1
Default Re: HELP! PHP Form being exploited

Hi Deb,
I was having the same problem with a cgi form. (Alien Form) No sort of validation I did on the client side stopped the spamming. (They were listing lots of websites in the textarea using anchor tags.) So I had to alter the script itself because they were bypassing the html form with their bot. Now the script on the server will not process the form if the textarea contains html tags.

Also, you may want to look at dB Masters FormM@iler. I haven't tried it yet, but it looks promising.
__________________
Jon Case
Small Business Website Design
Reply With Quote
  #5 (permalink)  
Old 07-17-2007, 10:26 AM
Dubbya's Avatar
WebProWorld 1,000+ Club
 

Join Date: Nov 2006
Location: Steinbach, Manitoba, Canada
Posts: 1,261
Dubbya RepRank 3Dubbya RepRank 3
Default Re: HELP! PHP Form being exploited

Are you certain that the script is being exploited?

You might want to check with the host to ensure that email relay has been disabled at the server.

They should also be able to specify that the server only sends email from the legit domain and email addresses.

I'd do my best to secure the form itself using SSL. If the form and the data it transmits isn't secured, it's vulnerable to interception.

I found a thread in *cough* in another forum with a few promising links to php security related info.

Check it out.
Securing PHP Forms - Kionic Community Forums

Good Luck.
__________________
Printer ink, inkjet & toner cartridges in Canada
"Price-wise printing supplies"
inkjetOasis.ca
Reply With Quote
  #6 (permalink)  
Old 07-17-2007, 10:38 AM
dharrison's Avatar
Moderator
WebProWorld Moderator
 

Join Date: May 2005
Location: Essex, UK
Posts: 1,434
dharrison RepRank 3dharrison RepRank 3
Default Re: HELP! PHP Form being exploited

Quote:
Originally Posted by wige View Post
Also, is the site on a shared or dedicated host?
I am on shared host.

It is definitely the form (or thats what the hosting people said).

Thanx for all your help so far.
__________________
Deb Harrison
DVH Design
Essex Web Design | Web Design Blog
Reply With Quote
  #7 (permalink)  
Old 07-17-2007, 10:41 AM
WebProWorld Veteran
 

Join Date: Aug 2003
Location: Cornwall, UK
Posts: 833
speed RepRank 1
Default Re: HELP! PHP Form being exploited

Quote:
Originally Posted by dharrison View Post
I am on shared host.

It is definitely the form (or thats what the hosting people said).

Thanx for all your help so far.
Have you asked the developers of the form about this, if it's a flaw in their code then they should fix it.

Whose form is it?
__________________
TOLRA Micro Systems Limited US & UK Web Hosting with Continuous Data Protection
Web Directory 2 for 1 Offer : Web Directory Script
Reply With Quote
  #8 (permalink)  
Old 07-17-2007, 10:45 AM
wige's Avatar
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,784
wige RepRank 4wige RepRank 4wige RepRank 4wige RepRank 4
Default Re: HELP! PHP Form being exploited

Quote:
Originally Posted by dharrison View Post
I am on shared host.
Well that rules out some things...

Quote:
Originally Posted by dharrison View Post
It is definitely the form.
I don't suppose they mentioned how they came to that conclusion, did they? (If they know it was done by the form, they might be able to determine what about the form was exploited) Would it be possible for you to either post or send me one of the bounce messages, or even better one of the spam e-mails, preferably with the headers intact?

Your site is vulnerable to a TRACE/TRACK XSS attack, which can be prevented by adding the following code to your htaccess file:
Code:
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule  .* - [F]
I was able to find a running smtp (email) server, but was not able to send a message to it, so that is a good sign. I may be able to determine more from one of the bounce messages though.
__________________
The best way to learn anything, is to question everything.

Last edited by wige : 07-17-2007 at 11:34 AM.
Reply With Quote
  #9 (permalink)  
Old 07-17-2007, 11:45 AM
wige's Avatar
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,784
wige RepRank 4wige RepRank 4wige RepRank 4wige RepRank 4
Default Re: HELP! PHP Form being exploited

Actually, I take back my previous post about not being able to access SMTP. I've never done much with those types of servers. You should see an e-mail from info@ustoresolutions.co.uk to mail@ustoresolutions.co.uk in a few moments, which I sent as a test. I think if I had passed a cc: it might have been able to spam outside of the network, but I am not extremely familiar with SMTP. It would not, however, let me directly send an e-mail to an external domain.
__________________
The best way to learn anything, is to question everything.
Reply With Quote
  #10 (permalink)  
Old 07-17-2007, 03:58 PM
WebProWorld New Member
 

Join Date: Dec 2004
Posts: 4
katom RepRank 0
Default Re: HELP! PHP Form being exploited

Quote:
Originally Posted by dharrison View Post
Please help.

One of my customers have a php form. A couple of weeks ago, he kept getting all these "Mail Delivery Failure" messages. They were all Viagra and horrid stuff like that. He got about 30 of them each evening.

Anyway the random code (part of the PHP form script) was text show I changed it to images and this worked for 2 weeks.

Anyway I got a message just now and it is being exploited again. I am beginning to run out of answers. Can anyone look on Contact U Store Solutions - Online Enquiry form and tell me if they see any obvious vulnerabilities.

Otherwise can anyone recommend another secure form script which should keep the b****rs out.

Any help gratefully received. Any quick help even more gratefully received.

TIA
We have received spam via php forms for some time and it really picked up a lot over the past 2 months. It has gotten to the point that we were receiving in excess of 300 per day. We are implementing captcha on all forms via php code in hopes of stopping the spam. We designed our forms where we receive the spam but it can not be forwarded on to others.
Reply With Quote
  #11 (permalink)  
Old 07-17-2007, 04:47 PM
WebProWorld Member
 

Join Date: Jun 2004
Location: NY
Posts: 31
tcustomgolf RepRank 0
Default Re: HELP! PHP Form being exploited

How about PHP Form Mail Script - Ultimate Form Mail

Seems to work for me and has lots of spam control, validation, etc.
__________________
Custom Golf Clubs and Repairs at: www.tcustomgolf.com
A GCA Accredited Clubmaker
Reply With Quote
  #12 (permalink)  
Old 07-17-2007, 04:59 PM
WebProWorld New Member
 

Join Date: Jun 2007
Location: lincolnshire, england
Posts: 18
colincartwright RepRank 0
Default Re: HELP! PHP Form being exploited

Not being that technically minded with PHP, I can't help you re-write the code so the spam goes away, but I did suffer a similar fate recently with two of my sites. I got around it by buying Form generating software from Coffee Cup Software. Their software is quite clever and designs the forms to work as SWF (shock wave flash forms). Since U uploaded these forms not had one bit of spam from the new forms - presumably its not possible for them to be spammed?

I have to say that the software allows you to be very creative designing forms, including images etc. All you do is placve the SWF object where you want the form to display on the page and upload a few extra files. Seems to work fine and it didn't cost that much to buy - about $34 if memory serves.

Another trick I read about recently was to do with spam coming from emails on websites, where people had designed the sites using the email address as text. Another poster on this form suggested designing email addresses as jpg or gif images with hyperlinks instead as being more effective at reducing direct email spam from your website?? Not tried this.
Reply With Quote
  #13 (permalink)  
Old 07-17-2007, 05:13 PM
wige's Avatar
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,784
wige RepRank 4wige RepRank 4wige RepRank 4wige RepRank 4
Default Re: HELP! PHP Form being exploited

There are a few other solutions as well, such as rather than having the form send an e-mail, it could simply take the passed data and store it in a text file on the server, then have a cron task set up to run a script every hour or so to check if the file exists (meaning someone filled out the form) and have that send the data to you and delete the text file. This way you are hardcoding the e-mail address in such a way that the script can't be hijacked (the script the public can access no longer knows how to send e-mail, and the new script that can send e-mail can not be accessed publicly).
__________________
The best way to learn anything, is to question everything.
Reply With Quote
  #14 (permalink)  
Old 07-17-2007, 06:40 PM
WebProWorld Member
 

Join Date: Oct 2005
Posts: 37
niggles RepRank 1
Default Re: HELP! PHP Form being exploited

There is an excellent article at the URL below which tells you about creating SPAM-free forms.

WebAIM: Blog - Spam-free accessible forms

A few of us have implemented these recommendations on several sites and they work really well, particularly the hidden field (if it gets filled in you know it's a spambot) and the timestamping (as spambots often process the form before going back later to submit it).

Cheers,
Nigel
__________________
-------------------------------------------------
World Music World - bringing the World's Folk Music Cultures Together
http://www.worldmusicworld.com/
-------------------------------------------------
Reply With Quote
  #15 (permalink)  
Old 07-17-2007, 06:56 PM
WebProWorld Member
 

Join Date: Feb 2005
Location: Albuquerque, NM
Posts: 32
wpriley RepRank 0
Default Re: HELP! PHP Form being exploited

Have you considered the possibility that your return E-mail address may have been spoofed by a spammer and that the return E-mails you're getting never originated on your server?
__________________
Pat Riley
Reply With Quote
  #16 (permalink)  
Old 07-17-2007, 07:30 PM
WebProWorld 1,000+ Club
 

Join Date: May 2004
Location: Philadelphia, PA
Posts: 1,726
deepsand RepRank 2
Default Re: HELP! PHP Form being exploited

Quote:
Originally Posted by wpriley View Post
Have you considered the possibility that your return E-mail address may have been spoofed by a spammer and that the return E-mails you're getting never originated on your server?

And, if the e-mail address was obtained by harvesting it from the site prior to its being changed from text to image, the horse is out of the barn, & it's not coming back!

In that case, the only good solution is to discard the old address, and make certain that the new one cannot be harvested.
Reply With Quote
  #17 (permalink)  
Old 07-17-2007, 09:05 PM
WebProWorld Pro
 

Join Date: May 2007
Location: DataCenter
Posts: 174
hostBrain RepRank 1
Default Re: HELP! PHP Form being exploited

Quote:
Originally Posted by colincartwright View Post
I got around it by buying Form generating software from Coffee Cup Software. Their software is quite clever and designs the forms to work as SWF (shock wave flash forms). Since U uploaded these forms not had one bit of spam from the new forms - presumably its not possible for them to be spammed?

I have to say that the software allows you to be very creative designing forms, including images etc. All you do is placve the SWF object where you want the form to display on the page and upload a few extra files. Seems to work fine and it didn't cost that much to buy - about $34 if memory serves.
Nice tip on this software... you've been repped

- will check it out
__________________
----Don't Call Me Brian----
Reply With Quote
  #18 (permalink)  
Old 07-18-2007, 12:32 AM
DrTandem1's Avatar
WebProWorld 1,000+ Club
 

Join Date: Oct 2003
Location: Encinitas, CA
Posts: 1,908
DrTandem1 RepRank 2
Default Re: HELP! PHP Form being exploited

At the moment, I'm getting a 404 error (page not found). You need to strip tags from the results as well as block line feeds. Also, I would recommend not allowing URLs in the text fields. The reason they exploit forms is to launch spam, usually using your own domain as the sender's domain. By disallowing your own domain from the form results, this will usually end it. Of course, I also recommend adding CAPTCHA, if you haven't already done so.

Lastly, it may simply be a virus/worm on your client's computer sending out spam using their web site's email address. Remember, when you see a hoof print, look for horses not zebras.
__________________
DrTandem's San Diego Web Page Design, drtandem.com
Reply With Quote
  #19 (permalink)  
Old 07-18-2007, 12:41 AM
WebProWorld 1,000+ Club
 

Join Date: May 2004
Location: Philadelphia, PA
Posts: 1,726
deepsand RepRank 2
Default Re: HELP! PHP Form being exploited

Quote:
Originally Posted by DrTandem1 View Post
<snip>

Remember, when you see a hoof print, look for horses not zebras.
But, how to tell the difference, considering that both are Animalia/Chordata/Mammalia/Perissodactyla/Equidae/Equus?
Reply With Quote
  #20 (permalink)  
Old 07-18-2007, 02:26 AM
dharrison's Avatar
Moderator
WebProWorld Moderator
 

Join Date: May 2005
Location: Essex, UK
Posts: 1,434
dharrison RepRank 3dharrison RepRank 3
Default Re: HELP! PHP Form being exploited

DT1 - You're getting a 404 page not found because I took this offline overnight. Basically the script/virus, etc sends out at night so I thought I would eliminate this. Good point though. Thanx man.

I have opted for ditching the PHP for the NMS formmail but I shall add RECAPTCHA to this. I don't know enough about PHP really.

Although I think I have worked out how they/it are exploiting the form thanks to that article. Thanx niggles.

Actually thanx all of you. There is certainly food for thought there.
__________________
Deb Harrison
DVH Design
Essex Web Design | Web Design Blog
Reply With Quote