gpt4 book ai didi

php - 人们如何通过我的联系表发送垃圾邮件

转载 作者:行者123 更新时间:2023-12-02 05:31:44 24 4
gpt4 key购买 nike

今天有人联系我说从某个域发送了大量垃圾邮件。这是一个相对简单的 php 网站,带有一个包含姓名、电子邮件、电话和消息的联系表。除非整个服务器都被黑了,否则我看不出该网站有任何其他方式可以用来向多个用户发送垃圾邮件。

电子邮件已通过验证,错误字符已从邮件正文中删除。我尝试了多种方法来尝试通过表单修改标题,但似乎无法正常工作,所以我开始认为这些表单是安全的。

这是表单验证:

                              $to='owner@website.com';

$messageSubject='Enquiry from the website';
$confirmationSubject='Your email to website.com';
$confirmationBody="Thankyou for your recent email enquiry to website.com.\n\nYour email has been sent and we will get back to you as soon as possible.\n\nThe message you sent was:\n";
$email='';
$body='';
$displayForm=true;
if ($_POST){
$email=stripslashes($_POST['email']);
$body=stripslashes($_POST['body']);
$name=stripslashes($_POST['name']);
$phone=stripslashes($_POST['phone']);
// validate e-mail address
$valid=eregi('^([0-9a-z]+[-._+&])*[0-9a-z]+@([-0-9a-z]+[.])+[a-z]{2,6}$',$email);
$crack=eregi("(\r|\n)(to:|from:|cc:|bcc:)",$body);
$spam=eregi("http",$body);
$businessBody = "Enquiry from: $name\nEmail: $email\nPhone: $phone\n\nMessage:\n$body";
if ($email && $body && $phone && $name && $valid && !$crack & !$spam){
if (mail($to,$messageSubject,$businessBody,'From: '.$email."\r\n") && mail($email,$confirmationSubject,$confirmationBody.$body,'From: '.$to."\r\n")){
$displayForm=false;
echo "<div><p>Your message to us was sent successfully, and a confirmation copy has also been sent to your e-mail address.</p><p>Your message was:<br>".htmlspecialchars($body)."</p></div>";
}
else echo '<div class="emailMessage"><p>Something went wrong when the server tried to send your message. This might be due to a server error, and is probably not your fault. We apologise for any inconvenience caused. You are welcome to telephone us on 01383 625110</p></div>'; // the messages could not be sent
}
else if ($crack) echo '<div class="emailMessage"><p>Your message contained e-mail headers within the message body. This seems to be a cracking attempt and the message has not been sent.</p></div>'; // cracking attempt
else if ($spam) echo '<div class="emailMessage"><p>Your message contained characters that our system has flagged as spam email and has not been sent.</p></div>'; // spam mail!
else echo '<div class="emailMessage"><p>Your message could not be sent. You must complete all fields - name, phone number, e-mail address and a message.</p></div>'; // form not complete
}

谁能看出滥用此表单的方式?

编辑

事实证明,有人在为群发邮件构建的服务器上放置了另一个加密文件,因此它实际上并非来自此表单。无论如何,感谢您的回答,他们可能会帮助其他人!

最佳答案

使用适当的邮件类,如 SwiftMailer而且你会遇到更少的麻烦(以及更好看的代码)。通常,通过向“来自”或其他 header 添加换行符来滥用这些类型的表单,从而允许它们设置自己的恶意 header 。

例如:

if (mail($to,$messageSubject,$businessBody,'From: '.$email."\r\n") && mail($email,$confirmationSubject,$confirmationBody.$body,'From: '.$to."\r\n")){

虽然您删除了斜杠,但您还没有删除新行。如果我将我的电子邮件设置为:

ceejayoz@example.com
Bcc: victim@example.com

victim@example.com 在电子邮件中被密件抄送。通过一些更聪明的东西 - 将其变成多部分电子邮件并添加额外的默认部分 - 他们可以完全自定义电子邮件。

关于php - 人们如何通过我的联系表发送垃圾邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12288928/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com