suricata
detect-base64-decode.c
Go to the documentation of this file.
1 /* Copyright (C) 2020-2024 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 #include "suricata-common.h"
19 #include "detect.h"
20 #include "detect-parse.h"
21 #include "detect-base64-decode.h"
22 #include "util-byte.h"
23 #include "util-print.h"
24 #include "detect-engine-build.h"
25 #include "rust.h"
26 
27 /* Arbitrary maximum buffer size for decoded base64 data. */
28 #define BASE64_DECODE_MAX 65535
29 
30 typedef struct DetectBase64Decode_ {
31  uint32_t bytes;
32  uint32_t offset;
33  uint8_t relative;
35 
36 static const char decode_pattern[] = "\\s*(bytes\\s+(\\d+),?)?"
37  "\\s*(offset\\s+(\\d+),?)?"
38  "\\s*(\\w+)?";
39 
40 static DetectParseRegex decode_pcre;
41 
42 static int DetectBase64DecodeSetup(DetectEngineCtx *, Signature *, const char *);
43 static void DetectBase64DecodeFree(DetectEngineCtx *, void *);
44 #ifdef UNITTESTS
45 static void DetectBase64DecodeRegisterTests(void);
46 #endif
47 
49 {
50  sigmatch_table[DETECT_BASE64_DECODE].name = "base64_decode";
52  "Decodes base64 encoded data.";
54  "/rules/base64-keywords.html#base64-decode";
55  sigmatch_table[DETECT_BASE64_DECODE].Setup = DetectBase64DecodeSetup;
56  sigmatch_table[DETECT_BASE64_DECODE].Free = DetectBase64DecodeFree;
57 #ifdef UNITTESTS
59  DetectBase64DecodeRegisterTests;
60 #endif
62 
63  DetectSetupParseRegexes(decode_pattern, &decode_pcre);
64 }
65 
67  const SigMatchData *smd, const uint8_t *payload, uint32_t payload_len)
68 {
70 
71 #if 0
72  printf("Input data:\n");
73  PrintRawDataFp(stdout, payload, payload_len);
74 #endif
75 
76  if (data->relative) {
77  payload += det_ctx->buffer_offset;
79  payload_len -= det_ctx->buffer_offset;
80  }
81 
82  if (data->offset) {
83  if (data->offset >= payload_len) {
84  return 0;
85  }
86  payload = payload + data->offset;
87  payload_len -= data->offset;
88  }
89 
90  uint32_t decode_len = MIN(payload_len, data->bytes);
91 #if 0
92  printf("Decoding:\n");
93  PrintRawDataFp(stdout, payload, decode_len);
94 #endif
95 
96  if (decode_len > 0) {
97  uint32_t num_decoded =
98  Base64Decode(payload, decode_len, Base64ModeRFC4648, det_ctx->base64_decoded);
99  det_ctx->base64_decoded_len = num_decoded;
100  SCLogDebug("Decoded %d bytes from base64 data.", det_ctx->base64_decoded_len);
101  }
102 #if 0
103  if (det_ctx->base64_decoded_len) {
104  printf("Decoded data:\n");
105  PrintRawDataFp(stdout, det_ctx->base64_decoded,
106  det_ctx->base64_decoded_len);
107  }
108 #endif
109 
110  return det_ctx->base64_decoded_len > 0;
111 }
112 
113 static int DetectBase64DecodeParse(const char *str, uint32_t *bytes,
114  uint32_t *offset, uint8_t *relative)
115 {
116  const char *bytes_str = NULL;
117  const char *offset_str = NULL;
118  const char *relative_str = NULL;
119  int retval = 0;
120 
121  *bytes = 0;
122  *offset = 0;
123  *relative = 0;
124  size_t pcre2_len;
125  pcre2_match_data *match = NULL;
126 
127  int pcre_rc = DetectParsePcreExec(&decode_pcre, &match, str, 0, 0);
128  if (pcre_rc < 3) {
129  goto error;
130  }
131 
132  if (pcre_rc >= 3) {
133  if (pcre2_substring_get_bynumber(match, 2, (PCRE2_UCHAR8 **)&bytes_str, &pcre2_len) == 0) {
134  if (StringParseUint32(bytes, 10, 0, bytes_str) <= 0) {
135  SCLogError("Bad value for bytes: \"%s\"", bytes_str);
136  goto error;
137  }
138  }
139  }
140 
141  if (pcre_rc >= 5) {
142  if (pcre2_substring_get_bynumber(match, 4, (PCRE2_UCHAR8 **)&offset_str, &pcre2_len) == 0) {
143  if (StringParseUint32(offset, 10, 0, offset_str) <= 0) {
144  SCLogError("Bad value for offset: \"%s\"", offset_str);
145  goto error;
146  }
147  }
148  }
149 
150  if (pcre_rc >= 6) {
151  if (pcre2_substring_get_bynumber(match, 5, (PCRE2_UCHAR8 **)&relative_str, &pcre2_len) ==
152  0) {
153  if (strcmp(relative_str, "relative") == 0) {
154  *relative = 1;
155  }
156  else {
157  SCLogError("Invalid argument: \"%s\"", relative_str);
158  goto error;
159  }
160  }
161  }
162 
163  retval = 1;
164 
165  pcre2_match_data_free(match);
166  match = NULL;
167 
168 error:
169 
170  if (bytes_str != NULL) {
171  pcre2_substring_free((PCRE2_UCHAR8 *)bytes_str);
172  }
173  if (offset_str != NULL) {
174  pcre2_substring_free((PCRE2_UCHAR8 *)offset_str);
175  }
176  if (relative_str != NULL) {
177  pcre2_substring_free((PCRE2_UCHAR8 *)relative_str);
178  }
179  if (match) {
180  pcre2_match_data_free(match);
181  }
182  return retval;
183 }
184 
185 static int DetectBase64DecodeSetup(DetectEngineCtx *de_ctx, Signature *s,
186  const char *str)
187 {
188  uint32_t bytes = 0;
189  uint32_t offset = 0;
190  uint8_t relative = 0;
191  DetectBase64Decode *data = NULL;
192  int sm_list;
193  SigMatch *pm = NULL;
194 
195  if (str != NULL) {
196  if (!DetectBase64DecodeParse(str, &bytes, &offset, &relative)) {
197  goto error;
198  }
199  }
200  data = SCCalloc(1, sizeof(DetectBase64Decode));
201  if (unlikely(data == NULL)) {
202  goto error;
203  }
204  data->bytes = bytes;
205  data->offset = offset;
206  data->relative = relative;
207 
208  if (s->init_data->list != DETECT_SM_LIST_NOTSET) {
209  sm_list = s->init_data->list;
210  }
211  else {
215  DETECT_ISDATAAT, -1);
216  if (pm == NULL) {
217  sm_list = DETECT_SM_LIST_PMATCH;
218  }
219  else {
220  sm_list = SigMatchListSMBelongsTo(s, pm);
221  if (sm_list < 0) {
222  goto error;
223  }
224  }
225  }
226 
227  if (SigMatchAppendSMToList(de_ctx, s, DETECT_BASE64_DECODE, (SigMatchCtx *)data, sm_list) ==
228  NULL) {
229  goto error;
230  }
231 
232  if (!data->bytes) {
233  data->bytes = BASE64_DECODE_MAX;
234  }
235  if (data->bytes > de_ctx->base64_decode_max_len) {
236 #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
237  data->bytes = BASE64_DECODE_MAX;
238 #endif
239  de_ctx->base64_decode_max_len = data->bytes;
240  }
241 
242  return 0;
243 error:
244  if (data != NULL) {
245  SCFree(data);
246  }
247  return -1;
248 }
249 
250 static void DetectBase64DecodeFree(DetectEngineCtx *de_ctx, void *ptr)
251 {
252  DetectBase64Decode *data = ptr;
253  SCFree(data);
254 }
255 
256 
257 #ifdef UNITTESTS
258 #include "detect-engine.h"
259 #include "util-unittest.h"
260 #include "util-unittest-helper.h"
261 #include "app-layer-parser.h"
262 #include "flow-util.h"
263 #include "stream-tcp.h"
264 
265 static int g_http_header_buffer_id = 0;
266 
267 static int DetectBase64TestDecodeParse(void)
268 {
269  int retval = 0;
270  uint32_t bytes = 0;
271  uint32_t offset = 0;
272  uint8_t relative = 0;
273 
274  if (!DetectBase64DecodeParse("bytes 1", &bytes, &offset, &relative)) {
275  goto end;
276  }
277  if (bytes != 1 || offset != 0 || relative != 0) {
278  goto end;
279  }
280 
281  if (!DetectBase64DecodeParse("offset 9", &bytes, &offset, &relative)) {
282  goto end;
283  }
284  if (bytes != 0 || offset != 9 || relative != 0) {
285  goto end;
286  }
287 
288  if (!DetectBase64DecodeParse("relative", &bytes, &offset, &relative)) {
289  goto end;
290  }
291  if (bytes != 0 || offset != 0 || relative != 1) {
292  goto end;
293  }
294 
295  if (!DetectBase64DecodeParse("bytes 1, offset 2", &bytes, &offset,
296  &relative)) {
297  goto end;
298  }
299  if (bytes != 1 || offset != 2 || relative != 0) {
300  goto end;
301  }
302 
303  if (!DetectBase64DecodeParse("bytes 1, offset 2, relative", &bytes, &offset,
304  &relative)) {
305  goto end;
306  }
307  if (bytes != 1 || offset != 2 || relative != 1) {
308  goto end;
309  }
310 
311  if (!DetectBase64DecodeParse("offset 2, relative", &bytes, &offset,
312  &relative)) {
313  goto end;
314  }
315  if (bytes != 0 || offset != 2 || relative != 1) {
316  goto end;
317  }
318 
319  /* Misspelled relative. */
320  if (DetectBase64DecodeParse("bytes 1, offset 2, relatve", &bytes, &offset,
321  &relative)) {
322  goto end;
323  }
324 
325  /* Misspelled bytes. */
326  if (DetectBase64DecodeParse("byts 1, offset 2, relatve", &bytes, &offset,
327  &relative)) {
328  goto end;
329  }
330 
331  /* Misspelled offset. */
332  if (DetectBase64DecodeParse("bytes 1, offst 2, relatve", &bytes, &offset,
333  &relative)) {
334  goto end;
335  }
336 
337  /* Misspelled empty string. */
338  if (DetectBase64DecodeParse("", &bytes, &offset, &relative)) {
339  goto end;
340  }
341 
342  retval = 1;
343 end:
344  return retval;
345 }
346 
347 /**
348  * Test keyword setup on basic content.
349  */
350 static int DetectBase64DecodeTestSetup(void)
351 {
354 
355  Signature *s = DetectEngineAppendSig(de_ctx, "alert tcp any any -> any any ("
356  "base64_decode; content:\"content\"; "
357  "sid:1; rev:1;)");
358  FAIL_IF_NULL(s);
360 
362  PASS;
363 }
364 
365 static int DetectBase64DecodeTestDecode(void)
366 {
367  ThreadVars tv;
368  DetectEngineCtx *de_ctx = NULL;
369  DetectEngineThreadCtx *det_ctx = NULL;
370  Packet *p = NULL;
371  int retval = 0;
372 
373  uint8_t payload[] = {
374  'S', 'G', 'V', 's', 'b', 'G', '8', 'g',
375  'V', '2', '9', 'y', 'b', 'G', 'Q', '=',
376  };
377 
378  memset(&tv, 0, sizeof(tv));
379 
380  if ((de_ctx = DetectEngineCtxInit()) == NULL) {
381  goto end;
382  }
383 
385  "alert tcp any any -> any any (msg:\"base64 test\"; "
386  "base64_decode; "
387  "sid:1; rev:1;)");
388  if (de_ctx->sig_list == NULL) {
389  goto end;
390  }
392  DetectEngineThreadCtxInit(&tv, (void *)de_ctx, (void *)&det_ctx);
393 
394  p = UTHBuildPacket(payload, sizeof(payload), IPPROTO_TCP);
395  if (p == NULL) {
396  goto end;
397  }
398 
399  SigMatchSignatures(&tv, de_ctx, det_ctx, p);
400  if (det_ctx->base64_decoded_len == 0) {
401  goto end;
402  }
403 
404  retval = 1;
405 end:
406  if (det_ctx != NULL) {
407  DetectEngineThreadCtxDeinit(&tv, det_ctx);
408  }
409  if (de_ctx != NULL) {
413  }
414  if (p != NULL) {
415  UTHFreePacket(p);
416  }
417  return retval;
418 }
419 
420 static int DetectBase64DecodeTestDecodeWithOffset(void)
421 {
422  ThreadVars tv;
423  DetectEngineCtx *de_ctx = NULL;
424  DetectEngineThreadCtx *det_ctx = NULL;
425  Packet *p = NULL;
426  int retval = 0;
427 
428  uint8_t payload[] = {
429  'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a',
430  'S', 'G', 'V', 's', 'b', 'G', '8', 'g',
431  'V', '2', '9', 'y', 'b', 'G', 'Q', '=',
432  };
433  char decoded[] = "Hello World";
434 
435  memset(&tv, 0, sizeof(tv));
436 
437  if ((de_ctx = DetectEngineCtxInit()) == NULL) {
438  goto end;
439  }
440 
442  "alert tcp any any -> any any (msg:\"base64 test\"; "
443  "base64_decode: offset 8; "
444  "sid:1; rev:1;)");
445  if (de_ctx->sig_list == NULL) {
446  goto end;
447  }
449  DetectEngineThreadCtxInit(&tv, (void *)de_ctx, (void *)&det_ctx);
450 
451  p = UTHBuildPacket(payload, sizeof(payload), IPPROTO_TCP);
452  if (p == NULL) {
453  goto end;
454  }
455 
456  SigMatchSignatures(&tv, de_ctx, det_ctx, p);
457  if (det_ctx->base64_decoded_len != (int)strlen(decoded)) {
458  goto end;
459  }
460  if (memcmp(det_ctx->base64_decoded, decoded, strlen(decoded))) {
461  goto end;
462  }
463 
464  retval = 1;
465 end:
466  if (det_ctx != NULL) {
467  DetectEngineThreadCtxDeinit(&tv, det_ctx);
468  }
469  if (de_ctx != NULL) {
473  }
474  if (p != NULL) {
475  UTHFreePacket(p);
476  }
477  return retval;
478 }
479 
480 static int DetectBase64DecodeTestDecodeLargeOffset(void)
481 {
482  ThreadVars tv;
483  DetectEngineCtx *de_ctx = NULL;
484  DetectEngineThreadCtx *det_ctx = NULL;
485  Packet *p = NULL;
486  int retval = 0;
487 
488  uint8_t payload[] = {
489  'S', 'G', 'V', 's', 'b', 'G', '8', 'g',
490  'V', '2', '9', 'y', 'b', 'G', 'Q', '=',
491  };
492 
493  memset(&tv, 0, sizeof(tv));
494 
495  if ((de_ctx = DetectEngineCtxInit()) == NULL) {
496  goto end;
497  }
498 
499  /* Offset is out of range. */
501  "alert tcp any any -> any any (msg:\"base64 test\"; "
502  "base64_decode: bytes 16, offset 32; "
503  "sid:1; rev:1;)");
504  if (de_ctx->sig_list == NULL) {
505  goto end;
506  }
508  DetectEngineThreadCtxInit(&tv, (void *)de_ctx, (void *)&det_ctx);
509 
510  p = UTHBuildPacket(payload, sizeof(payload), IPPROTO_TCP);
511  if (p == NULL) {
512  goto end;
513  }
514 
515  SigMatchSignatures(&tv, de_ctx, det_ctx, p);
516  if (det_ctx->base64_decoded_len != 0) {
517  goto end;
518  }
519 
520  retval = 1;
521 end:
522  if (det_ctx != NULL) {
523  DetectEngineThreadCtxDeinit(&tv, det_ctx);
524  }
525  if (de_ctx != NULL) {
529  }
530  if (p != NULL) {
531  UTHFreePacket(p);
532  }
533  return retval;
534 }
535 
536 static int DetectBase64DecodeTestDecodeRelative(void)
537 {
538  ThreadVars tv;
539  DetectEngineCtx *de_ctx = NULL;
540  DetectEngineThreadCtx *det_ctx = NULL;
541  Packet *p = NULL;
542  int retval = 0;
543 
544  uint8_t payload[] = {
545  'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a',
546  'S', 'G', 'V', 's', 'b', 'G', '8', 'g',
547  'V', '2', '9', 'y', 'b', 'G', 'Q', '=',
548  };
549  char decoded[] = "Hello World";
550 
551  memset(&tv, 0, sizeof(tv));
552 
553  if ((de_ctx = DetectEngineCtxInit()) == NULL) {
554  goto end;
555  }
556 
558  "alert tcp any any -> any any (msg:\"base64 test\"; "
559  "content:\"aaaaaaaa\"; "
560  "base64_decode: relative; "
561  "sid:1; rev:1;)");
562  if (de_ctx->sig_list == NULL) {
563  goto end;
564  }
566  DetectEngineThreadCtxInit(&tv, (void *)de_ctx, (void *)&det_ctx);
567 
568  p = UTHBuildPacket(payload, sizeof(payload), IPPROTO_TCP);
569  if (p == NULL) {
570  goto end;
571  }
572 
573  SigMatchSignatures(&tv, de_ctx, det_ctx, p);
574  if (det_ctx->base64_decoded_len != (int)strlen(decoded)) {
575  goto end;
576  }
577  if (memcmp(det_ctx->base64_decoded, decoded, strlen(decoded))) {
578  goto end;
579  }
580 
581  retval = 1;
582 end:
583  if (det_ctx != NULL) {
584  DetectEngineThreadCtxDeinit(&tv, det_ctx);
585  }
586  if (de_ctx != NULL) {
590  }
591  if (p != NULL) {
592  UTHFreePacket(p);
593  }
594  return retval;
595 }
596 
597 static void DetectBase64DecodeRegisterTests(void)
598 {
599  g_http_header_buffer_id = DetectBufferTypeGetByName("http_header");
600 
601  UtRegisterTest("DetectBase64TestDecodeParse", DetectBase64TestDecodeParse);
602  UtRegisterTest("DetectBase64DecodeTestSetup", DetectBase64DecodeTestSetup);
603  UtRegisterTest("DetectBase64DecodeTestDecode",
604  DetectBase64DecodeTestDecode);
605  UtRegisterTest("DetectBase64DecodeTestDecodeWithOffset",
606  DetectBase64DecodeTestDecodeWithOffset);
607  UtRegisterTest("DetectBase64DecodeTestDecodeLargeOffset",
608  DetectBase64DecodeTestDecodeLargeOffset);
609  UtRegisterTest("DetectBase64DecodeTestDecodeRelative",
610  DetectBase64DecodeTestDecodeRelative);
611 }
612 #endif /* UNITTESTS */
util-byte.h
SigTableElmt_::url
const char * url
Definition: detect.h:1312
DetectEngineThreadCtx_::buffer_offset
uint32_t buffer_offset
Definition: detect.h:1127
detect-engine.h
DETECT_SM_LIST_PMATCH
@ DETECT_SM_LIST_PMATCH
Definition: detect.h:116
FAIL_IF_NULL
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
Definition: util-unittest.h:89
SigTableElmt_::desc
const char * desc
Definition: detect.h:1311
sigmatch_table
SigTableElmt * sigmatch_table
Definition: detect-parse.c:128
offset
uint64_t offset
Definition: util-streaming-buffer.h:0
SigTableElmt_::Free
void(* Free)(DetectEngineCtx *, void *)
Definition: detect.h:1299
flow-util.h
DetectParseRegex
Definition: detect-parse.h:62
SigTableElmt_::name
const char * name
Definition: detect.h:1309
SignatureInitData_::smlists_tail
struct SigMatch_ * smlists_tail[DETECT_SM_LIST_MAX]
Definition: detect.h:590
DETECT_BYTEJUMP
@ DETECT_BYTEJUMP
Definition: detect-engine-register.h:86
stream-tcp.h
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
DetectBase64DecodeDoMatch
int DetectBase64DecodeDoMatch(DetectEngineThreadCtx *det_ctx, const Signature *s, const SigMatchData *smd, const uint8_t *payload, uint32_t payload_len)
Definition: detect-base64-decode.c:66
UtRegisterTest
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
Definition: util-unittest.c:103
DETECT_CONTENT
@ DETECT_CONTENT
Definition: detect-engine-register.h:72
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:269
SigMatchData_::ctx
SigMatchCtx * ctx
Definition: detect.h:361
SigTableElmt_::flags
uint16_t flags
Definition: detect.h:1303
DetectEngineCtx_
main detection engine ctx
Definition: detect.h:843
DetectEngineCtxFree
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
Definition: detect-engine.c:2623
rust.h
MIN
#define MIN(x, y)
Definition: suricata-common.h:391
UTHBuildPacket
Packet * UTHBuildPacket(uint8_t *payload, uint16_t payload_len, uint8_t ipproto)
UTHBuildPacket is a wrapper that build packets with default ip and port fields.
Definition: util-unittest-helper.c:359
SigMatchSignatures
void SigMatchSignatures(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p)
wrapper for old tests
Definition: detect.c:1950
DetectParsePcreExec
int DetectParsePcreExec(DetectParseRegex *parse_regex, pcre2_match_data **match, const char *str, int start_offset, int options)
Definition: detect-parse.c:2645
DetectBase64Decode
struct DetectBase64Decode_ DetectBase64Decode
SigCleanSignatures
void SigCleanSignatures(DetectEngineCtx *de_ctx)
Definition: detect-engine-build.c:55
DetectEngineAppendSig
Signature * DetectEngineAppendSig(DetectEngineCtx *, const char *)
Parse and append a Signature into the Detection Engine Context signature list.
Definition: detect-parse.c:2591
SigMatchData_
Data needed for Match()
Definition: detect.h:358
SigTableElmt_::Setup
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
Definition: detect.h:1294
util-unittest.h
util-unittest-helper.h
DetectBufferTypeGetByName
int DetectBufferTypeGetByName(const char *name)
Definition: detect-engine.c:1094
DetectBase64Decode_::offset
uint32_t offset
Definition: detect-base64-decode.c:32
PASS
#define PASS
Pass the test.
Definition: util-unittest.h:105
de_ctx
DetectEngineCtx * de_ctx
Definition: fuzz_siginit.c:17
DetectBase64Decode_
Definition: detect-base64-decode.c:30
DetectEngineThreadCtx_
Definition: detect.h:1098
DetectSetupParseRegexes
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
Definition: detect-parse.c:2771
SignatureInitData_::list
int list
Definition: detect.h:572
util-print.h
detect.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
DetectEngineThreadCtxInit
TmEcode DetectEngineThreadCtxInit(ThreadVars *tv, void *initdata, void **data)
initialize thread specific detection engine context
Definition: detect-engine.c:3365
StringParseUint32
int StringParseUint32(uint32_t *res, int base, size_t len, const char *str)
Definition: util-byte.c:313
SigInit
Signature * SigInit(DetectEngineCtx *de_ctx, const char *sigstr)
Parses a signature and adds it to the Detection Engine Context.
Definition: detect-parse.c:2289
PrintRawDataFp
void PrintRawDataFp(FILE *fp, const uint8_t *buf, uint32_t buflen)
Definition: util-print.c:111
app-layer-parser.h
DetectEngineThreadCtx_::base64_decoded_len
int base64_decoded_len
Definition: detect.h:1141
SigGroupCleanup
int SigGroupCleanup(DetectEngineCtx *de_ctx)
Definition: detect-engine-build.c:2212
BASE64_DECODE_MAX
#define BASE64_DECODE_MAX
Definition: detect-base64-decode.c:28
Packet_
Definition: decode.h:476
detect-engine-build.h
Signature_::init_data
SignatureInitData * init_data
Definition: detect.h:672
DETECT_PCRE
@ DETECT_PCRE
Definition: detect-engine-register.h:74
SigGroupBuild
int SigGroupBuild(DetectEngineCtx *de_ctx)
Convert the signature list into the runtime match structure.
Definition: detect-engine-build.c:2145
SigMatchCtx_
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
Definition: detect.h:344
DETECT_SM_LIST_NOTSET
#define DETECT_SM_LIST_NOTSET
Definition: detect.h:141
DetectBase64Decode_::relative
uint8_t relative
Definition: detect-base64-decode.c:33
DETECT_BYTETEST
@ DETECT_BYTETEST
Definition: detect-engine-register.h:85
suricata-common.h
DetectEngineThreadCtxDeinit
TmEcode DetectEngineThreadCtxDeinit(ThreadVars *tv, void *data)
Definition: detect-engine.c:3592
DetectEngineCtx_::sig_list
Signature * sig_list
Definition: detect.h:851
DetectBase64Decode_::bytes
uint32_t bytes
Definition: detect-base64-decode.c:31
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:32
SIGMATCH_OPTIONAL_OPT
#define SIGMATCH_OPTIONAL_OPT
Definition: detect.h:1502
detect-base64-decode.h
str
#define str(s)
Definition: suricata-common.h:291
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:261
SigMatchListSMBelongsTo
int SigMatchListSMBelongsTo(const Signature *s, const SigMatch *key_sm)
Definition: detect-parse.c:806
SCFree
#define SCFree(p)
Definition: util-mem.h:61
UTHFreePacket
void UTHFreePacket(Packet *p)
UTHFreePacket: function to release the allocated data from UTHBuildPacket and the packet itself.
Definition: util-unittest-helper.c:467
DETECT_BYTE_EXTRACT
@ DETECT_BYTE_EXTRACT
Definition: detect-engine-register.h:88
detect-parse.h
Signature_
Signature container.
Definition: detect.h:603
SigMatch_
a single match condition for a signature
Definition: detect.h:349
payload_len
uint16_t payload_len
Definition: stream-tcp-private.h:1
DETECT_ISDATAAT
@ DETECT_ISDATAAT
Definition: detect-engine-register.h:96
DetectEngineCtxInit
DetectEngineCtx * DetectEngineCtxInit(void)
Definition: detect-engine.c:2584
DetectEngineThreadCtx_::base64_decoded
uint8_t * base64_decoded
Definition: detect.h:1140
DETECT_BASE64_DECODE
@ DETECT_BASE64_DECODE
Definition: detect-engine-register.h:91
DetectGetLastSMFromLists
SigMatch * DetectGetLastSMFromLists(const Signature *s,...)
Returns the sm with the largest index (added latest) from the lists passed to us.
Definition: detect-parse.c:607
SigMatchAppendSMToList
SigMatch * SigMatchAppendSMToList(DetectEngineCtx *de_ctx, Signature *s, uint16_t type, SigMatchCtx *ctx, const int list)
Append a SigMatch to the list type.
Definition: detect-parse.c:437
DetectBase64DecodeRegister
void DetectBase64DecodeRegister(void)
Definition: detect-base64-decode.c:48
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
DetectEngineCtx_::base64_decode_max_len
uint32_t base64_decode_max_len
Definition: detect.h:934
DEBUG_VALIDATE_BUG_ON
#define DEBUG_VALIDATE_BUG_ON(exp)
Definition: util-validate.h:102
SigTableElmt_::RegisterTests
void(* RegisterTests)(void)
Definition: detect.h:1301