-키세팅
tripwire-setup-keyfiles <<<<<<<<<엔터엔터엔터
cat /etc/tripwire/twcfg.txt -> 키세팅 파일 생성
cd /etc/tripwire
cp twpol.txt twpol.txt.bak
vi twpol.txt
/bin -> $(ReadOnly);
/etc -> $(IgnoreNone)-SHa;
/var -> +pug;
/dev -> +pug;
/back -> +pug;
p 퍼미션
u uid
g gid
정책적용
twadmin --create-polfile twpol.txt
구동
tripwire --init
확인
tripwire --check
useradd korea
passwd [비번설정]
cp /backup/ping /usr/bin/ping
패킷 스니퍼 모드
패킷 로거 모드
네트워크 IDS 모드
Snort Inline
nc → 메세지 주고 받는 창 (간단한 실습)
nc -l 8080
nc 10.10.10.10 8080
시작 snort -i ens33 -c local
혹은 데몬 실행
snort 정책
alert icmp any any <> 10.10.10.10 any (msg:"ICMP PING";sid:50001;)
alert tcp any any -> 10.10.10.10 80 (msg:"SEVAS_HTTP";sid:50002;)
[action][protocol] [src_ip][src_port] -> [Dst_ip][Dst_port] [option]
액션 action : alert , pass ,drop , reject ,log
프로토콜 protocol : TCP,UDP , IP , ICMP
출발지 IP Src_ip : any , 10.10.10.10 , 10.10.10.0/24 !
출발지 port src_port : any , 22, 80 ,...... ! , : (1:1000)
패킷 흐름 방향 : -> , <>
도착지 IP Dst_ip : any , 10.10.10.10 , 10.10.10.0/24
도착지 port Dst_port : any , 22, 80 ,......
침입 탐지 옵션 option : msg ,content ,flow , rev......
- src → 공격자의 출발지를 ip 추적하고 싶을때 유용
- dst → (여러 ip로 부터)공격 받고 있는 대상 서버나 네트워크를 보호하고자 할 때 유용
rev : 규칙 수정버전
classtype : 유형별 정의
priority : 우선순위
reference : url로 정책 정의
- 옵션 ( <> 양방향 | -> 단방향 <- ) → 오탐 (IPS에서 중요), 미탐 방지 (IDS에서 중요)
- content 글자를 잡아낸다 ex) content:"sevas"; → 16진수의 경우 “| |” 로 감싸야함
- msg 메세지 내용 출력 ex) msg:"메롱";
- nocase 대소문자를 구분하지 않는다 ex) nocase;
- sid 규칙 식별자(정책 순서 지정) ex) dis:50005;
- offset 매칭 시작 문자열 위치 0으로 설정 시 1부터 검색
- depth 문자열 범위를 지정 0으로 설정 시 1부터 검색
- distance 옵션 값 이후 탐색 위치 지정 (이후) ex) content:”abc”; content:”test”; distance: 10;
- within 옵션 값 이후 탐색 범위 지정 (이내) (distance, offset, depth)
- abc | within (이내) 10 (이후) distance |
- pcre 문자열 (URL 검사)
- 정책 예시
- depth , offset → 123문자가 들어간 내용이 4바이트 이후부터 7바이트안에 존재하는지 알림
alert tcp 20.20.20.20 any -> 10.10.10.10 8080 (msg:"depth_TEST"; content:"123";offset:4; depth:7; sid:50008;)
- distance
alert tcp 20.20.20.20 any -> 10.10.10.10 8080 (msg:"distance_TEST"; content:"abc"; content:"test"; distance:10; sid:50009;)
- within
alert tcp 20.20.20.20 any -> 10.10.10.10 8080 (msg:"within_TEST"; content:"abc"; content:"test"; within:10; sid:50009;)
- pcre
alert tcp 10.10.10.0/24 any -> any 443 (msg:"SNS_ACCESS"; pcre:"/facebook.com|instargram.com/"; sid:50010;)
- telnet → 문구가 다르게 나오는 것을 와이어샤크로 확인 후 content로 작성
alert tcp 10.10.10.10 23 -> any any (msg:"Telnet OK"; content:"|6c617374206c6f67696e|"; nocase; sid:50007;)
alert tcp 10.10.10.10 23 -> any any (msg:"Telnet Fail"; content:"|4c 6f 67 69 6e 20 69 6e 63 6f 72 72 65 63 74|"; nocase; sid:50006;)
- ICMP 20 →10 으로 ping
alert icmp 20.20.20.20 any -> 10.10.10.10 any (msg:"REQUEST_ICMP"; itype:8; sid:50011;)
alert icmp 10.10.10.10 any -> 20.20.20.20 any (msg:"REPLY_ICMP"; itype:0; sid:50012;)
- threshold (5개마다 탐지)
alert icmp any any -> 10.10.10.10 any (msg:”THRESHOLD”; threshold: type threshold, track by_src, count 5, seconds 10; sid: 50013;)
- limit (5개까지 탐지)
alert icmp any any -> 10.10.10.10 any (msg:”limit”; threshold: type limit , track by_src, count 5, seconds 10; sid: 50013;)
- both (1개만 탐지)
alert icmp any any -> 10.10.10.10 any (msg:”limit”; threshold: type limit , track by_src, count 5, seconds 10; sid: 50013;)
<script>
잡아내기alert tcp any any -> 10.10.10.10 80 (msg:"XSS_ATTACK(http)"; content:"|253343736372697074253345|"; nocase; sid:50005;)
SYN 연결
ACK 응답
RST 재시작 (강제 종료)
FIN 종료
URG 긴급 → 순위 상승
PSH 우선순위 → 순위 상승
NULL flag Xflags : S R A P U F
fragsbits: R D M ( R:예약 D:분할X M:분할 )
sameip : 출발지와 도착지 IP가 같을 경우 탐지
alert ip any any -> 10.10.10.10 any (msg:"PING_OF_DEATH";threshold:type both,track by_src,count 50, seconds 10; fragbits:M;sid:50012;)
alert icmp any any -> 10.10.10.10 any (sid:50013; msg:"LAND attack";sameip;threshold:type both,track by_src,count 20,seconds 10;)
alert icmp any any -> 255.255.255.255 any (msg:"Smuf attack";itype:8; threshold type both,track by_dst,count 20,seconds 10; sid 50014;)
alert tcp any any -> 10.10.10.10 80 (sid:50015; msg:"TCP_SYN_FLOODING"; flags:S; threshold:type both,track by_dst,count 20,seconds 10;)
alert tcp any any -> 10.10.10.10 80 (sid:50016; msg:"TCP_Connect_FLOODING"; flags:A; threshold:type both,track by_src,count 20,seconds 10;)
alert udp !10.10.10.10 any -> 10.10.10.10 any (sid:50017; msg:"UDP_FLOODING"; threshold:type both,track by_src,count 20,seconds 10;)
alert tcp 10.10.10.10 any -> any 443 (msg:"SNS_ACCESS";pcre:"/facebook.com|[instagram.com/](http://instagram.com/)"; sid:50040;)
alert tcp any any -> 10.10.10.10 80 (msg:"sql_injection";pcre:"/UNION|SELECT|OR|%27|%23/i";content:"board_view.php"; sid:50041;)
alert tcp any any -> 10.10.10.10 80 (msg:"xss_attack";content:"script";nocase; sid:50042;)
alert tcp !10.10.10.10 any -> 10.10.10.10 any (msg:"X-MAS SCAN -sX";flags:UPF; threshold:type both,track by_src,count 20,seconds 10; sid:50020;)
alert tcp !10.10.10.10 any -> 10.10.10.10 any (msg:"FIN SCAN -sF";flags:F; threshold:type both,track by_src,count 20,seconds 10; sid:50021;)
alert tcp !10.10.10.10 any -> 10.10.10.10 any (msg:"SYN SCAN -sS"; flags:S; threshold:type both,track by_src,count 20,seconds 10; sid:50022;)
alert tcp !10.10.10.10 any -> 10.10.10.10 any (msg:"NULL SCAN -sN"; flags:0; threshold:type both,track by_src,count 20,seconds 10; sid:50023;)
alert tcp any any -> 10.10.10.10 22(sid:50050; msg:"SSH_Brute Force"; threshold:type both,track by_src,count 10,seconds 10; flags:S;)
16진수 변환 사이트: https://www.hextotext.com/kr/convert-hex-to-text 0