You cannot see this page without javascript.

modsecurity

Linux 조회 수 492 추천 수 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 조회 수
369 APM mariadb download origin address LynX 2019-06-19 1990
368 APM What one can and should optimize LynX 2019-06-03 1416
367 CentOS mariadb install LynX 2019-05-31 1180
366 CentOS init mode change LynX 2019-05-30 1289
365 APM ext zip install LynX 2019-02-19 1613
364 APM ext ImageMagick install LynX 2019-02-19 511
363 3D Printer Pronterface(PrintRun) install file LynX 2018-09-13 753
362 CentOS Grub UUID change LynX 2018-08-08 867
361 Linux letsencrypt wildcard LynX 2018-07-26 798
360 Printer cura usb connection LynX 2018-07-06 666
359 CentOS cli 무선랜 LynX 2018-06-07 446
358 APM 윈도우에 APM 페키지 설치 file LynX 2018-05-04 586
357 APM MySQLTuner 설치 LynX 2018-04-27 544
356 CentOS CentOS7 커널 업데이트 LynX 2018-04-23 699
355 HTML Tag CSS 여러가지 모양 만들기 LynX 2018-02-08 771
354 Linux wkhtmltopdf wkhtmltoimage install LynX 2018-01-31 602
353 APM LZ4_LIBS Not Found (CentOS7, MariaDB 10.1.29) LynX 2018-01-03 485
352 APM mysql ./configure LynX 2017-12-15 804
351 APM PHP-7.2.0 LynX 2017-12-12 3157
350 Linux libiconv LynX 2017-12-08 558

XE Login