suricata
detect-tls.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011-2012 ANSSI
3  * Copyright (C) 2022-2025 Open Information Security Foundation
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * 3. The name of the author may not be used to endorse or promote products
15  * derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
19  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
20  * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 /**
30  * \file
31  *
32  * \author Pierre Chifflier <pierre.chifflier@ssi.gouv.fr>
33  *
34  * Implements the tls.* keywords
35  */
36 
37 #include "suricata-common.h"
38 #include "threads.h"
39 #include "decode.h"
40 
41 #include "detect.h"
42 #include "detect-parse.h"
43 #include "detect-content.h"
44 
45 #include "detect-engine.h"
46 #include "detect-engine-mpm.h"
47 #include "detect-engine-state.h"
48 
49 #include "flow.h"
50 #include "flow-var.h"
51 #include "flow-util.h"
52 
53 #include "util-debug.h"
54 #include "util-unittest-helper.h"
55 
56 #include "app-layer.h"
57 
58 #include "app-layer-ssl.h"
59 #include "detect-tls.h"
61 
62 #include "stream-tcp.h"
63 
64 /**
65  * \brief Regex for parsing "id" option, matching number or "number"
66  */
67 
68 #define PARSE_REGEX "^([A-z0-9\\s\\-\\.=,\\*@]+|\"[A-z0-9\\s\\-\\.=,\\*@]+\")\\s*$"
69 #define PARSE_REGEX_FINGERPRINT "^([A-z0-9\\:\\*]+|\"[A-z0-9\\:\\* ]+\")\\s*$"
70 
71 static DetectParseRegex subject_parse_regex;
72 static DetectParseRegex issuerdn_parse_regex;
73 static DetectParseRegex fingerprint_parse_regex;
74 
75 static int DetectTlsSubjectMatch (DetectEngineThreadCtx *,
76  Flow *, uint8_t, void *, void *,
77  const Signature *, const SigMatchCtx *);
78 static int DetectTlsSubjectSetup (DetectEngineCtx *, Signature *, const char *);
79 static void DetectTlsSubjectFree(DetectEngineCtx *, void *);
80 
81 static int DetectTlsIssuerDNMatch (DetectEngineThreadCtx *,
82  Flow *, uint8_t, void *, void *,
83  const Signature *, const SigMatchCtx *);
84 static int DetectTlsIssuerDNSetup (DetectEngineCtx *, Signature *, const char *);
85 static void DetectTlsIssuerDNFree(DetectEngineCtx *, void *);
86 
87 static int DetectTlsFingerprintSetup (DetectEngineCtx *, Signature *, const char *);
88 static void DetectTlsFingerprintFree(DetectEngineCtx *, void *);
89 
90 static int DetectTlsStoreSetup (DetectEngineCtx *, Signature *, const char *);
91 static int DetectTlsStorePostMatch (DetectEngineThreadCtx *det_ctx,
92  Packet *, const Signature *s, const SigMatchCtx *unused);
93 
94 static int g_tls_cert_list_id = 0;
95 static int g_tls_cert_fingerprint_list_id = 0;
96 
97 /**
98  * \brief Registration function for keyword: tls.version
99  */
100 void DetectTlsRegister (void)
101 {
102  sigmatch_table[DETECT_TLS_SUBJECT].name = "tls.subject";
103  sigmatch_table[DETECT_TLS_SUBJECT].desc = "match TLS/SSL certificate Subject field";
104  sigmatch_table[DETECT_TLS_SUBJECT].url = "/rules/tls-keywords.html#tls-subject";
105  sigmatch_table[DETECT_TLS_SUBJECT].AppLayerTxMatch = DetectTlsSubjectMatch;
106  sigmatch_table[DETECT_TLS_SUBJECT].Setup = DetectTlsSubjectSetup;
107  sigmatch_table[DETECT_TLS_SUBJECT].Free = DetectTlsSubjectFree;
110 
111  sigmatch_table[DETECT_TLS_ISSUERDN].name = "tls.issuerdn";
112  sigmatch_table[DETECT_TLS_ISSUERDN].desc = "match TLS/SSL certificate IssuerDN field";
113  sigmatch_table[DETECT_TLS_ISSUERDN].url = "/rules/tls-keywords.html#tls-issuerdn";
114  sigmatch_table[DETECT_TLS_ISSUERDN].AppLayerTxMatch = DetectTlsIssuerDNMatch;
115  sigmatch_table[DETECT_TLS_ISSUERDN].Setup = DetectTlsIssuerDNSetup;
116  sigmatch_table[DETECT_TLS_ISSUERDN].Free = DetectTlsIssuerDNFree;
120 
121  sigmatch_table[DETECT_TLS_FINGERPRINT].name = "tls.fingerprint";
122  sigmatch_table[DETECT_TLS_FINGERPRINT].desc = "match TLS/SSL certificate SHA1 fingerprint";
123  sigmatch_table[DETECT_TLS_FINGERPRINT].url = "/rules/tls-keywords.html#tls-fingerprint";
124  sigmatch_table[DETECT_TLS_FINGERPRINT].Setup = DetectTlsFingerprintSetup;
125  sigmatch_table[DETECT_TLS_FINGERPRINT].Free = DetectTlsFingerprintFree;
129 
130  sigmatch_table[DETECT_TLS_STORE].name = "tls_store";
131  sigmatch_table[DETECT_TLS_STORE].alias = "tls.store";
132  sigmatch_table[DETECT_TLS_STORE].desc = "store TLS/SSL certificate on disk";
133  sigmatch_table[DETECT_TLS_STORE].url = "/rules/tls-keywords.html#tls-store";
134  sigmatch_table[DETECT_TLS_STORE].Match = DetectTlsStorePostMatch;
135  sigmatch_table[DETECT_TLS_STORE].Setup = DetectTlsStoreSetup;
137 
138  DetectSetupParseRegexes(PARSE_REGEX, &subject_parse_regex);
139  DetectSetupParseRegexes(PARSE_REGEX, &issuerdn_parse_regex);
140  DetectSetupParseRegexes(PARSE_REGEX_FINGERPRINT, &fingerprint_parse_regex);
141 
142  g_tls_cert_list_id = DetectBufferTypeRegister("tls_cert");
143  g_tls_cert_fingerprint_list_id = DetectBufferTypeRegister("tls.cert_fingerprint");
144 
147 
150 }
151 
152 /**
153  * \brief match the specified Subject on a tls session
154  *
155  * \param t pointer to thread vars
156  * \param det_ctx pointer to the pattern matcher thread
157  * \param p pointer to the current packet
158  * \param m pointer to the sigmatch that we will cast into DetectTlsData
159  *
160  * \retval 0 no match
161  * \retval 1 match
162  */
163 static int DetectTlsSubjectMatch (DetectEngineThreadCtx *det_ctx,
164  Flow *f, uint8_t flags, void *state, void *txv,
165  const Signature *s, const SigMatchCtx *m)
166 {
167  SCEnter();
168 
169  const DetectTlsData *tls_data = (const DetectTlsData *)m;
170  SSLState *ssl_state = (SSLState *)state;
171  if (ssl_state == NULL) {
172  SCLogDebug("no tls state, no match");
173  SCReturnInt(0);
174  }
175 
176  int ret = 0;
177 
178  SSLStateConnp *connp = NULL;
179  if (flags & STREAM_TOSERVER) {
180  connp = &ssl_state->client_connp;
181  } else {
182  connp = &ssl_state->server_connp;
183  }
184 
185  if (connp->cert0_subject != NULL) {
186  SCLogDebug("TLS: Subject is [%s], looking for [%s]\n",
187  connp->cert0_subject, tls_data->subject);
188 
189  if (SpmSearch(connp->cert0_subject, connp->cert0_subject_len,
190  (const uint8_t *)tls_data->subject,
191  (uint16_t)strlen(tls_data->subject)) != NULL) {
192  if (tls_data->flags & DETECT_CONTENT_NEGATED) {
193  ret = 0;
194  } else {
195  ret = 1;
196  }
197  } else {
198  if (tls_data->flags & DETECT_CONTENT_NEGATED) {
199  ret = 1;
200  } else {
201  ret = 0;
202  }
203  }
204  } else {
205  ret = 0;
206  }
207 
208  SCReturnInt(ret);
209 }
210 
211 /**
212  * \brief This function is used to parse IPV4 ip_id passed via keyword: "id"
213  *
214  * \param de_ctx Pointer to the detection engine context
215  * \param str Pointer to the user provided id option
216  *
217  * \retval id_d pointer to DetectTlsData on success
218  * \retval NULL on failure
219  */
220 static DetectTlsData *DetectTlsSubjectParse (DetectEngineCtx *de_ctx, const char *str, bool negate)
221 {
222  DetectTlsData *tls = NULL;
223  size_t pcre2_len;
224  const char *str_ptr;
225  char *orig = NULL;
226  char *tmp_str;
227  uint32_t flag = 0;
228 
229  pcre2_match_data *match = NULL;
230  int ret = DetectParsePcreExec(&subject_parse_regex, &match, str, 0, 0);
231  if (ret != 2) {
232  SCLogError("invalid tls.subject option");
233  goto error;
234  }
235 
236  if (negate)
237  flag = DETECT_CONTENT_NEGATED;
238 
239  int res = pcre2_substring_get_bynumber(match, 1, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
240  if (res < 0) {
241  SCLogError("pcre2_substring_get_bynumber failed");
242  goto error;
243  }
244 
245  /* We have a correct id option */
246  tls = SCMalloc(sizeof(DetectTlsData));
247  if (unlikely(tls == NULL))
248  goto error;
249  tls->subject = NULL;
250  tls->flags = flag;
251 
252  orig = SCStrdup((char*)str_ptr);
253  if (unlikely(orig == NULL)) {
254  goto error;
255  }
256  pcre2_substring_free((PCRE2_UCHAR *)str_ptr);
257 
258  tmp_str=orig;
259 
260  /* Let's see if we need to escape "'s */
261  if (tmp_str[0] == '"') {
262  tmp_str[strlen(tmp_str) - 1] = '\0';
263  tmp_str += 1;
264  }
265 
266  tls->subject = SCStrdup(tmp_str);
267  if (unlikely(tls->subject == NULL)) {
268  goto error;
269  }
270 
271  pcre2_match_data_free(match);
272  SCFree(orig);
273 
274  SCLogDebug("will look for TLS subject %s", tls->subject);
275 
276  return tls;
277 
278 error:
279  if (match) {
280  pcre2_match_data_free(match);
281  }
282  if (orig != NULL)
283  SCFree(orig);
284  if (tls != NULL)
285  DetectTlsSubjectFree(de_ctx, tls);
286  return NULL;
287 
288 }
289 
290 /**
291  * \brief this function is used to add the parsed "id" option
292  * \brief into the current signature
293  *
294  * \param de_ctx pointer to the Detection Engine Context
295  * \param s pointer to the Current Signature
296  * \param idstr pointer to the user provided "id" option
297  *
298  * \retval 0 on Success
299  * \retval -1 on Failure
300  */
301 static int DetectTlsSubjectSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str)
302 {
303  DetectTlsData *tls = NULL;
304 
306  return -1;
307 
308  tls = DetectTlsSubjectParse(de_ctx, str, s->init_data->negated);
309  if (tls == NULL)
310  goto error;
311 
312  /* Okay so far so good, lets get this into a SigMatch
313  * and put it in the Signature. */
314 
316  de_ctx, s, DETECT_TLS_SUBJECT, (SigMatchCtx *)tls, g_tls_cert_list_id) == NULL) {
317  goto error;
318  }
319  return 0;
320 
321 error:
322  if (tls != NULL)
323  DetectTlsSubjectFree(de_ctx, tls);
324  return -1;
325 
326 }
327 
328 /**
329  * \brief this function will free memory associated with DetectTlsData
330  *
331  * \param id_d pointer to DetectTlsData
332  */
333 static void DetectTlsSubjectFree(DetectEngineCtx *de_ctx, void *ptr)
334 {
335  DetectTlsData *id_d = (DetectTlsData *)ptr;
336  if (ptr == NULL)
337  return;
338  if (id_d->subject != NULL)
339  SCFree(id_d->subject);
340  SCFree(id_d);
341 }
342 
343 /**
344  * \brief match the specified IssuerDN on a tls session
345  *
346  * \param t pointer to thread vars
347  * \param det_ctx pointer to the pattern matcher thread
348  * \param p pointer to the current packet
349  * \param m pointer to the sigmatch that we will cast into DetectTlsData
350  *
351  * \retval 0 no match
352  * \retval 1 match
353  */
354 static int DetectTlsIssuerDNMatch (DetectEngineThreadCtx *det_ctx,
355  Flow *f, uint8_t flags, void *state, void *txv,
356  const Signature *s, const SigMatchCtx *m)
357 {
358  SCEnter();
359 
360  const DetectTlsData *tls_data = (const DetectTlsData *)m;
361  SSLState *ssl_state = (SSLState *)state;
362  if (ssl_state == NULL) {
363  SCLogDebug("no tls state, no match");
364  SCReturnInt(0);
365  }
366 
367  int ret = 0;
368 
369  SSLStateConnp *connp = NULL;
370  if (flags & STREAM_TOSERVER) {
371  connp = &ssl_state->client_connp;
372  } else {
373  connp = &ssl_state->server_connp;
374  }
375 
376  if (connp->cert0_issuerdn != NULL) {
377  SCLogDebug("TLS: IssuerDN is [%s], looking for [%s]\n",
378  connp->cert0_issuerdn, tls_data->issuerdn);
379 
380  if (SpmSearch(connp->cert0_issuerdn, connp->cert0_issuerdn_len,
381  (const uint8_t *)tls_data->issuerdn,
382  (uint16_t)strlen(tls_data->issuerdn)) != NULL) {
383  if (tls_data->flags & DETECT_CONTENT_NEGATED) {
384  ret = 0;
385  } else {
386  ret = 1;
387  }
388  } else {
389  if (tls_data->flags & DETECT_CONTENT_NEGATED) {
390  ret = 1;
391  } else {
392  ret = 0;
393  }
394  }
395  } else {
396  ret = 0;
397  }
398 
399  SCReturnInt(ret);
400 }
401 
402 /**
403  * \brief This function is used to parse IPV4 ip_id passed via keyword: "id"
404  *
405  * \param de_ctx Pointer to the detection engine context
406  * \param str Pointer to the user provided id option
407  *
408  * \retval id_d pointer to DetectTlsData on success
409  * \retval NULL on failure
410  */
411 static DetectTlsData *DetectTlsIssuerDNParse(DetectEngineCtx *de_ctx, const char *str, bool negate)
412 {
413  DetectTlsData *tls = NULL;
414  size_t pcre2_len;
415  const char *str_ptr;
416  char *orig = NULL;
417  char *tmp_str;
418  uint32_t flag = 0;
419 
420  pcre2_match_data *match = NULL;
421  int ret = DetectParsePcreExec(&issuerdn_parse_regex, &match, str, 0, 0);
422  if (ret != 2) {
423  SCLogError("invalid tls.issuerdn option");
424  goto error;
425  }
426 
427  if (negate)
428  flag = DETECT_CONTENT_NEGATED;
429 
430  int res = pcre2_substring_get_bynumber(match, 1, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
431  if (res < 0) {
432  SCLogError("pcre2_substring_get_bynumber failed");
433  goto error;
434  }
435 
436  /* We have a correct id option */
437  tls = SCMalloc(sizeof(DetectTlsData));
438  if (unlikely(tls == NULL))
439  goto error;
440  tls->issuerdn = NULL;
441  tls->flags = flag;
442 
443  orig = SCStrdup((char*)str_ptr);
444  if (unlikely(orig == NULL)) {
445  goto error;
446  }
447  pcre2_substring_free((PCRE2_UCHAR *)str_ptr);
448 
449  tmp_str=orig;
450 
451  /* Let's see if we need to escape "'s */
452  if (tmp_str[0] == '"')
453  {
454  tmp_str[strlen(tmp_str) - 1] = '\0';
455  tmp_str += 1;
456  }
457 
458  tls->issuerdn = SCStrdup(tmp_str);
459  if (unlikely(tls->issuerdn == NULL)) {
460  goto error;
461  }
462 
463  SCFree(orig);
464 
465  pcre2_match_data_free(match);
466  SCLogDebug("Will look for TLS issuerdn %s", tls->issuerdn);
467 
468  return tls;
469 
470 error:
471  if (match) {
472  pcre2_match_data_free(match);
473  }
474  if (orig != NULL)
475  SCFree(orig);
476  if (tls != NULL)
477  DetectTlsIssuerDNFree(de_ctx, tls);
478  return NULL;
479 
480 }
481 
482 /**
483  * \brief this function is used to add the parsed "id" option
484  * \brief into the current signature
485  *
486  * \param de_ctx pointer to the Detection Engine Context
487  * \param s pointer to the Current Signature
488  * \param idstr pointer to the user provided "id" option
489  *
490  * \retval 0 on Success
491  * \retval -1 on Failure
492  */
493 static int DetectTlsIssuerDNSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str)
494 {
495  DetectTlsData *tls = NULL;
496 
498  return -1;
499 
500  tls = DetectTlsIssuerDNParse(de_ctx, str, s->init_data->negated);
501  if (tls == NULL)
502  goto error;
503 
504  /* Okay so far so good, lets get this into a SigMatch
505  * and put it in the Signature. */
506 
508  de_ctx, s, DETECT_TLS_ISSUERDN, (SigMatchCtx *)tls, g_tls_cert_list_id) == NULL) {
509  goto error;
510  }
511  return 0;
512 
513 error:
514  if (tls != NULL)
515  DetectTlsIssuerDNFree(de_ctx, tls);
516  return -1;
517 
518 }
519 
520 /**
521  * \brief this function will free memory associated with DetectTlsData
522  *
523  * \param id_d pointer to DetectTlsData
524  */
525 static void DetectTlsIssuerDNFree(DetectEngineCtx *de_ctx, void *ptr)
526 {
527  DetectTlsData *id_d = (DetectTlsData *)ptr;
528  SCFree(id_d->issuerdn);
529  SCFree(id_d);
530 }
531 
532 /**
533  * \brief This function is used to parse fingerprint passed via keyword: "fingerprint"
534  *
535  * \param de_ctx Pointer to the detection engine context
536  * \param str Pointer to the user provided fingerprint option
537  *
538  * \retval pointer to DetectTlsData on success
539  * \retval NULL on failure
540  */
541 
542 /**
543  * \brief this function is used to add the parsed "fingerprint" option
544  * \brief into the current signature
545  *
546  * \param de_ctx pointer to the Detection Engine Context
547  * \param s pointer to the Current Signature
548  * \param id pointer to the user provided "fingerprint" option
549  *
550  * \retval 0 on Success
551  * \retval -1 on Failure
552  */
553 static int DetectTlsFingerprintSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str)
554 {
555  if (DetectContentSetup(de_ctx, s, str) < 0) {
556  return -1;
557  }
558 
560  g_tls_cert_fingerprint_list_id, ALPROTO_TLS) < 0)
561  return -1;
562 
563  return 0;
564 }
565 
566 /**
567  * \brief this function will free memory associated with DetectTlsData
568  *
569  * \param pointer to DetectTlsData
570  */
571 static void DetectTlsFingerprintFree(DetectEngineCtx *de_ctx, void *ptr)
572 {
573  DetectTlsData *id_d = (DetectTlsData *)ptr;
574  SCFree(id_d);
575 }
576 
577 /**
578  * \brief this function is used to add the parsed "store" option
579  * \brief into the current signature
580  *
581  * \param de_ctx pointer to the Detection Engine Context
582  * \param s pointer to the Current Signature
583  * \param idstr pointer to the user provided "store" option
584  *
585  * \retval 0 on Success
586  * \retval -1 on Failure
587  */
588 static int DetectTlsStoreSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str)
589 {
590 
592  return -1;
593 
594  s->flags |= SIG_FLAG_TLSSTORE;
595 
597  NULL) {
598  return -1;
599  }
600  return 0;
601 }
602 
603 /** \warning modifies Flow::alstate */
604 static int DetectTlsStorePostMatch (DetectEngineThreadCtx *det_ctx,
605  Packet *p, const Signature *s, const SigMatchCtx *unused)
606 {
607  SCEnter();
608 
609  if (p->flow == NULL)
610  return 0;
611 
612  SSLState *ssl_state = FlowGetAppState(p->flow);
613  if (ssl_state == NULL) {
614  SCLogDebug("no tls state, no match");
615  SCReturnInt(0);
616  }
617 
618  SSLStateConnp *connp;
619 
620  if (PKT_IS_TOSERVER(p)) {
621  connp = &ssl_state->client_connp;
622  } else {
623  connp = &ssl_state->server_connp;
624  }
625 
626  connp->cert_log_flag |= SSL_TLS_LOG_PEM;
627  SCReturnInt(1);
628 }
SigTableElmt_::url
const char * url
Definition: detect.h:1545
SSLState_
SSLv[2.0|3.[0|1|2|3]] state structure.
Definition: app-layer-ssl.h:263
detect-content.h
detect-engine.h
SIGMATCH_NOOPT
#define SIGMATCH_NOOPT
Definition: detect-engine-register.h:308
SigTableElmt_::desc
const char * desc
Definition: detect.h:1544
PARSE_REGEX
#define PARSE_REGEX
Regex for parsing "id" option, matching number or "number".
Definition: detect-tls.c:68
sigmatch_table
SigTableElmt * sigmatch_table
Definition: detect-parse.c:78
SigTableElmt_::Free
void(* Free)(DetectEngineCtx *, void *)
Definition: detect.h:1529
flow-util.h
DetectParseRegex
Definition: detect-parse.h:94
SigTableElmt_::name
const char * name
Definition: detect.h:1542
TLS_STATE_SERVER_CERT
@ TLS_STATE_SERVER_CERT
Definition: app-layer-ssl.h:90
stream-tcp.h
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
detect-tls-cert-fingerprint.h
SSLState_::client_connp
SSLStateConnp client_connp
Definition: app-layer-ssl.h:284
DETECT_TLS_CERT_ISSUER
@ DETECT_TLS_CERT_ISSUER
Definition: detect-engine-register.h:242
SigTableElmt_::flags
uint32_t flags
Definition: detect.h:1533
ALPROTO_TLS
@ ALPROTO_TLS
Definition: app-layer-protos.h:39
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:282
DetectTlsData_::issuerdn
char * issuerdn
Definition: detect-tls.h:41
SSLState_::server_connp
SSLStateConnp server_connp
Definition: app-layer-ssl.h:285
SSLStateConnp_
Definition: app-layer-ssl.h:177
threads.h
Flow_
Flow data structure.
Definition: flow.h:359
DetectEngineCtx_
main detection engine ctx
Definition: detect.h:995
DETECT_TLS_CERT_FINGERPRINT
@ DETECT_TLS_CERT_FINGERPRINT
Definition: detect-engine-register.h:245
SigTableElmt_::AppLayerTxMatch
int(* AppLayerTxMatch)(DetectEngineThreadCtx *, Flow *, uint8_t flags, void *alstate, void *txv, const Signature *, const SigMatchCtx *)
Definition: detect.h:1507
DetectTlsData_
Definition: detect-tls.h:37
p
Packet * p
Definition: fuzz_dataset.c:30
DetectParsePcreExec
int DetectParsePcreExec(DetectParseRegex *parse_regex, pcre2_match_data **match, const char *str, int start_offset, int options)
Definition: detect-parse.c:4025
m
SCMutex m
Definition: flow-hash.h:6
SCDetectSignatureSetAppProto
int SCDetectSignatureSetAppProto(Signature *s, AppProto alproto)
Definition: detect-parse.c:2619
DetectTlsData_::flags
uint32_t flags
Definition: detect-tls.h:39
SIG_FLAG_TOCLIENT
#define SIG_FLAG_TOCLIENT
Definition: detect.h:275
SigTableElmt_::Setup
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
Definition: detect.h:1524
DETECT_TLS_STORE
@ DETECT_TLS_STORE
Definition: detect-engine-register.h:157
DetectAppLayerInspectEngineRegister
void DetectAppLayerInspectEngineRegister(const char *name, AppProto alproto, uint32_t dir, uint8_t progress, InspectEngineFuncPtr Callback, InspectionBufferGetDataPtr GetData)
Registers an app inspection engine.
Definition: detect-engine.c:275
util-unittest-helper.h
DETECT_SM_LIST_POSTMATCH
@ DETECT_SM_LIST_POSTMATCH
Definition: detect.h:128
DetectTlsData_::subject
char * subject
Definition: detect-tls.h:40
PARSE_REGEX_FINGERPRINT
#define PARSE_REGEX_FINGERPRINT
Definition: detect-tls.c:69
SIG_FLAG_TOSERVER
#define SIG_FLAG_TOSERVER
Definition: detect.h:274
decode.h
util-debug.h
de_ctx
DetectEngineCtx * de_ctx
Definition: fuzz_siginit.c:22
DetectContentSetup
int DetectContentSetup(DetectEngineCtx *de_ctx, Signature *s, const char *contentstr)
Function to setup a content pattern.
Definition: detect-content.c:322
PKT_IS_TOSERVER
#define PKT_IS_TOSERVER(p)
Definition: decode.h:239
DetectEngineThreadCtx_
Definition: detect.h:1316
DetectSetupParseRegexes
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
Definition: detect-parse.c:4151
SCEnter
#define SCEnter(...)
Definition: util-debug.h:284
detect-engine-mpm.h
SCSigMatchAppendSMToList
SigMatch * SCSigMatchAppendSMToList(DetectEngineCtx *de_ctx, Signature *s, uint16_t type, SigMatchCtx *ctx, const int list)
Append a SigMatch to the list type.
Definition: detect-parse.c:424
detect.h
DETECT_CONTENT_NEGATED
#define DETECT_CONTENT_NEGATED
Definition: detect-content.h:40
SigTableElmt_::alternative
uint16_t alternative
Definition: detect.h:1540
Signature_::flags
uint32_t flags
Definition: detect.h:693
DetectEngineContentModifierBufferSetup
int DetectEngineContentModifierBufferSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg, int sm_type, int sm_list, AppProto alproto)
Definition: detect-parse.c:183
TLS_STATE_CLIENT_CERT
@ TLS_STATE_CLIENT_CERT
Definition: app-layer-ssl.h:82
Packet_
Definition: decode.h:516
SSLStateConnp_::cert0_issuerdn
uint8_t * cert0_issuerdn
Definition: app-layer-ssl.h:199
Signature_::init_data
SignatureInitData * init_data
Definition: detect.h:775
detect-engine-state.h
Data structures and function prototypes for keeping state for the detection engine.
SignatureInitData_::negated
bool negated
Definition: detect.h:611
SigTableElmt_::Match
int(* Match)(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
Definition: detect.h:1504
SIGMATCH_QUOTES_MANDATORY
#define SIGMATCH_QUOTES_MANDATORY
Definition: detect-engine-register.h:322
SigMatchCtx_
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
Definition: detect.h:355
DetectTlsRegister
void DetectTlsRegister(void)
Registration function for keyword: tls.version.
Definition: detect-tls.c:100
Packet_::flow
struct Flow_ * flow
Definition: decode.h:564
SSLStateConnp_::cert0_subject_len
uint32_t cert0_subject_len
Definition: app-layer-ssl.h:198
DetectBufferTypeRegister
int DetectBufferTypeRegister(const char *name)
Definition: detect-engine.c:1388
flags
uint8_t flags
Definition: decode-gre.h:0
SigTableElmt_::alias
const char * alias
Definition: detect.h:1543
detect-tls.h
suricata-common.h
SCStrdup
#define SCStrdup(s)
Definition: util-mem.h:56
DETECT_TLS_FINGERPRINT
@ DETECT_TLS_FINGERPRINT
Definition: detect-engine-register.h:156
DetectEngineInspectGenericList
uint8_t DetectEngineInspectGenericList(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, const struct DetectEngineAppInspectionEngine_ *engine, const Signature *s, Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
Definition: detect-engine.c:2155
SSL_TLS_LOG_PEM
#define SSL_TLS_LOG_PEM
Definition: app-layer-ssl.h:148
SCMalloc
#define SCMalloc(sz)
Definition: util-mem.h:47
str
#define str(s)
Definition: suricata-common.h:313
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:274
DETECT_TLS_SUBJECT
@ DETECT_TLS_SUBJECT
Definition: detect-engine-register.h:150
SCFree
#define SCFree(p)
Definition: util-mem.h:61
DETECT_TLS_ISSUERDN
@ DETECT_TLS_ISSUERDN
Definition: detect-engine-register.h:151
detect-parse.h
Signature_
Signature container.
Definition: detect.h:692
SSLStateConnp_::cert_log_flag
uint32_t cert_log_flag
Definition: app-layer-ssl.h:242
SSLStateConnp_::cert0_issuerdn_len
uint32_t cert0_issuerdn_len
Definition: app-layer-ssl.h:200
SpmSearch
#define SpmSearch(text, textlen, needle, needlelen)
Definition: util-spm.h:100
SIG_FLAG_TLSSTORE
#define SIG_FLAG_TLSSTORE
Definition: detect.h:277
flow.h
DETECT_TLS_CERT_SUBJECT
@ DETECT_TLS_CERT_SUBJECT
Definition: detect-engine-register.h:243
SCReturnInt
#define SCReturnInt(x)
Definition: util-debug.h:288
flow-var.h
SIGMATCH_HANDLE_NEGATION
#define SIGMATCH_HANDLE_NEGATION
Definition: detect-engine-register.h:326
app-layer-ssl.h
app-layer.h
f
Flow f
Definition: fuzz_dataset.c:32
SSLStateConnp_::cert0_subject
uint8_t * cert0_subject
Definition: app-layer-ssl.h:197