亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

PHP入侵檢測系統—PHPIDS

標簽:
PHP

PHP入侵检测系统—PHPIDS

部署要求:

PHP5.1.2 or better

Apache

mod_rewrite

安装步骤:

1、下载phpids   https://phpids.org/downloads/

2、解压phpids至网站根目录

3、如果无法解压至根目录可使用mod_rewrite

RewriteEngine On

RewriteCond %{REQUEST_URI} ^/phpids(.*)

RewriteRule ^(.+)$ – [F]

配置使用:

1、编辑config/config.ini.php自定义配置。

  1. [General] 

  2.     filter_type = xml 

  3.     use_base_path = false 

  4.     filter_path = default_filter.xml 

  5.     tmp_path  = tmp 

  6.     scan_keys  = false 

  7.     HTML_Purifier_Path = IDS/vendors/htmlpurifier/HTMLPurifier.auto.php 

  8.     HTML_Purifier_Cache = IDS/vendors/htmlpurifier/HTMLPurifier/DefinitionCache/Serializer 

  9.     html[] = __wysiwyg 

  10.     json[]  = __jsondata 

  11.     exceptions[]  = __utmz 

  12.     exceptions[] = __utmc 

  13.     min_php_version = 5.1.2 

  14. [Logging] 

  15.     path = tmp/phpids_log.txt 

  16.     recipients[] = [email protected] 

  17.     subject = “PHPIDS detected an intrusion attempt!” 

  18.     header = “From: <PHPIDS> [email protected]” 

  19.     envelope = “” 

  20.     safemode = true 

  21.     allowed_rate = 15 

  22.  

  23. [Caching] 

  24.     caching = file 

  25.     expiration_time = 600 

  26.     path = tmp/default_filter.cache 

2、启用phpids,可以将phpids的加载脚本写入一个单独的php文件,然后通过php.ini中的auto_prepend_file选项自动加载。

ids.php

  1. <?php 

  2.  

  3. // set the include path properly for PHPIDS 

  4. set_include_path( 

  5.     get_include_path() 

  6.     . PATH_SEPARATOR 

  7.     . ‘phpids/lib/’ 

  8. ); 

  9.  

  10. if (!session_id()) { 

  11.     session_start(); 

  12.  

  13. require_once ‘IDS/Init.php’; 

  14.  

  15. try { 

  16.     $request = array( 

  17.       ‘REQUEST’ => $_REQUEST, 

  18.       ‘GET’ => $_GET, 

  19.       ‘POST’ => $_POST, 

  20.       ‘COOKIE’ => $_COOKIE 

  21.     ); 

  22.     $init = IDS_Init::init(dirname(__FILE__) . ‘/phpids/lib/IDS/Config/Config.ini.php’); 

  23.     $f=$init->config['General']['base_path'] = dirname(__FILE__) . ‘/phpids/lib/IDS/’; 

  24.     echo $f; 

  25.     $init->config['General']['use_base_path'] = true; 

  26.     $init->config['Caching']['caching'] = ‘file’; 

  27.     $ids = new IDS_Monitor($request, $init); 

  28.     $result = $ids->run(); 

  29.     if (!$result->isEmpty()) { 

  30.         require_once ‘IDS/Log/File.php’; 

  31.         require_once ‘IDS/Log/Email.php’; 

  32.         require_once ‘IDS/Log/Composite.php’; 

  33.         $compositeLog = new IDS_Log_Composite(); 

  34.         $compositeLog->addLogger(IDS_Log_Email::getInstance($init),IDS_Log_File::getInstance($init)); 

  35.         $compositeLog->execute($result); 

  36.     } 

  37. } catch (Exception $e) { 

  38.    //this shouldn’t happen and if it does you don’t want the notification public. 

  39. ?> 

2、编辑php.ini,加入以下内容:

  1. auto_prepend_file /full/path/to/ids.php 


點擊查看更多內容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消