栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > PHP

PHP入侵检测系统—PHPIDS

PHP 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

PHP入侵检测系统—PHPIDS

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:  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.  

  2. // set the include path properly for PHPIDS 

  3. set_include_path( 

  4.     get_include_path() 

  5.     . PATH_SEPARATOR 

  6.     . ‘phpids/lib/’ 

  7. ); 

  8.  

  9. if (!session_id()) { 

  10.     session_start(); 

  11.  

  12. require_once ‘IDS/Init.php’; 

  13.  

  14. try { 

  15.     $request = array( 

  16.       ‘REQUEST’ => $_REQUEST, 

  17.       ‘GET’ => $_GET, 

  18.       ‘POST’ => $_POST, 

  19.       ‘cookie’ => $_cookie 

  20.     ); 

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

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

  23.     echo $f; 

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

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

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

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

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

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

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

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

  32.         $compositeLog = new IDS_Log_Composite(); 

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

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

  35.     } 

  36. } catch (Exception $e) { 

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

  38. ?> 

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

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


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/227854.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号