Security,Hole,Mail,Header,Inje DIY Security Hole Mail Header Injection at PHP


Normal 0 false false false MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable{mso-style-name:"Table Normal";mso-tstyle-rowband-size:0;mso-tstyle-colband-size:0;mso-style-noshow:yes;mso-style-parent:"";mso-padding-alt:0in When starting a new work at home business it is very easy to become consumed by it. We spend so much time trying to get the business up and running that we may end up becoming burned out and lose our motivation. There is so much to learn and


If you use PHP language to send an email (especially if using HTML form), you must take extra precautions. In the last few weeks, many have tried actively exploiting PHP scripts that use mail() function:mail($recipient, $subject, $message, [$extraheaders], [$extraparams]);Most general mistakes that have done by PHP programmer are, they didn't validate every variables that coming to their server. If there's some variables from HTML form, then someone can adding any header into it and that can cause trouble to your server or might send spams by using your server.As an example, let see this sample code:mail("[email protected]", $subject, $text, "From: $emailn");would have security hole if you didn't validate $subject variable and $email variable.The simple way to detect header injection exploitation is by checking whether there's newline character (r or n) at those variables. Here's the example to check $subject variable:Make sure that you check every variable that coming to your server. Beside the example above, you must also check $email variable that being used in mail() function.Here's the sample PHP code that i've used to prevent spam injection (your critics and suggestions are very welcome)function logbad($value) { $report_to = "your_email"; $name = www.monx007.com; $mail = "from_email"; // replace this with your own get_ip function... $ip = (empty($_SERVER['REMOTE_ADDR'])) ? 'empty' : $_SERVER['REMOTE_ADDR']; $rf = (empty($_SERVER['HTTP_REFERER'])) ? 'empty' : $_SERVER['HTTP_REFERER']; $ua = (empty($_SERVER['HTTP_USER_AGENT'])) ? 'empty' : $_SERVER['HTTP_USER_AGENT']; $ru = (empty($_SERVER['REQUEST_URI'])) ? 'empty' : $_SERVER['REQUEST_URI']; $rm = (empty($_SERVER['REQUEST_METHOD'])) ? 'empty' : $_SERVER['REQUEST_METHOD']; $headers = "MIME-Version: 1.0n"; $headers .= "Content-type: text/plain; charset=iso-8859-1n"; $headers .= "X-Priority: 1n"; $headers .= "X-MSMail-Priority: Normaln"; $headers .= "X-Mailer: phpn"; $headers .= "From: "".$nama."" rnrn"; @mail ( $report_to ,"[ABUSE] mailinjection @ " . $_SERVER['HTTP_HOST'] . " by " . $ip ,"Stopped possible mail-injection @ " . $_SERVER['HTTP_HOST'] . " by " . $ip . " (" . date('d/m/Y H:i:s') . ")rnrn" . "*** IP/HOSTrn" . $ip . "rnrn" . "*** USER AGENTrn" . $ua . "rnrn" . "*** REFERERrn" . $rf . "rnrn" . "*** REQUEST URIrn" . $ru . "rnrn" . "*** REQUEST METHODrn" . $rm . "rnrn" . "*** SUSPECTrn--rn" . $value . "rn--" ,$headers ); }// Check 1 //First, make sure the form was posted from a browser. // For basic web-forms, we don't care about anything // other than requests from a browser: if(!isset($_SERVER['HTTP_USER_AGENT'])){ die('Forbidden - You are not authorized to view this page (0)'); exit;}// Cek 2 // Make sure the form was indeed POST'ed: // (requires your html form to use: action="post") if(!$_SERVER['REQUEST_METHOD'] == "POST") { die('Forbidden - You are not authorized to view this page (1)'); exit; }// Host names from where the form is authorized // to be posted from: $authHosts = array("yourdomain.com");// Where have we been posted from? $fromArray = parse_url(strtolower($_SERVER['HTTP_REFERER']));// Test to see if the $fromArray used www to get here. $wwwUsed = strpos($fromArray['host'], "www. "); // Make sure the form was posted from an approved host name. if(!in_array(($wwwUsed === false ? $fromArray['host'] : substr(stristr($fromArray['host'], '.'), 1)), $authHosts)) { logbad("Form was not posted from an approved host name"); die(' Forbidden - You are not authorized to view this page (2)'); exit; } // Attempt to defend against header injections: $badStrings = array("content-type:", "mime-version:", "content-transfer-encoding:", "multipart/mixed", "charset=", "bcc:", "cc:"); // Loop through each POST'ed value and test if it contains // one of the $badStrings: foreach($_POST as $k => $v) { foreach($badStrings as $v2) { if(strpos(strtolower($v), $v2) !== false) { logbad($v); die('Form processing cancelled: string (`'.$v.'`) contains text portions that are potentially harmful to this server. Your input has not been sent! Please use your browser's `back`-button to return to the previous page and try rephrasing your input.'); exit; } } } // Made it past spammer test, free up some memory // and continuing the rest of script: unset($k, $v, $v2, $badStrings, $authHosts, $fromArray, $wwwUsed);See these sites below to find additional information: http://securephp.damonkohler.com/index.php/Email_Injection http://us2.php.net/mail (look at the comment section)Source: Security Hole Mail Header Injection at PHP Article Tags: Security Hole Mail, Hole Mail Header, Mail Header Injection, Security Hole, Hole Mail, Mail Header, Header Injection, Html Form, Make Sure, Nbsp $headers, Posted From

Security,Hole,Mail,Header,Inje

DIY

Soil testing as important as oil changes are for engines

When you have a vehicle that you are driving a lot, you know that oil changes are something that you need to do on a regular basis to keep your vehicle in good condition. This is the same as soil testing. Soil testing ensures that your soil ...

DIY

Foam bitumen - Sustainable Eco-friendly Roads

Dont you think it will be great if we have eco-friendly roads that will be sustainable and durable as well? If there are roads that are not harming the environment anymore? This isnt just something that is for the future. There are countrie ...

DIY

Soil Testing: It’s all about that soil

Soil testing. The success of your harvest is all about the quality of the soil. And, the only way to ensure that you have the best soil, is to know what your soil needs.Many dont think that soil testing is needed. They are only adding nutrie ...

DIY

Mobile Work and Aluminum Platforms That Fit Your Needs

There are many domestic, trade and industrial applications where an extension ladder is the best and safest choice. Although many people try to make do with tall stepladders, most don't know it's hazardous to stand on the top work platform o ...

DIY

Truck Access Platforms That suitable for you

Looking to plan and specialist a few kinds of platforms that give your workers safe access to single or multiple hatches on an assortment of Tank Trucks. In the event that your administrators are as of now getting to the highest points of tr ...

DIY

How to Choose a Custom T-shirt Printing Company?

Be it a family event, a noble cause, company event, or personal interest, wearing custom t-shirts gives importance to it. The fame of personalized shirts is soaring high with this. More and more men and women are wearing custom shirts while ...

DIY

Moving Jurney By Interm Packers and Movers

They perceive the ins and outs of transferring so it's a protected option to allow them to deal with your whole belongings as a result of they'll do it proper and do it with care. When you might be in a predicament corresponding to not havin ...

DIY

Use a Vacuum Excavation for an Unearthing Project

You may very well get yourself that you have to utilise a vacuum excavation for an uncovering venture. This can be anything from disposing of a channel that is blocked or to penetrate a gap in the ground without harming the encompassing zone ...

DIY

Detailed Information about Non-Destructive Digging

At the point when you consider digging a gap in the ground, the principal thing that rings a bell is this ordinarily winds up a total wreckage around the gap.Be that as it may, there is one technique called non-destructive digging. This is t ...

DIY

A Complete Guide to buying a Vacuum Truck

Buying a vacuum truck are something that you should consider on the off chance that you are searching for another business opportunity. There are a few advantages to having this sort of business in the event that you have a completely prepar ...

DIY

Best Methods of Underground Cable Detection!

While we are continually fabricating and remolding properties, unearthing is unavoidable and can be attempted for an assortment of reason. What we are going to discover right now while playing out an exhuming, you should discover any undergr ...

DIY

Vacuum Trucks Can Deal with Exact Unearthing Needs!

Some intriguing data about vacuum trucks. That it will have the option to give in your precise excavation and drilling needs. You may imagine that those enormous trucks won't have the option to penetrate precisely, without harming anything a ...

DIY

Utility Locators - Locating Underground Cable

There are numerous reasons why it is imperative to locate underground cables. Also, if the Cables can't be found effectively, the fiasco will be immense and can be destroying.This is the reason you have to ensure that you know however much a ...

DIY

Important Information about Hydro Excavation

Hydro excavation is the way toward expelling or moving soil with pressurized water. An air movement or vacuum is then used to move the dirt or trash to a garbage tank. This takes into account a non-damaging and progressively exact approach t ...

DIY

Foam Bitumen - Lab Tests for Pavement Construction

Foam Bitumen. Something that you probably won't have found out about. All in all, for what reason would it be advisable for you to consider what the different lab tests on bitumen for asphalt development are? But on the off chance that you a ...

DIY

Soil Testing & analysing Is Worth the Effort

There's nothing of the sort as a free lunch, even in the nursery. Contingent upon your soil's local ripeness and what you develop, your plants may perform for quite a long time without requiring extra manure. Be that as it may, at some point ...

DIY

Soil Testing For Construction

Soil testing is a significant piece of building and street development. Truth be told, no development task can continue without first ensuring the soil can bolster the heap. Subsequently, the reason for soil testing for construction is to de ...

DIY

Soil Testing Services for Construction Projects

Regardless of whether you are building your fantasy home, making an expansion to your current home or building up a business property, there is one thing that is of most extreme significance, soil testing. There are various building consulta ...

DIY

Property Insurance

Property is Peoples HopeIt is not wrong to say that property is a hope and main aim of every person. People put all their efforts and then purchase some property for time ahead reliability and safety. This property is result of a long term s ...