Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    3

    Default Relaying via PHP

    I am experiencing a customer's form being exploited where it has been used to relay spam. It obtained my attention when i saw an influx of bounce backs to nobody. Is there a way to lock this down? I've already made sure not to allow nobody to send email but it still is occuring.

  2. #2
    Member
    Join Date
    Jan 2005
    Posts
    1,880

    Default

    You might want to look into installing mod security. With the right rules, this can be used to block certain types of malicious requests.

    Forms are commonly exploited by including carriage returns and line feeds within a field followed by data such that the data is interpretted as being the cc and bcc fields for an email.

    Rather than relying soley on mod security to block malicious http requests, I find it's always better to fix exploitable scripts, or at least fix them to the extent that a given exploit won't work.

    If I find an exploited PHP script, I add the following code to help me investigate:

    PHP Code:
    while (list($key$val) = each($_POST)) {
      
    $sPostContents .= $key." = ".$value."\n";
    }
    mail("example@example.com""Post values for ".$_SERVER['http_host'], $sPostContents);
    reset($_POST); 
    If you place this as near to the top of the script as possible you can get the entire form contents, field names and values, emailed to you.

    You can then study what values are being used in what fields. Once you've spotted a pattern you can then add conditions to the script to check for the patterns and stop such requests.

    One of the obvious things to spot is that the value of exploited fields will often contain "Content-Type: multipart/" so that a multipart message (commonly HTML and plain text parts) will be sent. The HTML part will contain the spam, the plain text part will contain some random prose so as to confuse spam checkers.

    Here is a piece of code I recently added to a user's script to deal with something along these lines:

    PHP Code:
    $sNneedle "Content-Type: multipart/";
      while (list(
    $key$val) = each($_POST)) {
        if (
    $key != "message") {
          if (
    substr_count($_POST[$key], $sNneedle)) {
            
    mail("example@example.com""Form exploit killed : ".$_SERVER['HTTP_REFERER'], $sPostContents);
            exit();
          }            
        }
      }
    reset($_POST); 
    You don't necessarily need to have it email you, but I find it helps keep track on who is doing what.

  3. #3
    Super Moderator This forum account has been confirmed by cPanel staff to represent a vendor. chirpy's Avatar
    Join Date
    Jun 2002
    Location
    Go on, have a guess
    Posts
    13,495

    Default

    I would also recommend added extended exim logging which you can use to track back from bounces to the directory where the offending script(s) are so that you can remove/fix them.
    Jonathan Michaelson

    Need your cPanel servers secured and tuned?
    cPanel Server Configuration, Security, Recovery and Antivirus/AntiSpam Services
    Developers of the most effective (and free) Firewall & Security Solution for cPanel Servers - csf
    http://www.configserver.com

Similar Threads & Tags
Similar threads

  1. PHP mail() not relaying
    By apc1 in forum cPanel and WHM Discussions
    Replies: 7
    Last Post: 10-04-2005, 11:26 AM
  2. Spam relaying
    By PDW in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 11-13-2004, 09:39 AM
  3. Mail Relaying
    By sigep739 in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 08-07-2004, 01:43 AM
  4. mail relaying or not...
    By wrightee in forum cPanel and WHM Discussions
    Replies: 5
    Last Post: 01-29-2004, 12:24 AM
  5. Relaying denied
    By Jontxu40 in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 07-14-2003, 12:52 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube