Jump to content

Email Header Inject Test


mildlyincoherent

Recommended Posts

So I'm trying to write a script to check if someone is trying to do a header inject using my web based email form.  The problem is that, regardless of the content, it is being tagged as hijacked.  The following is the relevant part of my code:


[code] $ip=$_POST['ip'];
$httpref=$_POST['httpref'];
$httpagent=$_POST['httpagent'];
$visitor=$_POST['visitor'];
$visitormail=$_POST['visitormail'];
$subject=$_POST['subject'];
$notes=$_POST['notes'];

$passedTests = "yes";
$Hijacked = "no";
$HijackAttempt=$visitormail;

if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<div class=\"centerIt\">";
echo "The following error(s) were encountered: <br />";
echo "<font color='red'>Invalid email address. <br /></font>";
$passedTests = "no";
}

if(empty($visitor) || empty($visitormail) || empty($notes ))
{
if($passedTests == "yes")
{
echo "<div class=\"centerIt\">";
echo "The following error(s) were encountered: <br />";
}
echo "<font color='red'>Please fill in ALL of the required fields.</font>";
$passedTests = "no";
}

    if (!preg_match("/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i", $HijackAttempt) && ($passedTests == "yes"))
{
$passedTests = "no";
$Hijacked = "yes";
}[/code]

Any help identifying the problem with this code would be much appreciated.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.