본문 바로가기

Developement/Server

CentOS 5.x 64비트 ModSecurity 설치


modsecurity-apache_2.5.12.zip


ModSecurity_090311.zip

- OS 버전 : CentOS 5.x 64비트
- Apache 버전 : httpd-2.2.22

- modsecurity 버전 : modsecurity-apache_2.5.12


* 사전 준비

1. 아래 rpm 패키지들이 설치되어 있어야 합니다.
- pcre-devel
- apr-devel.x86_64
- apr-util-devel.x86_64

 

rpm -qa 로 확인할 수 있으며 설치는 yum 을 이용합니다.

 

예) yum -y install pcre-devel apr-devel.x86_64 apr-util-devel.x86_64


2. 아파치 소스 파일 

Apache 가 설치되어 있어야 하며 똑같은 버전의 아파치 소스파일이 준비되어야 합니다.

httpd-2.2.22 이 설치되어 있다면 apache.org 에서 같은 버전을 다운받으면 됩니다.

 

*  mod_unique_id 모듈을 설치

1. httpd-2.2.22 소스를 이용하여 모듈 생성

 cd /usr/local/src/httpd-2.2.22/modules/metadata/

/usr/local/apache2/bin/apxs -cia mod_unique_id.c

 

2. apxs 로 생성된 모듈 확인

ls -al /usr/local/apache2/modules/mod_unique_id.so

 

3. httpd.conf 에 정상적으로 load 되었는지 확인

[root@ ~]# cat /usr/local/apache2/conf/httpd.conf | grep unique

LoadModule unique_id_module   modules/mod_unique_id.so

 

* modsecurity 설치

1. 다운로드

- http://www.modsecurity.org/

 

2. 압축 해제

tar zxvf modsecurity-apache_2.5.12.tar.gz


3. 설치

cd /usr/local/modsecurity/modsecurity-apache_2.5.12/apache2/

./configure --with-apxs=/usr/local/apache2/bin/apxs --with-pcre=/usr --with-apr=/usr/local/apache2/bin/apr-1-config --with-apu=/usr/local/apache2/bin/apu-1-config make && make install

 

4. httpd.conf 설정

- 모듈 설정

LoadModule security2_module     modules/mod_security2.so

- 방화벽 정책 설정

Include conf/mod_security.conf


5. 웹방화벽 Rule 설정 

- 방화벽 정책은 정보보호진흥원(kisa.or.kr)에서 제공합니다.

- 정책을 mod_security.conf 에 넣고 아파치를 재시작합니다.

- 이 후 mod_security.conf 파일을 주기적으로 업데이트하여 최신 룰을 유지합니다.


6. 설치후 작동 확인

- 웹브라져에서 해킹 시도

http://localdomain.com/?file=../../etc/passwd 를 실행


- modSecurity Log 파일 확인

cd /usr/local/apache2/log

tail -n 30 modsec_audit.log


-끝-

'Developement > Server' 카테고리의 다른 글

Linux 설치 관련  (0) 2015.03.25
[관공서용] SSL 인증서 설치  (0) 2014.11.25
리눅스의 계정 목록을 확인 하기  (0) 2014.10.25
vsFtp 설정  (0) 2014.10.14
SSHD ROOT 로그인, IP별로 접속허용  (0) 2014.08.19