Skip to content

Instantly share code, notes, and snippets.

@miglen
Created July 15, 2015 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miglen/36f8d7e1c6d3e035fc1d to your computer and use it in GitHub Desktop.
Save miglen/36f8d7e1c6d3e035fc1d to your computer and use it in GitHub Desktop.
Web proxy filters and rewrites
# Source: http://whatever.truls.org/proxyfilters.text.shtml
RewriteEngine On
RewriteOptions inherit
RewriteLogLevel 5
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} (.*)rewritefiltertest(\x20*)any(.*) [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} (.*)rewritefiltertest(\x20*)end[$|\?(.*)] [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} (.*)XXXXXXXXXXXXXXXXXXXXXXXXX(.*) [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^(.*/)?(\x20*)winnt/(\x20*)system32/(.*) [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^(.*/)?(\x20*)winnt/(\x20*)system/(.*) [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^(.*/)?(\x20*)windows/(\x20*)system32/(.*) [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^(.*/)?(\x20*)windows/(\x20*)system/(.*) [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^(.*/)?(\x20*)cmd\.exe[$|\?(.*)] [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^(.*/)?(\x20*)scripts/(\x20*)root.exe[$|\?(.*)] [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^(.*/)?(\x20*)msadc/(\x20*)root\.exe[$|\?(.*)] [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^(.*/)?[\\/](\x20*)(%2E|\.)(%2E|\.)(.*) [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^(.*/)?[\\/](%20)*(%2E|\.)(%2E|\.)(.*) [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^(.*/)?[\\/](%2E|\.)(%2E|\.)(.*) [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^(.*/)?(\x20*)admin\.dll[$|\?(.*)] [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^(.*/)?(\x20*)msadcs\.dll[$|\?(.*)] [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^(.*/)?(\x20*)ext\.dll[$|\?(.*)] [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^(.*/)?(\x20*)fp..reg\.dll[$|\?(.*)] [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^(.*/)?(.*)bin/(\x20*)shtml\.(dll|exe)[$|\?(.*)] [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^(.*/)?(\x20*)php\.exe[$|\?(.*)] [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^(.*/)?(\x20*)perl\.exe[$|\?(.*)] [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^(.*/)?(\x20*)args\.(bat|cmd)[$|\?(.*)] [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^(.*/)?(\x20*)(ad)?xmlrpc\.php[$|\?(.*)] [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^(.*/)?(\x20*)thisdoesnotexistahaha\.php[$|\?(.*)] [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^(.*/)?(portal|stats|cacti)/cmd\.php[$|\?(.*)] [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^/?cmd\.php[$|\?(.*)] [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^(.*/)?cacti/rra/apo\.log[$|\?(.*)] [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^(.*/)?NULL.printer[$|\?(.*)|/(.*)] [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^(.*/)?(\x20+)[/|$|\?(.*)] [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} (.*)(%3C|\<)(.*) [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} (.*)(%3E|\>)(.*) [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} (.*)(%7C|\|)(.*) [NC,OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} [\x00-\x1f\x7f\xff]+ [OR]
RewriteCond %{REQUEST_URI} ^(.*/)?http:// [NC,OR]
RewriteCond %{REQUEST_URI} ^(.*/)?(FormMail|mailform)\.(pl|cgi)(/.*)?$ [NC,OR]
RewriteCond %{REQUEST_URI} ^/*(cp/|cgi/)?(awstats|stats|cgi|cgi-bin)/awstats\.(pl|cgi)(/.*)?$ [NC,OR]
RewriteCond %{REQUEST_URI} ^(.*/)?galaxy_[0-9]+\.[0-9]+$ [NC,OR]
RewriteCond %{REQUEST_URI} ^(.*/)?_vti_bin/(.*)\.(dll|exe)(.*) [NC,OR]
RewriteCond %{REQUEST_URI} ^(.*/)?_vti_inf.html [NC,OR]
RewriteCond %{REQUEST_URI} ^(.*/)?MSOffice/(.*)\.asp [NC,OR]
RewriteCond %{REQUEST_URI} ^(.*/)?(\x20*)\.(.*) [NC,OR]
RewriteCond %{REQUEST_URI} ^(.*/)?\%\%(.*) [OR]
RewriteCond %{REQUEST_URI} (.{255,}) [OR]
RewriteCond %{REQUEST_URI} (.*):(.*) [OR]
RewriteCond %{QUERY_STRING} (.*)\?\?(.*) [OR]
RewriteCond %{QUERY_STRING} (.{255,}) [OR]
RewriteCond %{THE_REQUEST} http:// [NC]
RewriteRule (.*) / [NC,F]
#RewriteCond %{REQUEST_URI} !^/sgs/bin/[-_/a-z]+\.php$
#RewriteCond %{REQUEST_URI}?%{QUERY_STRING} (.*)(%7C|\|)(.*) [NC]
#RewriteRule (.*) http://monty.frukt.org/error/filtered.html [NC,F]
RedirectMatch 404 ^/w00tw00t.at.[^/]+$
RedirectMatch 404 (?i)^/((php)?MyAdmin|pma)/
RedirectMatch 404 (?i).*/Win(NT|dows)/System(32)?/
RedirectMatch 404 (?i).*/Cmd\.exe(\?.*)?$
RedirectMatch 404 (?i).*/Scripts/Root\.exe(\?.*)?$
RedirectMatch 404 (?i).*/MSADC/Root\.exe(\?.*)?$
RedirectMatch 404 (?i).*/Default\.IDA(\?.*)?$
RedirectMatch 404 (?i).*/Admin\.dll(\?.*)?$
RedirectMatch 404 (?i).*/MSADCS\.dll(\?.*)?$
RedirectMatch 404 (?i).*/Ext\.dll(\?.*)?$
RedirectMatch 404 (?i).*/php\.exe\?
RedirectMatch 404 (.*)\\\.\.(.*)
RedirectMatch 404 (.*)/\.(.*)
RedirectMatch 404 (.*)\<(.*)
RedirectMatch 404 (.*)\>(.*)
RedirectMatch 404 (.*)\|(.*)
RedirectMatch 404 (.{255,})
RedirectMatch 404 [\x00-\x1f]+
RedirectMatch 404 [\x7f|\xff]+
#RedirectMatch 410 (.*)testmatch(.*)
# My favourite setting, when you need to restrict the query string size to 255 symbols:
RewriteCond %{REQUEST_URI} (.{255,}) [OR]
RewriteCond %{QUERY_STRING} (.{255,})
RewriteRule (.*) / [NC,F]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment