suricata
output-json-tls.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2020 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 /**
19  * \file
20  *
21  * \author Tom DeCanio <td@npulsetech.com>
22  *
23  * Implements TLS JSON logging portion of the engine.
24  */
25 
26 #include "suricata-common.h"
27 #include "debug.h"
28 #include "detect.h"
29 #include "pkt-var.h"
30 #include "conf.h"
31 
32 #include "threads.h"
33 #include "threadvars.h"
34 #include "tm-threads.h"
35 
36 #include "util-print.h"
37 #include "util-unittest.h"
38 
39 #include "util-debug.h"
40 #include "app-layer-parser.h"
41 #include "output.h"
42 #include "app-layer-ssl.h"
43 #include "app-layer.h"
44 #include "util-privs.h"
45 #include "util-buffer.h"
46 
47 #include "util-logopenfile.h"
48 #include "util-crypt.h"
49 #include "util-ja3.h"
50 
51 #include "output-json.h"
52 #include "output-json-tls.h"
53 
54 SC_ATOMIC_EXTERN(unsigned int, cert_id);
55 
56 #define MODULE_NAME "LogTlsLog"
57 #define DEFAULT_LOG_FILENAME "tls.json"
58 
59 #define LOG_TLS_DEFAULT 0
60 #define LOG_TLS_EXTENDED (1 << 0)
61 #define LOG_TLS_CUSTOM (1 << 1)
62 #define LOG_TLS_SESSION_RESUMPTION (1 << 2)
63 
64 #define LOG_TLS_FIELD_VERSION (1 << 0)
65 #define LOG_TLS_FIELD_SUBJECT (1 << 1)
66 #define LOG_TLS_FIELD_ISSUER (1 << 2)
67 #define LOG_TLS_FIELD_SERIAL (1 << 3)
68 #define LOG_TLS_FIELD_FINGERPRINT (1 << 4)
69 #define LOG_TLS_FIELD_NOTBEFORE (1 << 5)
70 #define LOG_TLS_FIELD_NOTAFTER (1 << 6)
71 #define LOG_TLS_FIELD_SNI (1 << 7)
72 #define LOG_TLS_FIELD_CERTIFICATE (1 << 8)
73 #define LOG_TLS_FIELD_CHAIN (1 << 9)
74 #define LOG_TLS_FIELD_SESSION_RESUMED (1 << 10)
75 #define LOG_TLS_FIELD_JA3 (1 << 11)
76 #define LOG_TLS_FIELD_JA3S (1 << 12)
77 
78 typedef struct {
79  const char *name;
80  uint64_t flag;
81 } TlsFields;
82 
84  { "version", LOG_TLS_FIELD_VERSION },
85  { "subject", LOG_TLS_FIELD_SUBJECT },
86  { "issuer", LOG_TLS_FIELD_ISSUER },
87  { "serial", LOG_TLS_FIELD_SERIAL },
88  { "fingerprint", LOG_TLS_FIELD_FINGERPRINT },
89  { "not_before", LOG_TLS_FIELD_NOTBEFORE },
90  { "not_after", LOG_TLS_FIELD_NOTAFTER },
91  { "sni", LOG_TLS_FIELD_SNI },
92  { "certificate", LOG_TLS_FIELD_CERTIFICATE },
93  { "chain", LOG_TLS_FIELD_CHAIN },
94  { "session_resumed", LOG_TLS_FIELD_SESSION_RESUMED },
95  { "ja3", LOG_TLS_FIELD_JA3 },
96  { "ja3s", LOG_TLS_FIELD_JA3S },
97  { NULL, -1 }
98 };
99 
100 typedef struct OutputTlsCtx_ {
102  uint32_t flags; /** Store mode */
103  uint64_t fields; /** Store fields */
106 
107 
108 typedef struct JsonTlsLogThread_ {
113 
114 static void JsonTlsLogSubject(JsonBuilder *js, SSLState *ssl_state)
115 {
116  if (ssl_state->server_connp.cert0_subject) {
117  jb_set_string(js, "subject",
118  ssl_state->server_connp.cert0_subject);
119  }
120 }
121 
122 static void JsonTlsLogIssuer(JsonBuilder *js, SSLState *ssl_state)
123 {
124  if (ssl_state->server_connp.cert0_issuerdn) {
125  jb_set_string(js, "issuerdn",
126  ssl_state->server_connp.cert0_issuerdn);
127  }
128 }
129 
130 static void JsonTlsLogSessionResumed(JsonBuilder *js, SSLState *ssl_state)
131 {
132  if (ssl_state->flags & SSL_AL_FLAG_SESSION_RESUMED) {
133  /* Only log a session as 'resumed' if a certificate has not
134  been seen, and the session is not TLSv1.3 or later. */
135  if ((ssl_state->server_connp.cert0_issuerdn == NULL &&
136  ssl_state->server_connp.cert0_subject == NULL) &&
137  (ssl_state->flags & SSL_AL_FLAG_STATE_SERVER_HELLO) &&
138  ((ssl_state->flags & SSL_AL_FLAG_LOG_WITHOUT_CERT) == 0)) {
139  jb_set_bool(js, "session_resumed", true);
140  }
141  }
142 }
143 
144 static void JsonTlsLogFingerprint(JsonBuilder *js, SSLState *ssl_state)
145 {
146  if (ssl_state->server_connp.cert0_fingerprint) {
147  jb_set_string(js, "fingerprint",
148  ssl_state->server_connp.cert0_fingerprint);
149  }
150 }
151 
152 static void JsonTlsLogSni(JsonBuilder *js, SSLState *ssl_state)
153 {
154  if (ssl_state->client_connp.sni) {
155  jb_set_string(js, "sni",
156  ssl_state->client_connp.sni);
157  }
158 }
159 
160 static void JsonTlsLogSerial(JsonBuilder *js, SSLState *ssl_state)
161 {
162  if (ssl_state->server_connp.cert0_serial) {
163  jb_set_string(js, "serial",
164  ssl_state->server_connp.cert0_serial);
165  }
166 }
167 
168 static void JsonTlsLogVersion(JsonBuilder *js, SSLState *ssl_state)
169 {
170  char ssl_version[SSL_VERSION_MAX_STRLEN];
171  SSLVersionToString(ssl_state->server_connp.version, ssl_version);
172  jb_set_string(js, "version", ssl_version);
173 }
174 
175 static void JsonTlsLogNotBefore(JsonBuilder *js, SSLState *ssl_state)
176 {
177  if (ssl_state->server_connp.cert0_not_before != 0) {
178  char timebuf[64];
179  struct timeval tv;
180  tv.tv_sec = ssl_state->server_connp.cert0_not_before;
181  tv.tv_usec = 0;
182  CreateUtcIsoTimeString(&tv, timebuf, sizeof(timebuf));
183  jb_set_string(js, "notbefore", timebuf);
184  }
185 }
186 
187 static void JsonTlsLogNotAfter(JsonBuilder *js, SSLState *ssl_state)
188 {
189  if (ssl_state->server_connp.cert0_not_after != 0) {
190  char timebuf[64];
191  struct timeval tv;
192  tv.tv_sec = ssl_state->server_connp.cert0_not_after;
193  tv.tv_usec = 0;
194  CreateUtcIsoTimeString(&tv, timebuf, sizeof(timebuf));
195  jb_set_string(js, "notafter", timebuf);
196  }
197 }
198 
199 static void JsonTlsLogJa3Hash(JsonBuilder *js, SSLState *ssl_state)
200 {
201  if (ssl_state->client_connp.ja3_hash != NULL) {
202  jb_set_string(js, "hash",
203  ssl_state->client_connp.ja3_hash);
204  }
205 }
206 
207 static void JsonTlsLogJa3String(JsonBuilder *js, SSLState *ssl_state)
208 {
209  if ((ssl_state->client_connp.ja3_str != NULL) &&
210  ssl_state->client_connp.ja3_str->data != NULL) {
211  jb_set_string(js, "string",
212  ssl_state->client_connp.ja3_str->data);
213  }
214 }
215 
216 static void JsonTlsLogJa3(JsonBuilder *js, SSLState *ssl_state)
217 {
218  jb_open_object(js, "ja3");
219 
220  JsonTlsLogJa3Hash(js, ssl_state);
221  JsonTlsLogJa3String(js, ssl_state);
222 
223  jb_close(js);
224 }
225 
226 static void JsonTlsLogJa3SHash(JsonBuilder *js, SSLState *ssl_state)
227 {
228  if (ssl_state->server_connp.ja3_hash != NULL) {
229  jb_set_string(js, "hash",
230  ssl_state->server_connp.ja3_hash);
231  }
232 }
233 
234 static void JsonTlsLogJa3SString(JsonBuilder *js, SSLState *ssl_state)
235 {
236  if ((ssl_state->server_connp.ja3_str != NULL) &&
237  ssl_state->server_connp.ja3_str->data != NULL) {
238  jb_set_string(js, "string",
239  ssl_state->server_connp.ja3_str->data);
240  }
241 }
242 
243 static void JsonTlsLogJa3S(JsonBuilder *js, SSLState *ssl_state)
244 {
245  jb_open_object(js, "ja3s");
246 
247  JsonTlsLogJa3SHash(js, ssl_state);
248  JsonTlsLogJa3SString(js, ssl_state);
249 
250  jb_close(js);
251 }
252 
253 static void JsonTlsLogCertificate(JsonBuilder *js, SSLState *ssl_state)
254 {
255  if (TAILQ_EMPTY(&ssl_state->server_connp.certs)) {
256  return;
257  }
258 
259  SSLCertsChain *cert = TAILQ_FIRST(&ssl_state->server_connp.certs);
260  if (cert == NULL) {
261  return;
262  }
263 
264  unsigned long len = cert->cert_len * 2;
265  uint8_t encoded[len];
266  if (Base64Encode(cert->cert_data, cert->cert_len, encoded, &len) ==
267  SC_BASE64_OK) {
268  jb_set_string(js, "certificate", (char *)encoded);
269  }
270 }
271 
272 static void JsonTlsLogChain(JsonBuilder *js, SSLState *ssl_state)
273 {
274  if (TAILQ_EMPTY(&ssl_state->server_connp.certs)) {
275  return;
276  }
277 
278  jb_open_array(js, "chain");
279 
280  SSLCertsChain *cert;
281  TAILQ_FOREACH(cert, &ssl_state->server_connp.certs, next) {
282  unsigned long len = cert->cert_len * 2;
283  uint8_t encoded[len];
284  if (Base64Encode(cert->cert_data, cert->cert_len, encoded, &len) ==
285  SC_BASE64_OK) {
286  jb_append_string(js, (char *)encoded);
287  }
288  }
289 
290  jb_close(js);
291 }
292 
293 void JsonTlsLogJSONBasic(JsonBuilder *js, SSLState *ssl_state)
294 {
295  /* tls subject */
296  JsonTlsLogSubject(js, ssl_state);
297 
298  /* tls issuerdn */
299  JsonTlsLogIssuer(js, ssl_state);
300 
301  /* tls session resumption */
302  JsonTlsLogSessionResumed(js, ssl_state);
303 }
304 
305 static void JsonTlsLogJSONCustom(OutputTlsCtx *tls_ctx, JsonBuilder *js,
306  SSLState *ssl_state)
307 {
308  /* tls subject */
309  if (tls_ctx->fields & LOG_TLS_FIELD_SUBJECT)
310  JsonTlsLogSubject(js, ssl_state);
311 
312  /* tls issuerdn */
313  if (tls_ctx->fields & LOG_TLS_FIELD_ISSUER)
314  JsonTlsLogIssuer(js, ssl_state);
315 
316  /* tls session resumption */
317  if (tls_ctx->fields & LOG_TLS_FIELD_SESSION_RESUMED)
318  JsonTlsLogSessionResumed(js, ssl_state);
319 
320  /* tls serial */
321  if (tls_ctx->fields & LOG_TLS_FIELD_SERIAL)
322  JsonTlsLogSerial(js, ssl_state);
323 
324  /* tls fingerprint */
325  if (tls_ctx->fields & LOG_TLS_FIELD_FINGERPRINT)
326  JsonTlsLogFingerprint(js, ssl_state);
327 
328  /* tls sni */
329  if (tls_ctx->fields & LOG_TLS_FIELD_SNI)
330  JsonTlsLogSni(js, ssl_state);
331 
332  /* tls version */
333  if (tls_ctx->fields & LOG_TLS_FIELD_VERSION)
334  JsonTlsLogVersion(js, ssl_state);
335 
336  /* tls notbefore */
337  if (tls_ctx->fields & LOG_TLS_FIELD_NOTBEFORE)
338  JsonTlsLogNotBefore(js, ssl_state);
339 
340  /* tls notafter */
341  if (tls_ctx->fields & LOG_TLS_FIELD_NOTAFTER)
342  JsonTlsLogNotAfter(js, ssl_state);
343 
344  /* tls certificate */
345  if (tls_ctx->fields & LOG_TLS_FIELD_CERTIFICATE)
346  JsonTlsLogCertificate(js, ssl_state);
347 
348  /* tls chain */
349  if (tls_ctx->fields & LOG_TLS_FIELD_CHAIN)
350  JsonTlsLogChain(js, ssl_state);
351 
352  /* tls ja3_hash */
353  if (tls_ctx->fields & LOG_TLS_FIELD_JA3)
354  JsonTlsLogJa3(js, ssl_state);
355 
356  /* tls ja3s */
357  if (tls_ctx->fields & LOG_TLS_FIELD_JA3S)
358  JsonTlsLogJa3S(js, ssl_state);
359 }
360 
361 void JsonTlsLogJSONExtended(JsonBuilder *tjs, SSLState * state)
362 {
363  JsonTlsLogJSONBasic(tjs, state);
364 
365  /* tls serial */
366  JsonTlsLogSerial(tjs, state);
367 
368  /* tls fingerprint */
369  JsonTlsLogFingerprint(tjs, state);
370 
371  /* tls sni */
372  JsonTlsLogSni(tjs, state);
373 
374  /* tls version */
375  JsonTlsLogVersion(tjs, state);
376 
377  /* tls notbefore */
378  JsonTlsLogNotBefore(tjs, state);
379 
380  /* tls notafter */
381  JsonTlsLogNotAfter(tjs, state);
382 
383  /* tls ja3 */
384  JsonTlsLogJa3(tjs, state);
385 
386  /* tls ja3s */
387  JsonTlsLogJa3S(tjs, state);
388 }
389 
390 static int JsonTlsLogger(ThreadVars *tv, void *thread_data, const Packet *p,
391  Flow *f, void *state, void *txptr, uint64_t tx_id)
392 {
393  JsonTlsLogThread *aft = (JsonTlsLogThread *)thread_data;
394  OutputTlsCtx *tls_ctx = aft->tlslog_ctx;
395 
396  SSLState *ssl_state = (SSLState *)state;
397  if (unlikely(ssl_state == NULL)) {
398  return 0;
399  }
400 
401  if ((ssl_state->server_connp.cert0_issuerdn == NULL ||
402  ssl_state->server_connp.cert0_subject == NULL) &&
403  ((ssl_state->flags & SSL_AL_FLAG_SESSION_RESUMED) == 0 ||
404  (tls_ctx->flags & LOG_TLS_SESSION_RESUMPTION) == 0) &&
405  ((ssl_state->flags & SSL_AL_FLAG_LOG_WITHOUT_CERT) == 0)) {
406  return 0;
407  }
408 
409  JsonBuilder *js = CreateEveHeader(p, LOG_DIR_FLOW, "tls", NULL);
410  if (unlikely(js == NULL)) {
411  return 0;
412  }
413 
414  EveAddCommonOptions(&tls_ctx->cfg, p, f, js);
415 
416  jb_open_object(js, "tls");
417 
418  /* reset */
419  MemBufferReset(aft->buffer);
420 
421  /* log custom fields */
422  if (tls_ctx->flags & LOG_TLS_CUSTOM) {
423  JsonTlsLogJSONCustom(tls_ctx, js, ssl_state);
424  }
425  /* log extended */
426  else if (tls_ctx->flags & LOG_TLS_EXTENDED) {
427  JsonTlsLogJSONExtended(js, ssl_state);
428  }
429  /* log basic */
430  else {
431  JsonTlsLogJSONBasic(js, ssl_state);
432  }
433 
434  /* print original application level protocol when it have been changed
435  because of STARTTLS, HTTP CONNECT, or similar. */
436  if (f->alproto_orig != ALPROTO_UNKNOWN) {
437  jb_set_string(js, "from_proto",
439  }
440 
441  /* Close the tls object. */
442  jb_close(js);
443 
444  OutputJsonBuilderBuffer(js, aft->file_ctx, &aft->buffer);
445  jb_free(js);
446 
447  return 0;
448 }
449 
450 static TmEcode JsonTlsLogThreadInit(ThreadVars *t, const void *initdata, void **data)
451 {
452  JsonTlsLogThread *aft = SCCalloc(1, sizeof(JsonTlsLogThread));
453  if (unlikely(aft == NULL)) {
454  return TM_ECODE_FAILED;
455  }
456 
457  if (initdata == NULL) {
458  SCLogDebug("Error getting context for eve-log tls 'initdata' argument NULL");
459  goto error_exit;
460  }
461 
463  if (aft->buffer == NULL) {
464  goto error_exit;
465  }
466 
467  /* use the Output Context (file pointer and mutex) */
468  aft->tlslog_ctx = ((OutputCtx *)initdata)->data;
469 
471  if (!aft->file_ctx) {
472  goto error_exit;
473  }
474  *data = (void *)aft;
475  return TM_ECODE_OK;
476 
477 error_exit:
478  if (aft->buffer != NULL) {
479  MemBufferFree(aft->buffer);
480  }
481  SCFree(aft);
482  return TM_ECODE_FAILED;
483 }
484 
485 static TmEcode JsonTlsLogThreadDeinit(ThreadVars *t, void *data)
486 {
487  JsonTlsLogThread *aft = (JsonTlsLogThread *)data;
488  if (aft == NULL) {
489  return TM_ECODE_OK;
490  }
491 
492  MemBufferFree(aft->buffer);
493 
494  /* clear memory */
495  memset(aft, 0, sizeof(JsonTlsLogThread));
496 
497  SCFree(aft);
498  return TM_ECODE_OK;
499 }
500 
501 static OutputTlsCtx *OutputTlsInitCtx(ConfNode *conf)
502 {
503  OutputTlsCtx *tls_ctx = SCMalloc(sizeof(OutputTlsCtx));
504  if (unlikely(tls_ctx == NULL))
505  return NULL;
506 
507  tls_ctx->flags = LOG_TLS_DEFAULT;
508  tls_ctx->fields = 0;
509 
510  if (conf == NULL)
511  return tls_ctx;
512 
513  const char *extended = ConfNodeLookupChildValue(conf, "extended");
514  if (extended) {
515  if (ConfValIsTrue(extended)) {
516  tls_ctx->flags = LOG_TLS_EXTENDED;
517  }
518  }
519 
520  ConfNode *custom = ConfNodeLookupChild(conf, "custom");
521  if (custom) {
522  tls_ctx->flags = LOG_TLS_CUSTOM;
523  ConfNode *field;
524  TAILQ_FOREACH(field, &custom->head, next)
525  {
526  TlsFields *valid_fields = tls_fields;
527  for ( ; valid_fields->name != NULL; valid_fields++) {
528  if (strcasecmp(field->val, valid_fields->name) == 0) {
529  tls_ctx->fields |= valid_fields->flag;
530  break;
531  }
532  }
533  }
534  }
535 
536  const char *session_resumption = ConfNodeLookupChildValue(conf, "session-resumption");
537  if (session_resumption == NULL || ConfValIsTrue(session_resumption)) {
538  tls_ctx->flags |= LOG_TLS_SESSION_RESUMPTION;
539  }
540 
541  if ((tls_ctx->fields & LOG_TLS_FIELD_JA3) &&
542  Ja3IsDisabled("fields")) {
543  /* JA3 is disabled, so don't log any JA3 fields */
544  tls_ctx->fields &= ~LOG_TLS_FIELD_JA3;
545  tls_ctx->fields &= ~LOG_TLS_FIELD_JA3S;
546  }
547 
548  if ((tls_ctx->fields & LOG_TLS_FIELD_CERTIFICATE) &&
549  (tls_ctx->fields & LOG_TLS_FIELD_CHAIN)) {
551  "Both 'certificate' and 'chain' contains the top "
552  "certificate, so only one of them should be enabled "
553  "at a time");
554  }
555 
556  return tls_ctx;
557 }
558 
559 static void OutputTlsLogDeinitSub(OutputCtx *output_ctx)
560 {
561  OutputTlsCtx *tls_ctx = output_ctx->data;
562  SCFree(tls_ctx);
563  SCFree(output_ctx);
564 }
565 
566 static OutputInitResult OutputTlsLogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
567 {
568  OutputInitResult result = { NULL, false };
569  OutputJsonCtx *ojc = parent_ctx->data;
570 
571  OutputTlsCtx *tls_ctx = OutputTlsInitCtx(conf);
572  if (unlikely(tls_ctx == NULL))
573  return result;
574 
575  OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
576  if (unlikely(output_ctx == NULL)) {
577  SCFree(tls_ctx);
578  return result;
579  }
580 
581  tls_ctx->file_ctx = ojc->file_ctx;
582  tls_ctx->cfg = ojc->cfg;
583 
584  if ((tls_ctx->fields & LOG_TLS_FIELD_CERTIFICATE) &&
585  (tls_ctx->fields & LOG_TLS_FIELD_CHAIN)) {
587  "Both 'certificate' and 'chain' contains the top "
588  "certificate, so only one of them should be enabled "
589  "at a time");
590  }
591 
592  output_ctx->data = tls_ctx;
593  output_ctx->DeInit = OutputTlsLogDeinitSub;
594 
596 
597  result.ctx = output_ctx;
598  result.ok = true;
599  return result;
600 }
601 
603 {
604  /* register as child of eve-log */
606  "JsonTlsLog", "eve-log.tls", OutputTlsLogInitSub, ALPROTO_TLS,
607  JsonTlsLogger, TLS_HANDSHAKE_DONE, TLS_HANDSHAKE_DONE,
608  JsonTlsLogThreadInit, JsonTlsLogThreadDeinit, NULL);
609 }
SSLStateConnp_::cert0_not_before
time_t cert0_not_before
Definition: app-layer-ssl.h:205
tm-threads.h
SSLStateConnp_::cert0_subject
char * cert0_subject
Definition: app-layer-ssl.h:202
SSLState_
SSLv[2.0|3.[0|1|2|3]] state structure.
Definition: app-layer-ssl.h:233
len
uint8_t len
Definition: app-layer-dnp3.h:2
LOG_TLS_FIELD_NOTBEFORE
#define LOG_TLS_FIELD_NOTBEFORE
Definition: output-json-tls.c:69
SSLCertsChain_::cert_len
uint32_t cert_len
Definition: app-layer-ssl.h:174
JsonTlsLogJSONBasic
void JsonTlsLogJSONBasic(JsonBuilder *js, SSLState *ssl_state)
Definition: output-json-tls.c:293
LOG_TLS_DEFAULT
#define LOG_TLS_DEFAULT
Definition: output-json-tls.c:59
ConfNode_::val
char * val
Definition: conf.h:34
OutputJsonCtx_::cfg
OutputJsonCommonSettings cfg
Definition: output-json.h:104
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
LOG_TLS_FIELD_JA3
#define LOG_TLS_FIELD_JA3
Definition: output-json-tls.c:75
SSLState_::client_connp
SSLStateConnp client_connp
Definition: app-layer-ssl.h:250
ALPROTO_TLS
@ ALPROTO_TLS
Definition: app-layer-protos.h:33
SC_WARN_DUPLICATE_OUTPUT
@ SC_WARN_DUPLICATE_OUTPUT
Definition: util-error.h:329
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:298
next
struct HtpBodyChunk_ * next
Definition: app-layer-htp.h:0
SSLState_::server_connp
SSLStateConnp server_connp
Definition: app-layer-ssl.h:251
SSL_AL_FLAG_SESSION_RESUMED
#define SSL_AL_FLAG_SESSION_RESUMED
Definition: app-layer-ssl.h:111
SSLStateConnp_::ja3_hash
char * ja3_hash
Definition: app-layer-ssl.h:219
JSON_OUTPUT_BUFFER_SIZE
#define JSON_OUTPUT_BUFFER_SIZE
Definition: output-json.h:63
threads.h
OutputJsonCtx_
Definition: output-json.h:101
Flow_
Flow data structure.
Definition: flow.h:347
OutputJsonCommonSettings_
Definition: output-json.h:91
SSL_AL_FLAG_STATE_SERVER_HELLO
#define SSL_AL_FLAG_STATE_SERVER_HELLO
Definition: app-layer-ssl.h:91
LogFileCtx_
Definition: util-logopenfile.h:60
TlsFields
Definition: output-json-tls.c:78
OutputTlsCtx_::cfg
OutputJsonCommonSettings cfg
Definition: output-json-tls.c:104
JsonTlsLogThread_::file_ctx
LogFileCtx * file_ctx
Definition: output-json-tls.c:109
SSL_VERSION_MAX_STRLEN
#define SSL_VERSION_MAX_STRLEN
Definition: app-layer-ssl.h:139
LOG_TLS_FIELD_NOTAFTER
#define LOG_TLS_FIELD_NOTAFTER
Definition: output-json-tls.c:70
TAILQ_EMPTY
#define TAILQ_EMPTY(head)
Definition: queue.h:347
TAILQ_FOREACH
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:350
Flow_::alproto_orig
AppProto alproto_orig
Definition: flow.h:456
output-json-tls.h
JA3Buffer_::data
char * data
Definition: util-ja3.h:30
OutputJsonBuilderBuffer
int OutputJsonBuilderBuffer(JsonBuilder *js, LogFileCtx *file_ctx, MemBuffer **buffer)
Definition: output-json.c:978
util-ja3.h
util-privs.h
EveAddCommonOptions
void EveAddCommonOptions(const OutputJsonCommonSettings *cfg, const Packet *p, const Flow *f, JsonBuilder *js)
Definition: output-json.c:444
SSLStateConnp_::sni
char * sni
Definition: app-layer-ssl.h:210
LOG_TLS_FIELD_SUBJECT
#define LOG_TLS_FIELD_SUBJECT
Definition: output-json-tls.c:65
TM_ECODE_FAILED
@ TM_ECODE_FAILED
Definition: tm-threads-common.h:81
LOGGER_JSON_TLS
@ LOGGER_JSON_TLS
Definition: suricata-common.h:452
JsonTlsLogThread
struct JsonTlsLogThread_ JsonTlsLogThread
LOG_TLS_FIELD_FINGERPRINT
#define LOG_TLS_FIELD_FINGERPRINT
Definition: output-json-tls.c:68
JsonTlsLogRegister
void JsonTlsLogRegister(void)
Definition: output-json-tls.c:602
TlsFields::flag
uint64_t flag
Definition: output-json-tls.c:80
SC_BASE64_OK
@ SC_BASE64_OK
Definition: util-crypt.h:37
OutputTlsCtx_::file_ctx
LogFileCtx * file_ctx
Definition: output-json-tls.c:101
util-unittest.h
SSLStateConnp_::cert0_issuerdn
char * cert0_issuerdn
Definition: app-layer-ssl.h:203
ConfValIsTrue
int ConfValIsTrue(const char *val)
Check if a value is true.
Definition: conf.c:565
OutputCtx_::data
void * data
Definition: tm-modules.h:81
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:80
OutputCtx_
Definition: tm-modules.h:78
Ja3IsDisabled
int Ja3IsDisabled(const char *type)
Check if JA3 is disabled.
Definition: util-ja3.c:263
SSLStateConnp_::cert0_not_after
time_t cert0_not_after
Definition: app-layer-ssl.h:206
Base64Encode
int Base64Encode(const unsigned char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen)
Definition: util-crypt.c:272
util-debug.h
TlsFields::name
const char * name
Definition: output-json-tls.c:79
TAILQ_FIRST
#define TAILQ_FIRST(head)
Definition: queue.h:339
LOG_TLS_FIELD_JA3S
#define LOG_TLS_FIELD_JA3S
Definition: output-json-tls.c:76
OutputInitResult_::ctx
OutputCtx * ctx
Definition: output.h:44
CreateEveHeader
JsonBuilder * CreateEveHeader(const Packet *p, enum OutputJsonLogDirection dir, const char *event_type, JsonAddrInfo *addr)
Definition: output-json.c:846
output-json.h
OutputRegisterTxSubModuleWithProgress
void OutputRegisterTxSubModuleWithProgress(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, AppProto alproto, TxLogger TxLogFunc, int tc_log_progress, int ts_log_progress, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Definition: output.c:378
LOG_TLS_CUSTOM
#define LOG_TLS_CUSTOM
Definition: output-json-tls.c:61
AppLayerParserRegisterLogger
void AppLayerParserRegisterLogger(uint8_t ipproto, AppProto alproto)
Definition: app-layer-parser.c:456
SSLCertsChain_
Definition: app-layer-ssl.h:172
util-print.h
util-crypt.h
detect.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
pkt-var.h
LogFileEnsureExists
LogFileCtx * LogFileEnsureExists(LogFileCtx *parent_ctx, int thread_id)
LogFileEnsureExists() Ensure a log file context for the thread exists.
Definition: util-logopenfile.c:659
OutputTlsCtx_::flags
uint32_t flags
Definition: output-json-tls.c:102
SSLVersionToString
void SSLVersionToString(uint16_t version, char *buffer)
Definition: app-layer-ssl.c:316
OutputInitResult_::ok
bool ok
Definition: output.h:45
app-layer-parser.h
ThreadVars_::id
int id
Definition: threadvars.h:87
LOG_TLS_FIELD_SERIAL
#define LOG_TLS_FIELD_SERIAL
Definition: output-json-tls.c:67
Packet_
Definition: decode.h:414
conf.h
TLS_HANDSHAKE_DONE
@ TLS_HANDSHAKE_DONE
Definition: app-layer-ssl.h:71
OutputTlsCtx
struct OutputTlsCtx_ OutputTlsCtx
TmEcode
TmEcode
Definition: tm-threads-common.h:79
SSLCertsChain_::cert_data
uint8_t * cert_data
Definition: app-layer-ssl.h:173
MemBuffer_
Definition: util-buffer.h:27
LOG_TLS_FIELD_ISSUER
#define LOG_TLS_FIELD_ISSUER
Definition: output-json-tls.c:66
ConfNodeLookupChild
ConfNode * ConfNodeLookupChild(const ConfNode *node, const char *name)
Lookup a child configuration node by name.
Definition: conf.c:814
MemBufferReset
#define MemBufferReset(mem_buffer)
Reset the mem buffer.
Definition: util-buffer.h:42
OutputInitResult_
Definition: output.h:43
suricata-common.h
OutputCtx_::DeInit
void(* DeInit)(struct OutputCtx_ *)
Definition: tm-modules.h:84
MemBufferFree
void MemBufferFree(MemBuffer *buffer)
Definition: util-buffer.c:82
JsonTlsLogThread_::buffer
MemBuffer * buffer
Definition: output-json-tls.c:111
tls_fields
TlsFields tls_fields[]
Definition: output-json-tls.c:83
LOG_TLS_FIELD_CERTIFICATE
#define LOG_TLS_FIELD_CERTIFICATE
Definition: output-json-tls.c:72
OutputTlsCtx_
Definition: output-json-tls.c:100
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:29
threadvars.h
LOG_DIR_FLOW
@ LOG_DIR_FLOW
Definition: output-json.h:40
SCMalloc
#define SCMalloc(sz)
Definition: util-mem.h:47
SCLogWarning
#define SCLogWarning(err_code,...)
Macro used to log WARNING messages.
Definition: util-debug.h:244
SCFree
#define SCFree(p)
Definition: util-mem.h:61
ConfNode_
Definition: conf.h:32
util-logopenfile.h
util-buffer.h
AppLayerGetProtoName
const char * AppLayerGetProtoName(AppProto alproto)
Given the internal protocol id, returns a string representation of the protocol.
Definition: app-layer.c:794
ALPROTO_UNKNOWN
@ ALPROTO_UNKNOWN
Definition: app-layer-protos.h:29
OutputJsonCtx_::file_ctx
LogFileCtx * file_ctx
Definition: output-json.h:102
OutputTlsCtx_::fields
uint64_t fields
Definition: output-json-tls.c:103
LOG_TLS_FIELD_SNI
#define LOG_TLS_FIELD_SNI
Definition: output-json-tls.c:71
SSLStateConnp_::cert0_fingerprint
char * cert0_fingerprint
Definition: app-layer-ssl.h:207
LOG_TLS_EXTENDED
#define LOG_TLS_EXTENDED
Definition: output-json-tls.c:60
SSLStateConnp_::ja3_str
JA3Buffer * ja3_str
Definition: app-layer-ssl.h:218
JsonTlsLogThread_::tlslog_ctx
OutputTlsCtx * tlslog_ctx
Definition: output-json-tls.c:110
LOG_TLS_FIELD_SESSION_RESUMED
#define LOG_TLS_FIELD_SESSION_RESUMED
Definition: output-json-tls.c:74
LOG_TLS_SESSION_RESUMPTION
#define LOG_TLS_SESSION_RESUMPTION
Definition: output-json-tls.c:62
JsonTlsLogJSONExtended
void JsonTlsLogJSONExtended(JsonBuilder *tjs, SSLState *state)
Definition: output-json-tls.c:361
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
LOG_TLS_FIELD_CHAIN
#define LOG_TLS_FIELD_CHAIN
Definition: output-json-tls.c:73
CreateUtcIsoTimeString
void CreateUtcIsoTimeString(const struct timeval *ts, char *str, size_t size)
Definition: util-time.c:233
SSLStateConnp_::cert0_serial
char * cert0_serial
Definition: app-layer-ssl.h:204
LOG_TLS_FIELD_VERSION
#define LOG_TLS_FIELD_VERSION
Definition: output-json-tls.c:64
JsonTlsLogThread_
Definition: output-json-tls.c:108
app-layer-ssl.h
SSL_AL_FLAG_LOG_WITHOUT_CERT
#define SSL_AL_FLAG_LOG_WITHOUT_CERT
Definition: app-layer-ssl.h:118
MemBufferCreateNew
MemBuffer * MemBufferCreateNew(uint32_t size)
Definition: util-buffer.c:32
debug.h
output.h
SC_ATOMIC_EXTERN
SC_ATOMIC_EXTERN(unsigned int, cert_id)
app-layer.h
SSLState_::flags
uint32_t flags
Definition: app-layer-ssl.h:239
SSLStateConnp_::version
uint16_t version
Definition: app-layer-ssl.h:189
ConfNodeLookupChildValue
const char * ConfNodeLookupChildValue(const ConfNode *node, const char *name)
Lookup the value of a child configuration node by name.
Definition: conf.c:842