CentOS 6.8 snort 설치
//2017.03.17 수정 (snort 구동문제)
1. snort
snort는 1998년에 마틴 로시(Martin Roesch)가 개발한 무료 오픈소스 네트워크 침입 차단 탐지 시스템이다.
여러 OS를 지원하고 snort 커뮤니티에서 rule을 다운받아 사용 가능하고 사용자가 직접 탐지 rule을 설정해서 사용할 수도 있다.
2. snort 기능
snort는 실시간 트래픽 분석과 패킷 로깅을 수행한다.
모드
- 패킷 스니퍼 모드 (Sniffer Mode)
tcpdump와 같은 네트워크상의 TCP/IP 패킷을 읽어 보여주는 기능
- 패킷 로거 모드 (PacketLogger Mode)
모니터링한 패킷을 저장하고 로그를 기록하는 기능
트래픽 디버깅에 유용
- 네트워크 침입 탐지 모드 (Network Intrusion Detection System Mode:NIDS)
침입탐지시스템(IDS), 네트워크 트래픽(패킷) 부석 및 공격 탐지 기능
- Snort Inline
침입방지시스템(IPS), 패킷 분석, 공격 차단 기능
옵션
-v : snort를 패킷 Sniffing 모드로 동작(TCP)
-d : 모든 네트워크 계층을 포함
-e : 데이터 링크 계층 헤더를 포함
-c : 패킷 검출
3. snort 구조
- Sniffer
Snort IDS를 통과한 모든 패킷 수집하여, 사람이 보기 쉽게 Decode한다.
어플리케이션 또는 하드웨어 장치에서 해당 네트워크의 트래픽을 도청할 수 있다.
- Preprocessor
효율적인 공격 탐지를 위해 몇가지 플러그인을 먼저 거치며 매칭 확인한다.
비정상 헤더 구조 패킷이나, 트래픽을 구분한다.
snort 디코더를 통해 분해하여 패킷구조, 플래그 정보, 프로토콜 정보를 이용하여 패킷의 형식이나 구조를 해석한다.
Fragment된 패킷은 조합하여 정상적인 패킷인지 검사한다.
- Detection Engine
rule기반의 탐지 엔진으로, 사전에 정의된 탐지룰과 매칭되는지 확인한다.
Payload에 포함된 Data를 분석해 공격 여부를 판단한다.
패킷과 일치하는 ruleset이 있으면 해당 패킷은 Alrt/Logging으로 전달된다.
- Alert/Logging
정책에 따른 로그 기록을 한다. Alert는 Log File, SMB, SNMP trap등으로 Log는 Text File 또는 DB에 저장한다.
OS : VMware CentOS 6.8 x86_64
snort : 2.9.9.0
daq : 2.0.6
snort rule : 2962(registered)
4-1. 라이브러리 설치
라이브러리를 다운받아 준다.
1 2 3 4 | yum install -y mysql mysql-server mysql-bench mysql-devel httpd php php-mbstring php-devel php-mysql php-pear gcc php-gd gd glib2-devel gcc g++ flex bison zlib tcpdump apache2 pcre* libxml2-devel vimenhanced* zlib-devel nbtscan libpcap yum -y groupinstall "Development Tools" | cs |
이후 구글에 libdnet을 검색하여 libdnet-1.12.tgz, libdnet-1.12-6.el6.x86_64.rpm, libdnet-devel-1.12-6.el6.x86_64.rpm 을 받아준다.
1 2 3 4 5 6 | tar -zxvf libdnet-1.12.tgz cd libdnet-1.12 ./configure cd .. rpm -ivh libdnet-1.12-6.el6.x86_64.rpm rpm -ivh libdnet-devel-1.12-6.el6.x86_64.rpm | cs |
다음 명령어로 각 파일을 설치한다.
4-2. daq, snort 설치
1 2 3 4 5 6 7 8 9 10 11 | wget https://www.snort.org/downloads/snort/daq-2.0.6.tar.gz wget https://www.snort.org/downloads/snort/snort-2.9.9.0.tar.gz cd /usr/local/src/ tar -zxvf /home/test/Desktop/daq-2.0.6.tar.gz tar -zxvf /home/test/Desktop/snort-2.9.9.0.tar.gz cd daq-2.0.6/ ./configure make && make install cd .. cd snort-2.9.9.0/ ./configure --enable-sourcefire && make && sudo make install | cs |
4-3. rule 설치, user 생성
1 2 3 4 5 6 7 8 9 10 11 | cd /etc mkdir snort cd snort cp /usr/local/src/snort-2.9.9.0/etc/* . tar -zxvf /home/test/Desktop/snortrules-snapshot-2962.tar.gz touch /etc/snort/rules/white_list.rules /etc/snort/rules/black_list.rules groupadd -g 40000 snort useradd snort -u 40000 -d /var/log/snort -s /sbin/nologin -c SNORT_IDS –g snort cd /etc/snort chown -R snort:snort * chown -R snort:snort /var/log/snort | cs |
4-4. conf 설정
1 | vi /etc/snort/snort.conf | cs |
자기가 모니터할 네크워크를 적어준다. (ex -192.168.1.0/24)
그 후 /RULE_PATH를 검색해 이동해준다.
위의 rules위치를 맞게 고쳐준다.
4-5. 권한 설정
권한은 755로 해도 무방해보인다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | cd /usr/local/src chown -R snort:snort daq-2.0.6 chmod -R 700 daq-2.0.6 chown -R snort:snort snort-2.9.9.0 chmod -R 700 snort-2.9.9.0 chown -R snort:snort snort_dynamicsrc chmod -R 700 snort_dynamicsrc cd /usr/local/src/snort-2.9.9.0/rpm cp snortd /etc/init.d/snort chkconfig --add /etc/init.d/snort cd /usr/sbin ln -s /usr/local/bon/snort snort cd /var/log chmod 755 snort chown -R snort:snort snort cd /usr/local/lib chown -R snort:snort snort* chown -R snort:snort snort_dynamic* chown -R snort:snort pkgconfig chmod -R 700 snort* chmod -R 700 pkgconfig cd /usr/local/bin chown -R snort:snort daq-modules-config chown -R snort:snort u2* chmod -R 700 daq-modules-config chmod 700 u2* cd /etc chown -R snort:snort snort chmod -R 700 snort | cs |
4-6. snort 실행
1 2 | cd /usr/local/bin ./snort -T -i eth0 -u snort -g snort -c /etc/snort/snort.conf | cs |
만약 ERROR: /etc/snort/snort.conf(253) Could not stat dynamic module path "/usr/local/lib/snort_dynamicrules": No such file or directory. 한 에러가 발생하면 디렉토리를 만들어 준다.
1 2 3 | mkdir -p /usr/local/lib/snort_dynamicrules chown -R snort:snort /usr/local/lib/snort_dynamicrules chmod -R 700 /usr/local/lib/snort_dynamicrules | cs |
성공
//참고
https://s3.amazonaws.com/snort-org-site/production/document_files/files/000/000/091/original/snort-centos6x-7x-298x.pdf?AWSAccessKeyId=AKIAIXACIED2SPMSC7GA&Expires=1489656188&Signature=iaDhrzaJxoHVS0olMrMY5JTiyFA%3D
https://www.youtube.com/watch?v=-aQj1s_mPkY
https://brunch.co.kr/@leesmain/34
패킷 분할 방법
1. editcap
와이어샤크를 설치할 때 같이 설치되는 파일로 와이어샤크가 설치된 폴더에 들어가면 있는 걸 볼 수 있다.
Editcap 1.12.4 (v1.12.4-0-gb4861da from master-1.12) Edit and/or translate the format of capture files. See http://www.wireshark.org for more information. Usage: editcap [options] ... <infile> <outfile> [ <packet#>[-<packet#>] ... ] <infile> and <outfile> must both be present. A single packet or a range of packets can be selected. Packet selection: -r keep the selected packets; default is to delete them. -A <start time> only output packets whose timestamp is after (or equal to) the given time (format as YYYY-MM-DD hh:mm:ss). -B <stop time> only output packets whose timestamp is before the given time (format as YYYY-MM-DD hh:mm:ss). Duplicate packet removal: -d remove packet if duplicate (window == 5). -D <dup window> remove packet if duplicate; configurable <dup window> Valid <dup window> values are 0 to 1000000. NOTE: A <dup window> of 0 with -v (verbose option) is useful to print MD5 hashes. -w <dup time window> remove packet if duplicate packet is found EQUAL TO OR LESS THAN <dup time window> prior to current packet. A <dup time window> is specified in relative seconds (e.g. 0.000001). NOTE: The use of the 'Duplicate packet removal' options with other editcap options except -v may not always work as expected. Specifically the -r, -t or -S options will very likely NOT have the desired effect if combined with the -d, -D or -w. Packet manipulation: -s <snaplen> truncate each packet to max. <snaplen> bytes of data. -C [offset:]<choplen> chop each packet by <choplen> bytes. Positive values chop at the packet beginning, negative values at the packet end. If an optional offset precedes the length, then the bytes chopped will be offset from that value. Positive offsets are from the packet beginning, negative offsets are from the packet end. You can use this option more than once, allowing up to 2 chopping regions within a packet provided that at least 1 choplen is positive and at least 1 is negative. -L adjust the frame length when chopping and/or snapping -t <time adjustment> adjust the timestamp of each packet; <time adjustment> is in relative seconds (e.g. -0.5). -S <strict adjustment> adjust timestamp of packets if necessary to insure strict chronological increasing order. The <strict adjustment> is specified in relative seconds with values of 0 or 0.000001 being the most reasonable. A negative adjustment value will modify timestamps so that each packet's delta time is the absolute value of the adjustment specified. A value of -0 will set all packets to the timestamp of the first packet. -E <error probability> set the probability (between 0.0 and 1.0 incl.) that a particular packet byte will be randomly changed. Output File(s): -c <packets per file> split the packet output to different files based on uniform packet counts with a maximum of <packets per file> each. -i <seconds per file> split the packet output to different files based on uniform time intervals with a maximum of <seconds per file> each. -F <capture type> set the output file type; default is pcapng. An empty "-F" option will list the file types. -T <encap type> set the output file encapsulation type; default is the same as the input file. An empty "-T" option will list the encapsulation types. Miscellaneous: -h display this help and exit. -v verbose output. If -v is used with any of the 'Duplicate Packet Removal' options (-d, -D or -w) then Packet lengths and MD5 hashes are printed to standard-error. | cs |
이런식으로 옵션에 맞게 패킷이 잘린다.
2. 패킷을 초 단위로 분할
참고 : http://apollo89.com/wordpress/?p=6900
'Network' 카테고리의 다른 글
CentOS 6.8 snort 설치 (0) | 2017.03.09 |
---|