You cannot see this page without javascript.

modsecurity

Linux 조회 수 475 추천 수 0 2017.12.06 10:06:59

1. 의존라이브러리 설치


yum -y install gcc-c++ libxml2 libxml2-devel httpd-devel apr-devel apr-util pcre-devel

 
 1-2 pcre / pcre-devel
  ./configure --prefix=/usr/local/pcre
  make
  make install


 1-3 mod_unique_id.so
  apache source file => /modules/metadata
  apxs -cia mod_unique_id.c
 


2. modsecurity 설치

 
 2-1 modsecurity
 ./configure --with-apxs=/usr/sbin/apxs --with-apr=/usr/bin/apr-1-config --with-apu=/usr/bin/apu-1-config --with-pcre=/usr/bin/
 make
 make install
 

 2-2 httpd.conf
 vi /etc/httpd/conf/httpd.conf


 LoadModule unique_id_module /usr/lib/httpd/modules/mod_unique_id.so
 LoadFile /usr/lib/libxml2.so
 LoadModule security2_module modules/mod_security2.so
 include conf.d/modsecurity/modsecurity.conf


 

 

 2-3 modsecurity.conf 적용
 /etc/httpd/conf/modsecurity.conf


 2-4 apache restart

 

 

 

 

 

ModSecurity-console

 

 

3. modsecurity-console 설치

 3-1 JDK 1.4버전 이상 설치
 ./jdk.bin

 

 3-1-1 JDK 설정
  ln -s [JDK설치 디렉토리] /usr/local/java

  vi /etc/profile

 

  JAVA_HOME=/usr/local/java

 

  pathmunge $JAVA_HOME/bin 

  export JAVA_HOME


 

 

  source /etc/profile

 

  3-2 modconsole port open(default 8886)
  vi /etc/sysconfig/ipstables


  #Modsecurity-Console
  -A RH-Firewall-1-INPUT -p tcp --dport 8886 -j ACCEPT
  -A RH-Firewall-1-INPUT -p tcp --sport 8886 -j ACCEPT
  -A RH-Firewall-1-OUTPUT -p tcp --dport 8886 -j ACCEPT
  -A RH-Firewall-1-OUTPUT -p tcp --sport 8886 -j ACCEPT



 

 

 3-3 Install

 

 3-3-1 mod-console source
 tar zxvf modconsole.tar.gz
 vi modconsole/etc/console.conf.default 설정 확인

 

 Property port "8886"

 



 ln -s [modsecurity-console 디렉토리]/modsecurity-console /usr/sbin/modsecurity-console
 modsecurity-console start

 

 

 

 3-3-2 mod-console RPM
 rpm -Uvh modsecurity-console_1_0_5_linux.rpm
 modsecurity-console start

 
 3-4 Lisence / Sensor Add

 

 

 

 

4. modsec-auditlog-collector.pl

 4-1 mkdir /etc/httpd/logs/data
  chmod 705 /var/log/httpd
  chmod 750 /var/log/httpd/data
  chown apache.apache /var/log/httpd/data

 
 4-2 cp modsec-auditlog-collector.pl /usr/local/bin
  vi modsec-auditlog-collector.pl

 


 

 

  my $CONSOLE_URI = "/rpc/auditLogReceiver";
  my $CONSOLE_HOST = "192.168.0.66";
  my $CONSOLE_PORT = "8886";
  my $CONSOLE_USERNAME = "[Sensor]";
  my $CONSOLE_PASSWORD = "[SensorPW]";

 


 

 

  4-3 vi /etc/httpd/conf/modsecurity.conf

 


 

  # 로그 파일 구조
  SecAuditLogType Concurrent
  SecDataDir /etc/httpd/logs/data
  SecAuditLogStorageDir /etc/httpd/logs/data
  SecAuditLog "|/usr/local/bin/modsec-auditlog-collector.pl /etc/httpd/logs/data/ /etc/httpd/logs/modsec_audit.log

  # 로그에 남길 부분
  SecAuditLogParts "ABFHZ

 



  modsecurity-console stop
  modsecurity-console start

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ModSecurity 설치도중 에러 발생시 Tip

 

pcre 설치시 gcc / g++ 필요

=> gcc / gcc-c++ 설치( yum )

 

apxs / apr / apu / pcre 가 없거나 찾지못해서 configure error

 => apxs / apr / apu 없을시 : httpd-devel / apr-devel / apr-util 설치

 => pcre : source

 => 경로를 지정해줌 (which apxs apr-1-config apu-1-config)  : --with-apxs=/usr/sbin/apxs --with-apr=/usr/bin/apr-1-config --with-apu=/usr/bin/apu-1-config --with-pcre=/usr/local/pcre

 

libxml2 / libxml2-devel 이 없어서 configure error

=> yum설치

 

------------------------------------------------------------------------------------

yum -y install gcc-c++ libxml libxml2 httpd-devel apr-devel apr-util

 

 

 

httpd.conf에 모듈 적재 후 아파치 재시작 시 ServerName error

=> /etc/sysconfig/network 에 HOSTNAME=localhost 로 수정 or setup에서 수정

=> 안되면 httpd.conf에 #ServerName 127.0.0.1로 수정

 

아파치 재시작 후 modsecurity가 패턴매치를 못하고 비정상 작동

=> modsec_audit.log엔 log가 남지 않고 error_log를 확인하면 mod_unique_id 모듈을 요청.

=>해당 아파치 소스파일/modules/metadata 에서 apxs -cia mod_unique_id.c (httpd.conf에 모듈 자동 적재)

=>아파치 재시작

 

/etc/httpd/logs/data (/var/log/httpd/data)아래에 log 생성시 httpd /  data의 퍼미션을 755 

 

엮인글 :
List of Articles
번호 제목 글쓴이 날짜 조회 수sort

Linux CentOS 6.5에 JSP를 위한 JDK & Tomcat file

  • LynX
  • 2014-07-05
  • 조회 수 477

LinuxMint joystick install file

  • LynX
  • 2016-09-30
  • 조회 수 476

APM 윈도우에 APM 페키지 설치 file

  • LynX
  • 2018-05-04
  • 조회 수 475

Linux modsecurity

  • LynX
  • 2017-12-06
  • 조회 수 475

Programing 겸손한 자바스크립트

  • LynX
  • 2016-03-16
  • 조회 수 465

CentOS7 ▒ Doly의 CentOS7 강좌20 7. 사용자와 그룹관리 1-사용자 관리 file [8]

  • LynX
  • 2014-11-21
  • 조회 수 461

Xpress Engine XE용 query xml 방식으로 일반 테이블도 접근 처리 하기

  • LynX
  • 2014-07-14
  • 조회 수 459

HTML Tag DIV 태그 (레이어)

  • LynX
  • 2014-06-02
  • 조회 수 459

APM ext ImageMagick install

  • LynX
  • 2019-02-19
  • 조회 수 458

APM MySQLTuner 설치

  • LynX
  • 2018-04-27
  • 조회 수 458

Linux DDOS 방어

  • LynX
  • 2016-09-19
  • 조회 수 457

Linux Custom Kernel 컴파일링 & 설치하기 [8]

  • LynX
  • 2014-08-06
  • 조회 수 457

APM Apache + PHP 설치

  • LynX
  • 2013-12-24
  • 조회 수 454

Media PDF 파일을 JPG 으로 변환하기 - Free PDF to JPG Converter file

  • LynX
  • 2013-06-25
  • 조회 수 452

Linux 하드 라이브 부팅 [13]

  • LynX
  • 2015-01-06
  • 조회 수 449

Windows Server 2012 설치 file

  • LynX
  • 2012-11-23
  • 조회 수 449

Linux Error in FS_Check

  • LynX
  • 2015-03-19
  • 조회 수 446

Programing ActiveX 설치 안될 경우 file

  • LynX
  • 2014-06-13
  • 조회 수 446

Linux CentOS7 페키지 FreeBSD, OpenBSD 비교 [6]

  • LynX
  • 2016-06-08
  • 조회 수 445

Linux LFS/Make Bootable System - LFS 시스템 부팅하기

  • LynX
  • 2014-08-06
  • 조회 수 445

XE Login