如何解决后请求ddos

今天我们的magento商店受到攻击,我希望有人可以帮助告诉我如何阻止来自100多个不同IP的这些请求:

182.255.44.234 - - [15/May/2017:13:24:14 +0100] "POST /calais-shop/customer/account/createpost/ HTTP/1.1" 503 1916 59.61.38.24 - - [15/May/2017:13:24:14 +0100] "POST /calais-shop/customer/account/createpost/ HTTP/1.1" 503 1916 120.39.95.47 - - [15/May/2017:13:24:13 +0100] "POST /calais-shop/customer/account/createpost/ HTTP/1.1" 503 1916 114.236.17.181 - - [15/May/2017:13:24:14 +0100] "POST /calais-shop/customer/account/createpost/ HTTP/1.1" 503 1916 114.236.17.181 - - [15/May/2017:13:23:47 +0100] "POST /calais-shop/customer/account/createpost/ HTTP/1.1" 503 1916 58.219.222.251 - - [15/May/2017:13:24:15 +0100] "POST /calais-shop/customer/account/createpost/ HTTP/1.1" 503 1916 182.46.161.100 - - [15/May/2017:13:24:16 +0100] "POST /calais-shop/customer/account/createpost/ HTTP/1.1" 503 1916 49.83.89.244 - - [15/May/2017:13:24:16 +0100] "POST /calais-shop/customer/account/createpost/ HTTP/1.1" 503 1916 117.28.127.48 - - [15/May/2017:13:24:16 +0100] "POST /calais-shop/customer/account/createpost/ HTTP/1.1" 503 1916 60.167.222.175 - - [15/May/2017:13:24:16 +0100] "POST /calais-shop/customer/account/createpost/ HTTP/1.1" 503 1916 114.236.17.181 - - [15/May/2017:13:24:16 +0100] "POST /calais-shop/customer/account/createpost/ HTTP/1.1" 503 1916 110.84.8.132 - - [15/May/2017:13:24:17 +0100] "POST /calais-shop/customer/account/createpost/ HTTP/1.1" 503 1916 

我不能阻止POST请求,所以我想知道什么是最好的解决scheme?

这是search“magento createPost攻击”的谷歌search结果,所以我会继续前进,在这里包括我的解决scheme。

免责声明你不应该修改Magento核心。 由于在这种持续的攻击中,您可能会惊慌失措,因此您可能会暂时修改Magento Core文件,并在禁用违规IP后实施适当的解决scheme

tl; dr将应用程序代码从该URL( /route/being/attacked )移动到另一个( /some/new/route ),更新前端代码以向/some/new/route提交表单IP地址访问/route/being/attacked并禁止他们与IPtables或您select的工具。

你在这里做的是创build一个蜜jar来捕获有问题的IP,这样你就可以永久禁止他们通过你喜欢的方式,例如iptables。

  1. 从Mage_Customer_AccountController :: createPostAction重新定位function

    只需在AccountController中创build一个新方法,例如createPostNewAction ,它是createPostNewAction内容的复制/粘贴

  2. 将前端表单URL更新为新的路由

    到/ customer / account / createPost的路由从Helper类Mage_Customer_Helper_Data::getRegisterPostUrl检索。 你应该修改这个方法,使它返回到你的新动作的路由,例如, return $this->_getUrl('customer/account/createpostnew');

  3. 将日志logging在createPostAction

    用logging语句replacecreatePostAction的内容。 确保这个日志文件不被覆盖或者如果你愿意的话会被自动截断。

     public function createPostAction { Mage::log($_SERVER['REMOTE_ADDR'], Zend_Log::DEBUG, 'ban_customer_spam_ips', true); return false; } 

所以现在我们所做的是将处理“新客户registry单”的function转移到一个新的路由上,并用一个日志logging语句取代了原来的路由,这个日志语句将把请求URL的人的IP地址logging到文件ban_customer_spam_ips 。 没有理由要求这条路线的合法请求,所以我们可以假设对这条路线的任何请求都是恶意的,我们可以禁止它们。

作为root用户, tail前面提到的日志文件和禁止IP使用任何你喜欢的方法。 在这里我使用了使用iptables fail2ban 。 你可以select直接使用iptables做任何你喜欢的事情。 根据需要调整path,我的Magento安装是/var/www/magento但你的可能会有所不同! 您可以创build一个.sh文件并在后台执行该文件,也可以在命令行上运行:

 tail -f /var/www/magento/var/log/ban_customer_spam_ips | awk ' BEGIN {} { print "banning ip: " $4 block_command = "fail2ban-client set apache banip "$4 system(block_command) close(block_command) }'