스노트 설치
우분투 22.04
cat /etc/*relesase*
sudo apt update
apt -y install snort
snort --version
네트워크 7계층
7계층 : 응용 계층
어플리케이션이 네트워크에 접근할 수 있도로 제공
6계층 : 표현 계층
응용계층에서 전달받은 데이터를 인코딩하거나 디코딩하는 계층
5계층 : 세션 계층
송/수신자의 연결을 관리하고 지속할 수 있도록 제공
4계층 : 전송 계층
데이터를 전송하고 오류를 보정해 주는 계층
3계층 : 네트워크 계층
전송 데이터를 목적지까지 겨로를 찾아주는 계층
2계층 : 데이터 링크 계층
데이터 오류 감지하ㅗ 물리 계층으로 데이터를 전송시켜주는 계층
1계층 : 물리 계층
통신 케이블을 통해 전기 신호나 광 신호로 변환하여 전송하는 계층
네트워크 계층 기반의 스노트 탐지
cd /etc/snort/rules
local.rules 만들어서 쓸것
IDS에서 확인 tcpdump -i enp0s3 icmp
/etc/snort/snort.conf
include local.rules빼고 주석처리
snort -A console -q -u snort -g snort -c /etc/snort/snort.conf
/etc/snort/rules에 정책추가
alert icmp any any -> any any (msg:'DetectToIcmp';sid:1000001;)
플러딩 공격
hping3 10.0.2.15 --icmp --flood
alert icmp any any -> any any (msg:"PingOfDeath";threshold:type both,track by_src,count 10,seconds 2;sid:1000002;)
2초 동안 10회 이상의 ICMP요청이 발생한다면 죽음의 핑 공격으로 판단하겠다!
공격
nmap 10.0.2.15 -p 22 -sT
alert tcp any any -> 10.0.2.15 22 (msg:"nmapScan";flags:S;sid:1000003;)
공격
ssh master@10.0.2.15
탐지
alert tcp any any -> 10.0.2.15 22 (msg:"sshAttack";content:"SSH";nocase;sid:1000004;)
nocase : 대소문자를 구별하지 않겠다.
content:"";nocase랑 쌍으로 사용함
공격
hydra -L user.txt -P passwd.txt -f 10.0.2.15 ssh ㅇ
hydra -L user.txt -P passwd.txt -f 10.0.2.15 ftp 설정에 master로 바꾸면 ㅇ
hydra -L user.txt -P passwd.txt -f 10.0.2.15 http-get ㅇ
slowhttptest -H -g -o slowloris -c 4000 -r 100 -i 10 -t GET -p 3 -x 3 -u http://10.0.2.15 ㅇ 설치필요
탐지
alert tcp any any -> 10.0.2.15 21 (msg:"ftpAttack";content:"user root";nocase;sid:1000005;) user master로 하면 뜸
alert tcp any any -> 10.0.2.15 22 (msg:"sshBruteForceAttack";content:"SSH";nocase;offset:0;depth:4;sid:1000006;)
alert tcp any any -> 10.0.2.15 80 (msg:"httpBruteForceAttack";content:"GET / HTTP/1.";nocase;offset:0;depth:4;sid:1000006;) depth값이 낮음
alert tcp any any -> 10.0.2.15 80 (msg:"ToDetectSlowlowLorisAttack";flow:to_server,established;pcre:"/[^\x0d\x0a]\x0d\0a$/";threshold:type both,track by_src,count 10,seconds 2;sid:1000007;)
pcre : (Perl Compatible Regular Expressions ) : 펄 호환 정규 표현식
offset/depth는 지정한 위치에서 문자열 검색을 하기 위함
nocase : 대소문자를 구별하지 않겠다.
content:"";nocase랑 쌍으로 사용함
스노트 로그 mysql에 저장하기
apt update
apt -y install build-essential
apt -y install libpcap-dev libpcre3-dev libdumbnet-dev
apt -y install mysql-server libmysqlclient-dev mysql-client autoconf libtool
apt -y install bison flex
mkdir snort_source
wget https://snort.org/downloads/snort/daq-2.0.7.tar.gz
tar -xvzf daq-2.0.7.tar.gz
./configure && make && make install
touch /etc/snort/sid-msg.map
cat /etc/snort/snort.conf -n | grep "output unified2
wget https://github.com/firnsy/barnyard2/archive/master.tar.gz
tar xzvf master.tar.gz
autoreconf -fvi -I ./m4
ln -s /usr/include/dumbnet.h /usr/include/dnet.h
getconf LONG_BIT
./configure --with-mysql --with-mysql-libraries=/usr/lib/x86_64-linux-gnu
make && make install
/usr/local/bin/barnyard2 -V
./configure --with-mysql=/usr/include/mysql/ --with-mysql-libraries=/usr/lib/x86_64-linux-gnu/
cd snort_source/barnyard2-master/src/output-plugins
nano spo_alert_fwsam.c
중간에 typedef int socket 지움
nano spo_database.h
my_bool -> bool
barnyard2 -c /etc/snort/barnyard2.conf -d /var/log/snort -f snort.u2 -w /var/log/snort/barnyard2.waldo -g snort -u snort
snort -q -u snort -g snort -c /etc/snort/snort.conf
var/log/snort/barnyard2.bookmark