]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
eve/ssh: change hassh logging format
authorVictor Julien <victor@inliniac.net>
Fri, 24 Jul 2020 08:49:20 +0000 (10:49 +0200)
committerVictor Julien <victor@inliniac.net>
Fri, 24 Jul 2020 11:27:41 +0000 (13:27 +0200)
Elastic search didn't accept the 'hassh' and 'hassh.string'. It would
see the first 'hassh' as a string and split the second key into a
object 'hassh' with a string member 'string'. So two different types
for 'hassh', so it rejected it.

This patch mimics the ja3(s) logging by creating a 'hassh' object
with 2 members: 'hash', which holds the md5 representation, and
'string' which holds the string representation.

doc/userguide/output/eve/eve-json-format.rst
rust/src/ssh/logger.rs

index 0b58c1df8e2207cbb1f8ef88891e4b4f4fa6ffef..823c079a71c68793a053d49dbda48b99fd92c926 100644 (file)
@@ -980,7 +980,7 @@ Fields
 
 * "proto_version": The protocol version transported with the ssh protocol (1.x, 2.x)
 * "software_version": The software version used by end user
-* "hassh": MD5 of hassh algorithms of client or server
+* "hassh.hash": MD5 of hassh algorithms of client or server
 * "hassh.string": hassh algorithms of client or server
 
 Hassh must be enabled in the Suricata config file (set 'app-layer.protocols.ssh.hassh' to 'yes').
@@ -993,14 +993,18 @@ Example of SSH logging:
     "client": {
         "proto_version": "2.0",
         "software_version": "OpenSSH_6.7",
-        "hassh": "ec7378c1a92f5a8dde7e8b7a1ddf33d1",
-        "hassh.string": "curve25519-sha256,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c",
+        "hassh": {
+            "hash": "ec7378c1a92f5a8dde7e8b7a1ddf33d1",
+            "string": "curve25519-sha256,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c",
+        }
      },
     "server": {
         "proto_version": "2.0",
         "software_version": "OpenSSH_6.7",
-        "hassh": "ec7378c1a92f5a8dde7e8b7a1ddf33d1",
-        "hassh.string": "curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256",
+        "hassh": {
+            "hash": "ec7378c1a92f5a8dde7e8b7a1ddf33d1",
+            "string": "curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256",
+        }
      }
   }
 
index ae8dcb9028db579260b3eff0443e4ab75face173..7f5965146373eb375e554eb6a914ab6664fb9658 100644 (file)
@@ -28,11 +28,15 @@ fn log_ssh(tx: &SSHTransaction, js: &mut JsonBuilder) -> Result<bool, JsonError>
         if tx.cli_hdr.swver.len() > 0 {
             js.set_string_from_bytes("software_version", &tx.cli_hdr.swver)?;
         }
-        if tx.cli_hdr.hassh.len() > 0 {
-            js.set_string_from_bytes("hassh", &tx.cli_hdr.hassh)?;
-        }
-        if tx.cli_hdr.hassh_string.len() > 0 {
-            js.set_string_from_bytes("hassh.string", &tx.cli_hdr.hassh_string)?;
+        if tx.cli_hdr.hassh.len() > 0 || tx.cli_hdr.hassh_string.len() > 0 {
+            js.open_object("hassh")?;
+            if tx.cli_hdr.hassh.len() > 0 {
+                js.set_string_from_bytes("hash", &tx.cli_hdr.hassh)?;
+            }
+            if tx.cli_hdr.hassh_string.len() > 0 {
+                js.set_string_from_bytes("string", &tx.cli_hdr.hassh_string)?;
+            }
+            js.close()?;
         }
         js.close()?;
     }
@@ -42,11 +46,15 @@ fn log_ssh(tx: &SSHTransaction, js: &mut JsonBuilder) -> Result<bool, JsonError>
         if tx.srv_hdr.swver.len() > 0 {
             js.set_string_from_bytes("software_version", &tx.srv_hdr.swver)?;
         }
-        if tx.srv_hdr.hassh.len() > 0 {
-            js.set_string_from_bytes("hassh", &tx.srv_hdr.hassh)?;
-        }
-        if tx.srv_hdr.hassh_string.len() > 0 {
-            js.set_string_from_bytes("hassh.string", &tx.srv_hdr.hassh_string)?;
+        if tx.srv_hdr.hassh.len() > 0 || tx.srv_hdr.hassh_string.len() > 0 {
+            js.open_object("hassh")?;
+            if tx.srv_hdr.hassh.len() > 0 {
+                js.set_string_from_bytes("hash", &tx.srv_hdr.hassh)?;
+            }
+            if tx.srv_hdr.hassh_string.len() > 0 {
+                js.set_string_from_bytes("string", &tx.srv_hdr.hassh_string)?;
+            }
+            js.close()?;
         }
         js.close()?;
     }