]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
tests/tls: add testcases for JA3S
authorMats Klepsland <mats.klepsland@gmail.com>
Thu, 16 May 2019 09:44:31 +0000 (11:44 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 20 May 2019 18:45:49 +0000 (20:45 +0200)
tests/tls-ja3s/input.pcap [new file with mode: 0644]
tests/tls-ja3s/suricata.yaml [new file with mode: 0644]
tests/tls-ja3s/test-ja3s-hash.lua [new file with mode: 0644]
tests/tls-ja3s/test-ja3s-string.lua [new file with mode: 0644]
tests/tls-ja3s/test.rules [new file with mode: 0644]
tests/tls-ja3s/test.yaml [new file with mode: 0644]

diff --git a/tests/tls-ja3s/input.pcap b/tests/tls-ja3s/input.pcap
new file mode 100644 (file)
index 0000000..f50866f
Binary files /dev/null and b/tests/tls-ja3s/input.pcap differ
diff --git a/tests/tls-ja3s/suricata.yaml b/tests/tls-ja3s/suricata.yaml
new file mode 100644 (file)
index 0000000..282e8ae
--- /dev/null
@@ -0,0 +1,26 @@
+%YAML 1.1
+---
+
+outputs:
+  - eve-log:
+      enabled: yes
+      filetype: regular #regular|syslog|unix_dgram|unix_stream|redis
+      filename: eve.json
+      types:
+        - alert:
+            payload: no
+            payload-buffer-size: 4kb
+            payload-printable: no
+            packet: no
+            metadata: no
+        - tls:
+            extended: yes
+
+app-layer:
+  protocols:
+    tls:
+      enabled: yes
+      detection-ports:
+        dp: 443
+
+      ja3-fingerprints: yes
diff --git a/tests/tls-ja3s/test-ja3s-hash.lua b/tests/tls-ja3s/test-ja3s-hash.lua
new file mode 100644 (file)
index 0000000..791afa7
--- /dev/null
@@ -0,0 +1,18 @@
+function init(args)
+    local needs = {}
+    needs["tls"] = tostring(true)
+    return needs
+end
+
+function match(args)
+    hash = Ja3SGetHash()
+    if hash == nil then
+        return 0
+    end
+
+    if hash == "5d79edf64e03689ff559a54e9d9487bc" then
+        return 1
+    end
+
+    return 0
+end
diff --git a/tests/tls-ja3s/test-ja3s-string.lua b/tests/tls-ja3s/test-ja3s-string.lua
new file mode 100644 (file)
index 0000000..2ea8b0d
--- /dev/null
@@ -0,0 +1,18 @@
+function init(args)
+    local needs = {}
+    needs["tls"] = tostring(true)
+    return needs
+end
+
+function match(args)
+    str = Ja3SGetString()
+    if str == nil then
+        return 0
+    end
+
+    if str == "771,49199,65281-0-11-16-23" then
+        return 1
+    end
+
+    return 0
+end
diff --git a/tests/tls-ja3s/test.rules b/tests/tls-ja3s/test.rules
new file mode 100644 (file)
index 0000000..a5b259b
--- /dev/null
@@ -0,0 +1,4 @@
+alert tls any any -> any any (msg:"ja3s.hash test"; flow:established,to_client; ja3s.hash; content:"5d79edf64e03689ff559a54e9d9487bc"; sid:1;)
+alert tls any any -> any any (msg:"ja3s.string test"; flow:established,to_client; ja3s.string; content:"771,49199,65281-0-11-16-23"; sid:2;)
+alert tls any any -> any any (msg:"ja3s.hash Lua test"; flow:established,to_client; lua:test-ja3s-hash.lua; sid:3;)
+alert tls any any -> any any (msg:"ja3s.string Lua test"; flow:established,to_client; lua:test-ja3s-string.lua; sid:4;)
diff --git a/tests/tls-ja3s/test.yaml b/tests/tls-ja3s/test.yaml
new file mode 100644 (file)
index 0000000..f1730f4
--- /dev/null
@@ -0,0 +1,24 @@
+requires:
+  min-version: 5.0.0
+  features:
+    - HAVE_LIBJANSSON
+    - HAVE_NSS
+    - HAVE_LUA
+
+args:
+ - -k none
+
+checks:
+  # Check that we have the following events in eve.json
+  # 2 - alert events
+  # 1 - tls event
+  - filter:
+      count: 4
+      match:
+        event_type: alert
+  - filter:
+      count: 1
+      match:
+        event_type: tls
+        tls.ja3s.hash: "5d79edf64e03689ff559a54e9d9487bc"
+        tls.ja3s.string: "771,49199,65281-0-11-16-23"