博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
分享纯 nginx 防御代码 nginx safe.conf
阅读量:6155 次
发布时间:2019-06-21

本文共 3250 字,大约阅读时间需要 10 分钟。

hot3.png

if ($request_uri ~* "([+|(%20)]and[+|(%20)])|([+|(%20)]or[+|(%20)])|([+|(%20)]select[+|(%20)])|([+|(%20)]exec[+|(%20)])|([+|(%20)]union[+|(%20)])") {	return 403;}if ($request_uri ~* "(cost\()|(concat\()") {	return 404;}if ($query_string ~ "(<|%3C).*script.*(>|%3E)") {	return 404;}if ($query_string ~ "GLOBALS(=|[|%[0-9A-Z]{ 0,2})") {	return 404;}if ($query_string ~ "_REQUEST(=|[|%[0-9A-Z]{ 0,2})") {	return 404;}if ($query_string ~ "proc/self/environ") {	return 404;}if ($query_string ~ "mosConfig_[a-zA-Z_]{ 1,21}(=|%3D)") {	return 404;}if ($query_string ~ "base64_(en|de)code(.*)") {	return 404;}if ($http_user_agent ~ "Python-urllib") {	return 404;}if ($query_string ~ "union.*select.*\("){	set $block_sql_injections 1;}if ($query_string ~ "union.*all.*select.*"){ set $block_sql_injections 1; }if ($query_string ~ "concat.*\("){  set $block_sql_injections 1; }if ($block_sql_injections = 1){  return 403; }if ($query_string ~ "[a-zA-Z0-9_]=http://"){  set $block_file_injections 1; }if ($query_string ~ "[a-zA-Z0-9_]=(\.\.//?)+"){  set $block_file_injections 1; }if ($query_string ~ "[a-zA-Z0-9_]=/([a-z0-9_.]//?)+"){  set $block_file_injections 1; }if ($block_file_injections = 1){  return 403; }## Block common exploitsset $block_common_exploits 0;if ($query_string ~ "(<|%3C).*script.*(>|%3E)"){  set $block_common_exploits 1; }if ($query_string ~ "GLOBALS(=|\[|\%[0-9A-Z]{  0,2 })"){  set $block_common_exploits 1; }if ($query_string ~ "_REQUEST(=|\[|\%[0-9A-Z]{  0,2 })"){  set $block_common_exploits 1; }if ($query_string ~ "proc/self/environ"){  set $block_common_exploits 1; }if ($query_string ~ "mosConfig_[a-zA-Z_]{  1,21 }(=|\%3D)"){  set $block_common_exploits 1; }if ($query_string ~ "base64_(en|de)code\(.*\)"){  set $block_common_exploits 1; }if ($block_common_exploits = 1){  return 403; }## Block spamset $block_spam 0;if ($query_string ~ "\b(ultram|unicauca|valium|viagra|vicodin|xanax|ypxaieo)\b"){  set $block_spam 1; }if ($query_string ~ "\b(erections|hoodia|huronriveracres|impotence|levitra|libido)\b"){  set $block_spam 1; }if ($query_string ~ "\b(ambien|blue\spill|cialis|cocaine|ejaculation|erectile)\b"){  set $block_spam 1; }if ($query_string ~ "\b(lipitor|phentermin|pro[sz]ac|sandyauer|tramadol|troyhamby)\b"){  set $block_spam 1; }if ($block_spam = 1){  return 403; }## Block user agentsset $block_user_agents 0;# Don't disable wget if you need it to run cron jobs!##if ($http_user_agent ~ "Wget")# {  # set $block_user_agents 1;# }# Disable Akeeba Remote Control 2.5 and earlierif ($http_user_agent ~ "Indy Library"){  set $block_user_agents 1; }# Common bandwidth hoggers and hacking tools.if ($http_user_agent ~ "libwww-perl"){  set $block_user_agents 1; }if ($http_user_agent ~ "GetRight"){  set $block_user_agents 1; }if ($http_user_agent ~ "GetWeb!"){  set $block_user_agents 1; }if ($http_user_agent ~ "Go!Zilla"){  set $block_user_agents 1; }if ($http_user_agent ~ "Download Demon"){  set $block_user_agents 1; }if ($http_user_agent ~ "Go-Ahead-Got-It"){  set $block_user_agents 1; }if ($http_user_agent ~ "TurnitinBot"){  set $block_user_agents 1; }if ($http_user_agent ~ "GrabNet"){  set $block_user_agents 1; }if ($block_user_agents = 1){  return 403; }

转载于:https://my.oschina.net/u/1176204/blog/974104

你可能感兴趣的文章
跨域-学习笔记
查看>>
the assignment of reading paper
查看>>
android apk 逆向中常用工具一览
查看>>
MyEclipse 报错 Errors running builder 'JavaScript Validator' on project......
查看>>
Skip List——跳表,一个高效的索引技术
查看>>
Yii2单元测试初探
查看>>
五、字典
查看>>
前端js之JavaScript
查看>>
Log4J日志配置详解
查看>>
实验7 BindService模拟通信
查看>>
scanf
查看>>
Socket编程注意接收缓冲区大小
查看>>
SpringMVC初写(五)拦截器
查看>>
检测oracle数据库坏块的方法
查看>>
SQL server 安装教程
查看>>
Linux下ftp和ssh详解
查看>>
跨站脚本功攻击,xss,一个简单的例子让你知道什么是xss攻击
查看>>
js时间和时间戳之间如何转换(汇总)
查看>>
js插件---图片懒加载echo.js结合 Amaze UI ScrollSpy 使用
查看>>
java中string和int的相互转换
查看>>