SOC Lab 1, Snort 3 as an IDS
Stack: Snort 3, Filebeat, Logstash, Elasticsearch, Kibana Environment: Docker Continues in: SOC Lab 2, Snort 3 inline, where this IDS is put into the data path and starts blocking traffic.
We build a Dockerized SOC pipeline around Snort 3: an attacker container generates traffic against a victim, Snort sniffs the traffic and raises alerts, Filebeat collects the alerts, Logstash normalizes them, Elasticsearch stores them and Kibana turns them into a dashboard.
The pipeline: a passive tap on the monitored Docker bridge; the alerts flow to the Elastic stack.
We generate the traffic ourselves and watch it flow through every component; no canned data involved.
Roadmap
Eleven stages, in the order they were run. Each one ends with the evidence it produced, so you can tell whether yours worked before moving on.
- Lab setup. One
docker-compose.yml: seven containers across two bridges,soc-monitoredfor the traffic andsoc-managementfor the stack. Verified withdocker ps. - Meet Snort 3. Locate the binary inside the
ciscotalos/snort3image and read the version you are about to configure. - Snort as an IDS/IPS: the theory. Two deployments, one engine: the stages a packet passes through and the four rule actions, so the build that follows has a model behind it.
- Attaching Snort to the monitored network. Pick the Docker bridge out of the host’s interfaces, prove the sensor can see it, and learn why
-i anyfails here. - Snort configuration.
snort.lua:HOME_NET, the rules include, andalert_jsonfor one JSON object per alert. Validated withsnort -Tbefore anything runs. - Writing detection rules. 24 rules in
local.rules, SIDs 1000001 to 1000070, grouped by attack class: recon, web recon, sensitive-file discovery, traversal, SQLi, command injection, web tooling, SSH. - Starting Snort. The startup banner as evidence: 24 rules loaded,
pcap DAQ configured to passive., the monitored bridge bound. - Generating traffic. A ping from
soc-attackertosoc-victim, and the first compact JSON alert off SID 1000001 inalert_json.txt. - Shipping alerts to the Elastic stack. Filebeat collects, Logstash normalizes to ECS, Elasticsearch stores under
snort-alerts-v2-*, Kibana renders theSNORT IDS | SOC OVERVIEWdashboard. - End-to-end test. One ping traced through all five stages, measured from packet on the wire to searchable event.
- Final result. The finished pipeline as Detect, Collect, Parse, Store, Visualize, and where Part 2 takes it.
One thing before starting: the ruleset covers more attack classes than the lab actually generates. Only the ping is fired; the rest are written and validated but never executed. That is why the walkthrough spends its time on the pipeline rather than on attacks.
Lab setup
1
2
3
mkdir -p ~/soc-lab/{filebeat,logstash/pipeline,snort/{config,rules,logs}}
cd ~/soc-lab
tree
1
2
3
4
5
6
7
8
9
10
11
12
13
soc-lab/
├── docker-compose.yml
├── filebeat
│ └── filebeat.yml
├── logstash
│ └── pipeline
│ └── logstash.conf
└── snort
├── config
│ └── snort.lua
├── logs
└── rules
└── local.rules
The lab is split into two Docker networks, keeping the traffic we monitor separate from the management plane that ships it:
1
2
3
4
5
soc-monitored soc-management
soc-attacker ┐ soc-filebeat
soc-victim ┘ soc-logstash
soc-elasticsearch
soc-kibana
Attacker and victim talk over the monitored network
The attacker and victim communicate over soc-monitored, which is the segment Snort inspects. The Elastic stack lives on soc-management, away from the traffic under test.
The attacker is Kali, the victim is a plain nginx, and the whole stack lives in one docker-compose.yml at the repo root. Service names are short (attacker, victim, snort, filebeat, logstash, elasticsearch, kibana); container_name: is what gives them the soc- prefix used everywhere above:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
services:
# ============================================================
# ELASTICSEARCH
# ============================================================
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:9.5.2
container_name: soc-elasticsearch
restart: unless-stopped
environment:
- discovery.type=single-node
- xpack.security.enabled=false
- xpack.security.enrollment.enabled=false
- bootstrap.memory_lock=true
- ES_JAVA_OPTS=-Xms1g -Xmx1g
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- /home/soc-data/elasticsearch:/usr/share/elasticsearch/data
ports:
- "9200:9200"
networks:
- soc-management
healthcheck:
test:
[
"CMD-SHELL",
"curl -fs http://localhost:9200/_cluster/health || exit 1"
]
interval: 10s
timeout: 5s
retries: 30
# ============================================================
# LOGSTASH
# ============================================================
logstash:
image: docker.elastic.co/logstash/logstash:9.5.2
container_name: soc-logstash
restart: unless-stopped
depends_on:
elasticsearch:
condition: service_healthy
environment:
LS_JAVA_OPTS: "-Xms512m -Xmx512m"
volumes:
- ./logstash/pipeline:/usr/share/logstash/pipeline:ro
- ./snort/logs:/var/log/snort:ro
ports:
- "5044:5044"
networks:
- soc-management
healthcheck:
test:
[
"CMD-SHELL",
"curl -fs http://localhost:9600/?pretty || exit 1"
]
interval: 10s
timeout: 5s
retries: 30
# ============================================================
# KIBANA
# ============================================================
kibana:
image: docker.elastic.co/kibana/kibana:9.5.2
container_name: soc-kibana
restart: unless-stopped
depends_on:
elasticsearch:
condition: service_healthy
environment:
ELASTICSEARCH_HOSTS: '["http://elasticsearch:9200"]'
ports:
- "5601:5601"
networks:
- soc-management
# ============================================================
# FILEBEAT
# ============================================================
filebeat:
image: docker.elastic.co/beats/filebeat:9.5.2
container_name: soc-filebeat
restart: unless-stopped
user: root
depends_on:
logstash:
condition: service_healthy
command:
- filebeat
- -e
- --strict.perms=false
volumes:
- ./filebeat/filebeat.yml:/usr/share/filebeat/filebeat.yml:ro
- ./snort/logs:/var/log/snort:ro
- filebeat-data:/usr/share/filebeat/data
networks:
- soc-management
# ============================================================
# SNORT IDS
#
# Linux host networking is intentional here.
# It lets Snort see the host's Docker bridges.
# ============================================================
snort:
image: ciscotalos/snort3:latest
container_name: soc-snort
restart: unless-stopped
network_mode: host
user: root
cap_add:
- NET_ADMIN
- NET_RAW
entrypoint:
- /home/snorty/snort3/bin/snort
command:
- -c
- /etc/snort/snort.lua
- -R
- /etc/snort/rules/local.rules
- -i
- br-909e429c8d47
- -A
- alert_json
- -l
- /var/log/snort
volumes:
- ./snort/config/snort.lua:/etc/snort/snort.lua:ro
- ./snort/rules/local.rules:/etc/snort/rules/local.rules:ro
- ./snort/logs:/var/log/snort
# ============================================================
# VICTIM
# ============================================================
victim:
image: nginx:alpine
container_name: soc-victim
restart: unless-stopped
networks:
- monitored
ports:
- "8080:80"
# ============================================================
# ATTACKER / TEST MACHINE
# ============================================================
attacker:
image: kalilinux/kali-rolling
container_name: soc-attacker
command:
- /bin/bash
stdin_open: true
tty: true
networks:
- monitored
# ==============================================================
# NETWORKS
# ==============================================================
networks:
monitored:
name: soc-monitored
driver: bridge
soc-management:
name: soc-management
driver: bridge
# ==============================================================
# VOLUMES
# ==============================================================
volumes:
filebeat-data:
name: soc-filebeat-data
Two things to know before using the file. The snort service command pins the bridge discovered under “Attaching Snort to the monitored network” (-i br-909e429c8d47), a name Docker generates per host; swap it for the interface the awk command prints on your host. And the compose file bind-mounts the configs written in the rest of the walkthrough (snort.lua, local.rules, filebeat.yml, logstash.conf), so those services only start once the files exist. We start the traffic pair now, then bring the rest up as each config lands:
1
2
3
4
5
6
# start the traffic side right away; the sensor side joins once its configs exist
docker compose up -d attacker victim
# once the config files are written, stand up the full stack
docker compose up -d
docker ps
Seven containers up and running
Meet Snort 3
We get a shell in the Snort container and verify the install:
1
docker exec -it soc-snort /bin/bash
The binary isn’t on the default PATH, so we locate it:
1
2
find / -type f -name snort 2>/dev/null
# /home/snorty/snort3/bin/snort
1
/home/snorty/snort3/bin/snort -V
Snort as an IDS/IPS: the theory
Before wiring it up, it’s worth being precise about what Snort is. Snort is an open-source, rules-driven network intrusion detection and prevention engine [1]. First written by Martin Roesch in 1998, it’s now developed by Cisco and is one of the most widely deployed NIDS/NIPS in the world [2]. We’re running Snort 3, the ground-up rewrite: C++ instead of C, multi-threaded, configured through Lua rather than a flat text file, and built on a modular plugin architecture [1][3].
IDS vs IPS: two deployments, one engine
The “I” and the “P” aren’t features you toggle; they describe where Snort sits:
1
2
3
4
5
6
IDS (detection) | IPS (prevention)
|
attacker ──► victim attacker ──► [ Snort ] ──► victim
│ └── match → drop/reject the packet
└── Snort watches, (Snort is inline, traffic flows *through* it)
match → alert
- IDS : a passive observer. Snort taps the traffic, compares packets against its rules and raises alerts, but never touches the data path.
- IPS : an inline gate. Snort physically sits between the networks and, on a match, can actively block/drop/reject the offending packets before they reach the target [2].
Inline prevention needs two interfaces and a Data Acquisition (DAQ) module in inline mode; our lab runs Snort in the simpler, passive IDS role. We keep it passive for the whole of this lab; Part 2, Snort 3 inline, stands the same engine between two endpoints and lets drop/reject actually block.
Inside the engine
Regardless of deployment, Snort’s analysis follows the same stages:
1
2
3
Capture ─► Decode ─► Preprocessors/inspectors ─► Detection engine ─► Output
(DAQ) (link→IP→ (normalize, protocol (match packets (alert / log)
transport) reassembly, etc.) against rules)
- Data Acquisition (DAQ) pulls packets off the interface.
- The decoder walks each packet from the link layer up to the application layer.
- Preprocessors / inspectors normalize and reassemble the stream (fragments, TCP segments) so rules match against rebuilt sessions, not raw packets.
- The detection engine runs the packet against every loaded rule.
- On a match, an output module writes the event, in our case structured JSON.
A rule’s action decides the outcome: alert logs and raises an event, drop/reject block the flow in inline IPS mode, pass whitelists, and so on [3]. Everything in this lab fires alert, because we’re operating as a passive IDS.
Attaching Snort to the monitored network
Snort has to actually see the traffic. The key detail: soc-snort runs in the host network namespace, so it has no IP of its own on soc-monitored, instead it can read the host’s Docker bridge directly.
1
2
docker inspect soc-snort --format 'NetworkMode='
# NetworkMode=host
1
docker network inspect soc-monitored --format ' -> \n'
soc-snort doesn’t appear in the listing, expected, since it borrows the host’s network stack.
Finding the right interface
We should not assume the interface is eth0. The monitored network is on 172.21.0.0/16, so we pick the interface bound to that subnet:
1
2
3
4
5
6
7
➜ soc-lab docker exec soc-snort ip -br addr
lo UNKNOWN 127.0.0.1/8 ::1/128
eth0 DOWN
wlan0 UP 192.168.100.148/24 ...
br-909e429c8d47 UP 172.21.0.1/16 fe80::2095:b4ff:fe4e:9c87/64
br-ee5cbd371a0c UP 172.20.0.1/16 fe80::9c00:7fff:fec3:7531/64
docker0 DOWN 172.17.0.1/16 ...
1
2
➜ soc-lab ip -o -4 addr show | awk '$4 ~ /^172\.21\./ {print $2, $4}'
br-909e429c8d47 172.21.0.1/16
We confirm that this bridge is the path to the victim:
1
2
3
➜ soc-lab ip route get 172.21.0.2
172.21.0.2 dev br-909e429c8d47 src 172.21.0.1 uid 1000
cache
So br-909e429c8d47 is our sensor interface. Rather than hardcoding the Docker-generated name, we select it dynamically by subnet:
1
2
root@nsm:/home/snorty# MONITORED_IF=$(ip -o -4 addr show | awk '$4 ~ /^172\.21\./ {print $2; exit}'); echo "$MONITORED_IF"
br-909e429c8d47
Why not -i any?
We tried it first, and Snort aborts with:
1
No codec found for data link type 113
Snort has no decoder for Docker’s mixed any link type, and capturing from every interface is a poor sensor design anyway. Selecting the concrete bridge gives us a clean, explicit listening point.
Snort configuration
Snort 3 is configured in Lua. The relevant snort.lua is short:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
----------------------------------------------------------------
-- SOC LAB - SNORT 3 IDS
----------------------------------------------------------------
HOME_NET = 'any'
EXTERNAL_NET = 'any'
ips =
{
rules = [[
include /etc/snort/rules/local.rules
]]
}
alert_json =
{
file = true,
}
Three ideas here:
HOME_NET/EXTERNAL_NETset toanykeep the network model trivial, so rules match regardless of source/destination.- The
ipsblock drives the rule engine. Instead of inlining signatures, it includeslocal.rules, so configuration stays separate from detection logic. alert_jsonwrites alerts as structured JSON (see below) rather than human text, which is exactly what the rest of the pipeline wants.
Before anything else, we validate the whole config (Lua file and rules):
1
2
3
4
/home/snorty/snort3/bin/snort \
-c /etc/snort/snort.lua \
-R /etc/snort/rules/local.rules \
-T
No config errors, and we’re clear to write detections. (-T is test mode; -R loads a rules file directly, handy while iterating [3].)
Writing detection rules
Snort’s detection logic lives in rules, and every rule has two sections [3]:
1
2
3
4
Rule Header Rule Options
Where/what traffic? What evidence?
alert tcp any any -> any 80 ( msg:"..."; content:"/admin"; sid:2000001; rev:1; )
└── matches the rule └── conditions that must ALL be true before the header's action fires
The header declares the action, protocol, source/destination networks and ports, and direction. The options hold the evidence conditions; the rule only fires when every option evaluates to true.
Rule header
1
2
alert tcp any any -> any 80
action proto src spt dir dst dpt
Four moving parts:
alert: the action, i.e. what the sensor does on a match.alertraises an event and logs the packet,loglogs without alerting, and in inline IPS modedrop/rejectblock the flow whilepasswhitelists it. A passive IDS like ours lives onalert[3].tcp: the protocol (ip,icmp,tcp,udp). In Snort 3 the header can name a service instead (more on that below) [3].any any/any 80: source and destination network:port. Networks can be a literal CIDR (172.21.0.0/24),any, or variables defined insnort.lualike$HOME_NET/$EXTERNAL_NET(ours areany). Ports can be single values, ranges (1:1024), lists, orany[3].->: the direction operator;<>matches traffic flowing either way.
Read as: alert on TCP traffic from any source to any host on port 80.
Rule options
Options add the evidence. msg, sid and rev are the general options every rule carries: the human-readable message, the signature ID, and the rule revision [3]. Our very first rule is about as minimal as a rule gets:
1
2
3
4
5
6
# /etc/snort/rules/local.rules
alert icmp any any -> any any (
msg:"SOC-LAB ICMP Host Discovery";
sid:1000001;
rev:1;
)
So: if ICMP traffic matches the header → raise an alert → tagged SID 1000001 → message “SOC-LAB ICMP Host Discovery”. That’s rule 1000001, the one we’ll trigger with a ping later.
A header alone is broad. We sharpen detection with payload conditions: content does pattern matching against packet data, tunable with modifiers like nocase, depth, offset, distance, within and fast_pattern [3]:
1
2
3
4
5
6
7
# simplified for illustration
alert tcp any any -> any 80 (
msg:"Suspicious HTTP URI";
content:"/admin";
sid:2000001;
rev:1;
)
i.e. TCP to port 80 and “/admin” present in the inspected data → alert. And with non-payload conditions we can reason about packet properties instead of strings: flags:S tests TCP flags (F, S, R, P, A, U, C, E), dsize:>50 tests payload size, handy for spotting large DNS payloads or unusual SYN behavior [3]. Real rules almost always combine both: the service-probe rules below pair a header (tcp ... 22) with flags:S to catch the very first SYN of an SSH scan.
Matching a service, not a port
Ports are a useful first cut, but a fragile proxy for what the traffic is: a service can run on any port. Snort 3 lets the header name a service instead of a protocol+port, and the HTTP/file inspectors decode the session so rules match the result no matter where it rides [3]:
1
2
3
4
5
6
7
8
9
10
# simplified for illustration
alert http (
msg:"Suspicious HTTP URI (service rule)";
flow:to_server,established;
service:http;
http_uri;
content:"/admin";
sid:2000002;
rev:1;
)
Two Snort 3 habits worth stealing from real rule-sets:
- Sticky buffers point
contentat a decoded part of the session instead of the whole payload. The buffer keyword comes first and sticks until changed:http_uri; content:"/admin";only looks inside the HTTP URI,http_header:field user-agent; content:"sqlmap";only inside the User-Agent header, and options chain so you can require FOO then BAR, both in the URI. contentmatches bytes, and any byte can be spelled in hex:content:"ABCD"is exactlycontent:"|41 42 43 44|". Non-printable bytes can only be written that way.
You’ll also see service:http tagged onto otherwise port-based rules, and alert file ( ... ) headers that match a transferred file regardless of protocol, ports or service. flow:to_server,established (above) gates a rule on established client→server sessions so we don’t also match the reply half of the conversation.
We stay port-based for the rest of this lab (the point is the pipeline, not port-80 hunting), but this is the direction real Snort 3 rule-sets take.
A rule like /admin doesn’t prove an attack succeeded; it hands the SOC an event worth investigating. That’s the detection-engineering trade-off in one line:
1
2
Broad rule → more visibility, more noise
Specific rule → cleaner signal, less coverage
Our ruleset
Five rules teach the syntax; a real ruleset organizes it. Ours holds 24 rules grouped by attack phase, each category under a comment banner: recon service-probes (SYN-only), web-scanning User-Agents, sensitive-file and path discovery, path traversal, SQLi and command-injection indicators, attack-tool fingerprints, and SSH. SID ranges double as a taxonomy: 1000001-1000006 recon, 1000010+ web recon, 1000020+ file discovery, and so on.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# /etc/snort/rules/local.rules
# ------------------------------------------------------------
# RECON / DISCOVERY
# ------------------------------------------------------------
alert icmp any any -> any any (
msg:"SOC-LAB ICMP Host Discovery";
sid:1000001; rev:1;
)
alert tcp any any -> any 22 (
msg:"SOC-LAB SSH Service Probe";
flags:S; sid:1000002; rev:1;
)
alert tcp any any -> any 21 (
msg:"SOC-LAB FTP Service Probe";
flags:S; sid:1000003; rev:1;
)
alert tcp any any -> any 23 (
msg:"SOC-LAB Telnet Service Probe";
flags:S; sid:1000004; rev:1;
)
alert tcp any any -> any 80 (
msg:"SOC-LAB HTTP Connection";
flags:S; sid:1000005; rev:1;
)
alert tcp any any -> any 443 (
msg:"SOC-LAB HTTPS Connection";
flags:S; sid:1000006; rev:1;
)
# ------------------------------------------------------------
# WEB RECON
# ------------------------------------------------------------
alert tcp any any -> any 80 (
msg:"SOC-LAB Web Scanner User Agent";
flow:to_server,established; content:"nikto";
sid:1000010; rev:1;
)
alert tcp any any -> any 80 (
msg:"SOC-LAB Nmap HTTP Probe";
flow:to_server,established; content:"Nmap";
sid:1000011; rev:1;
)
# ------------------------------------------------------------
# SENSITIVE FILE / PATH DISCOVERY
# ------------------------------------------------------------
alert tcp any any -> any 80 (
msg:"SOC-LAB Sensitive File Probe - passwd";
flow:to_server,established; content:"/etc/passwd";
sid:1000020; rev:1;
)
alert tcp any any -> any 80 (
msg:"SOC-LAB Sensitive File Probe - shadow";
flow:to_server,established; content:"/etc/shadow";
sid:1000021; rev:1;
)
alert tcp any any -> any 80 (
msg:"SOC-LAB Git Directory Probe";
flow:to_server,established; content:"/.git";
sid:1000022; rev:1;
)
alert tcp any any -> any 80 (
msg:"SOC-LAB Environment File Probe";
flow:to_server,established; content:"/.env";
sid:1000023; rev:1;
)
# ------------------------------------------------------------
# PATH TRAVERSAL
# ------------------------------------------------------------
alert tcp any any -> any 80 (
msg:"SOC-LAB Possible Directory Traversal";
flow:to_server,established; content:"../";
sid:1000030; rev:1;
)
alert tcp any any -> any 80 (
msg:"SOC-LAB Encoded Directory Traversal";
flow:to_server,established; content:"%2e%2e";
sid:1000031; rev:1;
)
# ------------------------------------------------------------
# SQL INJECTION INDICATORS
# ------------------------------------------------------------
alert tcp any any -> any 80 (
msg:"SOC-LAB SQL Injection - OR Condition";
flow:to_server,established; content:"' OR '";
sid:1000040; rev:1;
)
alert tcp any any -> any 80 (
msg:"SOC-LAB SQL Injection - UNION SELECT";
flow:to_server,established; content:"UNION SELECT";
sid:1000041; rev:1;
)
alert tcp any any -> any 80 (
msg:"SOC-LAB SQL Injection - Comment";
flow:to_server,established; content:"--";
sid:1000042; rev:1;
)
# ------------------------------------------------------------
# COMMAND INJECTION INDICATORS
# ------------------------------------------------------------
alert tcp any any -> any 80 (
msg:"SOC-LAB Possible Command Injection - Shell";
flow:to_server,established; content:"/bin/sh";
sid:1000050; rev:1;
)
alert tcp any any -> any 80 (
msg:"SOC-LAB Possible Command Injection - /bin/bash";
flow:to_server,established; content:"/bin/bash";
sid:1000051; rev:1;
)
alert tcp any any -> any 80 (
msg:"SOC-LAB Command Injection Metacharacter";
flow:to_server,established; content:"%3B";
sid:1000052; rev:1;
)
# ------------------------------------------------------------
# WEB ATTACK TOOL INDICATORS
# ------------------------------------------------------------
alert tcp any any -> any 80 (
msg:"SOC-LAB SQLMap User Agent";
flow:to_server,established; content:"sqlmap";
sid:1000060; rev:1;
)
alert tcp any any -> any 80 (
msg:"SOC-LAB Gobuster User Agent";
flow:to_server,established; content:"gobuster";
sid:1000061; rev:1;
)
alert tcp any any -> any 80 (
msg:"SOC-LAB Wfuzz User Agent";
flow:to_server,established; content:"Wfuzz";
sid:1000062; rev:1;
)
# ------------------------------------------------------------
# SSH
# ------------------------------------------------------------
alert tcp any any -> any 22 (
msg:"SOC-LAB SSH Connection Attempt";
flags:S; sid:1000070; rev:1;
)
The layout reads like a playbook: the broad, cheap SYN probes (flags:S on port 22/21/23/80/443) flag a port scan with almost no false-positive surface, while the web rules lean on established client→server flows plus a content fingerprint so they fire only when a real HTTP request carries nikto, /etc/passwd, ../, ' OR ', sqlmap and friends. Each signature is its own small hypothesis an analyst can triage: a gobuster User-Agent is not a breach, it’s a lead.
SIDs above 1,000,000 keep custom rules clear of any official signature namespace [3]. 24 text rules is exactly what Snort reports when it boots.
One hiccup during development: our first attempt used nocase, which the installed Snort build rejected. Lesson: keep the first rules simple and lean on snort -T after every change; it catches syntax errors before you ever generate traffic. (While you’re learning the syntax, a form-based rule builder such as Snorpy can scaffold a rule for you.)
Starting Snort
We launch Snort on the monitored bridge (picking it by subnet, as above):
1
2
3
4
/home/snorty/snort3/bin/snort \
-c /etc/snort/snort.lua \
-R /etc/snort/rules/local.rules \
-i "$MONITORED_IF"
Running it by hand this way is the interactive equivalent of the snort service in the compose file written during “Lab setup”. If that service is already up from docker compose up -d, stop it first so the interface isn’t bound twice; you can watch its alerts just as well with docker compose logs -f snort.
The startup banner loads the Lua config, compiles the rules, and reports rule counts:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
--------------------------------------------------
o")~ Snort++ 3.10.0.0
--------------------------------------------------
Loading /etc/snort/snort.lua:
output trace alert_json ips daq host_tracker ...
Finished /etc/snort/snort.lua:
...
rule counts
total rules loaded: 24
duplicate rules: 24
text rules: 24
--------------------------------------------------
pcap DAQ configured to passive.
Commencing packet processing
Retry queue interval is: 200 ms
++ [0] br-909e429c8d47
Note “pcap DAQ configured to passive”: Snort confirms it’s sniffing, not sitting inline. It’s now listening on the path:
1
soc-attacker (172.21.0.3) ──► Docker bridge (172.21.0.0/16) ──► soc-victim (172.21.0.2)
Generating traffic
From the attacker container, ping the victim:
1
2
docker exec -it soc-attacker /bin/bash
ping 172.21.0.2
1
2
3
PING 172.21.0.2 (172.21.0.2) 64 bytes of data.
64 bytes from 172.21.0.2: icmp_seq=1 ttl=64 time=0.1 ms
64 bytes from 172.21.0.2: icmp_seq=2 ttl=64 time=0.1 ms
Our ICMP rule (SID 1000001) should fire. Snort writes the events to /var/log/snort/alert_json.txt, bind-mounted to snort/logs/ on the host, so we follow them live:
1
tail -f snort/logs/alert_json.txt
A generated alert is one compact JSON line per matched packet:
1
2
3
4
{ "timestamp" : "09/01-00:50:44.711076", "pkt_num" : 81, "proto" : "ICMP",
"pkt_gen" : "raw", "pkt_len" : 84, "dir" : "UNK",
"src_ap" : "172.21.0.3:0", "dst_ap" : "172.21.0.2:0",
"rule" : "1:1000001:1", "action" : "allow" }
Notice what’s not here: the endpoints are still crammed into src_ap/dst_ap, there’s no @timestamp, and no message text; rule is still gid:sid:rev. The rest of the pipeline exists to turn this flat line into a searchable, analyst-friendly event. Note "action": "allow": we’re a passive IDS, so matching packets are let through and merely logged; an inline IPS rule would show a drop/reject action here. We run the same engine inline and watch those drop/reset actions appear in Part 2, Snort 3 inline.
First link of the chain works:
1
packet ─► rule match ─► alert ─► JSON event
Shipping alerts to the Elastic stack
Filebeat: collection
Filebeat tails snort/logs/alert_json.txt, ndjson-parses each line, and forwards it to Logstash. But it also does the field shaping Snort never bothered with [4]:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# filebeat.yml
filebeat.inputs:
- type: filestream
id: snort-alerts
enabled: true
paths:
- /var/log/snort/alert_json.txt
parsers:
- ndjson:
target: ""
overwrite_keys: true
fields:
event.dataset: snort.alert
observer.type: ids
observer.product: snort
observer.vendor: Cisco
fields_under_root: true
processors:
- add_host_metadata: ~
- timestamp:
field: timestamp
layouts:
- '01/02-15:04:05.000000'
ignore_missing: true
ignore_failure: true
output.logstash:
hosts: ["logstash:5044"]
Two things matter here. First, fields_under_root: true stamps ECS observer and event.dataset fields directly onto each document, so observer.product == "snort" exists downstream even though Snort’s own JSON never wrote it [8]. Second, the timestamp processor parses Snort’s 09/01-00:50:44.711076 (Go layout 01/02-15:04:05.000000) into a proper @timestamp, which is what Kibana’s time filter will later use. Detection still stays in Snort; Filebeat just collects and decorates [4].
Logstash: normalization
Logstash receives each event and maps the flat Snort fields into the dotted ECS layout the rest of the stack expects [5]. The pipeline is the classic input → filter → output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# logstash/pipeline/logstash.conf
input {
beats { port => 5044 }
}
filter {
# Filebeat stamped observer.product, so this gate picks out Snort-origin docs
if [observer][product] == "snort" {
mutate {
add_field => {
"[event][kind]" => "alert"
"[event][category]" => "network"
"[event][type]" => "connection"
"[event][module]" => "snort"
}
}
# "172.21.0.3:0" -> source.ip / source.port
if [src_ap] {
dissect { mapping => { "src_ap" => "%{[source][ip]}:%{[source][port]}" } }
}
if [dst_ap] {
dissect { mapping => { "dst_ap" => "%{[destination][ip]}:%{[destination][port]}" } }
}
mutate {
convert => {
"[source][port]" => "integer"
"[destination][port]" => "integer"
}
}
# "ICMP" / "UNK" -> ECS network.transport / network.direction
if [proto] { mutate { lowercase => [ "proto" ] } }
if [dir] { mutate { lowercase => [ "dir" ] } }
mutate {
rename => {
"proto" => "[network][transport]"
"dir" => "[network][direction]"
}
}
# "1:1000001:1" -> rule.gid / rule.id / rule.version
if [rule] {
mutate {
copy => { "rule" => "[@metadata][snort_rule]" }
remove_field => [ "rule" ]
}
mutate {
split => { "[@metadata][snort_rule]" => ":" }
add_field => {
"[rule][gid]" => "%{[@metadata][snort_rule][0]}"
"[rule][id]" => "%{[@metadata][snort_rule][1]}"
"[rule][version]" => "%{[@metadata][snort_rule][2]}"
}
}
mutate {
convert => {
"[rule][gid]" => "integer"
"[rule][id]" => "integer"
"[rule][version]" => "integer"
}
}
}
# packet metadata -> snort.*
mutate {
rename => {
"pkt_len" => "[snort][packet][length]"
"pkt_num" => "[snort][packet][number]"
}
}
mutate { add_tag => [ "snort", "ids", "soc-lab" ] }
}
}
output {
elasticsearch {
hosts => ["http://elasticsearch:9200"]
index => "snort-alerts-v2-%{+YYYY.MM.dd}"
}
stdout { codec => rubydebug } # handy while debugging
}
The dissect and mutate plugins unpack Snort’s cramped strings into proper fields: dissect splits on the colon delimiters, convert coerces numeric types, lowercase+rename normalizes the protocol and direction into ECS names, and the rule string is tokenized into gid/sid/rev:
1
2
3
src_ap "172.21.0.3:0" → source.ip = 172.21.0.3, source.port = 0
rule "1:1000001:1" → rule.gid = 1, rule.id = 1000001, rule.version = 1
proto "ICMP" → network.transport = icmp
After the filter each event carries source.ip, source.port, destination.ip, destination.port, network.transport, network.direction, rule.gid/id/version, event.* and snort.packet.*, plus the @timestamp Filebeat derived earlier.
Elasticsearch: storage
Logstash indexes into snort-alerts-v2-YYYY.MM.DD [6]:
1
curl http://localhost:9200/_cat/indices?v
1
2
health status index
green open snort-alerts-v2-2026.09.01
1
curl -s "http://localhost:9200/snort-alerts-v2-*/_count" | jq
1
{ "count": 40 }
Two single-node lab housekeeping notes:
Disk. Elasticsearch eats disk fast; our root FS was at 95% (58G/65G) with watermark warnings. We moved the data dir off the container writable layer to
/home/soc-data/elasticsearch:1 2
volumes: - /home/soc-data/elasticsearch:/usr/share/elasticsearch/data
Replicas. Single-node = no redundancy to gain, so we zero the replicas to avoid permanently-unassigned shards:
1 2 3
curl -X PUT "http://localhost:9200/snort-alerts-v2-*/_settings" \ -H 'Content-Type: application/json' \ -d '{ "index": { "number_of_replicas": 0 } }'
(Production clusters would keep replicas.)
Mapping. Logstash’s dynamic mapping would store IPs as strings. We verify the index mapping gives fields the types Kibana needs:
1
curl -s "http://localhost:9200/snort-alerts-v2-*/_mapping" | jq
1 2 3 4 5 6 7
source.ip / destination.ip ip source.port / destination.port integer network.transport / direction keyword event.kind/category/type/module keyword rule.gid / rule.id / version integer snort.packet.length integer snort.packet.number long
An
ip-typedsource.ipmakes aggregations and range queries behave correctly [6].
Kibana: visualization
With events indexed, we create a data view over snort-alerts-v2-* with @timestamp as the time field, name it “Snort IDS”, and build a five-panel SOC overview dashboard [7]:
1
2
3
4
5
6
7
8
9
┌─────────────────────────────────────────────────────────────┐
│ SNORT IDS | SOC OVERVIEW │
├─────────────────────────────────────────────────────────────┤
│ Alerts Over Time │
├──────────────────────────────┬──────────────────────────────┤
│ Top Alert Signatures │ Top Source IPs │
├──────────────────────────────┼──────────────────────────────┤
│ Top Destination IPs │ Protocol Distribution │
└──────────────────────────────┴──────────────────────────────┘
- Alerts Over Time: alert volume in the selected window.
- Top Alert Signatures: which detections fire the most events, bucketed by
rule.id(for our ping test: SID 1000001, the ICMP host-discovery rule). - Top Source / Destination IPs: which hosts generate and receive the detected traffic.
Protocol Distribution: a terms aggregation on
network.transport:1
COUNT(alerts) GROUP BY network.transport
Because Logstash normalized Snort’s protocol into network.transport, Kibana can slice the whole event set by protocol in one panel. Our test traffic shows up as an ICMP slice.
End-to-end test
The real proof: one ping, and the event travels the whole chain:
1
2
3
4
5
6
ping ─► Docker network ─► Snort 3 (SID 1000001)
─► alert_json.txt
─► Filebeat
─► Logstash (source.ip, rule.id, network.transport, ...)
─► Elasticsearch
─► Kibana dashboard
We can even measure the latency: the packet was generated at 00:40:06.236566842, and Snort’s alert timestamp reads 09/01-00:40:06.365128, about 129 ms from wire to event. For a Dockerized lab, that is near real time.
Final result
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
NETWORK TRAFFIC
│
▼
┌───────────────────────┐
│ Snort 3 (IDS) │ detect
└───────────┬───────────┘
│ JSON alerts
▼
┌───────────────────────┐
│ Filebeat │ collect
└───────────┬───────────┘
▼
┌───────────────────────┐
│ Logstash (ECS-normal)│ parse
└───────────┬───────────┘
▼
┌───────────────────────┐
│ Elasticsearch │ store
└───────────┬───────────┘
▼
┌───────────────────────┐
│ Kibana SOC dashboard │ visualize
└───────────────────────┘
Raw packets in, searchable security events out: Detect → Collect → Parse → Store → Visualize. Each component is a swap-able piece (swap Snort for Suricata, Filebeat for another shipper) without rebuilding the lab.
Two directions lead on from here. Replace the toy rules with realistic detections (port scans, suspicious HTTP URIs, DNS anomalies, SSH brute-force patterns), and run Snort inline with drop/reject rules. The second is built end to end in Part 2: SOC Lab 2, Snort 3 inline, where this same engine and these same rules move from a tap into the data path and start blocking traffic.
Conclusion
This lab is a minimal SOC architecture: Snort detects, Filebeat collects, Logstash normalizes to ECS, Elasticsearch stores, and Kibana presents. The value is seeing a single packet become an analyst-facing event through a chain you built and can extend rule by rule.
References
- Snort, the Network Intrusion Detection & Prevention System (official project).
- Snort (software), Wikipedia: history, IDS/IPS modes and the Snort 3 rewrite.
- Snort 3 Rule Writing Guide, “The Basics”, Cisco Talos: rule header and options, rule actions, general and payload options.
- Filebeat Reference: filestream inputs and the ndjson parser.
- Logstash Reference: the input/filter/output pipeline and the
dissect/mutatefilters. - Elasticsearch Reference: indices, settings and mapping.
- Kibana Guide: data views and dashboards.
- Elastic Common Schema (ECS) Reference.
Tags
#Snort #Snort3 #IDS #Docker #SOC #BlueTeam #Filebeat #Logstash #Elasticsearch #Kibana



