JA3 --- JA3 的详细信息通过 ``suricata.ja3`` 库暴露给 Lua 脚本。例如:: local ja3 = require("suricata.ja3") 如果你想使用 ja3,可以在 suricata.yaml 中设置选项 ``app-layer.protocols.tls.ja3-fingerprints`` 为 true, 或者在你的 lua 脚本的 ``init`` 函数中通过调用 ``ja3.enable_ja3()`` 来指定:: function init (args) ja3.enable_ja3() return {} end 如果 ja3 被显式禁用,``ja3.enable_ja3()`` 将不会启用 ja3,因此你应该在规则中添加 ``requires: feature ja3;`` (参见 :ref:`keyword_requires`)。 为了在规则匹配中使用,规则应该在 init 脚本中需要 ``ja3`` 或 ``ja3s``:: function init (args) ja3.enable_ja3() local needs = {} needs["ja3s"] = true return needs end 事务 ~~~~~~~~~~~ JA3 是基于事务的,使用前必须先获取当前事务:: local tx, err = ja3.get_tx() if tx == err then print(err) end 所有其他函数都是事务(QUIC 或 TLS)的方法。 事务方法 ~~~~~~~~~~~~~~~~~~~ ``ja3_get_hash()`` ^^^^^^^^^^^^^^^^^^ 获取 ja3 值的哈希形式。 示例:: local tx = ja3.get_tx() local h = tx:ja3_get_hash(); print (h) ``ja3_get_string()`` ^^^^^^^^^^^^^^^^^^^^ 获取 ja3 值的字符串形式。 示例:: local tx = ja3.get_tx() local s = tx:ja3_get_string(); print (s) ``ja3s_get_hash()`` ^^^^^^^^^^^^^^^^^^^ 获取 ja3s 值的哈希形式。 示例:: local tx = ja3.get_tx() local h = tx:ja3s_get_hash(); print (h) ``ja3s_get_string()`` ^^^^^^^^^^^^^^^^^^^^^ 获取 ja3s 值的字符串形式。 示例:: local tx = ja3.get_tx() local s = tx:ja3s_get_string(); print (s)