Home > Backend Development > PHP Tutorial > 360 anti-cross-site attack script

360 anti-cross-site attack script

WBOY
Release: 2016-07-25 09:02:17
Original
1260 people have browsed it
360 anti-cross-site attack script转载地址: http://blog.qita.in/?post=275

使用方法:
require_once('360.php');
  1. //http://blog.qita.in
  2. function customError($errno, $errstr, $errfile, $errline)
  3. {
  4. echo "Error number: [$errno],error on line $errline in $errfile
    ";
  5. die();
  6. }
  7. set_error_handler("customError",E_ERROR);
  8. $getfilter="'|(and|or)\b.+?(>|$postfilter="\b(and|or)\b.{1,6}?(=|>|$cookiefilter="\b(and|or)\b.{1,6}?(=|>|function StopAttack($StrFiltKey,$StrFiltValue,$ArrFiltReq){
  9. if(is_array($StrFiltValue))
  10. {
  11. $StrFiltValue=implode($StrFiltValue);
  12. }
  13. if (preg_match("/".$ArrFiltReq."/is",$StrFiltValue)==1){
  14. //slog("

    操作IP: ".$_SERVER["REMOTE_ADDR"]."
    操作时间: ".strftime("%Y-%m-%d %H:%M:%S")."
    操作页面:".$_SERVER["PHP_SELF"]."
    提交方式: ".$_SERVER["REQUEST_METHOD"]."
    提交参数: ".$StrFiltKey."
    提交数据: ".$StrFiltValue);
  15. print "360websec notice:Illegal operation!";
  16. exit();
  17. }
  18. }
  19. //$ArrPGC=array_merge($_GET,$_POST,$_COOKIE);
  20. foreach($_GET as $key=>$value){
  21. StopAttack($key,$value,$getfilter);
  22. }
  23. foreach($_POST as $key=>$value){
  24. StopAttack($key,$value,$postfilter);
  25. }
  26. foreach($_COOKIE as $key=>$value){
  27. StopAttack($key,$value,$cookiefilter);
  28. }
  29. function slog($logs)
  30. {
  31. $toppath=$_SERVER["DOCUMENT_ROOT"]."/log.htm";
  32. $Ts=fopen($toppath,"a+");
  33. fputs($Ts,$logs."rn");
  34. fclose($Ts);
  35. }
  36. ?>
复制代码


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template