본문 바로가기
정보보안/네트워크 보안

snort 설치 방법

by meanjung 2022. 2. 8.

 

  • 오픈소스 NIDS/NIPS
  • 네트워크 침투를 탐지하고 방지하는데 사용된다. 
  • snort는 특정 네트워크 인터페이스를 통해 보내고 받는 package data를 모니터한다.
  • NIDS는 signature-based detection과 protocol analysis technologies를 이용해 우리 시스템의 취약점을 타겟팅하는 위협을 확인할 수 있다. 
  • NIDS software가 제대로 설치되었다면 다양한 종류의 공격과 의심행위들을 확인할 수 있다.
    • ex) CGI attacks/ network policy viloations/ SMB probes/ malware infections/ a compromised system/ stealth port scan

설치방법

https://upcloud.com/community/tutorials/install-snort-ubuntu/

 

How to install Snort on Ubuntu

Snort is a popular choice for running a network intrusion detection systems on your server. This guide shows how to configure and run Snort in NIDS mode with a basic setup that you can later expand as needed.

upcloud.com

  • snort 자체를 설치할 cloud server를 준비하려면 먼저 prerequisite software를 설치해야 한다.
    • sudo apt update
    • sudo apt upgrade
    • sudo apt install -y gcc libpcre3-dev zlib1g-dev libluajit-5.1-dev
    • sudo apt install -y libpcap-dev openssl libssl-dev libnghttp2-dev libdumbnet-dev
    • sudo apt install -y bison flex libdnet autoconf libtool
  • installing from the source
  • configuring snort to run in NIDS mode
    • sudo ldconfig
    • sudo ln -s /usr/local/bin/snort /usr/sbin/snort
  • setting up username(root 권한없이 snort를 사용하는게 안전하다.)
    • sudo groupadd snort
    • sudo useradd snort -r -s /sbin/nologin -c SNORT_IDS -g snort
      • -s : 쉘 지정
      • -c : 사용자 생성시 사용자에 대한 설명
      • -g : 그룹 지정
      • -r : 사용자의 uid 정보를 1~499번 사이의 값으로 생성
  •  setting up folder structure(snort configuration을 저장하기 위한 폴더를 생성한다.) 
    • sudo mkdir -p /etc/snort/rules
    • sudo mkdir /var/log/snort
    • sudo mkdir /usr/local/lib/snort_dynamicrules
    • 새로 만든 디렉터리에 permission 세팅
      • sudo chmod -R 5775 /etc/snort
      • sudo chmod -R 5775 /var/log/snort
      • sudo chmod -R 5775 /usr/local/lib/snort_dynamicrules
      • sudo chown -R snort:snort /etc/snort
      • sudo chown -R snort:snort /var/log/snort
      • sudo chown -R snort:snort /usr/local/lib/snort_dynamicrules
    • whitelist, blacklist, local rules에 대한 새 파일을 만든다. 
      • sudo touch /etc/snort/rules/white_list.rules
      • sudo touch /etc/snort/rules/black_list.rules
      • sudo touch /etc/snort/rules/local.rules
    • 다운로드 폴더에서 configuration file을 복사한다.
      • sudo cp ~/path/to/snort_src/snort-2.9.19/etc/*.conf* /etc/snort
      • sudo cp ~/path/to/snort_src/snort-2.9.19/etc/*.map /etc/snort
    • 이제 snort가 potential threat을 확인하기 위해 따라야 할 detection rules을 다운받아야 한다. snorts는 rule sets의 3티어를 제공한다.
      • community rules : 약간 제한되어있지만 freely available
      • registered rules : 그들의 웹사이트에 무료로 등록함으로써 당신의 Oink code에 접근할 수 있다. Oink code는 registered users rule sets을 다운로드하게 해준다. 
      • subscriber rules : 사용자들에게 snort 서비스에 대한 active subscription이 있는 사용자가 사용할 수 있다. 
  • [Option 1] Using community rules
    • (적당한 위치에서) wget https://www.snort.org/rules/community
    • sudo tar -xvf community.tar.gz
    • sudo cp community-rules/* /etc/snort/rules
    • By default, 우분투에서의 snort는 community rules에 포함되지 않는 많은 다른 rule files를 찾기를 원한다. 
      • sudo sed -i 's/include $RULE_PATH/#include $RULE_PATH/' /etc/snort/snort.conf

snort 실습

출처 : https://ast-216.tistory.com/25

  • rule header, rule option으로 이루어져있다. 

1. /etc/snort/rules/local.rules

(example)

# ICMP
alert icmp any any -> $HOME_NET any (msg:"## ICMP Echo ##"; itype:8; sid:1000001; rev:1;)
alert icmp $HOME_NET any -> any any (msg:"## ICMP Echo-Reply ##"; itype:0; sid:1000002; rev:1;)

# FTP
alert tcp any any -> $HOME_NET 21 (msg:"## FTP Request ##"; content:"USER"; sid:1000003; rev:1;)
alert tcp $HOME_NET 21 -> any any (msg:"## FTP Response ##"; content:"vsFTPd"; sid:1000004; rev:1;)

# TELNET
alert tcp any any -> $HOME_NET 23 (msg:"## Telnet Request ##"; sid:1000005; rev:1;)
alert tcp $HOME_NET 23 -> any any (msg:"## Telnet Response ##"; content:"login"; sid:1000006; rev:1;)

# Web
alert tcp any any -> $HOME_NET 80 (msg:"## HTTP Request ##"; sid:1000007; rev:1;)
alert tcp $HOME_NET 80 -> any any (msg:"## HTTP Response ##"; sid:1000008; rev:1;)
  • action
    • alert : 경고 발생, 로그 기록
    • log, pass, drop, reject, sdrop, active, dynamic
  • protocol
    • tcp, udp, ip, icmp, any
  • $HOME_NET : snort.conf에서 확인할 수 있다. 
  • itype : ICMP type
  • sid : 각 룰의 고유 번호
    • 0 - 99 : 예약이 끝난 상태
    • 100 - 1000000 : snort.org 공식 배포 룰 용 
    • 사용자 정의 룰의 경우 항상 백만번 이후의 sid를 사용해야 한다.
  • rev : 규칙의 버전 번호. sid와 함께 쓰인다. 
  • content : 텍스트 검색

2. snort 콘솔 디버깅 실시

  • sudo sed -i 's/include $RULE_PATH/#include $RULE_PATH/' /etc/snort/snort.conf
    • using community rules 
    • 이 명령을 해야 오류가 나지 않는다. 이 명령어가 없으면 무슨 .rules 파일이 없다느니 엄청 뜬다.
    • By default, Snort on Ubuntu expects to find a number of different rule files which are not included in the community rules. You can easily comment out the unnecessary lines using the sed command underneath.
  • sudo snort -q -v -A console -b -c /etc/snort/snort.conf
    • -q : 배너 없애기
    • -A : set alert mode(fast, full, console, test, none)
    • -b : log packets in tcpdump format
    • -c : use rule file
    • -v : 상세 내용 보기(이 옵션 선택하지 않으면 룰에서 alert 설정한 거 안보인다.)
  • 같은 네트워크에 있는 다른 PC에서 해당 PC로 ping을 날리면 다음과 같이 로그를 확인할 수 있다. 

 


참조

https://net123.tistory.com/581

 

Snort - 05. Snort 실습 I

Snort - 05. Snort 실습 I 1. Snort 룰 설정  1) ICMP, FTP, Telnet, HTTP에 대한 Snort 룰 설정 root@Snort:~# vi /etc/snort/rules/local.rules # $Id: local.rules,v 1.11 2004/07/23 20:15:44 bmc Exp $ # -..

net123.tistory.com

https://girrr.tistory.com/132

 

IDS - 스노트(Snort) : 기본

IDS - Snort 운영 (기본) • Snort 실행 - #snort [-options] - 기본 실행(Packet Sniffing 모드)  # snort - 초기화된 설정 파일로 구동  # snort -c /etc/snort/snort.conf - 상세 트래픽 포함하여 덤프..

girrr.tistory.com

 

'정보보안 > 네트워크 보안' 카테고리의 다른 글

firewall 방화벽, 침입차단시스템  (0) 2022.02.07
IDS 침입탐지시스템  (0) 2022.02.07

댓글