Jiniya

WEB

ModSecurity 설치

사전에 필수로 설치되어 있어야 할 것들

 

pcre

libxml2

unique_id (apache 컴파일 시에 --enable-unique-id 되어 있어야 한다)

 

pcre 설치

# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.01.tar.gz

# tar xvzf pcre-8.01.tar.gz

# cd pcre-8.01.tar.gz

# ./configure

# make

# make install

 

unique_id 설정되어 있지 않을 경우

apache 소스 파일 다운 후 압축을 푼 다음 unique_id만 컴파일 설치한다.

# tar xvzf httpd-2.2.9.tar.gz

# cd httpd-2.2.9/modules/metadata

# /usr/local/apache/bin/apxs -cia mod_unique_id.c

 

/usr/local/apache/modules/ 디렉토리에 mod_unique_id.so 파일이 생성되고 httpd.conf 파일에

모듈 로드 설정이 삽입된다.

 

 

ModSecurity 설치

# wget http://www.modsecurity.org/download/modsecurity-apache_2.5.7.tar.gz

# tar xvzf modsecurity-apache_2.5.7.tar.gz

# cd modsecurity-apache_2.5.7/apache2

# ./configure --with-apr=/usr/local/apache --with-apu=/usr/local/apache --with-apxs=/usr/local/apache/bin/apxs --with-pcre=/usr --with-apr=/usr/local/apache/bin/apr-1-config --with-apu=/usr/local/apache/bin/apu-1-config

# make && make install

 

/usr/local/apache/modules/mod_security2.so 파일이 생성되었는지 확인.

 

httpd.conf 설정 수정

# vi /usr/local/apache/conf/httpd.conf

 

LoadModule security2_module  modules/mod_security2.so

LoadFile /usr/lib/libxml2.so

 

ModSecurity 공격 차단 룰 설정

첨부된 파일 중 적당한 룰을 /usr/local/apache/conf 디렉토리에 복사해 넣고 httpd.conf 파일을 수정한다.

modsecurity_2x_hosting_090311.conf 파일을 적용한다고 가정.

conf 파일의 38번 주석 제거하고, 39번줄 주석 처리한다.

 

SecDefaultAction "deny,log,phase:2,status:406,t:urlDecodeUni,t:htmlEntityDecode,t:lowercase"
 # SecDefaultAction "pass,log,auditlog,phase:2,t:urlDecodeUni,t:htmlEntityDecode,t:lowercase"

 

# vi /usr/local/apache/conf/httpd.conf

Include conf/modsecurity_2x_hosting_090311.conf

 

저장 후 apache 재시동

 

ModSecurity 공격 차단 룰에 대한 설정과 설명은 나중에...