block-exploits.conf 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. ## Block SQL injections
  2. set $block_sql_injections 0;
  3. if ($query_string ~ "union.*select.*\(") {
  4. set $block_sql_injections 1;
  5. }
  6. if ($query_string ~ "union.*all.*select.*") {
  7. set $block_sql_injections 1;
  8. }
  9. if ($query_string ~ "concat.*\(") {
  10. set $block_sql_injections 1;
  11. }
  12. if ($block_sql_injections = 1) {
  13. return 403;
  14. }
  15. ## Block file injections
  16. set $block_file_injections 0;
  17. if ($query_string ~ "[a-zA-Z0-9_]=http://") {
  18. set $block_file_injections 1;
  19. }
  20. if ($query_string ~ "[a-zA-Z0-9_]=(\.\.//?)+") {
  21. set $block_file_injections 1;
  22. }
  23. if ($query_string ~ "[a-zA-Z0-9_]=/([a-z0-9_.]//?)+") {
  24. set $block_file_injections 1;
  25. }
  26. if ($block_file_injections = 1) {
  27. return 403;
  28. }
  29. ## Block common exploits
  30. set $block_common_exploits 0;
  31. if ($query_string ~ "(<|%3C).*script.*(>|%3E)") {
  32. set $block_common_exploits 1;
  33. }
  34. if ($query_string ~ "GLOBALS(=|\[|\%[0-9A-Z]{0,2})") {
  35. set $block_common_exploits 1;
  36. }
  37. if ($query_string ~ "_REQUEST(=|\[|\%[0-9A-Z]{0,2})") {
  38. set $block_common_exploits 1;
  39. }
  40. if ($query_string ~ "proc/self/environ") {
  41. set $block_common_exploits 1;
  42. }
  43. if ($query_string ~ "mosConfig_[a-zA-Z_]{1,21}(=|\%3D)") {
  44. set $block_common_exploits 1;
  45. }
  46. if ($query_string ~ "base64_(en|de)code\(.*\)") {
  47. set $block_common_exploits 1;
  48. }
  49. if ($block_common_exploits = 1) {
  50. return 403;
  51. }
  52. ## Block spam
  53. set $block_spam 0;
  54. if ($query_string ~ "\b(ultram|unicauca|valium|viagra|vicodin|xanax|ypxaieo)\b") {
  55. set $block_spam 1;
  56. }
  57. if ($query_string ~ "\b(erections|hoodia|huronriveracres|impotence|levitra|libido)\b") {
  58. set $block_spam 1;
  59. }
  60. if ($query_string ~ "\b(ambien|blue\spill|cialis|cocaine|ejaculation|erectile)\b") {
  61. set $block_spam 1;
  62. }
  63. if ($query_string ~ "\b(lipitor|phentermin|pro[sz]ac|sandyauer|tramadol|troyhamby)\b") {
  64. set $block_spam 1;
  65. }
  66. if ($block_spam = 1) {
  67. return 403;
  68. }
  69. ## Block user agents
  70. set $block_user_agents 0;
  71. # Disable Akeeba Remote Control 2.5 and earlier
  72. if ($http_user_agent ~ "Indy Library") {
  73. set $block_user_agents 1;
  74. }
  75. # Common bandwidth hoggers and hacking tools.
  76. if ($http_user_agent ~ "libwww-perl") {
  77. set $block_user_agents 1;
  78. }
  79. if ($http_user_agent ~ "GetRight") {
  80. set $block_user_agents 1;
  81. }
  82. if ($http_user_agent ~ "GetWeb!") {
  83. set $block_user_agents 1;
  84. }
  85. if ($http_user_agent ~ "Go!Zilla") {
  86. set $block_user_agents 1;
  87. }
  88. if ($http_user_agent ~ "Download Demon") {
  89. set $block_user_agents 1;
  90. }
  91. if ($http_user_agent ~ "Go-Ahead-Got-It") {
  92. set $block_user_agents 1;
  93. }
  94. if ($http_user_agent ~ "TurnitinBot") {
  95. set $block_user_agents 1;
  96. }
  97. if ($http_user_agent ~ "GrabNet") {
  98. set $block_user_agents 1;
  99. }
  100. if ($block_user_agents = 1) {
  101. return 403;
  102. }