Simple is IT, 누구나 보고 누구나 깨닫는 IT
침입 차단/탐지 시스템(IPS/IDS) Snort 관리 및 사용법 본문
Snort
네트워크 침입 차단/탐지 시스템(NIPS, NIDS, Network Instrusion Prevention/Detection System)
-> 프로토콜을 분석하며 내용 검색 그리고 매칭을 수행한다.
Sniffer, Packet Logger, 침입 탐지가 주요 모드
다음과 같은 구성에서 각종 사용법 등을 알아볼 것이다.
서로 간의 라우팅, 인터넷은 되는 상태
Kali : 외부에서 침입을 시도하는 Hacker
Snort : 침입을 방어하기 위한 일종의 보안 장비(CentOS)
XP : 사용자
# yum -y install http://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/d/daq-2.0.6-1.el7.x86_64.rpm
# yum -y install gcc gcc-c++ flex bison zlib libpcap pcre libdnet tcpdump
# yum -y install ftp://ftp.pbone.net/mirror/archive.fedoraproject.org/epel/7/x86_64/Packages/l/libnghttp2-1.31.1-1.el7.x86_64.rpm
# wget http://ftp.psu.ac.th/pub/snort/libdnet-1.12.tgz
# tar zxvf libdnet-1.12.tgz
# yum install https://www.snort.org/downloads/snort/snort-2.9.16-1.centos7.x86_64.rpm
|
Example Settings
configure
테스트로 작성할 Rule을 위해 기존의 rule을 주석처리
/etc/snort/snort.conf
-> line 253, 511, 512, 548 ~ 651 - 주석
/etc/snort/rules/local.rules
: alert icmp any any -> any any ( msg:"ICMP Detected"; sid:1000001; )
!! Rule의 구성에 대해서는 아래에 자세히
|
Snort Start
# snort -c /etc/snort/snort.conf -i ens37
Log Check
# tail -f /var/log/snort/alert
XP -> 8.8.8.8 Ping
|
[Action] [Protocol] [S_IP] [S_Port] [->, <>] [D_IP] [D_Port] [Options]
alert : 룰에 일치하는 경우 경고를 발생 시키고 로그로 기록한다.
reject : 패킷을 차단하고 로그, tcp 패킷 : rst 응답 udp 패킷 : icmp unreachable 패킷 응답
sdrop : 패킷을 차단하고 로그를 남기지 않는다.
!1:1024 = 1 ~ 1024 제외 나머지
|
genaral : 룰에 대한 정보를 포함해 탐지
msg : alert 엔진을 통해 전달하는 메세지를 설정
sid : Snort ID의 약자, 룰 식별로 사용
payload : Protocol의 내용으로 탐지
content : 페이로드 내 존재하는 문자열을 판별
ex) content:"cgi-bin/phf"; offset:4; depth:20;
non-payload : 페이로드가 없는 데이터에서 사용
fragoffset : Fragment 오프셋 필드 값 비교
fragoffset:[!]<|>]<number>;
ttl : traceroute 명령어 탐지 키워드
ttl:[<,>,=,<=,>=]<number>; , ttl:[<number>]-[<number>];
fragbits : 단편화 패킷이나 IP Header 내 Flags필드에 비트설정 확인
flags : TCP Flag 비트 확인 시 사용(U, A, P, R, S, F, 0)
seq : TCP Sequence Number 확인
ack : TCP Acknowledge Number 확인
Post-detection : 사후탐지에 대한 옵션, 룰 실행 후의 규칙
react : 패킷을 차단하거나 경고 메세지를 출력
|
Example 1) Windows XP에서 naver로 접속을 시도할 시 탐지
local.rules configure
alert udp 10.10.10.0/24 any -> any 53 ( msg:"NAVER Detected!!"; sid:1000001; content:"naver"; nocase; )
Log
Example 2) 내부에서 외부로 나가는 HTTP 트래픽의 Header 중 GET만을 탐지
local.rules configure
alert tcp 10.0.0.0/24 any -> any 80 (msg:"GET Method Detected!"; content:'get"; depth:3; nocase; sid:1000001;)
Log
Example 3) Snort의 SSH로 접근하려는 트래픽 중 내부를 제외한 나머지 트래픽을 담지
local.rules configure
alert tcp ![10.0.0.0/24,20.0.0.10/32] any -> [20.0.0.10/32,10.0.0.2/32] 22 (msg:"ssh"; sid:1000001;)
Log