SlideShare une entreprise Scribd logo
1  sur  10
Télécharger pour lire hors ligne
Apache 安装配置 ModSecurity
               ----ourren 2012.8.2
1、安装 LAMP 和编译环境

安装 apache+php+mysql

   #yum -y install httpd php mysql mysql-server php-mysql

apache 版本




Mysql 版本




Centos 版本




安装编译环境

   #yum install gcc make
   #yum install libxml2 libxml2-devel httpd-devel pcre-devel curl-devel

启动服务测试

   #service httpd start
   #service mysqld start

注意:需要 iptables 允许所有 IP 访问 80 端口
2、安装 mod_security

  从官方下载源码、编译并安装。

  //sourceforge fuck gwf
  #wget http://www.modsecurity.org/download/modsecurity-apache_2.6.6.tar.gz
  # tar xzf modsecurity-apache_2.6.6.tar.gz
  # cd modsecurity-apache_2.6.6
  # ./configure
  # make install
  # cp modsecurity.conf-recommended /etc/httpd/conf.d/modsecurity.conf
3、规则配置

      需要配置一些规则防范未知漏洞和扫描,采用 Modsecurity 推荐规则和 OWASP_CRS 两个

规则进行组合,如下:


      详细规则采用 OWASP_CRS:

http://downloads.sourceforge.net/project/mod-security/modsecurity-crs/0-CURRENT/modsecurity-crs_2.2.5.tar.gz


      基本规则设置采用 Modsecurity 推荐规则:

http://mod-security.svn.sourceforge.net/viewvc/mod-security/m2/trunk/modsecurity.conf-recommended


      使用的时候将 Modsecurity 推荐规则文件内容加在 modsecurity_crs_10_config.conf 的前

面,并把 SecRuleEngine DetectionOnly 改为 SecRuleEngine On 即可(因为需要的不仅仅是检

测,需要防御)。

# cd /etc/httpd/
# wget http://downloads.sourceforge.net/project/mod-security/modsecurity-crs/0-CURRENT/modsecurity-crs_2.2.5.tar.gz
# tar xzf modsecurity-crs_2.2.5.tar.gz
# mv modsecurity-crs_2.2.5 modsecurity-crs
# cd modsecurity-crs
# cp modsecurity_crs_10_setup.conf.example modsecurity_crs_10_config.conf
# vi /etc/httpd/modsecurity.d/modsecurity_crs_10_config.conf
4、加载模块

Apache 加载 mod_security 模块,注意要修改的时候需要关闭 apache。

   # vi /etc/httpd/conf/httpd.conf

在其中找到 LoadModule 并在下面添加下面的代码:

   #LoadModule security2_module modules/mod_security2.so
   #LoadModule unique_id_module modules/mod_unique_id.so




然后添加模块的配置文件

   <IfModule security2_module>
        Include /etc/httpd/modsecurity-crs/modsecurity_crs_10_config.conf
        Include /etc/httpd/modsecurity-crs/base_rules/*.conf
   </IfModule>




重启 apache

   # service httpd restart
5、功能测试

创建数据库

  #CREATE TABLE user (id int(5),username VARCHAR(20), password CHAR(1));

php 测试代码




数据库结构




插入数据

  # insert user(id,username,password) values(1,'admin','adminpass');
测试网页




可以看到用 Havij 成功爆出了数据库和数据




加载 mod_security 模块后,正常访问看看效果:




可以看到现在无法用 Havij 爆出数据信息,其日志信息中有提示,
                                “Please register to enable

mod_security bypass”,但是当开启这个功能后,发现还是不能注入。
Apache安装配置mod security
看 modsec_audit 日志是发现有注入的,并且利用了注释来绕过防火墙。
6、总结

    通过上面的安装和测试,发现 modsecurity 可以防御一些攻击,同时用户可以根据需求

自定义规则,从功能方面来看还是很不错的,不过规则配置相对比较复杂,实际应用的话需

要深入研究才行。



参考资料

http://www.tecmint.com/protect-apache-using-mod_security-and-mod_evasive-on-rhel-centos-f
edora/
http://mod-security.svn.sourceforge.net/viewvc/mod-security/m2/trunk/modsecurity.conf-reco
mmended
http://blog.secaserver.com/2011/10/install-mod_security-apache2-easiest/

Contenu connexe

Tendances

Bypat博客出品-利用cent os快速构建自己的发行版-进阶版v1.1
Bypat博客出品-利用cent os快速构建自己的发行版-进阶版v1.1Bypat博客出品-利用cent os快速构建自己的发行版-进阶版v1.1
Bypat博客出品-利用cent os快速构建自己的发行版-进阶版v1.1redhat9
 
Node.js长连接开发实践
Node.js长连接开发实践Node.js长连接开发实践
Node.js长连接开发实践longhao
 
Lamp安全全攻略
Lamp安全全攻略Lamp安全全攻略
Lamp安全全攻略Da Zhao
 
VMware Rhel5 Oracle10g Rac
VMware Rhel5 Oracle10g RacVMware Rhel5 Oracle10g Rac
VMware Rhel5 Oracle10g Racguest77e407
 
下一代虚拟存储解决方案:Vaai
下一代虚拟存储解决方案:Vaai下一代虚拟存储解决方案:Vaai
下一代虚拟存储解决方案:VaaiITband
 
Hadoop平台搭建
Hadoop平台搭建Hadoop平台搭建
Hadoop平台搭建Liyang Tang
 
V tiger 5.4.0 图文安装教程
V tiger 5.4.0 图文安装教程V tiger 5.4.0 图文安装教程
V tiger 5.4.0 图文安装教程YUCHENG HU
 
Oraliux+mysql5单机多实例安装文档
Oraliux+mysql5单机多实例安装文档Oraliux+mysql5单机多实例安装文档
Oraliux+mysql5单机多实例安装文档xuebao_zx
 
Oracle enterprise manager cloud control 12c release 5 installation on oracle ...
Oracle enterprise manager cloud control 12c release 5 installation on oracle ...Oracle enterprise manager cloud control 12c release 5 installation on oracle ...
Oracle enterprise manager cloud control 12c release 5 installation on oracle ...Zhaoyang Wang
 
超。光速 網站最佳化實戰 -twMVC#8
超。光速 網站最佳化實戰 -twMVC#8超。光速 網站最佳化實戰 -twMVC#8
超。光速 網站最佳化實戰 -twMVC#8twMVC
 
Burp suite injection中的应用by小冰
Burp suite injection中的应用by小冰Burp suite injection中的应用by小冰
Burp suite injection中的应用by小冰fangjiafu
 
Nagios的安装部署和与cacti的整合(linuxtone)
Nagios的安装部署和与cacti的整合(linuxtone)Nagios的安装部署和与cacti的整合(linuxtone)
Nagios的安装部署和与cacti的整合(linuxtone)Yiwei Ma
 
Npm node.js的套件管理程式
Npm node.js的套件管理程式Npm node.js的套件管理程式
Npm node.js的套件管理程式Chuyi Huang
 
twMVC#26 | 淺談 ASP.NET Caching 技術與實踐
twMVC#26 | 淺談 ASP.NET Caching 技術與實踐twMVC#26 | 淺談 ASP.NET Caching 技術與實踐
twMVC#26 | 淺談 ASP.NET Caching 技術與實踐twMVC
 
利用Cent Os快速构建自己的发行版
利用Cent Os快速构建自己的发行版利用Cent Os快速构建自己的发行版
利用Cent Os快速构建自己的发行版xingsu1021
 
My sql 5.5 innodb xtradb 性能诊断与优化
My sql 5.5 innodb xtradb 性能诊断与优化My sql 5.5 innodb xtradb 性能诊断与优化
My sql 5.5 innodb xtradb 性能诊断与优化YUCHENG HU
 
Install Oracle11g For Aix 5 L
Install Oracle11g For Aix 5 LInstall Oracle11g For Aix 5 L
Install Oracle11g For Aix 5 Lheima911
 
03.python工作环境
03.python工作环境03.python工作环境
03.python工作环境modou li
 
Oracle prm安装说明
Oracle prm安装说明Oracle prm安装说明
Oracle prm安装说明maclean liu
 

Tendances (20)

Bypat博客出品-利用cent os快速构建自己的发行版-进阶版v1.1
Bypat博客出品-利用cent os快速构建自己的发行版-进阶版v1.1Bypat博客出品-利用cent os快速构建自己的发行版-进阶版v1.1
Bypat博客出品-利用cent os快速构建自己的发行版-进阶版v1.1
 
Node.js长连接开发实践
Node.js长连接开发实践Node.js长连接开发实践
Node.js长连接开发实践
 
Lamp安全全攻略
Lamp安全全攻略Lamp安全全攻略
Lamp安全全攻略
 
VMware Rhel5 Oracle10g Rac
VMware Rhel5 Oracle10g RacVMware Rhel5 Oracle10g Rac
VMware Rhel5 Oracle10g Rac
 
下一代虚拟存储解决方案:Vaai
下一代虚拟存储解决方案:Vaai下一代虚拟存储解决方案:Vaai
下一代虚拟存储解决方案:Vaai
 
Hadoop平台搭建
Hadoop平台搭建Hadoop平台搭建
Hadoop平台搭建
 
V tiger 5.4.0 图文安装教程
V tiger 5.4.0 图文安装教程V tiger 5.4.0 图文安装教程
V tiger 5.4.0 图文安装教程
 
Oraliux+mysql5单机多实例安装文档
Oraliux+mysql5单机多实例安装文档Oraliux+mysql5单机多实例安装文档
Oraliux+mysql5单机多实例安装文档
 
Oracle enterprise manager cloud control 12c release 5 installation on oracle ...
Oracle enterprise manager cloud control 12c release 5 installation on oracle ...Oracle enterprise manager cloud control 12c release 5 installation on oracle ...
Oracle enterprise manager cloud control 12c release 5 installation on oracle ...
 
超。光速 網站最佳化實戰 -twMVC#8
超。光速 網站最佳化實戰 -twMVC#8超。光速 網站最佳化實戰 -twMVC#8
超。光速 網站最佳化實戰 -twMVC#8
 
Burp suite injection中的应用by小冰
Burp suite injection中的应用by小冰Burp suite injection中的应用by小冰
Burp suite injection中的应用by小冰
 
Nagios的安装部署和与cacti的整合(linuxtone)
Nagios的安装部署和与cacti的整合(linuxtone)Nagios的安装部署和与cacti的整合(linuxtone)
Nagios的安装部署和与cacti的整合(linuxtone)
 
Npm node.js的套件管理程式
Npm node.js的套件管理程式Npm node.js的套件管理程式
Npm node.js的套件管理程式
 
twMVC#26 | 淺談 ASP.NET Caching 技術與實踐
twMVC#26 | 淺談 ASP.NET Caching 技術與實踐twMVC#26 | 淺談 ASP.NET Caching 技術與實踐
twMVC#26 | 淺談 ASP.NET Caching 技術與實踐
 
利用Cent Os快速构建自己的发行版
利用Cent Os快速构建自己的发行版利用Cent Os快速构建自己的发行版
利用Cent Os快速构建自己的发行版
 
My sql 5.5 innodb xtradb 性能诊断与优化
My sql 5.5 innodb xtradb 性能诊断与优化My sql 5.5 innodb xtradb 性能诊断与优化
My sql 5.5 innodb xtradb 性能诊断与优化
 
Install Oracle11g For Aix 5 L
Install Oracle11g For Aix 5 LInstall Oracle11g For Aix 5 L
Install Oracle11g For Aix 5 L
 
03.python工作环境
03.python工作环境03.python工作环境
03.python工作环境
 
Oracle prm安装说明
Oracle prm安装说明Oracle prm安装说明
Oracle prm安装说明
 
unixtoolbox_zh_CN
unixtoolbox_zh_CNunixtoolbox_zh_CN
unixtoolbox_zh_CN
 

En vedette

Methods to Bypass a Web Application Firewall Eng
Methods to Bypass a Web Application Firewall EngMethods to Bypass a Web Application Firewall Eng
Methods to Bypass a Web Application Firewall EngDmitry Evteev
 
Waf bypassing Techniques
Waf bypassing TechniquesWaf bypassing Techniques
Waf bypassing TechniquesAvinash Thapa
 
台北市研習_LAMP_20140815
台北市研習_LAMP_20140815台北市研習_LAMP_20140815
台北市研習_LAMP_20140815fweng322
 
PHP & AppServ
PHP & AppServPHP & AppServ
PHP & AppServHt Wang
 
{{more}} Kibana4
{{more}} Kibana4{{more}} Kibana4
{{more}} Kibana4琛琳 饶
 
Introduction to MySQL and phpMyAdmin
Introduction to MySQL and phpMyAdminIntroduction to MySQL and phpMyAdmin
Introduction to MySQL and phpMyAdminDrake Huang
 
Sql injection bypassing hand book blackrose
Sql injection bypassing hand book blackroseSql injection bypassing hand book blackrose
Sql injection bypassing hand book blackroseNoaman Aziz
 
The Hidden XSS - Attacking the Desktop & Mobile Platforms
The Hidden XSS - Attacking the Desktop & Mobile PlatformsThe Hidden XSS - Attacking the Desktop & Mobile Platforms
The Hidden XSS - Attacking the Desktop & Mobile Platformskosborn
 
Cross Domain Hijacking - File Upload Vulnerability
Cross Domain Hijacking - File Upload VulnerabilityCross Domain Hijacking - File Upload Vulnerability
Cross Domain Hijacking - File Upload VulnerabilityRonan Dunne, CEH, SSCP
 
XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015
XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015
XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015CODE BLUE
 
주로사용되는 Xss필터와 이를 공격하는 방법
주로사용되는 Xss필터와 이를 공격하는 방법주로사용되는 Xss필터와 이를 공격하는 방법
주로사용되는 Xss필터와 이를 공격하는 방법guestad13b55
 
New Methods in Automated XSS Detection & Dynamic Exploit Creation
New Methods in Automated XSS Detection & Dynamic Exploit CreationNew Methods in Automated XSS Detection & Dynamic Exploit Creation
New Methods in Automated XSS Detection & Dynamic Exploit CreationKen Belva
 
Web Application Firewalls Detection, Bypassing And Exploitation
Web Application Firewalls  Detection, Bypassing And ExploitationWeb Application Firewalls  Detection, Bypassing And Exploitation
Web Application Firewalls Detection, Bypassing And ExploitationSandro Gauci
 
Codeigniter 3.0 之 30 分鐘就上手
Codeigniter 3.0 之 30 分鐘就上手Codeigniter 3.0 之 30 分鐘就上手
Codeigniter 3.0 之 30 分鐘就上手Piece Chao
 
libinjection: from SQLi to XSS  by Nick Galbreath
libinjection: from SQLi to XSS  by Nick Galbreathlibinjection: from SQLi to XSS  by Nick Galbreath
libinjection: from SQLi to XSS  by Nick GalbreathCODE BLUE
 
XML Attack Surface - Pierre Ernst (OWASP Ottawa)
XML Attack Surface - Pierre Ernst (OWASP Ottawa)XML Attack Surface - Pierre Ernst (OWASP Ottawa)
XML Attack Surface - Pierre Ernst (OWASP Ottawa)OWASP Ottawa
 

En vedette (20)

Methods to Bypass a Web Application Firewall Eng
Methods to Bypass a Web Application Firewall EngMethods to Bypass a Web Application Firewall Eng
Methods to Bypass a Web Application Firewall Eng
 
Waf bypassing Techniques
Waf bypassing TechniquesWaf bypassing Techniques
Waf bypassing Techniques
 
台北市研習_LAMP_20140815
台北市研習_LAMP_20140815台北市研習_LAMP_20140815
台北市研習_LAMP_20140815
 
PHP & AppServ
PHP & AppServPHP & AppServ
PHP & AppServ
 
{{more}} Kibana4
{{more}} Kibana4{{more}} Kibana4
{{more}} Kibana4
 
Introduction to MySQL and phpMyAdmin
Introduction to MySQL and phpMyAdminIntroduction to MySQL and phpMyAdmin
Introduction to MySQL and phpMyAdmin
 
File upload vulnerabilities & mitigation
File upload vulnerabilities & mitigationFile upload vulnerabilities & mitigation
File upload vulnerabilities & mitigation
 
Sql injection bypassing hand book blackrose
Sql injection bypassing hand book blackroseSql injection bypassing hand book blackrose
Sql injection bypassing hand book blackrose
 
The Hidden XSS - Attacking the Desktop & Mobile Platforms
The Hidden XSS - Attacking the Desktop & Mobile PlatformsThe Hidden XSS - Attacking the Desktop & Mobile Platforms
The Hidden XSS - Attacking the Desktop & Mobile Platforms
 
Cross Domain Hijacking - File Upload Vulnerability
Cross Domain Hijacking - File Upload VulnerabilityCross Domain Hijacking - File Upload Vulnerability
Cross Domain Hijacking - File Upload Vulnerability
 
XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015
XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015
XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015
 
Building Advanced XSS Vectors
Building Advanced XSS VectorsBuilding Advanced XSS Vectors
Building Advanced XSS Vectors
 
주로사용되는 Xss필터와 이를 공격하는 방법
주로사용되는 Xss필터와 이를 공격하는 방법주로사용되는 Xss필터와 이를 공격하는 방법
주로사용되는 Xss필터와 이를 공격하는 방법
 
New Methods in Automated XSS Detection & Dynamic Exploit Creation
New Methods in Automated XSS Detection & Dynamic Exploit CreationNew Methods in Automated XSS Detection & Dynamic Exploit Creation
New Methods in Automated XSS Detection & Dynamic Exploit Creation
 
Web Application Firewalls Detection, Bypassing And Exploitation
Web Application Firewalls  Detection, Bypassing And ExploitationWeb Application Firewalls  Detection, Bypassing And Exploitation
Web Application Firewalls Detection, Bypassing And Exploitation
 
XPath Injection
XPath InjectionXPath Injection
XPath Injection
 
Codeigniter 3.0 之 30 分鐘就上手
Codeigniter 3.0 之 30 分鐘就上手Codeigniter 3.0 之 30 分鐘就上手
Codeigniter 3.0 之 30 分鐘就上手
 
libinjection: from SQLi to XSS  by Nick Galbreath
libinjection: from SQLi to XSS  by Nick Galbreathlibinjection: from SQLi to XSS  by Nick Galbreath
libinjection: from SQLi to XSS  by Nick Galbreath
 
XML Attack Surface - Pierre Ernst (OWASP Ottawa)
XML Attack Surface - Pierre Ernst (OWASP Ottawa)XML Attack Surface - Pierre Ernst (OWASP Ottawa)
XML Attack Surface - Pierre Ernst (OWASP Ottawa)
 
How To Detect Xss
How To Detect XssHow To Detect Xss
How To Detect Xss
 

Similaire à Apache安装配置mod security

康盛创想项目部Linux 服务器部署标准(最新版)
康盛创想项目部Linux 服务器部署标准(最新版)康盛创想项目部Linux 服务器部署标准(最新版)
康盛创想项目部Linux 服务器部署标准(最新版)Yiwei Ma
 
X64服务器 lamp服务器部署标准 new
X64服务器 lamp服务器部署标准 newX64服务器 lamp服务器部署标准 new
X64服务器 lamp服务器部署标准 newYiwei Ma
 
Android系统移植技术详解
Android系统移植技术详解Android系统移植技术详解
Android系统移植技术详解zzc89522
 
尚观Linux研究室 linux驱动程序全解析
尚观Linux研究室   linux驱动程序全解析尚观Linux研究室   linux驱动程序全解析
尚观Linux研究室 linux驱动程序全解析hangejnu
 
8, lamp
8, lamp8, lamp
8, lampted-xu
 
Wamp环境下安装 wordpress
Wamp环境下安装 wordpressWamp环境下安装 wordpress
Wamp环境下安装 wordpressstrugglesmen
 
Puppet安装总结
Puppet安装总结Puppet安装总结
Puppet安装总结Yiwei Ma
 
unix toolbox 中文版
unix toolbox 中文版unix toolbox 中文版
unix toolbox 中文版Jie Bao
 
使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...
使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...
使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...Laird Cheng
 
linux安装以及LAMP 环境安装详细
linux安装以及LAMP 环境安装详细linux安装以及LAMP 环境安装详细
linux安装以及LAMP 环境安装详细colderboy17
 
GNU Autoconf / Automake #1
GNU Autoconf / Automake #1GNU Autoconf / Automake #1
GNU Autoconf / Automake #1imacat .
 
使用Rpm&yum进行基础软件管理
使用Rpm&yum进行基础软件管理使用Rpm&yum进行基础软件管理
使用Rpm&yum进行基础软件管理Jason Zheng
 
使用Rpm&yum进行基础软件管理
使用Rpm&yum进行基础软件管理使用Rpm&yum进行基础软件管理
使用Rpm&yum进行基础软件管理haiyuan ning
 
Node.js從無到有 基本課程
Node.js從無到有 基本課程Node.js從無到有 基本課程
Node.js從無到有 基本課程Simon Su
 
5, system admin
5, system admin5, system admin
5, system adminted-xu
 
Docker容器微服務 x WorkShop
Docker容器微服務 x WorkShopDocker容器微服務 x WorkShop
Docker容器微服務 x WorkShopPhilip Zheng
 
Linux network monitoring hands-on pratice
Linux network monitoring hands-on praticeLinux network monitoring hands-on pratice
Linux network monitoring hands-on praticeKenny (netman)
 
南投替代役整理組數位典藏報告
南投替代役整理組數位典藏報告南投替代役整理組數位典藏報告
南投替代役整理組數位典藏報告Bo-Yi Wu
 

Similaire à Apache安装配置mod security (20)

康盛创想项目部Linux 服务器部署标准(最新版)
康盛创想项目部Linux 服务器部署标准(最新版)康盛创想项目部Linux 服务器部署标准(最新版)
康盛创想项目部Linux 服务器部署标准(最新版)
 
X64服务器 lamp服务器部署标准 new
X64服务器 lamp服务器部署标准 newX64服务器 lamp服务器部署标准 new
X64服务器 lamp服务器部署标准 new
 
Android系统移植技术详解
Android系统移植技术详解Android系统移植技术详解
Android系统移植技术详解
 
尚观Linux研究室 linux驱动程序全解析
尚观Linux研究室   linux驱动程序全解析尚观Linux研究室   linux驱动程序全解析
尚观Linux研究室 linux驱动程序全解析
 
8, lamp
8, lamp8, lamp
8, lamp
 
Wamp环境下安装 wordpress
Wamp环境下安装 wordpressWamp环境下安装 wordpress
Wamp环境下安装 wordpress
 
Puppet安装总结
Puppet安装总结Puppet安装总结
Puppet安装总结
 
unix toolbox 中文版
unix toolbox 中文版unix toolbox 中文版
unix toolbox 中文版
 
使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...
使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...
使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...
 
linux安装以及LAMP 环境安装详细
linux安装以及LAMP 环境安装详细linux安装以及LAMP 环境安装详细
linux安装以及LAMP 环境安装详细
 
GNU Autoconf / Automake #1
GNU Autoconf / Automake #1GNU Autoconf / Automake #1
GNU Autoconf / Automake #1
 
使用Rpm&yum进行基础软件管理
使用Rpm&yum进行基础软件管理使用Rpm&yum进行基础软件管理
使用Rpm&yum进行基础软件管理
 
使用Rpm&yum进行基础软件管理
使用Rpm&yum进行基础软件管理使用Rpm&yum进行基础软件管理
使用Rpm&yum进行基础软件管理
 
Node.js從無到有 基本課程
Node.js從無到有 基本課程Node.js從無到有 基本課程
Node.js從無到有 基本課程
 
5, system admin
5, system admin5, system admin
5, system admin
 
LinuxGuide4F2E
LinuxGuide4F2ELinuxGuide4F2E
LinuxGuide4F2E
 
Linuxguide4f2e
Linuxguide4f2eLinuxguide4f2e
Linuxguide4f2e
 
Docker容器微服務 x WorkShop
Docker容器微服務 x WorkShopDocker容器微服務 x WorkShop
Docker容器微服務 x WorkShop
 
Linux network monitoring hands-on pratice
Linux network monitoring hands-on praticeLinux network monitoring hands-on pratice
Linux network monitoring hands-on pratice
 
南投替代役整理組數位典藏報告
南投替代役整理組數位典藏報告南投替代役整理組數位典藏報告
南投替代役整理組數位典藏報告
 

Dernier

函數畫圖_習題5.pptx 函數畫圖_習題5.pptx 函數畫圖_習題5.pptx
函數畫圖_習題5.pptx 函數畫圖_習題5.pptx 函數畫圖_習題5.pptx函數畫圖_習題5.pptx 函數畫圖_習題5.pptx 函數畫圖_習題5.pptx
函數畫圖_習題5.pptx 函數畫圖_習題5.pptx 函數畫圖_習題5.pptxNCU MCL
 
SymPy 在微積分上的應用_5.pptx SymPy 在微積分上的應用_5.pptx
SymPy 在微積分上的應用_5.pptx SymPy 在微積分上的應用_5.pptxSymPy 在微積分上的應用_5.pptx SymPy 在微積分上的應用_5.pptx
SymPy 在微積分上的應用_5.pptx SymPy 在微積分上的應用_5.pptxNCU MCL
 
SymPy 在微積分上的應用_4.pptx SymPy 在微積分上的應用_4.pptx
SymPy 在微積分上的應用_4.pptx SymPy 在微積分上的應用_4.pptxSymPy 在微積分上的應用_4.pptx SymPy 在微積分上的應用_4.pptx
SymPy 在微積分上的應用_4.pptx SymPy 在微積分上的應用_4.pptxNCU MCL
 
买假和真英国驾驶执照买了假的英国驾照,那跟真的有什么区别吗?买假和真正的澳大利亚驾驶执照【微信qoqoqdqd】
买假和真英国驾驶执照买了假的英国驾照,那跟真的有什么区别吗?买假和真正的澳大利亚驾驶执照【微信qoqoqdqd】买假和真英国驾驶执照买了假的英国驾照,那跟真的有什么区别吗?买假和真正的澳大利亚驾驶执照【微信qoqoqdqd】
买假和真英国驾驶执照买了假的英国驾照,那跟真的有什么区别吗?买假和真正的澳大利亚驾驶执照【微信qoqoqdqd】黑客 接单【TG/微信qoqoqdqd】
 
20211119 - demystified artificial intelligence with NLP
20211119 - demystified artificial intelligence with NLP20211119 - demystified artificial intelligence with NLP
20211119 - demystified artificial intelligence with NLPJamie (Taka) Wang
 
函數畫圖_習題7.pptx 函數畫圖_習題7.pptx 函數畫圖_習題7.pptx
函數畫圖_習題7.pptx 函數畫圖_習題7.pptx 函數畫圖_習題7.pptx函數畫圖_習題7.pptx 函數畫圖_習題7.pptx 函數畫圖_習題7.pptx
函數畫圖_習題7.pptx 函數畫圖_習題7.pptx 函數畫圖_習題7.pptxNCU MCL
 
20170104 - transaction_pattern
20170104 - transaction_pattern20170104 - transaction_pattern
20170104 - transaction_patternJamie (Taka) Wang
 
函數畫圖_習題6.pptx 函數畫圖_習題6.pptx 函數畫圖_習題6.pptx
函數畫圖_習題6.pptx 函數畫圖_習題6.pptx 函數畫圖_習題6.pptx函數畫圖_習題6.pptx 函數畫圖_習題6.pptx 函數畫圖_習題6.pptx
函數畫圖_習題6.pptx 函數畫圖_習題6.pptx 函數畫圖_習題6.pptxNCU MCL
 
函數微分_習題4.pptx 函數微分_習題4.pptx 函數微分_習題4.pptx
函數微分_習題4.pptx 函數微分_習題4.pptx 函數微分_習題4.pptx函數微分_習題4.pptx 函數微分_習題4.pptx 函數微分_習題4.pptx
函數微分_習題4.pptx 函數微分_習題4.pptx 函數微分_習題4.pptxNCU MCL
 
20161220 - domain-driven design
20161220 - domain-driven design20161220 - domain-driven design
20161220 - domain-driven designJamie (Taka) Wang
 

Dernier (15)

Entities in DCPS (DDS)
Entities in DCPS (DDS)Entities in DCPS (DDS)
Entities in DCPS (DDS)
 
函數畫圖_習題5.pptx 函數畫圖_習題5.pptx 函數畫圖_習題5.pptx
函數畫圖_習題5.pptx 函數畫圖_習題5.pptx 函數畫圖_習題5.pptx函數畫圖_習題5.pptx 函數畫圖_習題5.pptx 函數畫圖_習題5.pptx
函數畫圖_習題5.pptx 函數畫圖_習題5.pptx 函數畫圖_習題5.pptx
 
SymPy 在微積分上的應用_5.pptx SymPy 在微積分上的應用_5.pptx
SymPy 在微積分上的應用_5.pptx SymPy 在微積分上的應用_5.pptxSymPy 在微積分上的應用_5.pptx SymPy 在微積分上的應用_5.pptx
SymPy 在微積分上的應用_5.pptx SymPy 在微積分上的應用_5.pptx
 
SymPy 在微積分上的應用_4.pptx SymPy 在微積分上的應用_4.pptx
SymPy 在微積分上的應用_4.pptx SymPy 在微積分上的應用_4.pptxSymPy 在微積分上的應用_4.pptx SymPy 在微積分上的應用_4.pptx
SymPy 在微積分上的應用_4.pptx SymPy 在微積分上的應用_4.pptx
 
买假和真英国驾驶执照买了假的英国驾照,那跟真的有什么区别吗?买假和真正的澳大利亚驾驶执照【微信qoqoqdqd】
买假和真英国驾驶执照买了假的英国驾照,那跟真的有什么区别吗?买假和真正的澳大利亚驾驶执照【微信qoqoqdqd】买假和真英国驾驶执照买了假的英国驾照,那跟真的有什么区别吗?买假和真正的澳大利亚驾驶执照【微信qoqoqdqd】
买假和真英国驾驶执照买了假的英国驾照,那跟真的有什么区别吗?买假和真正的澳大利亚驾驶执照【微信qoqoqdqd】
 
20200226 - AI Overview
20200226 - AI Overview20200226 - AI Overview
20200226 - AI Overview
 
20211119 - demystified artificial intelligence with NLP
20211119 - demystified artificial intelligence with NLP20211119 - demystified artificial intelligence with NLP
20211119 - demystified artificial intelligence with NLP
 
20161027 - edge part2
20161027 - edge part220161027 - edge part2
20161027 - edge part2
 
20200323 - AI Intro
20200323 - AI Intro20200323 - AI Intro
20200323 - AI Intro
 
函數畫圖_習題7.pptx 函數畫圖_習題7.pptx 函數畫圖_習題7.pptx
函數畫圖_習題7.pptx 函數畫圖_習題7.pptx 函數畫圖_習題7.pptx函數畫圖_習題7.pptx 函數畫圖_習題7.pptx 函數畫圖_習題7.pptx
函數畫圖_習題7.pptx 函數畫圖_習題7.pptx 函數畫圖_習題7.pptx
 
20170104 - transaction_pattern
20170104 - transaction_pattern20170104 - transaction_pattern
20170104 - transaction_pattern
 
函數畫圖_習題6.pptx 函數畫圖_習題6.pptx 函數畫圖_習題6.pptx
函數畫圖_習題6.pptx 函數畫圖_習題6.pptx 函數畫圖_習題6.pptx函數畫圖_習題6.pptx 函數畫圖_習題6.pptx 函數畫圖_習題6.pptx
函數畫圖_習題6.pptx 函數畫圖_習題6.pptx 函數畫圖_習題6.pptx
 
函數微分_習題4.pptx 函數微分_習題4.pptx 函數微分_習題4.pptx
函數微分_習題4.pptx 函數微分_習題4.pptx 函數微分_習題4.pptx函數微分_習題4.pptx 函數微分_習題4.pptx 函數微分_習題4.pptx
函數微分_習題4.pptx 函數微分_習題4.pptx 函數微分_習題4.pptx
 
20151111 - IoT Sync Up
20151111 - IoT Sync Up20151111 - IoT Sync Up
20151111 - IoT Sync Up
 
20161220 - domain-driven design
20161220 - domain-driven design20161220 - domain-driven design
20161220 - domain-driven design
 

Apache安装配置mod security

  • 1. Apache 安装配置 ModSecurity ----ourren 2012.8.2
  • 2. 1、安装 LAMP 和编译环境 安装 apache+php+mysql #yum -y install httpd php mysql mysql-server php-mysql apache 版本 Mysql 版本 Centos 版本 安装编译环境 #yum install gcc make #yum install libxml2 libxml2-devel httpd-devel pcre-devel curl-devel 启动服务测试 #service httpd start #service mysqld start 注意:需要 iptables 允许所有 IP 访问 80 端口
  • 3. 2、安装 mod_security 从官方下载源码、编译并安装。 //sourceforge fuck gwf #wget http://www.modsecurity.org/download/modsecurity-apache_2.6.6.tar.gz # tar xzf modsecurity-apache_2.6.6.tar.gz # cd modsecurity-apache_2.6.6 # ./configure # make install # cp modsecurity.conf-recommended /etc/httpd/conf.d/modsecurity.conf
  • 4. 3、规则配置 需要配置一些规则防范未知漏洞和扫描,采用 Modsecurity 推荐规则和 OWASP_CRS 两个 规则进行组合,如下: 详细规则采用 OWASP_CRS: http://downloads.sourceforge.net/project/mod-security/modsecurity-crs/0-CURRENT/modsecurity-crs_2.2.5.tar.gz 基本规则设置采用 Modsecurity 推荐规则: http://mod-security.svn.sourceforge.net/viewvc/mod-security/m2/trunk/modsecurity.conf-recommended 使用的时候将 Modsecurity 推荐规则文件内容加在 modsecurity_crs_10_config.conf 的前 面,并把 SecRuleEngine DetectionOnly 改为 SecRuleEngine On 即可(因为需要的不仅仅是检 测,需要防御)。 # cd /etc/httpd/ # wget http://downloads.sourceforge.net/project/mod-security/modsecurity-crs/0-CURRENT/modsecurity-crs_2.2.5.tar.gz # tar xzf modsecurity-crs_2.2.5.tar.gz # mv modsecurity-crs_2.2.5 modsecurity-crs # cd modsecurity-crs # cp modsecurity_crs_10_setup.conf.example modsecurity_crs_10_config.conf # vi /etc/httpd/modsecurity.d/modsecurity_crs_10_config.conf
  • 5. 4、加载模块 Apache 加载 mod_security 模块,注意要修改的时候需要关闭 apache。 # vi /etc/httpd/conf/httpd.conf 在其中找到 LoadModule 并在下面添加下面的代码: #LoadModule security2_module modules/mod_security2.so #LoadModule unique_id_module modules/mod_unique_id.so 然后添加模块的配置文件 <IfModule security2_module> Include /etc/httpd/modsecurity-crs/modsecurity_crs_10_config.conf Include /etc/httpd/modsecurity-crs/base_rules/*.conf </IfModule> 重启 apache # service httpd restart
  • 6. 5、功能测试 创建数据库 #CREATE TABLE user (id int(5),username VARCHAR(20), password CHAR(1)); php 测试代码 数据库结构 插入数据 # insert user(id,username,password) values(1,'admin','adminpass');
  • 7. 测试网页 可以看到用 Havij 成功爆出了数据库和数据 加载 mod_security 模块后,正常访问看看效果: 可以看到现在无法用 Havij 爆出数据信息,其日志信息中有提示, “Please register to enable mod_security bypass”,但是当开启这个功能后,发现还是不能注入。
  • 10. 6、总结 通过上面的安装和测试,发现 modsecurity 可以防御一些攻击,同时用户可以根据需求 自定义规则,从功能方面来看还是很不错的,不过规则配置相对比较复杂,实际应用的话需 要深入研究才行。 参考资料 http://www.tecmint.com/protect-apache-using-mod_security-and-mod_evasive-on-rhel-centos-f edora/ http://mod-security.svn.sourceforge.net/viewvc/mod-security/m2/trunk/modsecurity.conf-reco mmended http://blog.secaserver.com/2011/10/install-mod_security-apache2-easiest/