> For the complete documentation index, see [llms.txt](https://docs.cooku222.kr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cooku222.kr/security/defensive-security/ids-ips-tools-introduction/snort-macos.md).

# Snort 소개 및 설치(MacOS)

**Snort란?**

네트워크 트래픽을 실시간 분석해서 악성 패킷을 탐지 또는 차단하는 오픈소스로, 사용자가 선언한 룰 기반의 패킷 탐지를 해준다고 한다.\
참고로, snort는 단일 스레드, IDS만 지원한다. suricata는 멀티 스레드를 지원하며 snort의 프로토콜 분석 성능이 더 향상되어있다.&#x20;

***

**Snort 설치(macOS)**

```
brew install snort
```

<figure><img src="https://blog.kakaocdn.net/dna/cslll5/dJMcadIzwGz/AAAAAAAAAAAAAAAAAAAAAAkfSjBYKmeiqCOd_2XZJK4VHcosWwlQKy89YszlI51S/img.png?credential=yqXZFxpELC7KVnFOS48ylbz2pIh7yKj8&#x26;expires=1782831599&#x26;allow_ip=&#x26;allow_referer=&#x26;signature=6OMEQN6BpItuwfwBW%2FuXzNyUN2Q%3D" alt=""><figcaption></figcaption></figure>

macOS에서는 brew 명령어로 간단하게 snort 툴을 설치할 수 있다.

```
snort --version
```

<figure><img src="https://blog.kakaocdn.net/dna/ZVDsW/dJMcafGrN0l/AAAAAAAAAAAAAAAAAAAAABsLe8taRFxgQjrSdt-OY7b8lU94OZxfWjb8OsCCGf2A/img.png?credential=yqXZFxpELC7KVnFOS48ylbz2pIh7yKj8&#x26;expires=1782831599&#x26;allow_ip=&#x26;allow_referer=&#x26;signature=iZFKrLBW1i1KgYTrEqFOUpRfI0w%3D" alt=""><figcaption></figcaption></figure>

위 명령어로 설치가 되었는지 확인한다.

```
snort -v -i en0
```

<figure><img src="https://blog.kakaocdn.net/dna/bzsQgB/dJMcaaE9A3T/AAAAAAAAAAAAAAAAAAAAAClnExnUa9dTIjAVpVk2qas7VsDAKF9O8f_tiaD3Vzpk/img.png?credential=yqXZFxpELC7KVnFOS48ylbz2pIh7yKj8&#x26;expires=1782831599&#x26;allow_ip=&#x26;allow_referer=&#x26;signature=vnQf8k0idU3xy6NY1tS3CBpvL20%3D" alt=""><figcaption></figcaption></figure>

스니퍼 모드는 네트워크를 지나다니는 패킷을 눈으로 보는 모드로, 위에서 헤더만 출력하는 명령어이다. \
참고로 snort는 버전마다 명령어가 다르니 주의하도록 한다.

```
# 기존 파일 덮어쓰기
cat > $(brew --prefix)/etc/snort/snort.conf << 'EOF'
HOME_NET = 'any'
EXTERNAL_NET = 'any'
EOF
# IDS 모드 켜기
sudo snort -c $(brew --prefix)/etc/snort/snort.conf -i en0
```

```
cooku222@cooku222s-MacBook-Air  ~  sudo snort -c $(brew --prefix)/etc/snort/snort.conf -i en0
Password:
--------------------------------------------------
o")~   Snort++ 3.12.2.0
--------------------------------------------------
Loading /opt/homebrew/etc/snort/snort.conf:
	active
	alerts
	daq
	decode
	host_cache
	host_tracker
	hosts
	network
	packets
	process
	search_engine
	output
Finished /opt/homebrew/etc/snort/snort.conf:
--------------------------------------------------
pcap DAQ configured to passive.
Commencing packet processing
Retry queue interval is: 200 ms
++ [0] en0
```

위 명령어를 입력하면 IDS 모드가 켜지면서 -en0 인터페이스에서 패킷이 캡쳐된다. 참고로 지금은 아무런 롤을 선언해주지 않아 출력되는 게 없다.

```
cooku222@cooku222s-MacBook-Air  ~  cat > $(brew --prefix)/etc/snort/local.rules << 'EOF'
alert icmp any any -> any any (msg:"ICMP Ping 감지!"; sid:1001; rev:1;)
EOF
```

우선 위와 같이 패킷 캡처를 위한 아주 간단한 룰을 선언해준다.&#x20;

```
# snort.conf에 출력 설정 추가
cat > $(brew --prefix)/etc/snort/snort.conf << 'EOF'
HOME_NET = 'any'
EXTERNAL_NET = 'any'

alert_fast = { file = false }

ips =
{
    rules = [[
        include /opt/homebrew/etc/snort/local.rules
    ]]
}
EOF
```

그리고 설정파일에 이 룰을 넣어준다. 알림 기능도 추가해, 패킷 탐지 후 알림도 받아보게 선언해준다.&#x20;

```
cooku222@cooku222s-MacBook-Air  ~  sudo snort -c $(brew --prefix)/etc/snort/snort.conf -i en0
Password:
Sorry, try again.
Password:
--------------------------------------------------
o")~   Snort++ 3.12.2.0
--------------------------------------------------
Loading /opt/homebrew/etc/snort/snort.conf:
	output
	active
	alerts
	daq
	decode
	host_cache
	host_tracker
	hosts
	network
	packets
	process
	search_engine
Finished /opt/homebrew/etc/snort/snort.conf:
--------------------------------------------------
pcap DAQ configured to passive.
Commencing packet processing
Retry queue interval is: 200 ms
++ [0] en0
```

패킷이 캡쳐되는 모양새를 보기 위해 iterm 창을 하나 더 켜서 ping 명령어를 날려본다. \
가장 기본적인 google.com으로 ping을 날린다.&#x20;

```
✘ cooku222@cooku222s-MacBook-Air  ~  ping google.com
PING google.com (142.251.23.100): 56 data bytes
64 bytes from 142.251.23.100: icmp_seq=0 ttl=110 time=37.152 ms
64 bytes from 142.251.23.100: icmp_seq=1 ttl=110 time=37.337 ms
64 bytes from 142.251.23.100: icmp_seq=2 ttl=110 time=40.879 ms
64 bytes from 142.251.23.100: icmp_seq=3 ttl=110 time=37.442 ms
64 bytes from 142.251.23.100: icmp_seq=4 ttl=110 time=37.414 ms
```

그러면 다시 snort shell로 돌아와 확인해보면 알림이 뜬다.&#x20;

```
04/30-20:33:35.338753 [**] [1:1001:1] "ICMP Ping 감지!" [**] [Priority: 0] {ICMP} 192.168.0.90 -> 142.251.119.100
04/30-20:33:35.376425 [**] [1:1001:1] "ICMP Ping 감지!" [**] [Priority: 0] {ICMP} 142.251.119.100 -> 192.168.0.90
04/30-20:33:36.343985 [**] [1:1001:1] "ICMP Ping 감지!" [**] [Priority: 0] {ICMP} 192.168.0.90 -> 142.251.119.100
04/30-20:33:36.386108 [**] [1:1001:1] "ICMP Ping 감지!" [**] [Priority: 0] {ICMP} 142.251.119.100 -> 192.168.0.90
04/30-20:33:37.349635 [**] [1:1001:1] "ICMP Ping 감지!" [**] [Priority: 0] {ICMP} 192.168.0.90 -> 142.251.119.100
04/30-20:33:37.387590 [**] [1:1001:1] "ICMP Ping 감지!" [**] [Priority: 0] {ICMP} 142.251.119.100 -> 192.168.0.90
04/30-20:33:38.590615 [**] [1:1001:1] "ICMP Ping 감지!" [**] [Priority: 0] {ICMP} 192.168.0.90 -> 142.251.119.100
04/30-20:33:38.628256 [**] [1:1001:1] "ICMP Ping 감지!" [**] [Priority: 0] {ICMP} 142.251.119.100 -> 192.168.0.90
04/30-20:33:39.036135 [**] [1:1001:1] "ICMP Ping 감지!" [**] [Priority: 0] {ICMP} 192.168.0.90 -> 17.253.114.65
```

내 맥북이 google.com에 ICMP(네트워크가 살아있는 확인하는 프로토콜) 요청을 보내, google.com에서 내 맥북으로 응답을 보낸다. 이 응답들이 snort에 찍히는 것이다.&#x20;

```
[**] ICMP Ping 감지! [**]
192.168.x.x -> 142.251.x.x   ← 내가 보낸 것
142.251.x.x -> 192.168.x.x   ← 구글이 응답한 것
```

위와 같은 통신이 이루어진다.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cooku222.kr/security/defensive-security/ids-ips-tools-introduction/snort-macos.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
