snort 규칙 -> iptables 규칙 변환하기

2011. 6. 27. 05:58카테고리 없음



@ snort 규칙을 iptables 규칙으로 변환하기 
 

1. content 옵션 관련snort 규칙 -> iptables 규칙 변환하기 

- 스노트 규칙 언어의 content 옵션에서는 인자가 바이트의 나열 형태, 예를 들어 /bin/sh여야 하며 스노트는 보이어-무어 문자열 검색 알고리즘을 사용해서 애플리케이션 계층 데이터에서 이런 바이트 나열을 검색한다. iptables 매칭 확장은 커널에 구현된 동일한 알고리즘을 사용해서 패킷이 네트워킹 스택으로 들어올 때 패킷의 애플리케이션 페이로드에 있는 바이트 나열을 검색한다.

- 스노트 규칙의 content 옵션에 문자열 “/bin/sh"가 있다면 이와 동등한 iptables 인자는 -m string --string --alog bm "/bin/sh"다.

[ 문자열 “/bin/sh"가 UDP 포트 53을 통해 DNS 서버에서 라우팅될 때 이를 탐지한다. ]

snort규칙> alert udp any any -> any 53 (msg: "DNS /bin/sh attempt"; content: "/bin/sh"; sid: 100001)

iptables 규칙> iptables -A FORWARD -p udp --dport 53 -m string --string "/bin/sh" --algo bm -j LOG --log-prefix "SID100001 "

 

2. snort 규칙 헤더 관련

[ 스노트가 임의의 출발지 IP 주소에서 192.168.10.0/24 서브넷에 존재하는 임의의 IP 주소의 포트 53으로 전송되는 모든 TCP 트래픽과 매칭시키게 지시한다. ]

snort규칙> alert tcp any any -> 192.168.10.0/24 53snort 규칙 -> iptables 규칙 변환하기 

iptables규칙> iptables -A FORWARD -p tcp -d 192.168.10.0/24 --dport 53 -j LOG

 

3. Trin00 DDoS 도구의 탐지

- Trin00은 다수의 공격 노트에서 동시에 많은 양의 UDP 패킷을 목표에 대해 전송해서 분산서비스 거부 공격을 시도하는 고전적인 도구다. Trin00은 공격 노드의 작업을 조정하는 자신만의 방법을 구현하며, 스노트 서명 집합에는 Trin00의 관리 목적 통신을 탐지하기 위한 몇 가지 서명이 존재한다.

[ 스노트 ID 237은 홈 네트워크에서 포트 27444가 목적지인 UDP 패킷에 포함된 문자열 144adsl을 검색한다.

snort규칙> alert udp $EXTERNAL_NET any -> $HOME_NET 27444 (msg:"DDOS Trin00 Master to Daemon default password attempt"; content:"144adsl"; reference:arachnids,197; classtype:attempted-dos; sid:237; rev2;)snort 규칙 -> iptables 규칙 변환하기 

iptables규칙> IPTABLES -A FWSNORT_FORWARD -d 192.168.10.0/24 -p udp --dport 27444 -m string --string "144adsl" --algo bm -m comment --comment "sid:237; msg: DDOS Trin00 Master to Daemon default password attempt; classtype: attempted-dos; reference: arachnids,197; rev: 2; FWS:1.0;" -j LOG --log-ip-options --log-prefix "[1] SID237 "

 

4. Nmap 명령 시도 서명 snort 규칙 -> iptables 규칙 변환하기 

- 스노트 파일 web-attacks.rules의 Nmap command attempt 서명은 웹서버를 통해 Nmap 스캐너를 실행하려는 시도를 탐지한다. 이 서명은 웹서버를 통해 좀 더 쉽게 접근할 수 있는 다른 시스템을 스캔하기 위해 웹서버를 사용하는 공격자의 시도를 탐지하는데 유용하다.

[ 수립된 TCP 연결을 통해 문자열 “nmap%20"이 전송될 때 촉발된다.]

snort규칙> alert tcp $EXTERNAL_NET any -> $HTTP_SERVERS $HTTP_PORTS (msg:"WEB-ATTACKS nmap command attempt"; flow:to_server,established; content:"nmap%20"; nocase; classtype:webapplication-attack; sid:1361; rev:5;)

iptables규칙> IPTABLES -A FWSNORT_FORWARD_ESTAB -p tcp --dport 80 -m string --string "nmap%20" --algo bm -m comment --comment "sid:1361; msg: WEB-ATTACKS nmap command attempt; classtype: web-application-attack; rev:5; FWS:1.0 -j LOG --log-ip-options --log-tcp-options --log-prefix "[20] SID1361 ESTAB"

 

5. depth 옵션

[ 패킷 페이로드의 1000번째 바이트 이내에 문자열 “/etc/passwd"를 포함하여 목적지 포트가 포트 80인 모든 TCP 패킷을 버리게 한다.]

snort규칙> alert tcp any any -> any 80 (msg: " DROP include /etc/passwd"; content: "/etc/passwd"; depth: 1000; within: 1000;)

iptables규칙> iptables -A INPUT -p tcp --dport 80 -m string --string "/etc/passwd" --to 1000 --algo bm -j DROP

 

6. offset 옵션

[ 패킷 페이로드에서 100번째 바이트 이후의 어디서라도 문자열 “/etc/passwd”를 포함하는 포트 80이 목적지인 모든 TCP 패킷을 버린다 ]

snort규칙> alert tcp any any -> any 80 (msg: " DROP from 100 /passwd"; content:"/etc/passwd"; offset:100)

iptables규칙> iptables -A INPUT -p tcp --dport 80 -m string --string "/etc/passwd" --from 100 --algo bm -j DROP

 

7. flags 옵션

[ TCP 패킷의 SYN과 FIN 플래그가 모두 설정됐을 때 이를 탐지한다.]

snort규칙> alert tcp any any -> any any (msg: "TCP SYN FIN"; flags: ALL SYN,FIN;)

iptables규칙> iptables -A INPUT -p tcp --tcp-flags ALL SYN,FIN -j LOG --log-prefix "SCAN SYN FIN"

 

8. itype과 icode

[ 모든 ICMP 소스-퀸치 메시지를 버린다. ]

snort규칙> alert icmp any any -> any any (msg: "DROP ICMP"; itype: 4; icode: 0;)

iptables규칙> iptables -A INPUT icmp --icmp-type 4/0 -j DROP

 

9. ttl

[ TTL 값이 0인 모든 IP 패킷을 탐지해서 기록한다. ]

snort규칙> alert ip any any -> any any (msg: "DETECT TTL 0"; ttl:0;)

iptables규칙> iptables -A INPUT -p ip -m ttl --ttl-eq 0 -j LOG --log-prefix "ZERO TTL TRAFIC"

 

10. tos

[ TOS 값이 16인 모든 IP 패킷을 기록한다. ]

snort규칙> alert ip any any -> any any (msg: "TOS 16"; tos:16;)

iptables규칙> iptables -A INPUT -p ip -m tos --tos 16 -j LOG --log-prefix "MIN-DELAY TOS"