]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
tests/transform: from_base64 test 1937/head suricata-6.0.20 suricata-7.0.6
authorJeff Lucovsky <jlucovsky@oisf.net>
Tue, 27 Feb 2024 14:02:35 +0000 (09:02 -0500)
committerVictor Julien <victor@inliniac.net>
Sat, 22 Jun 2024 13:54:36 +0000 (15:54 +0200)
Issue: 6487

Test cases for the from_base64 transform
- Case 01 tests RFC4648 (default) with various offsets
- Case 02 tests RFC2045 and verifies success and failure case
  (with other modes)
- Case 03 -- case 01 with fast_pattern associated with the
  post transform content.

tests/from_base64-01/README.md [new file with mode: 0644]
tests/from_base64-01/test.rules [new file with mode: 0644]
tests/from_base64-01/test.yaml [new file with mode: 0644]
tests/from_base64-02/README.md [new file with mode: 0644]
tests/from_base64-02/input.pcap [new file with mode: 0644]
tests/from_base64-02/test.rules [new file with mode: 0644]
tests/from_base64-02/test.yaml [new file with mode: 0644]
tests/from_base64-03/README.md [new file with mode: 0644]
tests/from_base64-03/test.rules [new file with mode: 0644]
tests/from_base64-03/test.yaml [new file with mode: 0644]

diff --git a/tests/from_base64-01/README.md b/tests/from_base64-01/README.md
new file mode 100644 (file)
index 0000000..d1024db
--- /dev/null
@@ -0,0 +1 @@
+from_base64 transform tests
diff --git a/tests/from_base64-01/test.rules b/tests/from_base64-01/test.rules
new file mode 100644 (file)
index 0000000..ef04cf0
--- /dev/null
@@ -0,0 +1,8 @@
+# input pcap contains a query to http://home.regit.org/?arg=dGhpc2lzYXRlc3QK
+# "dGhpc2lzYXRlc3QK" is "thisisatest\n"
+alert http any any -> any any (msg:"from_base64: offset #1 [mode rfc4648]"; http.uri; content:"/?arg=dGhpc2lzYXRlc3QK"; from_base64: offset 6 ; content:"thisisatest"; sid:1; rev:1;)
+alert http any any -> any any (msg:"from_base64: offset #2 [mode rfc4648]"; http.uri; content:"/?arg=dGhpc2lzYXRlc3QK"; from_base64: offset 10 ; content:"sisatest"; sid:2; rev:1;)
+alert http any any -> any any (msg:"from_base64: bytes, offset #1 [mode rfc4648]"; http.uri; content:"/?arg=dGhpc2lzYXRlc3QK"; from_base64: bytes 6, offset 6 ; content:"this"; sid:3; rev:1;)
+alert http any any -> any any (msg:"from_base64: offset #3, mode rfc2045 - will succeed"; http.uri; content:"/?arg=dGhpc2lzYXRlc3QK"; from_base64: offset 6, mode rfc2045 ; content:"thisisatest"; sid:4; rev:1;)
+alert http any any -> any any (msg:"from_base64: offset #3, mode rfc4648 - will succeed"; http.uri; content:"/?arg=dGhpc2lzYXRlc3QK"; from_base64: offset 6, mode rfc4648 ; content:"thisisatest"; sid:5; rev:1;)
+alert http any any -> any any (msg:"from_base64: offset #4, mode strict - will succeed"; http.uri; content:"/?arg=dGhpc2lzYXRlc3QK"; from_base64: offset 6, mode strict ; content:"thisisatest"; sid:6; rev:1;)
diff --git a/tests/from_base64-01/test.yaml b/tests/from_base64-01/test.yaml
new file mode 100644 (file)
index 0000000..97deff6
--- /dev/null
@@ -0,0 +1,34 @@
+requires:
+  min-version: 8
+
+pcap: ../base64/input.pcap
+
+args:
+  - -k none
+
+checks:
+  - filter:
+      count: 1
+      match:
+         event_type: alert
+         alert.signature_id: 1
+  - filter:
+      count: 1
+      match:
+         event_type: alert
+         alert.signature_id: 2
+  - filter:
+      count: 1
+      match:
+         event_type: alert
+         alert.signature_id: 3
+  - filter:
+      count: 1
+      match:
+         event_type: alert
+         alert.signature_id: 4
+  - filter:
+      count: 1
+      match:
+         event_type: alert
+         alert.signature_id: 5
diff --git a/tests/from_base64-02/README.md b/tests/from_base64-02/README.md
new file mode 100644 (file)
index 0000000..2b080d7
--- /dev/null
@@ -0,0 +1 @@
+Match on base64 operations using rfc2045 URI
diff --git a/tests/from_base64-02/input.pcap b/tests/from_base64-02/input.pcap
new file mode 100644 (file)
index 0000000..ae79adf
Binary files /dev/null and b/tests/from_base64-02/input.pcap differ
diff --git a/tests/from_base64-02/test.rules b/tests/from_base64-02/test.rules
new file mode 100644 (file)
index 0000000..c3a6f06
--- /dev/null
@@ -0,0 +1,4 @@
+# "Zm 9v Ym Fy" is "foobar" with mode RFC2045
+alert http any any -> any any (msg:"from_base64: RFC2045 - will succeed"; http.uri; content:"/?arg=Zm 9v Ym Fy"; from_base64: offset 6, mode rfc2045; content:"foobar"; sid:1; rev:1;)
+alert http any any -> any any (msg:"from_base64: mode strict - will fail"; http.uri; content:"/?arg=Zm 9v Ym Fy"; from_base64: offset 6, mode strict; content:"foobar"; sid:2; rev:1;)
+alert http any any -> any any (msg:"from_base64: mode RFC4648 - will fail"; http.uri; content:"/?arg=Zm 9v Ym Fy"; from_base64: offset 6, mode rfc4648; content:"foobar"; sid:3; rev:1;)
diff --git a/tests/from_base64-02/test.yaml b/tests/from_base64-02/test.yaml
new file mode 100644 (file)
index 0000000..190f846
--- /dev/null
@@ -0,0 +1,24 @@
+requires:
+  min-version: 8
+
+args:
+  - -k none
+
+pcap: input.pcap
+
+checks:
+  - filter:
+      count: 1
+      match:
+         event_type: alert
+         alert.signature_id: 1
+  - filter:
+      count: 0
+      match:
+         event_type: alert
+         alert.signature_id: 2
+  - filter:
+      count: 0
+      match:
+         event_type: alert
+         alert.signature_id: 2
diff --git a/tests/from_base64-03/README.md b/tests/from_base64-03/README.md
new file mode 100644 (file)
index 0000000..cfb70fc
--- /dev/null
@@ -0,0 +1 @@
+from_base64 transform tests that assign fast-pattern to the post-transform content
diff --git a/tests/from_base64-03/test.rules b/tests/from_base64-03/test.rules
new file mode 100644 (file)
index 0000000..b07e32c
--- /dev/null
@@ -0,0 +1,8 @@
+# input pcap contains a query to http://home.regit.org/?arg=dGhpc2lzYXRlc3QK
+# "dGhpc2lzYXRlc3QK" is "thisisatest"
+alert http any any -> any any (msg:"from_base64: offset #1 [mode rfc4648]"; http.uri; content:"/?arg=dGhpc2lzYXRlc3QK"; from_base64: offset 6 ; content:"thisisatest"; fast_pattern; sid:1; rev:1;)
+alert http any any -> any any (msg:"from_base64: offset #2 [mode rfc4648]"; http.uri; content:"/?arg=dGhpc2lzYXRlc3QK"; from_base64: offset 10 ; content:"sisatest"; fast_pattern; sid:2; rev:1;)
+alert http any any -> any any (msg:"from_base64: bytes, offset #1 [mode rfc4648]"; http.uri; content:"/?arg=dGhpc2lzYXRlc3QK"; from_base64: bytes 6, offset 6 ; content:"this"; fast_pattern; sid:3; rev:1;)
+alert http any any -> any any (msg:"from_base64: offset #3, mode rfc2045 - will succeed"; http.uri; content:"/?arg=dGhpc2lzYXRlc3QK"; from_base64: offset 6, mode rfc2045 ; content:"thisisatest"; fast_pattern; sid:4; rev:1;)
+alert http any any -> any any (msg:"from_base64: offset #3, mode rfc4648 - will succeed"; http.uri; content:"/?arg=dGhpc2lzYXRlc3QK"; from_base64: offset 6, mode rfc4648 ; content:"thisisatest"; fast_pattern; sid:5; rev:1;)
+alert http any any -> any any (msg:"from_base64: offset #4, mode strict - will succeed"; http.uri; content:"/?arg=dGhpc2lzYXRlc3QK"; from_base64: offset 6, mode strict ; content:"thisisatest"; fast_pattern; sid:6; rev:1;)
diff --git a/tests/from_base64-03/test.yaml b/tests/from_base64-03/test.yaml
new file mode 100644 (file)
index 0000000..97deff6
--- /dev/null
@@ -0,0 +1,34 @@
+requires:
+  min-version: 8
+
+pcap: ../base64/input.pcap
+
+args:
+  - -k none
+
+checks:
+  - filter:
+      count: 1
+      match:
+         event_type: alert
+         alert.signature_id: 1
+  - filter:
+      count: 1
+      match:
+         event_type: alert
+         alert.signature_id: 2
+  - filter:
+      count: 1
+      match:
+         event_type: alert
+         alert.signature_id: 3
+  - filter:
+      count: 1
+      match:
+         event_type: alert
+         alert.signature_id: 4
+  - filter:
+      count: 1
+      match:
+         event_type: alert
+         alert.signature_id: 5