为了账号安全,请及时绑定邮箱和手机立即绑定

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[] = admin@myhack58.com 

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

  18.     header = “From: <PHPIDS> noreply@domain.com” 

  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
提交
取消