Snort 후속 패키지라 생각하면된다.
네트워크 망을 통과하는 패킷을 컨트롤 한다. 즉, IDS/IPS의 기능이다.
일반 중소기업에서 고가의 보안 장비를 구입하는 대신 본 시스템을 구축하여 사용하는것도 좋다.
장점으로 기능도 많아졌지만 Multi-Thread방식, IPv6등을 지원한다.
[ yum을 통한 호환 라이브러리 설치 ]
# yum install libpcre3 libpcre3-dbg libpcre3-dev build-essential autoconf automake libtool libpcap-dev
libnet1-dev libyaml-0-2 libyaml-dev zlib1g zlib1g-dev libcap-ng-dev
libcap-ng0 make libmagic-dev libnetfilter-queue-dev libnetfilter-queue1
libnfnetlink-dev libnfnetlink0
# yum을 통한 라이브러리 설치 실패 시 아래 패키지를 따로 설치하자
# export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
# export LD_LIBRARY_PATH=/usr/local/lib:/lib:/usr/lib
ftp://ftp.netfilter.org
libmnl
libnetfilter_queue
libnfnetlink
[ suricata 설치 ]
# wget http://www.openinfosecfoundation.org/download/suricata-2.0.7.tar.gz
# cd ./suricata
# pfring동작은 kernel 2.6.32 이상이다.
# ./configure --disable-gccmarch --enable-pfring --enable-nfqueue --enable-af-packet --prefix=/usr --sysconfdir=/etc --localstatedir=/var
# make && make install-full
컴파일 문제
설치하다보면 여러가지 문제가 발생하는데 특히 pfring문제가 많이 발생한다.
아래는 조치 방식이다.
ERROR! --enable-pfring was passed but the library version is < 6, go get it
rpm -Uvh dkms-2.2.0.3-31.1.noarch.rpm
rpm -Uvh pfring-dkms-7.1.0-1592.noarch.rpm
rpm -Uvh pfring-7.1.0-1592.x86_64.rpm
# pfring사용시 모듈 설치(위에서 rpm을 설치했으면 그냥 통과...)
OS버전에 따라 설치 방식이 좀 다르다.
CentOS7 - https://www.ntop.org/get-started/download/#PF_RING
svn co https://svn.ntop.org/svn/ntop/trunk/PF_RING/
cd PF_RING/kernel
make
sudo insmod ./pf_ring.ko
cd ../userland
make
[ 패키지 모니터링 및 차단 ]
# 백그라운드로 실행(-D)
# suricata -D -c /etc/suricata/suricata.yaml --af-packet => 컴파일 시 af-packet을 지원해야한다.
# suricata -D -c /etc/suricata/suricata.yaml -i br0 => br0은 브릿지 모드이다.
에러처리
lib오류가 발생하면 아래와 같이 링크를 걸어주자.
suricata: error while loading shared libraries: libhtp.so.2: cannot open shared object file: No such file or directory
ln -s /usr/lib/libhtp.so.2 /lib64/libhtp.so.
[ 로그 확인 ]
# /etc/suricata/suricata.yaml파일의 설정에 따라 로그가 생성된다.
# ls /var/log/suricata (아래는 기본 로그이다.)
fast.log => 룰에 의한 접속 로그
http.log => http호출 헤더 정보
stat.log => 필터링 Counter, TM Name, Value를 보여줌
unified2.alert.숫자 => 접속 페이지 소스 저장
[ 환경 설정 ]
#rules 설정 파일 : /etc/suricata/suricata.yaml =>룰파일 추가 및 수정 시 적용 위치
default-rule-path: /etc/suricata/rules
rule-files:
- botcc.rules
- ciarmy.rules
- compromised.rules
#남기고자하는 상태를 no->yes로 바꾸면 해당 파일로 로그가 생성된다.
예) - drop:
enabled: yes
filename: drop.log
append: yes
행위 설정 파일 : /etc/suricata/rules/*.rules
alert http $HOME_NET any -> $EXTERNAL_NET $HTTP_PORTS 어쩌구 저쩌구
alert가 행위 상태를 말해준다. 만약 drop이 필요하면 아래와 같이 한다.
pass, drop, reject, alert 모드가 있다.
drop http $HOME_NET any -> $EXTERNAL_NET $HTTP_PORTS 어쩌구 저쩌구
# 실행 모드에 ips 옵션을 적용해야 패킷 drop이 가능하다.
[ 패킷 차단 방법1 ]
# iptables -I FORWARD -i eth0 -o eth1 -j NFQUEUE
# iptables -I FORWARD -i eth1 -o eth0 -j NFQUEUE
# suricata -c /etc/suricata/suricata.yaml -q 0
[ 패킷 차단 방법2 ]
# vi /etc/suricata/suricata.yaml
af-packet:
- interface: eth0
threads: 1
defrag: yes
cluster-type: cluster_flow
cluster-id: 98
copy-mode: ips
copy-iface: eth1
buffer-size: 64535
use-mmap: yes
- interface: eth1
threads: 1
cluster-id: 97
defrag: yes
cluster-type: cluster_flow
copy-mode: ips
copy-iface: eth0
buffer-size: 64535
use-mmap: yes
# suricata -c /etc/suricata/suricata.yaml --af-packet
사이트 참고 - https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Suricatayaml
*) - 로그 관리를 해주자. 무시하면 디스크 풀난다.
- 룰 다운로드 : https://rules.emergingthreats.net/open/
[ 기타 ]
# 특정 포트 대역을 차단하는 iptables룰이다.
# 토렌트의 경우 랜덤한 포트를 사용하기때문에 차단에 한계가 있다.
iptables -I FORWARD -p tcp -m multiport --dports 6882:6899 -m iprange --src-range 10.0.0.1-10.0.0.255 -j DROP
iptables -I FORWARD -p udp -m multiport --dports 6882:6899 -m iprange --src-range 10.0.0.1-10.0.0.255 -j DROP
* 룰 형식이 필요하면 아래 사이트를 방문하자.
https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Suricata_Rules
















덧글