Wednesday, January 23, 2019

Snort IPS 백도어 탐지 및 차단을 위한 기본 설정

2018-11-20 

Snort IPS 백도어 탐지 및 차단

작업 디렉토리 생성

  • mkdir -p /root/snort-install
  • cd /root/snort-install


libdnet 컴파일 설치

  • libdnet 최신버전이 아닌 1.12버전을 필요로하기 때문에 어쩔수 없이 다운받아 설치
  • wget http://ftp.psu.ac.th/pub/snort/libdnet-1.12.tgz
  • tar zxvf libdnet-1.12.tgz
  • cd libdnet-1.12
  • ./configure "CFLAGS=-fPIC"   //빌드(컴파일) 할  옵션을 지정하는 과정
  • make    //실제 컴파일(빌드) 과정
  • checkinstall -y    //CheckInstall will build a .deb package and install it. 
  • dpkg -l |grep libdnet   //패키지 설치 확인
  • ln -s /usr/local/lib/libdnet.1.0.1 /usr/lib/libdnet.1


DAQ 컴파일 및 설치

  • 설명 : Data AcQuisition : 데이터 수집
    • 참고 https://snortrules.wordpress.com/2010/10/22/snort-2-9-0-%EC%9D%98-daq-%EB%9D%BC%EC%9D%B4%EB%B8%8C%EB%9F%AC%EB%A6%AC-%EA%B8%B0%EB%8A%A5/
  • 스노트가 공격탐지할 때 필요한 정보를 제공하는 역할
    • cd /root/snort-install
    • wget https://www.snort.org/downloads/snort/daq-2.0.6.tar.gz
    • tar zxvf daq-2.0.6.tar.gz
    • cd daq-2.0.6
    • ./configure
    • make
    • checkinstall -y       //CheckInstall will build a .deb package and install it.
    • dpkg -l |grep daq


Snort 설치


  • cd /root/snort-install
  • wget https://www.snort.org/downloads/snort/snort-2.9.11.1.tar.gz
  • tar zxvf snort-2.9.11.1.tar.gz
  • cd snort-2.9.11.1
  • ./configure --enable-sourcefire
  • make
  • checkinstall -y       //CheckInstall will build a .deb package and install it.
  • ln -s /usr/local/bin/snort  /usr/sbin/snort
  • ldconfig -v   //설치 확인(버전 체크)
  • snort -V   //설치 확인(버전 체크)


# Snort Rule 설치


  • Snort.org 로그인
  • Step3 에서 Registered Rules 클릭
    •  로그인 하고 다운받아서(웹) 
  • tar -xvfz snortrules-snapshot-29111.tar.gz -C /etc/snort


# Snort 설정


  • mv /etc/snort/etc/* /etc/snort
  • vi /etc/snort/snort.conf
    • ipvar HOME_NET 192.168.0.0/24  //보호할 네트워크
    • ipvar EXTERNAL_NET !$HOME_NET
    • var RULE_PATH /etc/snort/rules
    • var SO_RULE_PATH /etc/snort/so_rules
    • var PREPROC_RULE_PATH /etc/snort/preproc_rules
    • var WHIE_LIST_PATH /etc/snort/rules
    • var BLACK_LIST_PATH /etc/snort/rules

   !!!! 주의 

   - HTTP 전처리기 설정에서 처리할 수 없는 오류 발생
   324번줄 \(BackSlash) 제거
   325줄 주석처리 (맨앞에 # 추가)  --> webroot no 이거 제거하려고
   326 주석처리 (맨앞에 # 추가)  --> decompress_swf 이거 제거하려고
   326 주석처리 (맨앞에 # 추가)  --> decompress_pdf 이거 제거하려고
   !! 룰 파일의 버전에 따라 줄번호가 조금 차이가 있을 수 있음.. 잘 확인하시오.
   
   touch /etc/snort/rules/white_list.rules --> 파일이 없어서 snort 실행시 에러발생
   touch /etc/snort/rules/black_list.rules --> 파일이 없어서 snort 실행시 에러발생
   mkdir /usr/local/lib/snort_dynamicrules  --> 디렉토리가 없어서 snort 실행시 에러발생

탐지 룰 추가 (icmp)


  • 설치한  Registered Rules에 포함된 룰이 부실하므로 추가적으로 다운로드하여 추가한다.
    • https://raw.githubusercontent.com/eldondev/Snort/master/rules/icmp.rules


# IPS 로 구동시키기


  • 차단 필터 구성
    • Beast 백도어 탐지 룰(Direct Connection)
      • vi /etc/snort/rules/icmp.rules
        • alert icmp $EXTERNAL_NET any -> $HOME_NET any (msg:"ICMP Large ICMP
        • Packet"; dsize:>800; reference:arachnids,246; classtype:bad-unknown; 
        • sid:499; rev:4;)
      • vi /etc/snort/rules/backdoor_test1.rules
        • alert tcp $EXTERNAL_NET any -> $HOME_NET any (msg:"Backdoor beast2.07
        • Connection"; flow:to_server,established; content:"666"; offset:0; depth:12; sid:181818;  rev:1)
    • 차단 필터 구성
      • vi /etc/snort/snort.conf  맨밑줄에 추가
        • rate_filter gen_id 1, sig_id 181818, track by_src, count 2, seconds 10, new_action drop, timeout 30
        • rate_filter gen_id 1, sig_id 499, track by_src, count 3, seconds 10, new_action drop, timeout 10
    • Snort 가동
      • snort -Q --daq afpacket --daq-mode inline --daq-var queue=0 -c /etc/snort/snort.conf  
    • A full -l /var/log/snort -K ascii -i enp0s3:enp0s8
 

    !! afpacket : Layer 2 방식 지원



  • 탐지 로그 실시간 확인
    • tail -f /var/log/snort/alert

  • 공격테스트 (Large ICMP)
    • ping -l 1000 호구IP주소

  • 비교테스트(일반 ICMP Echo)
    • ping 호구IP주소

No comments:

Post a Comment

List

MobSF

MobSF는 오픈소스 모바일 앱 자동 보안 진단 프레임워크로 자동 분석 시스템 구축할 때 사용한다. 정정 및 동적 분석이 가능하며, Android, iOS, Windows에 대해 침투 테스트, 멀웨어 분석 및 보안 평가를 할 수 있다. 참고자료 필...