Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Teddy Zugana
Teddy Zugana

Posted on • Edited on

     

Stop SQL Injection from .htaccess

# Enable rewrite engineRewriteEngine On# Block suspicious request methodsRewriteCond %{REQUEST_METHOD} ^(HEAD|TRACE|DELETE|TRACK|DEBUG) [NC]RewriteRule ^(.*)$ - [F,L]# Block WP timthumb hackRewriteCond %{REQUEST_URI} (timthumb\.php|phpthumb\.php|thumb\.php|thumbs\.php) [NC]RewriteRule . - [S=1]# Block suspicious user agents and requestsRewriteCond %{HTTP_USER_AGENT} (libwww-perl|wget|python|nikto|curl|scan|java|winhttp|clshttp|loader) [NC,OR]RewriteCond %{HTTP_USER_AGENT} (<|>|'|%0A|%0D|%27|%3C|%3E|%00) [NC,OR]RewriteCond %{HTTP_USER_AGENT} (;|<|>|'|"|\)|\(|%0A|%0D|%22|%27|%28|%3C|%3E|%00).*(libwww-perl|wget|python|nikto|curl|scan|java|winhttp|HTTrack|clshttp|archiver|loader|email|harvest|extract|grab|miner) [NC,OR]RewriteCond %{THE_REQUEST} \?\ HTTP/ [NC,OR]RewriteCond %{THE_REQUEST} \/\*\ HTTP/ [NC,OR]RewriteCond %{THE_REQUEST} etc/passwd [NC,OR]RewriteCond %{THE_REQUEST} cgi-bin [NC,OR]RewriteCond %{THE_REQUEST} (%0A|%0D) [NC,OR]# Block MySQL injections, RFI, base64, etc.RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=http:// [OR]RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=(\.\.//?)+ [OR]RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=/([a-z0-9_.]//?)+ [NC,OR]RewriteCond %{QUERY_STRING} \=PHP[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} [NC,OR]RewriteCond %{QUERY_STRING} (\.\./|\.\.) [OR]RewriteCond %{QUERY_STRING} ftp\: [NC,OR]RewriteCond %{QUERY_STRING} http\: [NC,OR]RewriteCond %{QUERY_STRING} https\: [NC,OR]RewriteCond %{QUERY_STRING} \=\|w\| [NC,OR]RewriteCond %{QUERY_STRING} ^(.*)/self/(.*)$ [NC,OR]RewriteCond %{QUERY_STRING} ^(.*)cPath=http://(.*)$ [NC,OR]RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]RewriteCond %{QUERY_STRING} (\<|%3C).*iframe.*(\>|%3E) [NC,OR]RewriteCond %{QUERY_STRING} (<|%3C)([^i]*i)+frame.*(>|%3E) [NC,OR]RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [NC,OR]RewriteCond %{QUERY_STRING} base64_(en|de)code[^(]*\([^)]*\) [NC,OR]RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) [OR]RewriteCond %{QUERY_STRING} ^.*(\[|\]|\(|\)|<|>).* [NC,OR]RewriteCond %{QUERY_STRING} (NULL|OUTFILE|LOAD_FILE) [OR]RewriteCond %{QUERY_STRING} (\./|\../|\.../)+(motd|etc|bin) [NC,OR]RewriteCond %{QUERY_STRING} (localhost|loopback|127\.0\.0\.1) [NC,OR]RewriteCond %{QUERY_STRING} (<|>|'|%0A|%0D|%27|%3C|%3E|%00) [NC,OR]RewriteCond %{QUERY_STRING} concat[^\(]*\( [NC,OR]RewriteCond %{QUERY_STRING} union([^s]*s)+elect [NC,OR]RewriteCond %{QUERY_STRING} union([^a]*a)+ll([^s]*s)+elect [NC,OR]RewriteCond %{QUERY_STRING} (;|<|>|'|"|\)|%0A|%0D|%22|%27|%3C|%3E|%00).*(/\*|union|select|insert|drop|delete|update|cast|create|char|convert|alter|declare|order|script|set|md5|benchmark|encode) [NC,OR]RewriteCond %{QUERY_STRING} (sp_executesql) [NC]RewriteRule ^(.*)$ - [F,L]
Enter fullscreen modeExit fullscreen mode

Top comments(1)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
maxime216 profile image
maxime216
I'm a fullstack dev angular symfony, passionate by architecture.Except tech things, I also love guitare and slackline !
  • Location
    Lyon
  • Work
    Dev Fullstack at Mounki
  • Joined

This seems to be interesting! Can you explain it more specifically pls?

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

vi veri veniversum vivus vici Noob Teams
  • Location
    Indonesia Jakarta
  • Education
    Computer Science Sriwijaya University
  • Work
    Programmer at Icon Plus, Ezeelink Jakarta
  • Joined

More fromTeddy Zugana

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp