Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
16 changes: 16 additions & 0 deletions tests/mqtt-connect-rules-2/suricata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
%YAML 1.1
---

outputs:
- eve-log:
enabled: yes
filetype: regular
filename: eve.json
types:
- mqtt
- alert

app-layer:
protocols:
mqtt:
enabled: yes
4 changes: 4 additions & 0 deletions tests/mqtt-connect-rules-2/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
alert mqtt any any -> any any (msg:"MQTT CONNACK reason code 134"; mqtt.type:CONNACK; mqtt.reason_code:134; sid:1;)
alert mqtt any any -> any any (msg:"MQTT CONNACK reason code 0"; mqtt.type:CONNACK; mqtt.reason_code:0; sid:2;)


19 changes: 19 additions & 0 deletions tests/mqtt-connect-rules-2/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
requires:
min-version: 8

args:
- -k none

checks:

- filter:
count: 1
match:
event_type: alert
alert.signature: MQTT CONNACK reason code 134

- filter:
count: 0
match:
event_type: alert
alert.signature: MQTT CONNACK reason code 0
2 changes: 2 additions & 0 deletions tests/mqtt-connect-rules/test.rules
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
alert mqtt any any -> any any (msg:"MQTT CONNECT protocol string SUCCESS"; mqtt.connect.protocol_string; content:"MQTT"; sid:1;)
alert mqtt any any -> any any (msg:"MQTT CONNECT protocol string SUCCESS2"; mqtt.connect.protocol_string; content:"M"; sid:2;)
alert mqtt any any -> any any (msg:"MQTT CONNECT protocol string FAIL"; mqtt.connect.protocol_string; content:"Foobar"; sid:3;)
alert mqtt any any -> any any (msg:"MQTT CONNACK reason code 0"; mqtt.type:CONNACK; mqtt.reason_code:0; sid:4;)
alert mqtt any any -> any any (msg:"MQTT DISCONNECT reason code 0"; mqtt.type:DISCONNECT; mqtt.reason_code:0; sid:5;)

12 changes: 12 additions & 0 deletions tests/mqtt-connect-rules/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,15 @@ checks:
match:
event_type: alert
alert.signature: MQTT CONNECT protocol string FAIL

- filter:
count: 1
match:
event_type: alert
alert.signature: MQTT CONNACK reason code 0

- filter:
count: 1
match:
event_type: alert
alert.signature: MQTT DISCONNECT reason code 0
2 changes: 1 addition & 1 deletion tests/mqtt-sub-rules/test.rules
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ alert mqtt any any -> any any (msg:"MQTT CONNECT flags"; mqtt.connect.flags:user
alert mqtt any any -> any any (msg:"MQTT CONNECT username"; mqtt.connect.username; content:"user"; sid:19;)
alert mqtt any any -> any any (msg:"MQTT CONNECT password"; mqtt.connect.password; content:"pass"; sid:20;)
alert mqtt any any -> any any (msg:"MQTT SUBSCRIBE topicY"; mqtt.type:SUBSCRIBE; mqtt.subscribe.topic; content:"topicY"; sid:15;)
alert mqtt any any -> any any (msg:"MQTT SUBSCRIBE topicY"; mqtt.type:SUBACK; mqtt.reason_code:0; sid:16;)
alert mqtt any any -> any any (msg:"MQTT SUBACK topicY reason code 0"; mqtt.type:SUBACK; mqtt.subscribe.topic; content:"topicY"; mqtt.reason_code:0; sid:16;)
17 changes: 17 additions & 0 deletions tests/mqtt-sub-rules/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ checks:
mqtt.subscribe.dup: false
mqtt.subscribe.topics: [{topic: topicX, qos: 0}, {topic: topicY, qos: 0} ]

- filter:
count: 1
match:
event_type: mqtt
mqtt.suback.qos: 0
mqtt.suback.retain: false
mqtt.suback.dup: false
mqtt.suback.message_id: 1
mqtt.suback.qos_granted: [ 0, 0 ]

- filter:
count: 1
match:
Expand Down Expand Up @@ -109,3 +119,10 @@ checks:
match:
event_type: alert
alert.signature: MQTT SUBSCRIBE topicY

- filter:
min-version: 8
count: 1
match:
event_type: alert
alert.signature: MQTT SUBACK topicY reason code 0
12 changes: 12 additions & 0 deletions tests/prefilter-multibuf-multipkts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Test
====

Test that multibuffer is prefiltered the right way, even if occurences of buffers
are spanned over multiple packets, and the first try does not match.

https://redmine.openinfosecfoundation.org/issues/7326

PCAP
====

Pcap crafted with some http server and some python client that delays or not the writing of the headers
Binary file added tests/prefilter-multibuf-multipkts/input.pcap
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/prefilter-multibuf-multipkts/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alert http any any -> any any ( sid: 2; http.stat_code; content: "200"; fast_pattern; http.response_header; content: "first";)
alert http any any -> any any ( sid: 3; http.stat_code; content: "200"; http.response_header; content: "first"; fast_pattern;)
17 changes: 17 additions & 0 deletions tests/prefilter-multibuf-multipkts/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
requires:
min-version: 8

args:
- -k none

checks:
- filter:
count: 1
match:
event_type: alert
alert.signature_id: 2
- filter:
count: 1
match:
event_type: alert
alert.signature_id: 3
2 changes: 2 additions & 0 deletions tests/rules/tcp_window/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alert tcp any any -> any any (msg:"TCP window size"; window:30336; sid:1;)
alert tcp any any -> any any (msg:"TCP window size"; tcp.window:!1024; sid:2;)
25 changes: 25 additions & 0 deletions tests/rules/tcp_window/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
requires:
min-version: 8.0
pcap: false

args:
- --engine-analysis

checks:
- filter:
filename: rules.json
count: 1
match:
id: 1
lists.packet.matches[0].name: "tcp.window"
lists.packet.matches[0].window.size: 30336
lists.packet.matches[0].window.negated: false

- filter:
filename: rules.json
count: 1
match:
id: 2
lists.packet.matches[0].name: "tcp.window"
lists.packet.matches[0].window.size: 1024
lists.packet.matches[0].window.negated: true