33 static const char ja3_tx[] =
"suricata:ja3:tx";
52 struct LuaTx *ltx = (
struct LuaTx *)lua_newuserdata(L,
sizeof(*ltx));
59 luaL_getmetatable(L, ja3_tx);
60 lua_setmetatable(L, -2);
67 struct LuaTx *ltx = luaL_testudata(L, 1, ja3_tx);
81 const uint8_t *buf = NULL;
83 if (!SCQuicTxGetJa3(ltx->
tx, STREAM_TOSERVER, &buf, &b_len)) {
87 uint8_t ja3_hash[SC_MD5_HEX_LEN + 1];
89 SCMd5HashBufferToHex(buf, b_len, (
char *)ja3_hash, SC_MD5_HEX_LEN + 1);
93 static int LuaJa3TxGetString(
lua_State *L)
95 struct LuaTx *ltx = luaL_testudata(L, 1, ja3_tx);
110 const uint8_t *buf = NULL;
112 if (!SCQuicTxGetJa3(ltx->
tx, STREAM_TOSERVER, &buf, &b_len)) {
119 static int LuaJa3TxGetServerHash(
lua_State *L)
121 struct LuaTx *ltx = luaL_testudata(L, 1, ja3_tx);
135 const uint8_t *buf = NULL;
137 if (!SCQuicTxGetJa3(ltx->
tx, STREAM_TOCLIENT, &buf, &b_len)) {
141 uint8_t ja3_hash[SC_MD5_HEX_LEN + 1];
143 SCMd5HashBufferToHex(buf, b_len, (
char *)ja3_hash, SC_MD5_HEX_LEN + 1);
147 static int LuaJa3TxGetServerString(
lua_State *L)
149 struct LuaTx *ltx = luaL_testudata(L, 1, ja3_tx);
164 const uint8_t *buf = NULL;
166 if (!SCQuicTxGetJa3(ltx->
tx, STREAM_TOCLIENT, &buf, &b_len)) {
173 static const struct luaL_Reg txlib[] = {
175 {
"ja3_get_hash", LuaJa3TxGetHash },
176 {
"ja3_get_string", LuaJa3TxGetString },
177 {
"ja3s_get_hash", LuaJa3TxGetServerHash },
178 {
"ja3s_get_string", LuaJa3TxGetServerString },
189 static const struct luaL_Reg ja3lib[] = {
191 {
"get_tx", LuaJa3GetTx },
192 {
"enable_ja3", LuaJa3Enable },
199 luaL_newmetatable(L, ja3_tx);
200 lua_pushvalue(L, -1);
201 lua_setfield(L, -2,
"__index");
202 luaL_setfuncs(L, txlib, 0);
204 luaL_newlib(L, ja3lib);