I'm trying to setup a RewriteRule
for Apache 2.4 that allows me to return
a 403 code when any keywords are found in the QUERY_STRING
.
I'm trying to return 403 whenever anyone does some malicious attacks such as:
wget /etc/passwd
or wp-login
in the QUERY_STRING
.
Here are a few generic examples Im trying to block:
"GET /wp-login.php HTTP/1.1"
"GET /setup.cgi?next_file=somefile HTTP/1.1"
"GET //public/html HTTP/1.1"
"GET /wget+http://192.168.1.1:8080/etc/passwd HTTP/1.1"
"POST /admin/Login.php?user=joe&passwd=77 HTTP/1.1"
"POST /httpdir/wp-login.php?user=bob&pw=12345 HTTP/1.1"
I have no idea why it does not appear to be working. I've tried several things to get it to work with no luck so far which is why I am posting. I'm sure its something subtle or easy.
RewriteCond %{QUERY_STRING} ^/.*(wget|/etc|admin|wp-login|setup|public).*$
RewriteRule .* - [F,NC]
[UPDATE] I added several specific examples and added the POST conditions I would like to catch as well. Thank you so much for your help!