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  uint16_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  SCBase64Decode(payload, decode_len, SCBase64ModeRFC4648, 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(
114  const char *str, uint16_t *bytes, 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 (StringParseUint16(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  uint16_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 {
214  if (pm == NULL) {
215  sm_list = DETECT_SM_LIST_PMATCH;
216  }
217  else {
218  sm_list = SigMatchListSMBelongsTo(s, pm);
219  if (sm_list < 0) {
220  goto error;
221  }
222  }
223  }
224 
226  NULL) {
227  goto error;
228  }
229 
230  if (!data->bytes) {
231  data->bytes = BASE64_DECODE_MAX;
232  }
233  if (data->bytes > de_ctx->base64_decode_max_len) {
234  de_ctx->base64_decode_max_len = data->bytes;
235  }
236 
237  return 0;
238 error:
239  if (data != NULL) {
240  SCFree(data);
241  }
242  return -1;
243 }
244 
245 static void DetectBase64DecodeFree(DetectEngineCtx *de_ctx, void *ptr)
246 {
247  DetectBase64Decode *data = ptr;
248  SCFree(data);
249 }
250 
251 
252 #ifdef UNITTESTS
253 #include "detect-engine.h"
254 #include "util-unittest-helper.h"
255 #include "app-layer-parser.h"
256 #include "flow-util.h"
257 #include "stream-tcp.h"
258 
259 static int g_http_header_buffer_id = 0;
260 
261 static int DetectBase64TestDecodeParse(void)
262 {
263  int retval = 0;
264  uint16_t bytes = 0;
265  uint32_t offset = 0;
266  uint8_t relative = 0;
267 
268  if (!DetectBase64DecodeParse("bytes 1", &bytes, &offset, &relative)) {
269  goto end;
270  }
271  if (bytes != 1 || offset != 0 || relative != 0) {
272  goto end;
273  }
274 
275  if (!DetectBase64DecodeParse("offset 9", &bytes, &offset, &relative)) {
276  goto end;
277  }
278  if (bytes != 0 || offset != 9 || relative != 0) {
279  goto end;
280  }
281 
282  if (!DetectBase64DecodeParse("relative", &bytes, &offset, &relative)) {
283  goto end;
284  }
285  if (bytes != 0 || offset != 0 || relative != 1) {
286  goto end;
287  }
288 
289  if (!DetectBase64DecodeParse("bytes 1, offset 2", &bytes, &offset,
290  &relative)) {
291  goto end;
292  }
293  if (bytes != 1 || offset != 2 || relative != 0) {
294  goto end;
295  }
296 
297  if (!DetectBase64DecodeParse("bytes 1, offset 2, relative", &bytes, &offset,
298  &relative)) {
299  goto end;
300  }
301  if (bytes != 1 || offset != 2 || relative != 1) {
302  goto end;
303  }
304 
305  if (!DetectBase64DecodeParse("offset 2, relative", &bytes, &offset,
306  &relative)) {
307  goto end;
308  }
309  if (bytes != 0 || offset != 2 || relative != 1) {
310  goto end;
311  }
312 
313  /* Misspelled relative. */
314  if (DetectBase64DecodeParse("bytes 1, offset 2, relatve", &bytes, &offset,
315  &relative)) {
316  goto end;
317  }
318 
319  /* Misspelled bytes. */
320  if (DetectBase64DecodeParse("byts 1, offset 2, relatve", &bytes, &offset,
321  &relative)) {
322  goto end;
323  }
324 
325  /* Misspelled offset. */
326  if (DetectBase64DecodeParse("bytes 1, offst 2, relatve", &bytes, &offset,
327  &relative)) {
328  goto end;
329  }
330 
331  /* Misspelled empty string. */
332  if (DetectBase64DecodeParse("", &bytes, &offset, &relative)) {
333  goto end;
334  }
335 
336  retval = 1;
337 end:
338  return retval;
339 }
340 
341 /**
342  * Test keyword setup on basic content.
343  */
344 static int DetectBase64DecodeTestSetup(void)
345 {
348 
349  Signature *s = DetectEngineAppendSig(de_ctx, "alert tcp any any -> any any ("
350  "base64_decode; content:\"content\"; "
351  "sid:1; rev:1;)");
352  FAIL_IF_NULL(s);
354 
356  PASS;
357 }
358 
359 static int DetectBase64DecodeTestDecode(void)
360 {
361  ThreadVars tv;
362  DetectEngineCtx *de_ctx = NULL;
363  DetectEngineThreadCtx *det_ctx = NULL;
364  Packet *p = NULL;
365  int retval = 0;
366 
367  uint8_t payload[] = {
368  'S', 'G', 'V', 's', 'b', 'G', '8', 'g',
369  'V', '2', '9', 'y', 'b', 'G', 'Q', '=',
370  };
371 
372  memset(&tv, 0, sizeof(tv));
374 
375  if ((de_ctx = DetectEngineCtxInit()) == NULL) {
376  goto end;
377  }
378 
380  "alert tcp any any -> any any (msg:\"base64 test\"; "
381  "base64_decode; "
382  "sid:1; rev:1;)");
383  if (de_ctx->sig_list == NULL) {
384  goto end;
385  }
387  DetectEngineThreadCtxInit(&tv, (void *)de_ctx, (void *)&det_ctx);
388 
389  p = UTHBuildPacket(payload, sizeof(payload), IPPROTO_TCP);
390  if (p == NULL) {
391  goto end;
392  }
393 
394  SigMatchSignatures(&tv, de_ctx, det_ctx, p);
395  if (det_ctx->base64_decoded_len == 0) {
396  goto end;
397  }
398 
399  retval = 1;
400 end:
401  if (det_ctx != NULL) {
402  DetectEngineThreadCtxDeinit(&tv, det_ctx);
403  }
404  if (de_ctx != NULL) {
406  }
407  if (p != NULL) {
408  UTHFreePacket(p);
409  }
411  return retval;
412 }
413 
414 static int DetectBase64DecodeTestDecodeWithOffset(void)
415 {
416  ThreadVars tv;
417  DetectEngineCtx *de_ctx = NULL;
418  DetectEngineThreadCtx *det_ctx = NULL;
419  Packet *p = NULL;
420  int retval = 0;
421 
422  uint8_t payload[] = {
423  'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a',
424  'S', 'G', 'V', 's', 'b', 'G', '8', 'g',
425  'V', '2', '9', 'y', 'b', 'G', 'Q', '=',
426  };
427  char decoded[] = "Hello World";
428 
429  memset(&tv, 0, sizeof(tv));
431 
432  if ((de_ctx = DetectEngineCtxInit()) == NULL) {
433  goto end;
434  }
435 
437  "alert tcp any any -> any any (msg:\"base64 test\"; "
438  "base64_decode: offset 8; "
439  "sid:1; rev:1;)");
440  if (de_ctx->sig_list == NULL) {
441  goto end;
442  }
444  DetectEngineThreadCtxInit(&tv, (void *)de_ctx, (void *)&det_ctx);
445 
446  p = UTHBuildPacket(payload, sizeof(payload), IPPROTO_TCP);
447  if (p == NULL) {
448  goto end;
449  }
450 
451  SigMatchSignatures(&tv, de_ctx, det_ctx, p);
452  if (det_ctx->base64_decoded_len != (int)strlen(decoded)) {
453  goto end;
454  }
455  if (memcmp(det_ctx->base64_decoded, decoded, strlen(decoded))) {
456  goto end;
457  }
458 
459  retval = 1;
460 end:
461  if (det_ctx != NULL) {
462  DetectEngineThreadCtxDeinit(&tv, det_ctx);
463  }
464  if (de_ctx != NULL) {
468  }
469  if (p != NULL) {
470  UTHFreePacket(p);
471  }
473  return retval;
474 }
475 
476 static int DetectBase64DecodeTestDecodeLargeOffset(void)
477 {
478  ThreadVars tv;
479  DetectEngineCtx *de_ctx = NULL;
480  DetectEngineThreadCtx *det_ctx = NULL;
481  Packet *p = NULL;
482  int retval = 0;
483 
484  uint8_t payload[] = {
485  'S', 'G', 'V', 's', 'b', 'G', '8', 'g',
486  'V', '2', '9', 'y', 'b', 'G', 'Q', '=',
487  };
488 
489  memset(&tv, 0, sizeof(tv));
491 
492  if ((de_ctx = DetectEngineCtxInit()) == NULL) {
493  goto end;
494  }
495 
496  /* Offset is out of range. */
498  "alert tcp any any -> any any (msg:\"base64 test\"; "
499  "base64_decode: bytes 16, offset 32; "
500  "sid:1; rev:1;)");
501  if (de_ctx->sig_list == NULL) {
502  goto end;
503  }
505  DetectEngineThreadCtxInit(&tv, (void *)de_ctx, (void *)&det_ctx);
506 
507  p = UTHBuildPacket(payload, sizeof(payload), IPPROTO_TCP);
508  if (p == NULL) {
509  goto end;
510  }
511 
512  SigMatchSignatures(&tv, de_ctx, det_ctx, p);
513  if (det_ctx->base64_decoded_len != 0) {
514  goto end;
515  }
516 
517  retval = 1;
518 end:
519  if (det_ctx != NULL) {
520  DetectEngineThreadCtxDeinit(&tv, det_ctx);
521  }
522  if (de_ctx != NULL) {
524  }
525  if (p != NULL) {
526  UTHFreePacket(p);
527  }
529  return retval;
530 }
531 
532 static int DetectBase64DecodeTestDecodeRelative(void)
533 {
534  ThreadVars tv;
535  DetectEngineCtx *de_ctx = NULL;
536  DetectEngineThreadCtx *det_ctx = NULL;
537  Packet *p = NULL;
538  int retval = 0;
539 
540  uint8_t payload[] = {
541  'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a',
542  'S', 'G', 'V', 's', 'b', 'G', '8', 'g',
543  'V', '2', '9', 'y', 'b', 'G', 'Q', '=',
544  };
545  char decoded[] = "Hello World";
546 
547  memset(&tv, 0, sizeof(tv));
549 
550  if ((de_ctx = DetectEngineCtxInit()) == NULL) {
551  goto end;
552  }
553 
555  "alert tcp any any -> any any (msg:\"base64 test\"; "
556  "content:\"aaaaaaaa\"; "
557  "base64_decode: relative; "
558  "sid:1; rev:1;)");
559  if (de_ctx->sig_list == NULL) {
560  goto end;
561  }
563  DetectEngineThreadCtxInit(&tv, (void *)de_ctx, (void *)&det_ctx);
564 
565  p = UTHBuildPacket(payload, sizeof(payload), IPPROTO_TCP);
566  if (p == NULL) {
567  goto end;
568  }
569 
570  SigMatchSignatures(&tv, de_ctx, det_ctx, p);
571  if (det_ctx->base64_decoded_len != (int)strlen(decoded)) {
572  goto end;
573  }
574  if (memcmp(det_ctx->base64_decoded, decoded, strlen(decoded))) {
575  goto end;
576  }
577 
578  retval = 1;
579 end:
580  if (det_ctx != NULL) {
581  DetectEngineThreadCtxDeinit(&tv, det_ctx);
582  }
583  if (de_ctx != NULL) {
585  }
586  if (p != NULL) {
587  UTHFreePacket(p);
588  }
590  return retval;
591 }
592 
593 static void DetectBase64DecodeRegisterTests(void)
594 {
595  g_http_header_buffer_id = DetectBufferTypeGetByName("http_header");
596 
597  UtRegisterTest("DetectBase64TestDecodeParse", DetectBase64TestDecodeParse);
598  UtRegisterTest("DetectBase64DecodeTestSetup", DetectBase64DecodeTestSetup);
599  UtRegisterTest("DetectBase64DecodeTestDecode",
600  DetectBase64DecodeTestDecode);
601  UtRegisterTest("DetectBase64DecodeTestDecodeWithOffset",
602  DetectBase64DecodeTestDecodeWithOffset);
603  UtRegisterTest("DetectBase64DecodeTestDecodeLargeOffset",
604  DetectBase64DecodeTestDecodeLargeOffset);
605  UtRegisterTest("DetectBase64DecodeTestDecodeRelative",
606  DetectBase64DecodeTestDecodeRelative);
607 }
608 #endif /* UNITTESTS */
util-byte.h
SigTableElmt_::url
const char * url
Definition: detect.h:1545
DetectEngineThreadCtx_::buffer_offset
uint32_t buffer_offset
Definition: detect.h:1340
detect-engine.h
DETECT_SM_LIST_PMATCH
@ DETECT_SM_LIST_PMATCH
Definition: detect.h:120
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:1544
sigmatch_table
SigTableElmt * sigmatch_table
Definition: detect-parse.c:78
offset
uint64_t offset
Definition: util-streaming-buffer.h:0
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
SignatureInitData_::smlists_tail
struct SigMatch_ * smlists_tail[DETECT_SM_LIST_MAX]
Definition: detect.h:668
DETECT_BYTEJUMP
@ DETECT_BYTEJUMP
Definition: detect-engine-register.h:92
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:101
DETECT_CONTENT
@ DETECT_CONTENT
Definition: detect-engine-register.h:78
SigTableElmt_::flags
uint32_t flags
Definition: detect.h:1533
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:282
SigMatchData_::ctx
SigMatchCtx * ctx
Definition: detect.h:372
SCDetectGetLastSMFromLists
SigMatch * SCDetectGetLastSMFromLists(const Signature *s,...)
Returns the sm with the largest index (added latest) from the lists passed to us.
Definition: detect-parse.c:600
DetectEngineCtx_
main detection engine ctx
Definition: detect.h:995
StringParseUint16
int StringParseUint16(uint16_t *res, int base, size_t len, const char *str)
Definition: util-byte.c:295
DetectEngineCtxFree
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
Definition: detect-engine.c:2912
rust.h
MIN
#define MIN(x, y)
Definition: suricata-common.h:413
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:241
SigMatchSignatures
void SigMatchSignatures(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p)
wrapper for old tests
Definition: detect.c:3305
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:4019
DetectBase64Decode
struct DetectBase64Decode_ DetectBase64Decode
SigCleanSignatures
void SigCleanSignatures(DetectEngineCtx *de_ctx)
Definition: detect-engine-build.c:56
DetectEngineAppendSig
Signature * DetectEngineAppendSig(DetectEngineCtx *, const char *)
Parse and append a Signature into the Detection Engine Context signature list.
Definition: detect-parse.c:3965
SigMatchData_
Data needed for Match()
Definition: detect.h:369
SigTableElmt_::Setup
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
Definition: detect.h:1524
util-unittest-helper.h
DetectBufferTypeGetByName
int DetectBufferTypeGetByName(const char *name)
Definition: detect-engine.c:1452
DetectEngineCtx_::base64_decode_max_len
uint16_t base64_decode_max_len
Definition: detect.h:1090
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:22
DetectBase64Decode_
Definition: detect-base64-decode.c:30
DetectEngineThreadCtx_
Definition: detect.h:1316
DetectSetupParseRegexes
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
Definition: detect-parse.c:4145
SignatureInitData_::list
int list
Definition: detect.h:645
util-print.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
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:57
DetectEngineThreadCtxInit
TmEcode DetectEngineThreadCtxInit(ThreadVars *tv, void *initdata, void **data)
initialize thread specific detection engine context
Definition: detect-engine.c:3660
StringParseUint32
int StringParseUint32(uint32_t *res, int base, size_t len, const char *str)
Definition: util-byte.c:268
SigInit
Signature * SigInit(DetectEngineCtx *de_ctx, const char *sigstr)
Parses a signature and adds it to the Detection Engine Context.
Definition: detect-parse.c:3618
PrintRawDataFp
void PrintRawDataFp(FILE *fp, const uint8_t *buf, uint32_t buflen)
Definition: util-print.c:112
app-layer-parser.h
DetectEngineThreadCtx_::base64_decoded_len
int base64_decoded_len
Definition: detect.h:1399
SigGroupCleanup
int SigGroupCleanup(DetectEngineCtx *de_ctx)
Definition: detect-engine-build.c:2371
BASE64_DECODE_MAX
#define BASE64_DECODE_MAX
Definition: detect-base64-decode.c:28
Packet_
Definition: decode.h:516
detect-engine-build.h
Signature_::init_data
SignatureInitData * init_data
Definition: detect.h:775
DetectBase64Decode_::bytes
uint16_t bytes
Definition: detect-base64-decode.c:31
DETECT_PCRE
@ DETECT_PCRE
Definition: detect-engine-register.h:80
SigGroupBuild
int SigGroupBuild(DetectEngineCtx *de_ctx)
Convert the signature list into the runtime match structure.
Definition: detect-engine-build.c:2300
StatsThreadInit
void StatsThreadInit(StatsThreadContext *stats)
Definition: counters.c:1332
SigMatchCtx_
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
Definition: detect.h:355
DETECT_SM_LIST_NOTSET
#define DETECT_SM_LIST_NOTSET
Definition: detect.h:145
DetectBase64Decode_::relative
uint8_t relative
Definition: detect-base64-decode.c:33
DETECT_BYTETEST
@ DETECT_BYTETEST
Definition: detect-engine-register.h:91
suricata-common.h
SIGMATCH_OPTIONAL_OPT
#define SIGMATCH_OPTIONAL_OPT
Definition: detect-engine-register.h:315
DetectEngineThreadCtxDeinit
TmEcode DetectEngineThreadCtxDeinit(ThreadVars *tv, void *data)
Definition: detect-engine.c:3905
DetectEngineCtx_::sig_list
Signature * sig_list
Definition: detect.h:1005
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:34
detect-base64-decode.h
str
#define str(s)
Definition: suricata-common.h:313
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:274
SigMatchListSMBelongsTo
int SigMatchListSMBelongsTo(const Signature *s, const SigMatch *key_sm)
Definition: detect-parse.c:799
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:470
DETECT_BYTE_EXTRACT
@ DETECT_BYTE_EXTRACT
Definition: detect-engine-register.h:94
detect-parse.h
Signature_
Signature container.
Definition: detect.h:692
SigMatch_
a single match condition for a signature
Definition: detect.h:360
payload_len
uint16_t payload_len
Definition: stream-tcp-private.h:1
DETECT_ISDATAAT
@ DETECT_ISDATAAT
Definition: detect-engine-register.h:102
DetectEngineCtxInit
DetectEngineCtx * DetectEngineCtxInit(void)
Definition: detect-engine.c:2873
DetectEngineThreadCtx_::base64_decoded
uint8_t * base64_decoded
Definition: detect.h:1398
DETECT_BASE64_DECODE
@ DETECT_BASE64_DECODE
Definition: detect-engine-register.h:97
DetectBase64DecodeRegister
void DetectBase64DecodeRegister(void)
Definition: detect-base64-decode.c:48
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
ThreadVars_::stats
StatsThreadContext stats
Definition: threadvars.h:120
StatsThreadCleanup
void StatsThreadCleanup(StatsThreadContext *stats)
Definition: counters.c:1428
DEBUG_VALIDATE_BUG_ON
#define DEBUG_VALIDATE_BUG_ON(exp)
Definition: util-validate.h:109
SigTableElmt_::RegisterTests
void(* RegisterTests)(void)
Definition: detect.h:1531