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.h"
55 #include "util-unittest-helper.h"
56 
57 #include "app-layer.h"
58 
59 #include "app-layer-ssl.h"
60 #include "detect-tls.h"
62 
63 #include "stream-tcp.h"
64 
65 /**
66  * \brief Regex for parsing "id" option, matching number or "number"
67  */
68 
69 #define PARSE_REGEX "^([A-z0-9\\s\\-\\.=,\\*@]+|\"[A-z0-9\\s\\-\\.=,\\*@]+\")\\s*$"
70 #define PARSE_REGEX_FINGERPRINT "^([A-z0-9\\:\\*]+|\"[A-z0-9\\:\\* ]+\")\\s*$"
71 
72 static DetectParseRegex subject_parse_regex;
73 static DetectParseRegex issuerdn_parse_regex;
74 static DetectParseRegex fingerprint_parse_regex;
75 
76 static int DetectTlsSubjectMatch (DetectEngineThreadCtx *,
77  Flow *, uint8_t, void *, void *,
78  const Signature *, const SigMatchCtx *);
79 static int DetectTlsSubjectSetup (DetectEngineCtx *, Signature *, const char *);
80 static void DetectTlsSubjectFree(DetectEngineCtx *, void *);
81 
82 static int DetectTlsIssuerDNMatch (DetectEngineThreadCtx *,
83  Flow *, uint8_t, void *, void *,
84  const Signature *, const SigMatchCtx *);
85 static int DetectTlsIssuerDNSetup (DetectEngineCtx *, Signature *, const char *);
86 static void DetectTlsIssuerDNFree(DetectEngineCtx *, void *);
87 
88 static int DetectTlsFingerprintSetup (DetectEngineCtx *, Signature *, const char *);
89 static void DetectTlsFingerprintFree(DetectEngineCtx *, void *);
90 
91 static int DetectTlsStoreSetup (DetectEngineCtx *, Signature *, const char *);
92 static int DetectTlsStorePostMatch (DetectEngineThreadCtx *det_ctx,
93  Packet *, const Signature *s, const SigMatchCtx *unused);
94 
95 static int g_tls_cert_list_id = 0;
96 static int g_tls_cert_fingerprint_list_id = 0;
97 
98 /**
99  * \brief Registration function for keyword: tls.version
100  */
101 void DetectTlsRegister (void)
102 {
103  sigmatch_table[DETECT_TLS_SUBJECT].name = "tls.subject";
104  sigmatch_table[DETECT_TLS_SUBJECT].desc = "match TLS/SSL certificate Subject field";
105  sigmatch_table[DETECT_TLS_SUBJECT].url = "/rules/tls-keywords.html#tls-subject";
106  sigmatch_table[DETECT_TLS_SUBJECT].AppLayerTxMatch = DetectTlsSubjectMatch;
107  sigmatch_table[DETECT_TLS_SUBJECT].Setup = DetectTlsSubjectSetup;
108  sigmatch_table[DETECT_TLS_SUBJECT].Free = DetectTlsSubjectFree;
111 
112  sigmatch_table[DETECT_TLS_ISSUERDN].name = "tls.issuerdn";
113  sigmatch_table[DETECT_TLS_ISSUERDN].desc = "match TLS/SSL certificate IssuerDN field";
114  sigmatch_table[DETECT_TLS_ISSUERDN].url = "/rules/tls-keywords.html#tls-issuerdn";
115  sigmatch_table[DETECT_TLS_ISSUERDN].AppLayerTxMatch = DetectTlsIssuerDNMatch;
116  sigmatch_table[DETECT_TLS_ISSUERDN].Setup = DetectTlsIssuerDNSetup;
117  sigmatch_table[DETECT_TLS_ISSUERDN].Free = DetectTlsIssuerDNFree;
121 
122  sigmatch_table[DETECT_TLS_FINGERPRINT].name = "tls.fingerprint";
123  sigmatch_table[DETECT_TLS_FINGERPRINT].desc = "match TLS/SSL certificate SHA1 fingerprint";
124  sigmatch_table[DETECT_TLS_FINGERPRINT].url = "/rules/tls-keywords.html#tls-fingerprint";
125  sigmatch_table[DETECT_TLS_FINGERPRINT].Setup = DetectTlsFingerprintSetup;
126  sigmatch_table[DETECT_TLS_FINGERPRINT].Free = DetectTlsFingerprintFree;
130 
131  sigmatch_table[DETECT_TLS_STORE].name = "tls_store";
132  sigmatch_table[DETECT_TLS_STORE].alias = "tls.store";
133  sigmatch_table[DETECT_TLS_STORE].desc = "store TLS/SSL certificate on disk";
134  sigmatch_table[DETECT_TLS_STORE].url = "/rules/tls-keywords.html#tls-store";
135  sigmatch_table[DETECT_TLS_STORE].Match = DetectTlsStorePostMatch;
136  sigmatch_table[DETECT_TLS_STORE].Setup = DetectTlsStoreSetup;
138 
139  DetectSetupParseRegexes(PARSE_REGEX, &subject_parse_regex);
140  DetectSetupParseRegexes(PARSE_REGEX, &issuerdn_parse_regex);
141  DetectSetupParseRegexes(PARSE_REGEX_FINGERPRINT, &fingerprint_parse_regex);
142 
143  g_tls_cert_list_id = DetectBufferTypeRegister("tls_cert");
144  g_tls_cert_fingerprint_list_id = DetectBufferTypeRegister("tls.cert_fingerprint");
145 
148 
151 }
152 
153 /**
154  * \brief match the specified Subject on a tls session
155  *
156  * \param t pointer to thread vars
157  * \param det_ctx pointer to the pattern matcher thread
158  * \param p pointer to the current packet
159  * \param m pointer to the sigmatch that we will cast into DetectTlsData
160  *
161  * \retval 0 no match
162  * \retval 1 match
163  */
164 static int DetectTlsSubjectMatch (DetectEngineThreadCtx *det_ctx,
165  Flow *f, uint8_t flags, void *state, void *txv,
166  const Signature *s, const SigMatchCtx *m)
167 {
168  SCEnter();
169 
170  const DetectTlsData *tls_data = (const DetectTlsData *)m;
171  SSLState *ssl_state = (SSLState *)state;
172  if (ssl_state == NULL) {
173  SCLogDebug("no tls state, no match");
174  SCReturnInt(0);
175  }
176 
177  int ret = 0;
178 
179  SSLStateConnp *connp = NULL;
180  if (flags & STREAM_TOSERVER) {
181  connp = &ssl_state->client_connp;
182  } else {
183  connp = &ssl_state->server_connp;
184  }
185 
186  if (connp->cert0_subject != NULL) {
187  SCLogDebug("TLS: Subject is [%s], looking for [%s]\n",
188  connp->cert0_subject, tls_data->subject);
189 
190  if (SpmSearch(connp->cert0_subject, connp->cert0_subject_len,
191  (const uint8_t *)tls_data->subject,
192  (uint16_t)strlen(tls_data->subject)) != NULL) {
193  if (tls_data->flags & DETECT_CONTENT_NEGATED) {
194  ret = 0;
195  } else {
196  ret = 1;
197  }
198  } else {
199  if (tls_data->flags & DETECT_CONTENT_NEGATED) {
200  ret = 1;
201  } else {
202  ret = 0;
203  }
204  }
205  } else {
206  ret = 0;
207  }
208 
209  SCReturnInt(ret);
210 }
211 
212 /**
213  * \brief This function is used to parse IPV4 ip_id passed via keyword: "id"
214  *
215  * \param de_ctx Pointer to the detection engine context
216  * \param str Pointer to the user provided id option
217  *
218  * \retval id_d pointer to DetectTlsData on success
219  * \retval NULL on failure
220  */
221 static DetectTlsData *DetectTlsSubjectParse (DetectEngineCtx *de_ctx, const char *str, bool negate)
222 {
223  DetectTlsData *tls = NULL;
224  size_t pcre2_len;
225  const char *str_ptr;
226  char *orig = NULL;
227  char *tmp_str;
228  uint32_t flag = 0;
229 
230  pcre2_match_data *match = NULL;
231  int ret = DetectParsePcreExec(&subject_parse_regex, &match, str, 0, 0);
232  if (ret != 2) {
233  SCLogError("invalid tls.subject option");
234  goto error;
235  }
236 
237  if (negate)
238  flag = DETECT_CONTENT_NEGATED;
239 
240  int res = pcre2_substring_get_bynumber(match, 1, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
241  if (res < 0) {
242  SCLogError("pcre2_substring_get_bynumber failed");
243  goto error;
244  }
245 
246  /* We have a correct id option */
247  tls = SCMalloc(sizeof(DetectTlsData));
248  if (unlikely(tls == NULL))
249  goto error;
250  tls->subject = NULL;
251  tls->flags = flag;
252 
253  orig = SCStrdup((char*)str_ptr);
254  if (unlikely(orig == NULL)) {
255  goto error;
256  }
257  pcre2_substring_free((PCRE2_UCHAR *)str_ptr);
258 
259  tmp_str=orig;
260 
261  /* Let's see if we need to escape "'s */
262  if (tmp_str[0] == '"') {
263  tmp_str[strlen(tmp_str) - 1] = '\0';
264  tmp_str += 1;
265  }
266 
267  tls->subject = SCStrdup(tmp_str);
268  if (unlikely(tls->subject == NULL)) {
269  goto error;
270  }
271 
272  pcre2_match_data_free(match);
273  SCFree(orig);
274 
275  SCLogDebug("will look for TLS subject %s", tls->subject);
276 
277  return tls;
278 
279 error:
280  if (match) {
281  pcre2_match_data_free(match);
282  }
283  if (orig != NULL)
284  SCFree(orig);
285  if (tls != NULL)
286  DetectTlsSubjectFree(de_ctx, tls);
287  return NULL;
288 
289 }
290 
291 /**
292  * \brief this function is used to add the parsed "id" option
293  * \brief into the current signature
294  *
295  * \param de_ctx pointer to the Detection Engine Context
296  * \param s pointer to the Current Signature
297  * \param idstr pointer to the user provided "id" option
298  *
299  * \retval 0 on Success
300  * \retval -1 on Failure
301  */
302 static int DetectTlsSubjectSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str)
303 {
304  DetectTlsData *tls = NULL;
305 
307  return -1;
308 
309  tls = DetectTlsSubjectParse(de_ctx, str, s->init_data->negated);
310  if (tls == NULL)
311  goto error;
312 
313  /* Okay so far so good, lets get this into a SigMatch
314  * and put it in the Signature. */
315 
317  de_ctx, s, DETECT_TLS_SUBJECT, (SigMatchCtx *)tls, g_tls_cert_list_id) == NULL) {
318  goto error;
319  }
320  return 0;
321 
322 error:
323  if (tls != NULL)
324  DetectTlsSubjectFree(de_ctx, tls);
325  return -1;
326 
327 }
328 
329 /**
330  * \brief this function will free memory associated with DetectTlsData
331  *
332  * \param id_d pointer to DetectTlsData
333  */
334 static void DetectTlsSubjectFree(DetectEngineCtx *de_ctx, void *ptr)
335 {
336  DetectTlsData *id_d = (DetectTlsData *)ptr;
337  if (ptr == NULL)
338  return;
339  if (id_d->subject != NULL)
340  SCFree(id_d->subject);
341  SCFree(id_d);
342 }
343 
344 /**
345  * \brief match the specified IssuerDN on a tls session
346  *
347  * \param t pointer to thread vars
348  * \param det_ctx pointer to the pattern matcher thread
349  * \param p pointer to the current packet
350  * \param m pointer to the sigmatch that we will cast into DetectTlsData
351  *
352  * \retval 0 no match
353  * \retval 1 match
354  */
355 static int DetectTlsIssuerDNMatch (DetectEngineThreadCtx *det_ctx,
356  Flow *f, uint8_t flags, void *state, void *txv,
357  const Signature *s, const SigMatchCtx *m)
358 {
359  SCEnter();
360 
361  const DetectTlsData *tls_data = (const DetectTlsData *)m;
362  SSLState *ssl_state = (SSLState *)state;
363  if (ssl_state == NULL) {
364  SCLogDebug("no tls state, no match");
365  SCReturnInt(0);
366  }
367 
368  int ret = 0;
369 
370  SSLStateConnp *connp = NULL;
371  if (flags & STREAM_TOSERVER) {
372  connp = &ssl_state->client_connp;
373  } else {
374  connp = &ssl_state->server_connp;
375  }
376 
377  if (connp->cert0_issuerdn != NULL) {
378  SCLogDebug("TLS: IssuerDN is [%s], looking for [%s]\n",
379  connp->cert0_issuerdn, tls_data->issuerdn);
380 
381  if (SpmSearch(connp->cert0_issuerdn, connp->cert0_issuerdn_len,
382  (const uint8_t *)tls_data->issuerdn,
383  (uint16_t)strlen(tls_data->issuerdn)) != NULL) {
384  if (tls_data->flags & DETECT_CONTENT_NEGATED) {
385  ret = 0;
386  } else {
387  ret = 1;
388  }
389  } else {
390  if (tls_data->flags & DETECT_CONTENT_NEGATED) {
391  ret = 1;
392  } else {
393  ret = 0;
394  }
395  }
396  } else {
397  ret = 0;
398  }
399 
400  SCReturnInt(ret);
401 }
402 
403 /**
404  * \brief This function is used to parse IPV4 ip_id passed via keyword: "id"
405  *
406  * \param de_ctx Pointer to the detection engine context
407  * \param str Pointer to the user provided id option
408  *
409  * \retval id_d pointer to DetectTlsData on success
410  * \retval NULL on failure
411  */
412 static DetectTlsData *DetectTlsIssuerDNParse(DetectEngineCtx *de_ctx, const char *str, bool negate)
413 {
414  DetectTlsData *tls = NULL;
415  size_t pcre2_len;
416  const char *str_ptr;
417  char *orig = NULL;
418  char *tmp_str;
419  uint32_t flag = 0;
420 
421  pcre2_match_data *match = NULL;
422  int ret = DetectParsePcreExec(&issuerdn_parse_regex, &match, str, 0, 0);
423  if (ret != 2) {
424  SCLogError("invalid tls.issuerdn option");
425  goto error;
426  }
427 
428  if (negate)
429  flag = DETECT_CONTENT_NEGATED;
430 
431  int res = pcre2_substring_get_bynumber(match, 1, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
432  if (res < 0) {
433  SCLogError("pcre2_substring_get_bynumber failed");
434  goto error;
435  }
436 
437  /* We have a correct id option */
438  tls = SCMalloc(sizeof(DetectTlsData));
439  if (unlikely(tls == NULL))
440  goto error;
441  tls->issuerdn = NULL;
442  tls->flags = flag;
443 
444  orig = SCStrdup((char*)str_ptr);
445  if (unlikely(orig == NULL)) {
446  goto error;
447  }
448  pcre2_substring_free((PCRE2_UCHAR *)str_ptr);
449 
450  tmp_str=orig;
451 
452  /* Let's see if we need to escape "'s */
453  if (tmp_str[0] == '"')
454  {
455  tmp_str[strlen(tmp_str) - 1] = '\0';
456  tmp_str += 1;
457  }
458 
459  tls->issuerdn = SCStrdup(tmp_str);
460  if (unlikely(tls->issuerdn == NULL)) {
461  goto error;
462  }
463 
464  SCFree(orig);
465 
466  pcre2_match_data_free(match);
467  SCLogDebug("Will look for TLS issuerdn %s", tls->issuerdn);
468 
469  return tls;
470 
471 error:
472  if (match) {
473  pcre2_match_data_free(match);
474  }
475  if (orig != NULL)
476  SCFree(orig);
477  if (tls != NULL)
478  DetectTlsIssuerDNFree(de_ctx, tls);
479  return NULL;
480 
481 }
482 
483 /**
484  * \brief this function is used to add the parsed "id" option
485  * \brief into the current signature
486  *
487  * \param de_ctx pointer to the Detection Engine Context
488  * \param s pointer to the Current Signature
489  * \param idstr pointer to the user provided "id" option
490  *
491  * \retval 0 on Success
492  * \retval -1 on Failure
493  */
494 static int DetectTlsIssuerDNSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str)
495 {
496  DetectTlsData *tls = NULL;
497 
499  return -1;
500 
501  tls = DetectTlsIssuerDNParse(de_ctx, str, s->init_data->negated);
502  if (tls == NULL)
503  goto error;
504 
505  /* Okay so far so good, lets get this into a SigMatch
506  * and put it in the Signature. */
507 
509  de_ctx, s, DETECT_TLS_ISSUERDN, (SigMatchCtx *)tls, g_tls_cert_list_id) == NULL) {
510  goto error;
511  }
512  return 0;
513 
514 error:
515  if (tls != NULL)
516  DetectTlsIssuerDNFree(de_ctx, tls);
517  return -1;
518 
519 }
520 
521 /**
522  * \brief this function will free memory associated with DetectTlsData
523  *
524  * \param id_d pointer to DetectTlsData
525  */
526 static void DetectTlsIssuerDNFree(DetectEngineCtx *de_ctx, void *ptr)
527 {
528  DetectTlsData *id_d = (DetectTlsData *)ptr;
529  SCFree(id_d->issuerdn);
530  SCFree(id_d);
531 }
532 
533 /**
534  * \brief This function is used to parse fingerprint passed via keyword: "fingerprint"
535  *
536  * \param de_ctx Pointer to the detection engine context
537  * \param str Pointer to the user provided fingerprint option
538  *
539  * \retval pointer to DetectTlsData on success
540  * \retval NULL on failure
541  */
542 
543 /**
544  * \brief this function is used to add the parsed "fingerprint" option
545  * \brief into the current signature
546  *
547  * \param de_ctx pointer to the Detection Engine Context
548  * \param s pointer to the Current Signature
549  * \param id pointer to the user provided "fingerprint" option
550  *
551  * \retval 0 on Success
552  * \retval -1 on Failure
553  */
554 static int DetectTlsFingerprintSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str)
555 {
556  if (DetectContentSetup(de_ctx, s, str) < 0) {
557  return -1;
558  }
559 
561  g_tls_cert_fingerprint_list_id, ALPROTO_TLS) < 0)
562  return -1;
563 
564  return 0;
565 }
566 
567 /**
568  * \brief this function will free memory associated with DetectTlsData
569  *
570  * \param pointer to DetectTlsData
571  */
572 static void DetectTlsFingerprintFree(DetectEngineCtx *de_ctx, void *ptr)
573 {
574  DetectTlsData *id_d = (DetectTlsData *)ptr;
575  SCFree(id_d);
576 }
577 
578 /**
579  * \brief this function is used to add the parsed "store" option
580  * \brief into the current signature
581  *
582  * \param de_ctx pointer to the Detection Engine Context
583  * \param s pointer to the Current Signature
584  * \param idstr pointer to the user provided "store" option
585  *
586  * \retval 0 on Success
587  * \retval -1 on Failure
588  */
589 static int DetectTlsStoreSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str)
590 {
591 
593  return -1;
594 
595  s->flags |= SIG_FLAG_TLSSTORE;
596 
598  NULL) {
599  return -1;
600  }
601  return 0;
602 }
603 
604 /** \warning modifies Flow::alstate */
605 static int DetectTlsStorePostMatch (DetectEngineThreadCtx *det_ctx,
606  Packet *p, const Signature *s, const SigMatchCtx *unused)
607 {
608  SCEnter();
609 
610  if (p->flow == NULL)
611  return 0;
612 
613  SSLState *ssl_state = FlowGetAppState(p->flow);
614  if (ssl_state == NULL) {
615  SCLogDebug("no tls state, no match");
616  SCReturnInt(0);
617  }
618 
619  SSLStateConnp *connp;
620 
621  if (PKT_IS_TOSERVER(p)) {
622  connp = &ssl_state->client_connp;
623  } else {
624  connp = &ssl_state->server_connp;
625  }
626 
627  connp->cert_log_flag |= SSL_TLS_LOG_PEM;
628  SCReturnInt(1);
629 }
SigTableElmt_::url
const char * url
Definition: detect.h:1461
SSLState_
SSLv[2.0|3.[0|1|2|3]] state structure.
Definition: app-layer-ssl.h:236
detect-content.h
detect-engine.h
SigTableElmt_::desc
const char * desc
Definition: detect.h:1460
PARSE_REGEX
#define PARSE_REGEX
Regex for parsing "id" option, matching number or "number".
Definition: detect-tls.c:69
sigmatch_table
SigTableElmt * sigmatch_table
Definition: detect-parse.c:79
SigTableElmt_::Free
void(* Free)(DetectEngineCtx *, void *)
Definition: detect.h:1445
flow-util.h
DetectParseRegex
Definition: detect-parse.h:93
SigTableElmt_::name
const char * name
Definition: detect.h:1458
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:257
DETECT_TLS_CERT_ISSUER
@ DETECT_TLS_CERT_ISSUER
Definition: detect-engine-register.h:249
SigTableElmt_::flags
uint32_t flags
Definition: detect.h:1449
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:258
SSLStateConnp_
Definition: app-layer-ssl.h:172
threads.h
Flow_
Flow data structure.
Definition: flow.h:347
DetectEngineCtx_
main detection engine ctx
Definition: detect.h:933
DETECT_TLS_CERT_FINGERPRINT
@ DETECT_TLS_CERT_FINGERPRINT
Definition: detect-engine-register.h:252
SigTableElmt_::AppLayerTxMatch
int(* AppLayerTxMatch)(DetectEngineThreadCtx *, Flow *, uint8_t flags, void *alstate, void *txv, const Signature *, const SigMatchCtx *)
Definition: detect.h:1423
DetectTlsData_
Definition: detect-tls.h:37
DetectParsePcreExec
int DetectParsePcreExec(DetectParseRegex *parse_regex, pcre2_match_data **match, const char *str, int start_offset, int options)
Definition: detect-parse.c:3501
m
SCMutex m
Definition: flow-hash.h:6
SCDetectSignatureSetAppProto
int SCDetectSignatureSetAppProto(Signature *s, AppProto alproto)
Definition: detect-parse.c:2236
DetectTlsData_::flags
uint32_t flags
Definition: detect-tls.h:39
SIG_FLAG_TOCLIENT
#define SIG_FLAG_TOCLIENT
Definition: detect.h:272
SigTableElmt_::Setup
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
Definition: detect.h:1440
util-unittest.h
DETECT_TLS_STORE
@ DETECT_TLS_STORE
Definition: detect-engine-register.h:147
util-unittest-helper.h
SIGMATCH_QUOTES_MANDATORY
#define SIGMATCH_QUOTES_MANDATORY
Definition: detect.h:1667
DETECT_SM_LIST_POSTMATCH
@ DETECT_SM_LIST_POSTMATCH
Definition: detect.h:127
DetectTlsData_::subject
char * subject
Definition: detect-tls.h:40
PARSE_REGEX_FINGERPRINT
#define PARSE_REGEX_FINGERPRINT
Definition: detect-tls.c:70
SIG_FLAG_TOSERVER
#define SIG_FLAG_TOSERVER
Definition: detect.h:271
decode.h
util-debug.h
de_ctx
DetectEngineCtx * de_ctx
Definition: fuzz_siginit.c:19
DetectContentSetup
int DetectContentSetup(DetectEngineCtx *de_ctx, Signature *s, const char *contentstr)
Function to setup a content pattern.
Definition: detect-content.c:323
PKT_IS_TOSERVER
#define PKT_IS_TOSERVER(p)
Definition: decode.h:238
DetectEngineThreadCtx_
Definition: detect.h:1245
DetectSetupParseRegexes
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
Definition: detect-parse.c:3627
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:388
detect.h
DETECT_CONTENT_NEGATED
#define DETECT_CONTENT_NEGATED
Definition: detect-content.h:40
SigTableElmt_::alternative
uint16_t alternative
Definition: detect.h:1456
Signature_::flags
uint32_t flags
Definition: detect.h:669
DetectEngineContentModifierBufferSetup
int DetectEngineContentModifierBufferSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg, int sm_type, int sm_list, AppProto alproto)
Definition: detect-parse.c:146
Packet_
Definition: decode.h:501
SSLStateConnp_::cert0_issuerdn
uint8_t * cert0_issuerdn
Definition: app-layer-ssl.h:194
SIGMATCH_HANDLE_NEGATION
#define SIGMATCH_HANDLE_NEGATION
Definition: detect.h:1671
Signature_::init_data
SignatureInitData * init_data
Definition: detect.h:747
detect-engine-state.h
Data structures and function prototypes for keeping state for the detection engine.
SignatureInitData_::negated
bool negated
Definition: detect.h:597
SigTableElmt_::Match
int(* Match)(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
Definition: detect.h:1420
TLS_STATE_SERVER_CERT_DONE
@ TLS_STATE_SERVER_CERT_DONE
Definition: app-layer-ssl.h:88
SigMatchCtx_
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
Definition: detect.h:351
DetectTlsRegister
void DetectTlsRegister(void)
Registration function for keyword: tls.version.
Definition: detect-tls.c:101
Packet_::flow
struct Flow_ * flow
Definition: decode.h:546
SSLStateConnp_::cert0_subject_len
uint32_t cert0_subject_len
Definition: app-layer-ssl.h:193
DetectBufferTypeRegister
int DetectBufferTypeRegister(const char *name)
Definition: detect-engine.c:1214
flags
uint8_t flags
Definition: decode-gre.h:0
SigTableElmt_::alias
const char * alias
Definition: detect.h:1459
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:146
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)
Do the content inspection & validation for a signature.
Definition: detect-engine.c:1946
TLS_STATE_CLIENT_CERT_DONE
@ TLS_STATE_CLIENT_CERT_DONE
Definition: app-layer-ssl.h:80
SSL_TLS_LOG_PEM
#define SSL_TLS_LOG_PEM
Definition: app-layer-ssl.h:143
SCMalloc
#define SCMalloc(sz)
Definition: util-mem.h:47
str
#define str(s)
Definition: suricata-common.h:308
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:140
SCFree
#define SCFree(p)
Definition: util-mem.h:61
DETECT_TLS_ISSUERDN
@ DETECT_TLS_ISSUERDN
Definition: detect-engine-register.h:141
detect-parse.h
Signature_
Signature container.
Definition: detect.h:668
SSLStateConnp_::cert_log_flag
uint32_t cert_log_flag
Definition: app-layer-ssl.h:215
SIGMATCH_NOOPT
#define SIGMATCH_NOOPT
Definition: detect.h:1650
SSLStateConnp_::cert0_issuerdn_len
uint32_t cert0_issuerdn_len
Definition: app-layer-ssl.h:195
DetectAppLayerInspectEngineRegister
void DetectAppLayerInspectEngineRegister(const char *name, AppProto alproto, uint32_t dir, int progress, InspectEngineFuncPtr Callback, InspectionBufferGetDataPtr GetData)
Registers an app inspection engine.
Definition: detect-engine.c:273
SpmSearch
#define SpmSearch(text, textlen, needle, needlelen)
Definition: util-spm.h:99
SIG_FLAG_TLSSTORE
#define SIG_FLAG_TLSSTORE
Definition: detect.h:274
flow.h
DETECT_TLS_CERT_SUBJECT
@ DETECT_TLS_CERT_SUBJECT
Definition: detect-engine-register.h:250
SCReturnInt
#define SCReturnInt(x)
Definition: util-debug.h:288
flow-var.h
app-layer-ssl.h
app-layer.h
SSLStateConnp_::cert0_subject
uint8_t * cert0_subject
Definition: app-layer-ssl.h:192