360提供的php防注入代碼

來源:互聯網
上載者:User
  1. //Code By Safe3
  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.+?(>|<|=|in|like)|\\/\\*.+?\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?Select|Update.+?SET|Insert\\s+INTO.+?VALUES|(Select|Delete).+?FROM|(Create|Alter|Drop|TRUNCATE)\\s+(TABLE|DATABASE)" ;
  9. $postfilter="\\b(and|or)\\b.{1,6}?(=|>|<|\\bin\\b|\\blike\\b)|\\/\\*.+?\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?Select|Update.+?SET|Insert\\s+INTO.+?VALUES|(Select|Delete).+?FROM|(Create|Alter|Drop|TRUNCATE)\\s+(TABLE|DATABASE)" ;
  10. $cookiefilter="\\b(and|or)\\b.{1,6}?(=|>|<|\\bin\\b|\\blike\\b)|\\/\\*.+?\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?Select|Update.+?SET|Insert\\s+INTO.+?VALUES|(Select|Delete).+?FROM|(Create|Alter|Drop|TRUNCATE)\\s+(TABLE|DATABASE)" ;
  11. function StopAttack($StrFiltKey,$StrFiltValue,$ArrFiltReq){
  12. if(is_array($StrFiltValue))
  13. {
  14. $StrFiltValue=implode($StrFiltValue);
  15. }
  16. if (preg_match("/".$ArrFiltReq."/is",$StrFiltValue)==1){
  17. //slog("

    操作IP: ".$_SERVER["REMOTE_ADDR"]."
    操作時間: ".strftime("%Y-%m-%d %H:%M:%S")."
    操作頁面:".$_SERVER["PHP_SELF"]."
    提交方式: ".$_SERVER["REQUEST_METHOD"]."
    提交參數: ".$StrFiltKey."
    提交資料: ".$StrFiltValue);
  18. print "360websec notice:Illegal operation!" ;
  19. exit();
  20. }
  21. }
  22. //$ArrPGC=array_merge($_GET,$_POST,$_COOKIE);
  23. foreach($_GET as $key=>$value){
  24. StopAttack($key,$value,$getfilter);
  25. }
  26. foreach($_POST as $key=>$value){
  27. StopAttack($key,$value,$postfilter);
  28. }
  29. foreach($_COOKIE as $key=>$value){
  30. StopAttack($key,$value,$cookiefilter);
  31. }
  32. /*
  33. if (file_exists('update360.php')) {
  34. echo "請重新命名檔案update360.php,防止駭客利用
    ";
  35. die();
  36. }
  37. */
  38. function slog($logs)
  39. {
  40. $toppath=$_SERVER["DOCUMENT_ROOT"]."/log.htm";
  41. $Ts=fopen($toppath,"a+");
  42. fputs($Ts,$logs."\r\n");
  43. fclose($Ts);
  44. }
複製代碼
php
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.