hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Hosting Security and Technology : Form Scripts
Reply

Hosting Security and Technology Configuring and optimizing web hosting servers and operating systems, developing administration scripts, building servers, protecting against hackers, and general security (SSL certificates, etc.)
Forum Jump

Form Scripts

Reply Post New Thread In Hosting Security and Technology Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 12-12-2005, 03:17 PM
ankushdawar ankushdawar is offline
Newbie
 
Join Date: Feb 2004
Posts: 21

Form Scripts


Hello.

Suddenly I see a rise in spam exploits in many servers.
Which use form scripts based on php. I think .. its an
exploit ... is anyone else is also facing this issue.

Please guide me ... to stop this !!
Its causing my servers to become spam sorces.

Regards

Ankush Dawar

Reply With Quote


Sponsored Links
  #2  
Old 12-12-2005, 03:56 PM
StackHost StackHost is offline
Froggy Support
 
Join Date: Aug 2004
Posts: 1,384
Why do you think it is php exploits?

__________________
FrogJumper.com, Superb Cpanel Web Hosting.
Excellent, High Paying Affiliate Program.

Reply With Quote
  #3  
Old 12-12-2005, 04:05 PM
ankushdawar ankushdawar is offline
Newbie
 
Join Date: Feb 2004
Posts: 21
Hello.

Its not a php expoit ..
Its .. Email Header Injection in a formscript .. used by many users on
many servers, I have no idea to secure it serverwide ?
http://www.nyphp.org/phundamentals/e..._injection.php

Regards,

Ankush Dawar

Reply With Quote
Sponsored Links
  #4  
Old 12-12-2005, 04:50 PM
emalbum emalbum is offline
Junior Guru Wannabe
 
Join Date: Jun 2004
Posts: 37
Prevent email injection

Hello,

I had the same problem. See the following article:
http://securephp.damonkohler.com/ind...mail_Injection

Here is what I did to fix the issue.

- created a file called email.php
PHP Code:
<?php

function sendEmail($to$from$subject$message$page) {
  
// filter and validate email
  
$from filter($from);
  if (!
valid($from)) {
    
$from 'admin@yourEmail.com';
    
$subject "HACKING ATTEMPT"
  }
  
  
// wordwrap message
  
$message wordwrap($message70);
  
  
// build header
  
$header "From: $from\n";
  
$header .= "X-Mailer: PHP/$page";

  
// send email
  
mail($to$subject$message$header);
}

function 
filter($value) {
  
$pattern = array("/\n/","/\r/","/content-type:/i","/to:/i""/from:/i""/cc:/i""/bcc:/i");
  
$value preg_replace($pattern""$value);
  return 
$value;
}

function 
valid($email) {
  
// copied from http://www.php.net/manual/en/function.eregi.php#52458

  
$atom '[-a-z0-9!#$%&\'*+/=?^_`{|}~]';    // allowed characters for part before "at" character
  
$domain '([a-z]([-a-z0-9]*[a-z0-9]+)?)'// allowed characters for part after "at" character

  
$regex '^' $atom '+' .         // One or more atom characters.
  
'(\.' $atom '+)*' .              // Followed by zero or more dot separated sets of one or more atom characters
  
'@' .                                // Followed by an "at" character.
  
'(' $domain '{1,63}\.)+' .       // Followed by one or max 63 domain characters (dot separated).
  
$domain '{2,63}' .                 // Must be followed by one set consisting a period of two
  
'$'
  if (
eregi($regex$email)) {
    return 
true;
  } else {
    return 
false;
  }
}

?>
Then in my contact form, contact.php, I have (this is a very stripped down version):
PHP Code:
<?php
require("email.php");

if (!
defined($_REQUEST['sent'])) {
    print 
'
<form name="" method="post">
  <input type="text" name="email"/><br/>
  <textarea name="note" rows="5" cols="50"></textarea>
  <input type="hidden" name="sent" value="1"/>
</form>'
;

} else {
    
// You can validate entries here, if you like

    // Send the email
    
sendEmail('your@emailHere.com'$_REQUEST{'email'}, 'Your Subject Here'$_REQUEST{'note'}, 'contact');
}
?>
The 'contact' is just a string that I use to say which page it came from, for tracking purposes. I just use the form to submit a contact email, but you could modify it to filter and validate the To address as well.

HTH.

-Eric

__________________
emAlbum - Image Gallery Sofware

Reply With Quote
  #5  
Old 12-12-2005, 05:02 PM
ankushdawar ankushdawar is offline
Newbie
 
Join Date: Feb 2004
Posts: 21
Hi,

But the problem is I have over 10000+ Clients, how do I fix this server wide ?

Regards,

Ankush Dawar

Reply With Quote
  #6  
Old 12-12-2005, 05:25 PM
emalbum emalbum is offline
Junior Guru Wannabe
 
Join Date: Jun 2004
Posts: 37
There are probably a few things you could do. Each one requires your customer to update/replace or remove their scripts. Seriously though, if this isn't fixed, it will cause you serious problems in the long run, like being blacklisted.

- Do what my host did...suspend their account until they fix the problem.
- Write a script that changes permissions on all "known" script names that could cause the problem, example: contact.php
- Stop the email service =)

__________________
emAlbum - Image Gallery Sofware

Reply With Quote
  #7  
Old 12-12-2005, 07:03 PM
GOT GOT is offline
WHT Addict
 
Join Date: Jun 2002
Location: Portsmouth, VA
Posts: 159
You need to install mod_security if you have not already and you need to add some rules that scan the post data for the string bcc:

I saw this on five servers about a month ago. It was a HUGE mess.

__________________
---
Jon Berry
Proactive Server Management
http://www.got-management.com

Reply With Quote
  #8  
Old 12-13-2005, 12:26 PM
ankushdawar ankushdawar is offline
Newbie
 
Join Date: Feb 2004
Posts: 21
can you provide those specific rules related to this issue.

Thanks.

Reply With Quote
  #9  
Old 12-13-2005, 04:41 PM
GOT GOT is offline
WHT Addict
 
Join Date: Jun 2002
Location: Portsmouth, VA
Posts: 159
I am using

SecFilterSelective POST_PAYLOAD "bcc\:"

Though some might find that a bit heavy handed.

__________________
---
Jon Berry
Proactive Server Management
http://www.got-management.com

Reply With Quote
  #10  
Old 12-14-2005, 03:56 PM
ankushdawar ankushdawar is offline
Newbie
 
Join Date: Feb 2004
Posts: 21
Will this block webmail .. bcc also ?
I dont want to stop that on webmail services.
Just forms ...

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Web Host PromptSpace Launches Shared Hosting Platform Web Hosting News 2011-12-27 18:15:25
Web Host Secure Cloud Space Integrates Softaculous Auto-Installer with Control Panel Web Hosting News 2011-12-19 16:39:33
Softaculous Adds 17 New Apps to Auto Installer Library Web Hosting News 2011-09-12 17:51:10
Web Host HostingZoom Adds Softaculous Auto-Installer to Hosting Plans Web Hosting News 2011-08-17 17:52:34
Web Host JaguarPC Adds Auto-Installer Softaculous to Hosting Plans Web Hosting News 2011-07-27 18:55:46


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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 Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?