sql.php 1.2 KB

123456789101112131415161718192021
  1. <?
  2. $getfilter = "'|(and|or)\\b.+?(>|<|=|in|like)|\\/\\*.+?\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?SELECT|INSERT\\s+INTO.+?VALUES|(SELECT|DELETE).+?FROM|(CREATE|ALTER|DROP|TRUNCATE)\\s+(TABLE|DATABASE)";
  3. $postfilter = "\\b(and|or)\\b.{1,6}?(=|>|<|\\bin\\b|\\blike\\b)|\\/\\*.+?\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?SELECT|INSERT\\s+INTO.+?VALUES|(SELECT|DELETE).+?FROM|(CREATE|ALTER|DROP|TRUNCATE)\\s+(TABLE|DATABASE)";
  4. $cookiefilter = "\\b(and|or)\\b.{1,6}?(=|>|<|\\bin\\b|\\blike\\b)|\\/\\*.+?\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?SELECT|INSERT\\s+INTO.+?VALUES|(SELECT|DELETE).+?FROM|(CREATE|ALTER|DROP|TRUNCATE)\\s+(TABLE|DATABASE)";
  5. function stopattack($StrFiltKey, $StrFiltValue, $ArrFiltReq){
  6. if(is_array($StrFiltValue))$StrFiltValue = implode($StrFiltValue);
  7. if (preg_match("/".$ArrFiltReq."/is",$StrFiltValue) == 1){
  8. echo '4004';exit;
  9. }
  10. }
  11. foreach($_GET as $key=>$value){
  12. if(stripos($value,"<?")!==false){echo '4004';exit;}
  13. if(stripos($value,"&lt;?")!==false){echo '4004';exit;}
  14. if(stripos($value,"?>")!==false){echo '4004';exit;}
  15. if(stripos($value,"?&gt;")!==false){echo '4004';exit;}
  16. if(stripos($value,"<script")!==false){echo '4004';exit;}
  17. stopattack($key,$value,$getfilter);
  18. }
  19. ?>