Snort는 오픈 소스 침입 탐지 시스템(IDS)으로, 네트워크 트래픽을 실시간으로 모니터링하고 패킷을 분석하여 악의적인 활동을 탐지합니다. Snort의 규칙 구조는 다음과 같습니다:
action protocol source_ip source_port direction destination_ip destination_port (options)
alert, log, pass, droptcp, udp, icmp-> (단방향), <-> (양방향)content:
content:"bad";는 페이로드 내에서 "bad"라는 문자열이 포함된 패킷을 찾습니다.depth:
content 옵션과 함께 사용되며, 검색할 바이트 수를 제한합니다.depth:20;는 패킷의 시작부터 20바이트 이내에서만 검색합니다.offset:
content 옵션과 함께 사용되며, 검색을 시작할 위치를 지정합니다.offset:10;는 패킷의 10바이트 이후(10 초과 === 11이상)에서 검색을 시작합니다.nocase:
content:"password"; nocase;는 "password", "PASSWORD", "PassWord" 등 모든 조합을 탐지합니다.pcre:
pcre:"/bad|malicious/i";는 "bad" 또는 "malicious"라는 문자열을 대소문자 구분 없이 검색합니다.sid:
sid:1000001;은 이 규칙의 고유 ID를 설정합니다.alert tcp any any -> any 80 (msg:"HTTP traffic detected"; sid:1000001;)
drop tcp 192.168.1.100 any -> any any (msg:"Malicious IP blocked"; sid:1000002;)
alert tcp any any -> any 443 (content:"' OR '1'='1"; msg:"SQL Injection Attempt"; sid:1000003;)
alert tcp any any -> any 21 (content:"USER "; msg:"FTP User Attempt"; sid:1000004;)
USER  문자열이 포함되면 경고를 발생시킵니다.alert tcp any any -> any any (content:!"|90 90|"; msg:"Non-zero binary content detected"; sid:1000005;)
90)이 아닌 내용을 탐지합니다. 바이너리 분석을 통해 악성 코드 또는 비정상적인 트래픽을 감지할 수 있습니다.alert tcp any any -> any any (content:"bad"; offset:10; depth:20; msg:"Bad content detected"; sid:1000006;)
offset은 패킷 데이터에서 검색을 시작할 위치를 지정하고, depth는 검색할 바이트 수를 제한합니다.