snort 실습

justugi·2025년 6월 10일

네트워크 보안

목록 보기
12/13

실습

  • server 10.10.10.1/24
    • telnet, web (admin/index.html), dns server 구성
  • IDS (snort) 10.10.10.10/24
  • hacker (kali) 192.168.100.100/24
  • R2 : server -> IDS 포트 미러링 설정
  1. telnet login 성공 시 탐지
  2. telnet login 실패 시 탐지
  3. 외부에서 web server 접속 요청 시 탐지
  4. 외부에서 관리자 페이지 요청 시 탐지
  5. land attack 탐지
  6. ping of death attack 탐지
  7. syn flooding 탐지
  8. udp flooding 탐지
  9. icmp flooding 탐지

[IDS]

  • snort 탐지 정책 설정
    • /etc/snort/rules/local.rules

alert tcp 10.10.10.1 23 -> any any (content:"Last login";msg:"telnet success"; sid:1000001;)

alert tcp 10.10.10.1 23 -> any any (content:"Login incorrect";msg:"telnet failed";sid:1000002;)

alert tcp !10.10.10.0/24 any -> 10.10.10.1 80 (flags:S;msg:"external connect";sid:1000003;)
→ alert tcp !10.10.10.0/24 any -> 10.10.10.1 80 (content:"GET";http_method;msg:"external connect";sid:1000003;)
→ alert tcp !10.10.10.0/24 any -> 10.10.10.1 80 (content:"GET";depth:5;msg:"external connect";sid:1000003;)
→ (favicon.ico 제외) alert tcp !10.10.10.0/24 any -> 10.10.10.1 80 (content:"GET";depth:5;content:!"favicon";content:!"/admin";nocase;flags:PA;msg:"external connect";sid:1000003;)

alert tcp !10.10.10.0/24 any -> 10.10.10.1 80 (content:"admin";http_uri;msg:"ADMIN PAGE connect";sid:1000004;)
→ alert tcp !10.10.10.0/24 any -> 10.10.10.1 80 (content:"GET";http_method;content:"/admin";nocase;content:!"favicon";flags:PA;msg:"external connect";sid:1000003;

land attack

alert icmp any any -> any any (sameip;msg:"LAND ATTACK";sid:1000005;)

→ (10.10.10.1 밖에 없을 때 적용 가능, 특정 타입과 코드만 지엽적으로 탐지)
alert icmp 10.10.10.1 any -> 10.10.10.1 any (itype:8;icode:0;msg:"LAND ATTACK";sid:1000005;)

→ (10.10.10.1 이 서비스하는 telnet, dns, web 등 tcp 의 SYN (tcp 는 SYN 으로 통신 시작하니까 갑자기 다른 flag 오면 drop 하니까 SYN 으로 공격), udp 등 추가로 막기)
alert tcp any any -> any any (sameip;flags:S;msg:"LAND ATTACK";sid:1000005;)

ping of death attack

alert icmp any any -> 10.10.10.1 any (dsize:>1000;msg:"PING OF DEATH";sid:1000006;)

→ (시그니쳐 값 활용)
alert icmp any any -> 10.10.10.1 any (content:"XXXXXXXXX";msg:"PING OF DEATH";sid:1000006;)

  • 그러나 전처리기 동작 때문에 한번씩 밖에 탐지 안됨.

syn flooding

alert tcp any any -> 10.10.10.1 any (flags:S;threshold:type both,track by_dst, count 1000, seconds 1;msg:"SYN FLOODING";sid:1000010;)

→ (hping3 으로 공격 시 window size 가 512 로 고정인 것 추가 탐지)
alert tcp any any -> 10.10.10.1 any (flags:S;window:512;threshold:type both,track by_dst, count 1000, seconds 1;msg:"SYN FLOODING";sid:1000010;)

→ (land attack 과 구분하기 위해 출발지 주소 변경)
alert tcp !10.10.10.1 any -> 10.10.10.1 any (flags:S;window:512;threshold:type both,track by_dst, count 1000, seconds 1;msg:"SYN FLOODING";sid:1000010;)

udp flooding

alert udp any any -> 10.10.10.1 any (threshold:type both,track by_dst, count 1000, seconds 1;msg:"UDP FLOODING";sid:1000011;)

icmp flooding

alert icmp any any -> 10.10.10.1 any (threshold:type both,track by_dst, count 1000, seconds 1;msg:"ICMP FLOODING";sid:1000012;)
→ 정상 ping 통신과 다르게 hping3 으로 공격 시 Frags 비트 비워서 보냄. 그러나 라우터에서 ping 통신 할 때도 Frags 비트 비워서 보내서 해당 정보를 기준으로는 공격을 선별 탐지 불가

flooding 하는 DoS bot IP 탐지

alert tcp any any -> 10.10.10.1 any (flags:S;threshold:type both,track by_src, count 100, seconds 1;msg:"SYN FLOODING(same src)";sid:1000007;)

alert udp any any -> 10.10.10.1 any (threshold:type both,track by_src, count 100, seconds 1;msg:"UDP FLOODING(same src)";sid:1000008;)

alert icmp any any -> 10.10.10.1 any (threshold:type both,track by_src, count 100, seconds 1;msg:"ICMP FLOODING(same src)";sid:1000009;)

  • snort 탐지 실행

    • snort -vd -c /etc/snort/snort.conf
  • snort 탐지 확인

    • tail -f /var/log/snort/alert

[hacker]

  • 탐지 확인용 공격

    • land attack
      • hping3 -1 -a 10.10.10.1 10.10.10.1
      • 포트까지 같게 설정하여 tcp SYN 으로 공격
        • hping3 -a 10.10.10.1 10.10.10.1 -s 80 -k -p 80 -S
    • ping of death attack
      • hping3 --icmp --rand-source 10.10.10.1 -d 10000
    • syn flooding
      • hping3 --rand-source 10.10.10.1 -p 80 -S --flood
    • udp flooding
      • hping3 -2 --rand-source 10.10.10.1 -p 53 --flood
    • icmp flooding
      • hping3 --icmp --rand-source 10.10.10.1 --flood
      • 출발지 주소를 알고 있는 내부 주소로 설정하면 더 큰 부하를 가할 수 있음
        • hping3 --icmp -a 10.10.10.254 10.10.10.1 --flood
  • 위 순서와 반대로, 공격 받은 경험 (로그) 을 바탕으로 탐지 정책을 세울 수 있음

profile
IT 보안, 관심 있는 것을 공부합니다.

0개의 댓글