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