SSH ---
SSH事务的详细信息通过 suricata.ssh
库暴露给Lua脚本。例如:
local ssh = require("suricata.ssh")
如需使用hassh功能,可在suricata.yaml中设置 app-layer.protocols.ssh.hassh
为true,
或在Lua脚本的 init
函数中调用 ssh.enable_hassh()
来启用:
function init (args)
ssh.enable_hassh()
return {}
end
用于规则匹配时,规则必须**挂钩**到SSH事务状态。可用状态见 钩子函数。 例如:
alert ssh:response_banner_done any any -> any any (...
20.3.24. 配置¶
若需创建日志脚本,按如下方式初始化缓冲区:
function init (args)
local needs = {}
return needs
end
若将脚本用于规则匹配,请选择 lua-detection 中列出的可用SSH缓冲区, 并按以下模式操作:
function init (args)
local needs = {}
return needs
end
20.3.24.1. 事务¶
SSH基于事务机制,使用前需获取当前事务:
local tx, err = ssh.get_tx()
if tx == err then
print(err)
end
其他所有函数均为事务表的方法。
20.3.24.2. 事务方法¶
20.3.25. server_proto()
¶
获取字符串类型的 server_proto
值。
示例:
local tx = ssh.get_tx()
local proto = tx:server_proto();
print (proto)
20.3.26. client_proto()
¶
获取字符串类型的 client_proto
值。
示例:
local tx = ssh.get_tx()
local proto = tx:client_proto();
print (proto)
20.3.27. server_software()
¶
获取字符串类型的 server_software
值。
示例:
local tx = ssh.get_tx()
local software = tx:server_software();
print (software)
20.3.28. client_software()
¶
获取字符串类型的 client_software
值。
示例:
local tx = ssh.get_tx()
local software = tx:client_software();
print (software)
20.3.29. client_hassh()
¶
需配合 ssh.enable_hassh()
使用。
通过client_hassh获取客户端使用的hassh算法MD5值。
示例:
local tx = ssh.get_tx()
local h = tx:client_hassh();
print (h)
20.3.30. client_hassh_string()
¶
需配合 ssh.enable_hassh()
使用。
通过client_hassh_string获取客户端使用的hassh算法字符串。
示例:
local tx = ssh.get_tx()
local h = tx:client_hassh_string();
print (h)
20.3.31. server_hassh()
¶
需配合 ssh.enable_hassh()
使用。
通过server_hassh获取服务端使用的hassh算法MD5值。
示例:
local tx = ssh.get_tx()
local h = tx:server_hassh();
print (h)
20.3.32. server_hassh_string()
¶
需配合 ssh.enable_hassh()
使用。
通过server_hassh_string获取服务端使用的hassh算法字符串。
示例:
local tx = ssh.get_tx()
local h = tx:server_hassh_string();
print (h)