아림이의 라이프~~~~!!!
리눅스 서버 본문
설치환경은 다음과 같다. Glibc 2.1.3 libpcap 0.6.2 SNORT 1.8.2 SNORT설치 본인은 프로그램 자체에 대한 설명을 많이 하지는 않는다. 자신이 원할때 해야 집중력이나 이해력에 정점에 이르는 것이다. - 갑자기 뚱딴지 .. SNORT는 IDS(Instrusion Detection System)이다. 즉, 기존 방화벽등이 외부의 침입을 막는데 중점을 두었다면(iptables, tcp wrapper...), 이 놈은 침입하려는 것을 탐지하는데 중점을 두었다. 패킷내의 특정 부분이(침임흔적이라고 판단되는) 발견되면 이를 탐지할 수 있다. 이런 특정 부분은 계속 갱신되어야 하므로 룰셋이라는 별도의 파일로 계속 갱신되어 제공되고 있다. libpcap 설치 snort는 libpcap라이브러리를 사용하므로 설치되어 있지 않다면 설치해 준다. [root@ns /down]$ wget http://www.tcpdump.org/daily/libpcap-current.tar.gz [root@ns /down]# tar xvzf libpcap-current.tar.gz -C /usr/local/src [root@ns /down]# cd /usr/local/src/libpcap-2001.11.03 [root@ns libpcap-2001.11.03]# ./configure [root@ns libpcap-2001.11.03]# make snort 설치 SNORT는 www.snort.org에서 배포한다. [root@ns /down]# wget http://www.snort.org/releases/snort-1.8.2.tar.gz [root@ns /down]# tar xvzf snort-1.8.2.tar.gz -C /usr/local/src [root@ns /down]# cd /usr/local/src/snort-1.8.2/ [root@ns snort-1.8.2]# ./configure [root@ns snort-1.8.2]# make [root@ns snort-1.8.2]# make install 사용 배포tar에 SnortUsersManual.pdf라는 매뉴얼이 들어 있으니 보면 되겠다. 그냥 쉘프롬프트에서 snort라고만 입력하여 실행해보자. [root@ns snort-1.8.2]# snort Log directory = /var/log/snort Initializing Network Interface eth0 using config file ./snort.conf Initializing Preprocessors! Initializing Plug-ins! Initializating Output Plugins! Parsing Rules file ./snort.conf +++++++++++++++++++++++++++++++++++++++++++++++++++ Initializing rule chains... No arguments to frag2 directive, setting defaults to: Fragment timeout: 60 seconds Fragment memory cap: 4194304 bytes Stream4 config: Stateful inspection: ACTIVE Session statistics: INACTIVE Session timeout: 30 seconds Session memory cap: 8388608 bytes State alerts: INACTIVE Scan alerts: ACTIVE Log Flushed Streams: INACTIVE No arguments to stream4_reassemble, setting defaults: Reassemble client: ACTIVE Reassemble server: INACTIVE Reassemble ports: 21 23 25 53 80 143 110 111 513 Reassembly alerts: ACTIVE Back Orifice detection brute force: DISABLED Using LOCAL time 882 Snort rules read... 882 Option Chains linked into 92 Chain Headers 0 Dynamic rules +++++++++++++++++++++++++++++++++++++++++++++++++++ Rule application order: ->activation->dynamic->alert->pass->log --== Initializing Snort ==-- Initializing Network Interface eth0 Decoding Ethernet on interface eth0 --== Initialization Complete ==-- -*> Snort! <*- Version 1.8.2 (Build 86) By Martin Roesch (roesch@sourcefire.com, www.snort.org) Foreground로 실행되었으므로 종료하려면 Ctrl+C를 누른다. =============================================================================== Snort analyzed 1222 out of 1222 packets, dropping 0(0.000%) packets Breakdown by protocol: Action Stats: TCP: 484 (39.607%) ALERTS: 33 UDP: 109 (8.920%) LOGGED: 33 ICMP: 0 (0.000%) PASSED: 0 ARP: 375 (30.687%) IPv6: 0 (0.000%) IPX: 0 (0.000%) OTHER: 253 (20.704%) DISCARD: 0 (0.000%) =============================================================================== Fragmentation Stats: Fragmented IP Packets: 0 (0.000%) Fragment Trackers: 0 Rebuilt IP Packets: 0 Frag elements used: 0 Discarded(incomplete): 0 Discarded(timeout): 0 Frag2 memory faults: 0 =============================================================================== TCP Stream Reassembly Stats: TCP Packets Used: 484 (39.607%) Stream Trackers: 41 Stream flushes: 1 Segments used: 1 Stream4 Memory Faults: 0 =============================================================================== Snort received signal 2, exiting [root@ns snort-1.8.2]# 위에서 보듯이 기본적으로 882의 룰(rule)이 제공된다. 이는 추가적으로 정의될 수 있으므로 룰셋의 개념은 중요하다. ruleset 설치 snortrules.tar.gz에는 snort설정파일인 snort.conf파일이 존재한다. [root@ns /down]# wget http://www.snort.org/downloads/snortrules.tar.gz [root@ns /down]# tar xvzf snortrules.tar.gz -C /usr/local/bin [root@ns /down]# cd /usr/local/bin/rules snort.conf에서 설정 다음값들을 자신의 환경에 맞게 지정하고 나머지는 디폴트로 사용한다. 바이러스(님다,..)로 인해 ISS에 대한 로그가 많으므로 디스크 절약차원에서 아예 빼버렸다. os가 리눅스이므로 이에 대한 피해는 없을것이다. var HOME_NET 211.41.23.0/24 preprocessor portscan-ignorehosts: $DNS_SERVERS #include web-iis.rules 실행 [root@ns src]# snort -D -b -A fast -c /usr/local/bin/rules/snort.conf -D: 데몬모드 -b: text변화제거 -c: 설정파일 지정 테스트 호스트 B에서 호스트 A로 포트스캔을 해본다. [호스트B] [root@A /down]# nmap -O -sS 211.41.23.236 [호스트A] /var/log/snort/alert 11/04-04:27:16.607990 [**] [1:618:1] INFO - Possible Squid Scan [**] [Classification: Attempted Information Leak] [Priority: 2] {TCP} 211.41.23.252:37372 -> 211.41.23.236:3128 11/04-04:27:18.580974 [**] [100:1:1] spp_portscan: PORTSCAN DETECTED to port 25 from 211.41.23.252 (STEALTH) [**] 11/04-04:27:18.580209 [**] [111:12:1] spp_stream4: NMAP FINGERPRINT (stateful) detection [**] {TCP} 211.41.23.252:37382 -> 211.41.23.236:25 11/04-04:27:18.580257 [**] [1:628:1] SCAN nmap TCP [**] [Classification: Attempted Information Leak] [Priority: 2] {TCP} 211.41.23.252:37384 -> 211.41.23.236:1 11/04-04:27:18.580282 [**] [111:10:1] spp_stream4: STEALTH ACTIVITY (nmap XMAS scan) detection [**] {TCP} 211.41.23.252:37385 -> 211.41.23.236:1 11/04-04:27:21.380211 [**] [111:12:1] spp_stream4: NMAP FINGERPRINT (stateful) detection [**] {TCP} 211.41.23.252:37382 -> 211.41.23.236:25 11/04-04:27:21.380260 [**] [1:628:1] SCAN nmap TCP [**] [Classification: Attempted Information Leak] [Priority: 2] {TCP} 211.41.23.252:37384 -> 211.41.23.236:1 11/04-04:27:21.380284 [**] [111:10:1] spp_stream4: STEALTH ACTIVITY (nmap XMAS scan) detection [**] {TCP} 211.41.23.252:37385 -> 211.41.23.236:1 11/04-04:27:24.181210 [**] [100:2:1] spp_portscan: portscan status from 211.41.23.252: 3 connections across 1 hosts: TCP(3), UDP(0) STEALTH [**] 11/04-04:27:24.180302 [**] [111:12:1] spp_stream4: NMAP FINGERPRINT (stateful) detection [**] {TCP} 211.41.23.252:37382 -> 211.41.23.236:25 11/04-04:27:24.180351 [**] [1:628:1] SCAN nmap TCP [**] [Classification: Attempted Information Leak] [Priority: 2] {TCP} 211.41.23.252:37384 -> 211.41.23.236:1 11/04-04:27:24.180376 [**] [111:10:1] spp_stream4: STEALTH ACTIVITY (nmap XMAS scan) detection [**] {TCP} 211.41.23.252:37385 -> 211.41.23.236:1 [root@ns snort]# cat portscan.log Nov 4 04:27:24 211.41.23.252:37380 -> 211.41.23.236:25 NULL ******** Nov 4 04:27:21 211.41.23.252:37381 -> 211.41.23.236:25 NMAPID **U*P*SF Nov 4 04:27:21 211.41.23.252:37385 -> 211.41.23.236:1 XMAS **U*P**F [SNORT SNARF] snort로그파일을 분석해 웹페이지에서 볼 수 있도록 해준다. MRTG같이 CRON으로 돌려 본다. 단, mrtg가 보통 5분주기로 돌리지만, 이 놈은 1일주기로 돌리는 것이 좋겠다. 이 툴은 snort사이트에 링크되어 있어 괜찮은(?) 놈이라고 생각했다. 하지만... 자원사용이 너무 많다. 서버사양이 왠만큼 받쳐주지 않으면 절대 돌리지 말라. 예) alert로그크기가 11M정도일 때 실행했으나, 끝날 생각을 안했다. top으로 파악한 CPU, 메모리사용량은 각각 90%이상, 140M이상으로 서버다운의 위기를 느꼈다. 즉시, 실행을 취소하고, alert를 지우고 portscan.log(크기가 944byte밖에 되지 않는다)만으로 다시 실행해봤으나 5초정도 걸렸던 것 같다. 물론 이 때도 리소스사용량은 시간에 비례해 기하급수적으로 올라갔다. 성능이 너무 실망스러워, 쓰지 않기로 결정했다. snort로그분석툴을 몇개 찾고 있다. 이중 가장 괜찮은 놈을 찾을면 이글을 업데이트할 것이다. snortSnarf설치과정 [root@ns SnortSnarf-010821.1]# cd include/ [root@ns include]# cp -R * /usr/lib/perl5/site_perl/5.005/ [root@ns SnortSnarf-010821.1]# cd cgi/ [root@ns cgi]# cp * /usr/local/apache/cgi-bin/ [root@ns SnortSnarf-010821.1]# cp snortsnarf.pl /usr/local/bin snortsnarf.pl \ -rulesdir /usr/local/bin/rules \ -rulesfile /usr/local/bin/rules/snort.conf \ -d /webhosting/admin/snort /var/log/snort/alert /var/log/snort/portscan.log 참조: http://www.certcc.or.kr/tools/Snort.html http://www.snort.org http://www.silicondefense.com/software/snortsnarf/index.htm |
Comments