55 static void DetectContentRegisterTests(
void);
84 uint8_t **pstr, uint16_t *plen)
89 slen = strlen(contentstr);
93 uint8_t buffer[slen + 1];
94 strlcpy((
char *)&buffer, contentstr, slen + 1);
106 uint8_t binstr[3] =
"";
108 uint16_t bin_count = 0;
110 for (i = 0, x = 0; i < slen; i++) {
116 SCLogError(
"Incomplete hex code in content - %s. Invalidating signature.",
124 }
else if(!escape &&
str[i] ==
'\\') {
128 if (isdigit((
unsigned char)
str[i]) ||
129 str[i] ==
'A' ||
str[i] ==
'a' ||
130 str[i] ==
'B' ||
str[i] ==
'b' ||
131 str[i] ==
'C' ||
str[i] ==
'c' ||
132 str[i] ==
'D' ||
str[i] ==
'd' ||
133 str[i] ==
'E' ||
str[i] ==
'e' ||
134 str[i] ==
'F' ||
str[i] ==
'f')
138 binstr[binpos] = (char)
str[i];
142 uint8_t c = strtol((
char *)binstr, (
char **) NULL, 16) & 0xFF;
148 }
else if (
str[i] ==
' ') {
151 else if (
str[i] !=
',') {
153 "content - %s, hex %c. Invalidating signature.",
171 }
else if (
str[i] ==
'"') {
172 SCLogError(
"Invalid unescaped double quote within content section.");
181 if (bin_count % 2 != 0) {
183 "%s - %s. Invalidating signature.",
184 keyword, contentstr);
198 memcpy(ptr,
str, slen);
200 *plen = (uint16_t)slen;
212 const char *contentstr)
215 uint8_t *content = NULL;
236 spm_global_thread_ctx);
254 const char *contentstr)
266 SCLogDebug(
"DetectContentData \"cd\" is NULL");
270 if (tmpstr != NULL) {
299 if (tmprstr != NULL) {
351 SCLogError(
"content string \"%s\" incompatible with %s transform", contentstr, tstr);
411 int max_offset = 0, total_len = 0;
413 for (; sm != NULL; sm = sm->
next) {
419 SCLogDebug(
"content_len %d; negated: %s; distance: %d, offset: %d, depth: %d",
431 if (max_size < check) {
442 max_offset =
MAX(max_offset, cd->
offset);
456 #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
457 bool has_pcre =
false;
458 bool has_content =
false;
467 if (has_pcre && !has_content) {
480 if (max_right_edge_i < 0) {
484 uint32_t max_right_edge = (uint32_t)max_right_edge_i;
487 if (min_dsize_required >= 0) {
488 SCLogDebug(
"min_dsize %d; max_right_edge %d", min_dsize_required, max_right_edge);
489 if ((uint32_t)min_dsize_required > max_right_edge) {
490 SCLogError(
"signature can't match as required content length %d exceeds dsize value %d",
491 min_dsize_required, max_right_edge);
514 #define VALIDATE(e) \
519 uint16_t offset_plus_pat = 0;
521 bool has_active_depth_chain =
false;
523 bool has_depth =
false;
524 bool has_ends_with =
false;
525 uint16_t ends_with_depth = 0;
527 for (
SigMatch *sm = sm_head; sm != NULL; sm = sm->
next) {
536 has_active_depth_chain =
false;
539 if (sm->prev == NULL) {
564 has_active_depth_chain =
false;
570 has_active_depth_chain =
true;
573 SCLogDebug(
"sm %p depth %u offset %u distance %d within %d", sm, cd->
depth,
582 has_active_depth_chain =
false;
586 SCLogDebug(
"no distance, reset offset_plus_pat & offset");
587 offset_plus_pat =
offset = 0;
590 SCLogDebug(
"stored: offset %u depth %u offset_plus_pat %u "
591 "has_active_depth_chain %s",
592 offset, depth, offset_plus_pat, has_active_depth_chain ?
"true" :
"false");
600 if (abs(cd->
distance) > offset_plus_pat)
609 if (has_active_depth_chain) {
611 if (depth && depth > offset_plus_pat) {
616 "distance to add: %u. depth + dist %u", dist, depth + dist);
620 depth + cd->
within + dist <= UINT16_MAX);
621 depth = cd->
depth = (uint16_t)(depth + cd->
within + dist);
629 if (cd->
depth == 0 && depth != 0) {
634 offset_plus_pat + cd->
distance <= UINT16_MAX);
640 depth + cd->
within <= UINT16_MAX);
641 depth = cd->
depth = (uint16_t)(cd->
within + depth);
645 has_ends_with =
true;
646 if (ends_with_depth == 0)
647 ends_with_depth = depth;
648 ends_with_depth =
MIN(ends_with_depth, depth);
656 cd->
offset = offset_plus_pat;
685 has_ends_with =
true;
686 if (ends_with_depth == 0)
687 ends_with_depth = depth;
688 ends_with_depth =
MIN(ends_with_depth, depth);
692 has_active_depth_chain =
false;
703 SCLogDebug(
"non-anchored PCRE not supported, reset offset_plus_pat & offset");
704 offset_plus_pat =
offset = depth = 0;
706 has_active_depth_chain =
false;
710 SCLogDebug(
"keyword not supported, reset offset_plus_pat & offset");
711 offset_plus_pat =
offset = depth = 0;
712 has_active_depth_chain =
false;
717 if (has_depth && has_ends_with) {
718 for (
SigMatch *sm = sm_head; sm != NULL; sm = sm->
next) {
723 cd->
depth = ends_with_depth;
743 static inline bool NeedsAsHex(uint8_t c)
767 if (NeedsAsHex(cd->
content[i])) {
769 snprintf(hex_str,
sizeof(hex_str),
"%s%02X", !hex ?
"|" :
" ", cd->
content[i]);
774 snprintf(p_str,
sizeof(p_str),
"%s%c", hex ?
"|" :
"", cd->
content[i]);
787 SCLogError(
"can't use multiple nocase modifiers with the same content");
811 static bool TestLastContent(
const Signature *s, uint16_t o, uint16_t d)
827 if (d != cd->
depth) {
834 #define TEST_RUN(sig, o, d) \
836 SCLogDebug("TEST_RUN start: '%s'", (sig)); \
837 DetectEngineCtx *de_ctx = DetectEngineCtxInit(); \
838 FAIL_IF_NULL(de_ctx); \
839 de_ctx->flags |= DE_QUIET; \
841 snprintf(rule, sizeof(rule), "alert tcp any any -> any any (%s sid:1; rev:1;)", (sig)); \
842 Signature *s = DetectEngineAppendSig(de_ctx, rule); \
844 SigPrepareStage1(de_ctx); \
845 bool res = TestLastContent(s, (o), (d)); \
846 FAIL_IF(res == false); \
847 DetectEngineCtxFree(de_ctx); \
854 static int DetectContentDepthTest01(
void)
857 TEST_RUN(
"content:\"abc\"; offset:1; depth:3;", 1, 4);
859 TEST_RUN(
"dsize:10; content:\"abc\";", 0, 10);
860 TEST_RUN(
"dsize:<10; content:\"abc\";", 0, 10);
861 TEST_RUN(
"dsize:5<>10; content:\"abc\";", 0, 10);
864 TEST_RUN(
"content:\"abc\"; depth:3; content:\"xyz\"; distance:0; within:3; ", 3, 6);
866 TEST_RUN(
"content:\"abc\"; offset:3; depth:3; content:\"xyz\"; distance:0; within:3; ", 6, 9);
867 TEST_RUN(
"content:\"abc\"; depth:6; content:\"xyz\"; distance:0; within:3; ", 3, 9);
870 TEST_RUN(
"content:\"abc\"; depth:3; content:\"klm\"; distance:0; within:3; content:\"xyz\"; distance:0; within:3; ", 6, 9);
872 TEST_RUN(
"content:\"abc\"; depth:3; content:\"klm\"; content:\"xyz\"; distance:0; within:3; ", 3, 0);
874 TEST_RUN(
"content:\"abc\"; depth:3; pcre:/\"klm\"/; content:\"xyz\"; distance:0; within:3; ", 0, 0);
876 TEST_RUN(
"content:\"abc\"; depth:3; pcre:/\"klm\"/R; content:\"xyz\"; distance:0; within:3; ", 3, 0);
877 TEST_RUN(
"content:\"abc\"; offset:3; depth:3; pcre:/\"klm\"/R; content:\"xyz\"; distance:0; within:3; ", 6, 0);
879 TEST_RUN(
"content:\"abc\"; depth:3; content:\"klm\"; within:3; content:\"xyz\"; within:3; ", 0, 9);
881 TEST_RUN(
"content:\"abc\"; depth:3; content:\"klm\"; distance:0; content:\"xyz\"; distance:0; ", 6, 0);
884 TEST_RUN(
"content:\"abc\"; depth:6; isdataat:!1,relative; content:\"klm\";", 0, 6);
885 TEST_RUN(
"content:\"abc\"; depth:3; content:\"klm\"; within:3; content:\"xyz\"; within:3; isdataat:!1,relative; content:\"def\"; ", 0, 9);
887 TEST_RUN(
"content:\"|03|\"; depth:1; content:\"|e0|\"; distance:4; within:1;", 5, 6);
888 TEST_RUN(
"content:\"|03|\"; depth:1; content:\"|e0|\"; distance:4; within:1; content:\"Cookie|3a|\"; distance:5; within:7;", 11, 18);
890 TEST_RUN(
"content:\"this\"; content:\"is\"; within:6; content:\"big\"; within:8; content:\"string\"; within:8;", 0, 0);
892 TEST_RUN(
"dsize:<80; content:!\"|00 22 02 00|\"; depth: 4; content:\"|00 00 04|\"; distance:8; within:3; content:\"|00 00 00 00 00|\"; distance:6; within:5;", 17, 80);
893 TEST_RUN(
"content:!\"|00 22 02 00|\"; depth: 4; content:\"|00 00 04|\"; distance:8; within:3; content:\"|00 00 00 00 00|\"; distance:6; within:5;", 17, 0);
895 TEST_RUN(
"content:\"|0d 0a 0d 0a|\"; content:\"code=\"; distance:0;", 4, 0);
896 TEST_RUN(
"content:\"|0d 0a 0d 0a|\"; content:\"code=\"; distance:0; content:\"xploit.class\"; distance:2; within:18;", 11, 0);
898 TEST_RUN(
"content:\"|16 03|\"; depth:2; content:\"|55 04 0a|\"; distance:0;", 2, 0);
899 TEST_RUN(
"content:\"|16 03|\"; depth:2; content:\"|55 04 0a|\"; distance:0; content:\"|0d|LogMeIn, Inc.\"; distance:1; within:14;", 6, 0);
900 TEST_RUN(
"content:\"|16 03|\"; depth:2; content:\"|55 04 0a|\"; distance:0; content:\"|0d|LogMeIn, Inc.\"; distance:1; within:14; content:\".app\";", 0, 0);
902 TEST_RUN(
"content:\"=\"; offset:4; depth:9;", 4, 13);
905 TEST_RUN(
"content:\"=\"; offset:4; depth:9; content:\"=&\"; distance:55; within:2;", 60, 70);
908 TEST_RUN(
"content:\"0123456789\"; content:\"abcdef\"; distance:1048576;", 0, 0);
911 TEST_RUN(
"content:\"SMB\"; depth:8; content:\"|09 00|\"; distance:8; within:2;", 11, 18);
912 TEST_RUN(
"content:\"SMB\"; depth:8; content:\"|09 00|\"; distance:8; within:2; content:\"|05 "
913 "00 00|\"; distance:0;",
915 TEST_RUN(
"content:\"SMB\"; depth:8; content:\"|09 00|\"; distance:8; within:2; content:\"|05 "
916 "00 00|\"; distance:0; content:\"|0c 00|\"; distance:19; within:2;",
918 TEST_RUN(
"content:\"SMB\"; depth:8; content:\"|09 00|\"; distance:8; within:2; content:\"|05 "
919 "00 00|\"; distance:0; content:\"|0c 00|\"; distance:19; within:2; content:\"|15 00 "
920 "00 00|\"; distance:20; within:4;",
931 static void DetectContentPrintAll(
SigMatch *sm)
943 for (; first_sm != NULL; first_sm = first_sm->
next) {
945 SCLogDebug(
"Printing SigMatch DETECT_CONTENT %d", ++i);
953 static int g_file_data_buffer_id = 0;
954 static int g_dce_stub_data_buffer_id = 0;
959 static int DetectContentParseTest01 (
void)
963 const char *teststring =
"abc\\:def";
964 const char *teststringparsed =
"abc:def";
968 FAIL_IF(spm_global_thread_ctx == NULL);
972 if (memcmp(cd->
content, teststringparsed, strlen(teststringparsed)) != 0) {
973 SCLogDebug(
"expected %s got ", teststringparsed);
980 SCLogDebug(
"expected %s got NULL: ", teststringparsed);
990 static int DetectContentParseTest02 (
void)
994 const char *teststring =
"abc\\;def";
995 const char *teststringparsed =
"abc;def";
999 FAIL_IF(spm_global_thread_ctx == NULL);
1003 if (memcmp(cd->
content, teststringparsed, strlen(teststringparsed)) != 0) {
1004 SCLogDebug(
"expected %s got ", teststringparsed);
1011 SCLogDebug(
"expected %s got NULL: ", teststringparsed);
1021 static int DetectContentParseTest03 (
void)
1025 const char *teststring =
"abc\\\"def";
1026 const char *teststringparsed =
"abc\"def";
1030 FAIL_IF(spm_global_thread_ctx == NULL);
1034 if (memcmp(cd->
content, teststringparsed, strlen(teststringparsed)) != 0) {
1035 SCLogDebug(
"expected %s got ", teststringparsed);
1042 SCLogDebug(
"expected %s got NULL: ", teststringparsed);
1052 static int DetectContentParseTest04 (
void)
1056 const char *teststring =
"abc\\\\def";
1057 const char *teststringparsed =
"abc\\def";
1061 FAIL_IF(spm_global_thread_ctx == NULL);
1066 if (memcmp(cd->
content, teststringparsed,
len) != 0) {
1067 SCLogDebug(
"expected %s got ", teststringparsed);
1074 SCLogDebug(
"expected %s got NULL: ", teststringparsed);
1084 static int DetectContentParseTest05 (
void)
1088 const char *teststring =
"abc\\def";
1092 FAIL_IF(spm_global_thread_ctx == NULL);
1109 static int DetectContentParseTest06 (
void)
1113 const char *teststring =
"a|42|c|44|e|46|";
1114 const char *teststringparsed =
"abcdef";
1118 FAIL_IF(spm_global_thread_ctx == NULL);
1123 if (memcmp(cd->
content, teststringparsed,
len) != 0) {
1124 SCLogDebug(
"expected %s got ", teststringparsed);
1131 SCLogDebug(
"expected %s got NULL: ", teststringparsed);
1141 static int DetectContentParseTest07 (
void)
1145 const char *teststring =
"";
1149 FAIL_IF(spm_global_thread_ctx == NULL);
1164 static int DetectContentParseTest08 (
void)
1168 const char *teststring =
"";
1172 FAIL_IF(spm_global_thread_ctx == NULL);
1193 static int DetectContentLongPatternMatchTest(uint8_t *raw_eth_pkt, uint16_t pktsize,
const char *sig,
1203 memset(&th_v, 0,
sizeof(th_v));
1222 SCLogDebug(
"---DetectContentLongPatternMatchTest---");
1242 static int DetectContentLongPatternMatchTestWrp(
const char *sig, uint32_t sid)
1249 uint8_t raw_eth_pkt[] = {
1250 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
1251 0x00,0x00,0x00,0x00,0x08,0x00,0x45,0x00,
1252 0x00,0x85,0x00,0x01,0x00,0x00,0x40,0x06,
1253 0x7c,0x70,0x7f,0x00,0x00,0x01,0x7f,0x00,
1254 0x00,0x01,0x00,0x14,0x00,0x50,0x00,0x00,
1255 0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x02,
1256 0x20,0x00,0xc9,0xad,0x00,0x00,0x48,0x69,
1257 0x2c,0x20,0x74,0x68,0x69,0x73,0x20,0x69,
1258 0x73,0x20,0x61,0x20,0x62,0x69,0x67,0x20,
1259 0x74,0x65,0x73,0x74,0x20,0x74,0x6f,0x20,
1260 0x63,0x68,0x65,0x63,0x6b,0x20,0x63,0x6f,
1261 0x6e,0x74,0x65,0x6e,0x74,0x20,0x6d,0x61,
1262 0x74,0x63,0x68,0x65,0x73,0x20,0x6f,0x66,
1263 0x20,0x73,0x70,0x6c,0x69,0x74,0x74,0x65,
1264 0x64,0x20,0x70,0x61,0x74,0x74,0x65,0x72,
1265 0x6e,0x73,0x20,0x62,0x65,0x74,0x77,0x65,
1266 0x65,0x6e,0x20,0x6d,0x75,0x6c,0x74,0x69,
1267 0x70,0x6c,0x65,0x20,0x63,0x68,0x75,0x6e,
1270 return DetectContentLongPatternMatchTest(raw_eth_pkt, (uint16_t)
sizeof(raw_eth_pkt),
1277 static int DetectContentLongPatternMatchTest01(
void)
1279 const char *sig =
"alert tcp any any -> any any (msg:\"Nothing..\";"
1280 " content:\"Hi, this is a big test\"; sid:1;)";
1281 return DetectContentLongPatternMatchTestWrp(sig, 1);
1287 static int DetectContentLongPatternMatchTest02(
void)
1289 const char *sig =
"alert tcp any any -> any any (msg:\"Nothing..\";"
1290 " content:\"Hi, this is a big test to check content matches of"
1291 " splitted patterns between multiple chunks!\"; sid:1;)";
1292 return DetectContentLongPatternMatchTestWrp(sig, 1);
1299 static int DetectContentLongPatternMatchTest03(
void)
1302 const char *sig =
"alert tcp any any -> any any (msg:\"Nothing..\";"
1303 " content:\"Hi, this is a big test to check content matches of"
1304 " splitted patterns between multiple splitted chunks!\"; sid:1;)";
1305 return (DetectContentLongPatternMatchTestWrp(sig, 1) == 0) ? 1: 0;
1311 static int DetectContentLongPatternMatchTest04(
void)
1313 const char *sig =
"alert tcp any any -> any any (msg:\"Nothing..\"; "
1314 " content:\"Hi, this is\"; depth:15 ;content:\"a big test\"; "
1315 " within:15; content:\"to check content matches of\"; "
1316 " within:30; content:\"splitted patterns\"; distance:1; "
1319 return DetectContentLongPatternMatchTestWrp(sig, 1);
1327 static int DetectContentLongPatternMatchTest05(
void)
1329 const char *sig =
"alert tcp any any -> any any (msg:\"Nothing..\"; "
1330 " content:\"Hi, this is a big\"; depth:17; "
1331 " isdataat:30, relative; "
1332 " content:\"test\"; within: 5; distance:1; "
1333 " isdataat:15, relative; "
1334 " content:\"of splitted\"; within:37; distance:15; "
1335 " isdataat:20,relative; "
1336 " content:\"patterns\"; within:9; distance:1; "
1337 " isdataat:10, relative; "
1339 return DetectContentLongPatternMatchTestWrp(sig, 1);
1347 static int DetectContentLongPatternMatchTest06(
void)
1349 const char *sig =
"alert tcp any any -> any any (msg:\"Nothing..\"; "
1350 " content:\"Hi, this is a big test to check cont\"; depth:36;"
1351 " content:\"ent matches\"; within:11; distance:0; "
1352 " content:\"of splitted patterns between multiple\"; "
1353 " within:38; distance:1; "
1354 " content:\"chunks!\"; within: 8; distance:1; "
1356 return DetectContentLongPatternMatchTestWrp(sig, 1);
1363 static int DetectContentLongPatternMatchTest07(
void)
1365 const char *sig =
"alert tcp any any -> any any (msg:\"Nothing..\"; "
1366 " content:\"chunks!\"; "
1367 " content:\"content matches\"; offset:32; depth:47; "
1368 " content:\"of splitted patterns between multiple\"; "
1369 " content:\"Hi, this is a big\"; offset:0; depth:17; "
1371 return DetectContentLongPatternMatchTestWrp(sig, 1);
1378 static int DetectContentLongPatternMatchTest08(
void)
1380 const char *sig =
"alert tcp any any -> any any (msg:\"Nothing..\"; "
1381 " content:\"ent matches\"; "
1382 " content:\"of splitted patterns between multiple\"; "
1383 " within:38; distance:1; "
1384 " content:\"chunks!\"; within: 8; distance:1; "
1385 " content:\"Hi, this is a big test to check cont\"; depth:36;"
1387 return DetectContentLongPatternMatchTestWrp(sig, 1);
1394 static int DetectContentLongPatternMatchTest09(
void)
1396 const char *sig =
"alert tcp any any -> any any (msg:\"Nothing..\"; "
1397 " content:\"ent matches\"; "
1398 " content:\"of splitted patterns between multiple\"; "
1399 " offset:47; depth:85; "
1400 " content:\"chunks!\"; within: 8; distance:1; "
1401 " content:\"Hi, this is a big test to chec\"; depth:36;"
1402 " content:\"k cont\"; distance:0; within:6;"
1404 return DetectContentLongPatternMatchTestWrp(sig, 1);
1410 static int DetectContentLongPatternMatchTest10(
void)
1412 const char *sig =
"alert tcp any any -> any any (msg:\"Nothing..\"; "
1413 " content:\"Hi, this is a big test to check \"; "
1414 " content:\"con\"; "
1416 return DetectContentLongPatternMatchTestWrp(sig, 1);
1422 static int DetectContentLongPatternMatchTest11(
void)
1424 const char *sig =
"alert tcp any any -> any any (msg:\"Nothing..\"; "
1428 return DetectContentLongPatternMatchTestWrp(sig, 1);
1431 static int DetectContentParseTest09(
void)
1434 const char *teststring =
"boo";
1438 FAIL_IF(spm_global_thread_ctx == NULL);
1451 static int DetectContentParseTest17(
void)
1454 const char *sigstr =
"alert tcp any any -> any any (msg:\"Dummy\"; "
1455 "content:\"one\"; content:\"two\"; within:2; sid:1;)";
1477 static int DetectContentParseTest18(
void)
1505 static int DetectContentParseTest19(
void)
1514 "(msg:\"Testing dce iface, stub_data with content\"; "
1515 "dce_iface:3919286a-b10c-11d0-9ba8-00c04fd92ef5; "
1517 "content:\"one\"; distance:0; sid:1;)");
1529 "alert tcp any any -> any any "
1530 "(msg:\"Testing dce iface, stub_data with contents & distance, within\"; "
1531 "dce_iface:3919286a-b10c-11d0-9ba8-00c04fd92ef5; "
1533 "content:\"one\"; distance:0; content:\"two\"; within:10; sid:2;)");
1548 "alert tcp any any -> any any "
1549 "(msg:\"Testing dce iface, stub with contents, distance, within\"; "
1550 "dce_iface:3919286a-b10c-11d0-9ba8-00c04fd92ef5; "
1552 "content:\"one\"; distance:0; "
1553 "content:\"two\"; within:10; distance:2; sid:3;)");
1568 "(msg:\"Testing content\"; "
1569 "content:\"one\"; sid:4;)");
1581 static int DetectContentParseTest20(
void)
1592 "alert udp any any -> any any "
1593 "(msg:\"test\"; content:\"\"; sid:238012;)");
1610 static int DetectContentParseTest21(
void)
1621 "alert udp any any -> any any "
1622 "(msg:\"test\"; content:\"; sid:238012;)");
1639 static int DetectContentParseTest22(
void)
1650 "alert udp any any -> any any "
1651 "(msg:\"test\"; content:\"boo; sid:238012;)");
1668 static int DetectContentParseTest23(
void)
1679 "alert udp any any -> any any "
1680 "(msg:\"test\"; content:boo\"; sid:238012;)");
1697 static int DetectContentParseTest24(
void)
1710 "alert udp any any -> any any "
1711 "(msg:\"test\"; content: !\"boo\"; sid:238012;)");
1713 printf(
"de_ctx->sig_list == NULL: ");
1720 printf(
"de_ctx->pmatch_tail == NULL || de_ctx->pmatch_tail->ctx == NULL: ");
1739 static int DetectContentParseTest25(
void)
1750 "alert udp any any -> any any "
1751 "(msg:\"test\"; content:\"|\"; sid:1;)");
1768 static int DetectContentParseTest26(
void)
1779 "alert udp any any -> any any "
1780 "(msg:\"test\"; content:\"|af\"; sid:1;)");
1797 static int DetectContentParseTest27(
void)
1808 "alert udp any any -> any any "
1809 "(msg:\"test\"; content:\"af|\"; sid:1;)");
1826 static int DetectContentParseTest28(
void)
1837 "alert udp any any -> any any "
1838 "(msg:\"test\"; content:\"|af|\"; sid:1;)");
1855 static int DetectContentParseTest29(
void)
1866 "alert udp any any -> any any "
1867 "(msg:\"test\"; content:\"aast|\"; sid:1;)");
1884 static int DetectContentParseTest30(
void)
1895 "alert udp any any -> any any "
1896 "(msg:\"test\"; content:\"aast|af\"; sid:1;)");
1913 static int DetectContentParseTest31(
void)
1924 "alert udp any any -> any any "
1925 "(msg:\"test\"; content:\"aast|af|\"; sid:1;)");
1942 static int DetectContentParseTest32(
void)
1953 "alert udp any any -> any any "
1954 "(msg:\"test\"; content:\"|af|asdf\"; sid:1;)");
1971 static int DetectContentParseTest33(
void)
1982 "alert udp any any -> any any "
1983 "(msg:\"test\"; content:\"|af|af|\"; sid:1;)");
2000 static int DetectContentParseTest34(
void)
2011 "alert udp any any -> any any "
2012 "(msg:\"test\"; content:\"|af|af|af\"; sid:1;)");
2029 static int DetectContentParseTest35(
void)
2040 "alert udp any any -> any any "
2041 "(msg:\"test\"; content:\"|af|af|af|\"; sid:1;)");
2055 static int SigTestPositiveTestContent(
const char *rule, uint8_t *buf)
2057 uint16_t buflen = strlen((
char *)buf);
2061 memset(&th_v, 0,
sizeof(th_v));
2087 static int DetectContentParseTest41(
void)
2092 char *teststring =
SCMalloc(
sizeof(
char) * (patlen + 1));
2096 for (
int i = 0; i < patlen; idx++, i++) {
2097 teststring[idx] =
'a';
2099 teststring[idx++] =
'\0';
2103 FAIL_IF(spm_global_thread_ctx == NULL);
2120 static int DetectContentParseTest42(
void)
2125 char *teststring =
SCMalloc(
sizeof(
char) * (patlen + 1));
2129 for (
int i = 0; i < patlen; idx++, i++) {
2130 teststring[idx] =
'a';
2132 teststring[idx++] =
'\0';
2136 FAIL_IF(spm_global_thread_ctx == NULL);
2150 static int DetectContentParseTest43(
void)
2155 char *teststring =
SCMalloc(
sizeof(
char) * (patlen + 1));
2159 teststring[idx++] =
'|';
2160 teststring[idx++] =
'4';
2161 teststring[idx++] =
'6';
2162 teststring[idx++] =
'|';
2163 for (
int i = 0; i < (patlen - 4); idx++, i++) {
2164 teststring[idx] =
'a';
2166 teststring[idx++] =
'\0';
2170 FAIL_IF(spm_global_thread_ctx == NULL);
2187 static int DetectContentParseTest44(
void)
2192 char *teststring =
SCMalloc(
sizeof(
char) * (patlen + 1));
2196 teststring[idx++] =
'|';
2197 teststring[idx++] =
'4';
2198 teststring[idx++] =
'6';
2199 teststring[idx++] =
'|';
2200 for (
int i = 0; i < (patlen - 4); idx++, i++) {
2201 teststring[idx] =
'a';
2203 teststring[idx++] =
'\0';
2207 FAIL_IF(spm_global_thread_ctx == NULL);
2224 static int DetectContentParseTest45(
void)
2233 "alert tcp any any -> any any "
2234 "(msg:\"test\"; content:\"|ff|\" content:\"TEST\"; sid:1;)");
2242 static int SigTestNegativeTestContent(
const char *rule, uint8_t *buf)
2244 uint16_t buflen = strlen((
char *)buf);
2249 memset(&th_v, 0,
sizeof(th_v));
2274 if (det_ctx != NULL) {
2290 static int SigTest41TestNegatedContent(
void)
2292 return SigTestPositiveTestContent(
"alert tcp any any -> any any "
2293 "(msg:\"HTTP URI cap\"; content:!\"GES\"; sid:1;)",
2295 (uint8_t *)
"GET /one/ HTTP/1.1\r\n Host: one.example.org\r\n\r\n\r\n"
2296 "GET /two/ HTTP/1.1\r\nHost: two.example.org\r\n\r\n\r\n");
2304 static int SigTest41aTestNegatedContent(
void)
2306 (void)SigTestPositiveTestContent(
"alert tcp any any -> any any (msg:\"HTTP URI cap\"; flow:to_server; content:\"GET\"; sid:1;)", (uint8_t *)
"GET /one/ HTTP/1.1\r\n Host: one.example.org\r\n\r\n\r\nGET /two/ HTTP/1.1\r\nHost: two.example.org\r\n\r\n\r\n");
2315 static int SigTest42TestNegatedContent(
void)
2317 return SigTestPositiveTestContent(
2318 "alert tcp any any -> any any (content:!\"eeeeeeeeeee\"; depth:22; offset:35; sid:1;)",
2319 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff gggggggg hhhhhhhh");
2329 static int SigTest43TestNegatedContent(
void)
2331 return SigTestNegativeTestContent(
2332 "alert tcp any any -> any any (content:!\"eeeeeeeeeee\"; depth:34; offset:23; sid:1;)",
2333 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff gggggggg hhhhhhhh");
2341 static int SigTest44TestNegatedContent(
void)
2343 return SigTestPositiveTestContent(
2344 "alert tcp any any -> any any (content:!\"eeeeeeeeeee\"; offset:40; depth:35; sid:1;)",
2345 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff gggggggg hhhhhhhh");
2352 static int SigTest45TestNegatedContent(
void)
2354 return SigTestPositiveTestContent(
"alert tcp any any -> any any (content:\"aaa\"; depth:5; "
2355 "content:!\"eeeeeeeeeee\"; depth:23; sid:1;)",
2356 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff gggggggg hhhhhhhh");
2363 static int SigTest46TestNegatedContent(
void)
2365 return SigTestNegativeTestContent(
"alert tcp any any -> any any (content:\"aaaE\"; "
2366 "content:!\"eeeeeeeeeee\"; depth:23; sid:1;)",
2367 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff gggggggg hhhhhhhh");
2375 static int SigTest47TestNegatedContent(
void)
2377 return SigTestNegativeTestContent(
"alert tcp any any -> any any (content:\"aaa\"; offset:5; "
2378 "content:!\"eeeeeeeeeee\"; depth:23; sid:1;)",
2379 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff gggggggg hhhhhhhh");
2386 static int SigTest48TestNegatedContent(
void)
2388 return SigTestPositiveTestContent(
2389 "alert tcp any any -> any any (content:\"GET\"; content:!\"GES\"; within:26; sid:1;)",
2390 (uint8_t *)
"GET /one/ HTTP/1.1\r\n Host: one.example.org\r\n\r\n\r\nGET /two/ "
2391 "HTTP/1.1\r\nHost: two.example.org\r\n\r\n\r\n");
2398 static int SigTest49TestNegatedContent(
void)
2400 return SigTestNegativeTestContent(
2401 "alert tcp any any -> any any (content:\"GET\"; content:!\"Host\"; within:26; sid:1;)",
2402 (uint8_t *)
"GET /one/ HTTP/1.1\r\n Host: one.example.org\r\n\r\n\r\nGET /two/ "
2403 "HTTP/1.1\r\nHost: two.example.org\r\n\r\n\r\n");
2410 static int SigTest50TestNegatedContent(
void)
2412 return SigTestPositiveTestContent(
2413 "alert tcp any any -> any any (content:\"GET\"; content:!\"GES\"; distance:25; sid:1;)",
2414 (uint8_t *)
"GET /one/ HTTP/1.1\r\n Host: one.example.org\r\n\r\n\r\nGET /two/ "
2415 "HTTP/1.1\r\nHost: two.example.org\r\n\r\n\r\n");
2425 static int SigTest51TestNegatedContent(
void)
2427 return SigTestNegativeTestContent(
"alert tcp any any -> any any (content:\"GET\"; content:!\"Host\"; distance:17; sid:1;)", (uint8_t *)
"GET /one/ HTTP/1.1\r\nHost: one.example.org\r\n\r\n\r\nGET /two/ HTTP/1.1\r\nHost: two.example.org\r\n\r\n\r\n");
2434 static int SigTest52TestNegatedContent(
void)
2436 return SigTestNegativeTestContent(
2437 "alert tcp any any -> any any (content:\"GES\"; content:!\"BOO\"; sid:1;)",
2438 (uint8_t *)
"GET /one/ HTTP/1.1\r\n Host: one.example.org\r\n\r\n\r\nGET /two/ "
2439 "HTTP/1.1\r\nHost: two.example.org\r\n\r\n\r\n");
2446 static int SigTest53TestNegatedContent(
void)
2448 return SigTestNegativeTestContent(
2449 "alert tcp any any -> any any (content:\"aaa\"; content:!\"Ggggg\"; within:56; sid:1;)",
2450 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2457 static int SigTest54TestNegatedContent(
void)
2459 return SigTestPositiveTestContent(
"alert tcp any any -> any any (content:\"aaa\"; "
2460 "content:!\"gggggg\"; within:20; sid:1;)",
2461 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff ggggggggg hhhhhhhh");
2468 static int SigTest55TestNegatedContent(
void)
2470 return SigTestNegativeTestContent(
2471 "alert tcp any any -> any any (content:!\"aaa\"; depth:5; sid:1;)",
2472 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff gggggggg hhhhhhhh");
2479 static int SigTest56TestNegatedContent(
void)
2481 return SigTestPositiveTestContent(
2482 "alert tcp any any -> any any (content:\"aaa\"; content:\"Ggggg\"; within:56; sid:1;)",
2483 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Gggggggg hhhhhhhh");
2490 static int SigTest57TestNegatedContent(
void)
2492 return SigTestNegativeTestContent(
2493 "alert tcp any any -> any any (content:\"aaa\"; content:!\"Ggggg\"; within:56; sid:1;)",
2494 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2501 static int SigTest58TestNegatedContent(
void)
2503 return SigTestPositiveTestContent(
"alert tcp any any -> any any (content:\"aaa\"; "
2504 "content:!\"Ggggg\"; distance:57; sid:1;)",
2505 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2512 static int SigTest59TestNegatedContent(
void)
2514 return SigTestNegativeTestContent(
"alert tcp any any -> any any (content:\"aaa\"; "
2515 "content:!\"Gggg\"; distance:30; sid:1;)",
2516 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2519 static int SigTest60TestNegatedContent(
void)
2521 return SigTestNegativeTestContent(
2522 "alert tcp any any -> any any (content:!\"aaa\"; content:\"Ggggg\"; sid:1;)",
2523 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2526 static int SigTest61TestNegatedContent(
void)
2528 return SigTestPositiveTestContent(
"alert tcp any any -> any any (content:\"aaa\"; depth:10; "
2529 "content:!\"Ggggg\"; within:30; sid:1;)",
2530 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2540 static int SigTest62TestNegatedContent(
void)
2542 return SigTestNegativeTestContent(
"alert tcp any any -> any any (content:\"aaa\"; depth:10; "
2543 "content:!\"Gggggg\"; within:49; sid:1;)",
2544 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2547 static int SigTest63TestNegatedContent(
void)
2549 return SigTestNegativeTestContent(
"alert tcp any any -> any any (content:\"aaa\"; depth:10; "
2550 "content:!\"Gggggg\"; within:56; sid:1;)",
2551 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2554 static int SigTest64TestNegatedContent(
void)
2556 return SigTestPositiveTestContent(
"alert tcp any any -> any any (content:\"aaa\"; depth:10; "
2557 "content:!\"Gggggg\"; within:30; sid:1;)",
2558 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2568 static int SigTest65TestNegatedContent(
void)
2570 return SigTestNegativeTestContent(
"alert tcp any any -> any any (content:\"aaa\"; depth:10; "
2571 "content:!\"Gggggg\"; distance:0; within:49; sid:1;)",
2572 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2575 static int SigTest66TestNegatedContent(
void)
2577 return SigTestPositiveTestContent(
"alert tcp any any -> any any (content:\"aaa\"; depth:10; "
2578 "content:!\"Gggggg\"; within:30; sid:1;)",
2579 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2582 static int SigTest67TestNegatedContent(
void)
2584 return SigTestNegativeTestContent(
"alert tcp any any -> any any (content:\"aaa\"; depth:10; "
2585 "content:!\"XXXX\"; within:56; sid:1;)",
2586 (uint8_t *)
"aaa bbbb cccc XXXXdddd eeeeeeeeeee ffffffffff XXXXggggg hhhhhhhh");
2589 static int SigTest68TestNegatedContent(
void)
2591 return SigTestPositiveTestContent(
2592 "alert tcp any any -> any any (content:\"aaa\"; depth:10; content:\"cccc\"; offset:8; "
2593 "content:!\"Gggggg\"; within:28; content:\"hhhhhhhh\"; sid:1;)",
2594 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2597 static int SigTest69TestNegatedContent(
void)
2599 return SigTestNegativeTestContent(
2600 "alert tcp any any -> any any (content:\"aaa\"; depth:10; content:\"cccc\"; offset:8; "
2601 "content:!\"Gggggg\"; within:48; content:\"hhhhhhhh\"; sid:1;)",
2602 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2605 static int SigTest70TestNegatedContent(
void)
2607 return SigTestNegativeTestContent(
"alert tcp any any -> any any (content:\"aaa\"; "
2608 "content:!\"Gggggg\"; within:52; sid:1;)",
2609 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2613 static int SigTest71TestNegatedContent(
void)
2615 return SigTestNegativeTestContent(
"alert tcp any any -> any any (content:\"aaa\"; "
2616 "content:!\"Gggggg\"; within:40; distance:43; sid:1;)",
2617 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2620 static int SigTest72TestNegatedContent(
void)
2622 return SigTestNegativeTestContent(
"alert tcp any any -> any any (content:\"aaa\"; "
2623 "content:!\"Gggggg\"; within:49; distance:43; sid:1;)",
2624 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2627 static int SigTest73TestNegatedContent(
void)
2629 return SigTestNegativeTestContent(
"alert tcp any any -> any any (content:\"aaa\"; depth:5; "
2630 "content:!\"eeeeeeeeeee\"; depth:35; sid:1;)",
2631 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff ggggggggg hhhhhhhh");
2634 static int SigTest74TestNegatedContent(
void)
2636 return SigTestPositiveTestContent(
"alert tcp any any -> any any (msg:\"HTTP URI cap\"; content:\"USER\"; content:!\"PASS\"; sid:1;)", (uint8_t *)
"USER apple");
2639 static int SigTest75TestNegatedContent(
void)
2641 return SigTestPositiveTestContent(
"alert tcp any any -> any any (msg:\"HTTP URI cap\"; content:\"USER\"; content:\"!PASS\"; sid:1;)", (uint8_t *)
"USER !PASS");
2644 static int SigTest76TestBug134(
void)
2646 uint8_t *buf = (uint8_t *)
"test detect ${IFS} in traffic";
2647 uint16_t buflen = strlen((
char *)buf);
2652 memset(&f, 0,
sizeof(
Flow));
2661 char sig[] =
"alert tcp any any -> any 515 "
2662 "(msg:\"detect IFS\"; flow:to_server,established; content:\"${IFS}\";"
2663 " depth:50; offset:0; sid:900091; rev:1;)";
2678 static int SigTest77TestBug139(
void)
2681 0x12, 0x23, 0x34, 0x35, 0x52, 0x52, 0x24, 0x42, 0x22, 0x24,
2682 0x52, 0x24, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x34 };
2683 uint16_t buflen =
sizeof(buf);
2688 char sig[] =
"alert udp any any -> any 53 (msg:\"dns testing\";"
2689 " content:\"|00 00|\"; depth:5; offset:13; sid:9436601;"
2703 static int DetectLongContentTestCommon(
const char *sig, uint32_t sid)
2706 static uint8_t pkt[739] = {
2707 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2708 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
2709 0x02, 0xd5, 0x4a, 0x18, 0x40, 0x00, 0x40, 0x06,
2710 0xd7, 0xd6, 0x0a, 0x10, 0x01, 0x0b, 0x0a, 0x10,
2711 0x01, 0x0a, 0xdb, 0x36, 0x00, 0x50, 0xca, 0xc5,
2712 0xcc, 0xd1, 0x95, 0x77, 0x0f, 0x7d, 0x80, 0x18,
2713 0x00, 0xe5, 0x77, 0x9d, 0x00, 0x00, 0x01, 0x01,
2714 0x08, 0x0a, 0x1d, 0xe0, 0x86, 0xc6, 0xfc, 0x73,
2715 0x49, 0xf3, 0x50, 0x4f, 0x53, 0x54, 0x20, 0x2f,
2716 0x20, 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e,
2717 0x31, 0x0d, 0x0a, 0x55, 0x73, 0x65, 0x72, 0x2d,
2718 0x41, 0x67, 0x65, 0x6e, 0x74, 0x3a, 0x20, 0x63,
2719 0x75, 0x72, 0x6c, 0x2f, 0x37, 0x2e, 0x33, 0x37,
2720 0x2e, 0x30, 0x0d, 0x0a, 0x48, 0x6f, 0x73, 0x74,
2721 0x3a, 0x20, 0x31, 0x30, 0x2e, 0x31, 0x36, 0x2e,
2722 0x31, 0x2e, 0x31, 0x30, 0x0d, 0x0a, 0x41, 0x63,
2723 0x63, 0x65, 0x70, 0x74, 0x3a, 0x20, 0x2a, 0x2f,
2724 0x2a, 0x0d, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65,
2725 0x6e, 0x74, 0x2d, 0x4c, 0x65, 0x6e, 0x67, 0x74,
2726 0x68, 0x3a, 0x20, 0x35, 0x32, 0x38, 0x0d, 0x0a,
2727 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d,
2728 0x54, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x61, 0x70,
2729 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f,
2730 0x6e, 0x2f, 0x78, 0x2d, 0x77, 0x77, 0x77, 0x2d,
2731 0x66, 0x6f, 0x72, 0x6d, 0x2d, 0x75, 0x72, 0x6c,
2732 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x64, 0x0d,
2733 0x0a, 0x0d, 0x0a, 0x58, 0x58, 0x58, 0x58, 0x58,
2734 0x58, 0x58, 0x58, 0x41, 0x41, 0x41, 0x41, 0x41,
2735 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2736 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2737 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2738 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2739 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2740 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2741 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2742 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2743 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2744 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2745 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2746 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2747 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2748 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2749 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2750 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2751 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2752 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2753 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2754 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2755 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2756 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2757 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2758 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2759 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2760 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2761 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2762 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2763 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2764 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2765 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2766 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2767 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2768 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2769 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2770 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2771 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2772 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2773 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2774 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2775 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2776 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2777 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2778 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2779 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2780 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2781 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2782 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2783 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2784 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2785 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2786 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2787 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2788 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2789 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2790 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2791 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2792 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2793 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2794 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2795 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2796 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2797 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2798 0x41, 0x41, 0x41, 0x58, 0x58, 0x58, 0x58, 0x58,
2802 return DetectContentLongPatternMatchTest(pkt, (uint16_t)
sizeof(pkt), sig,
2806 static int DetectLongContentTest1(
void)
2809 const char *sig =
"alert tcp any any -> any any (msg:\"Test Rule\"; content:\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"; sid:1;)";
2811 return DetectLongContentTestCommon(sig, 1);
2814 static int DetectLongContentTest2(
void)
2817 const char *sig =
"alert tcp any any -> any any (msg:\"Test Rule\"; content:\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"; sid:1;)";
2819 return DetectLongContentTestCommon(sig, 1);
2822 static int DetectLongContentTest3(
void)
2825 const char *sig =
"alert tcp any any -> any any (msg:\"Test Rule\"; content:\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"; sid:1;)";
2827 return !DetectLongContentTestCommon(sig, 1);
2830 static int DetectBadBinContent(
void)
2837 de_ctx,
"alert tcp any any -> any any (msg:\"test\"; content:\"|a|\"; sid:1;)"));
2839 de_ctx,
"alert tcp any any -> any any (msg:\"test\"; content:\"|aa b|\"; sid:1;)"));
2841 de_ctx,
"alert tcp any any -> any any (msg:\"test\"; content:\"|aa bz|\"; sid:1;)"));
2844 de_ctx,
"alert tcp any any -> any any (msg:\"test\"; content:\"|22 2 22|\"; sid:1;)"));
2852 static void DetectContentRegisterTests(
void)
2857 UtRegisterTest(
"DetectContentDepthTest01", DetectContentDepthTest01);
2859 UtRegisterTest(
"DetectContentParseTest01", DetectContentParseTest01);
2860 UtRegisterTest(
"DetectContentParseTest02", DetectContentParseTest02);
2861 UtRegisterTest(
"DetectContentParseTest03", DetectContentParseTest03);
2862 UtRegisterTest(
"DetectContentParseTest04", DetectContentParseTest04);
2863 UtRegisterTest(
"DetectContentParseTest05", DetectContentParseTest05);
2864 UtRegisterTest(
"DetectContentParseTest06", DetectContentParseTest06);
2865 UtRegisterTest(
"DetectContentParseTest07", DetectContentParseTest07);
2866 UtRegisterTest(
"DetectContentParseTest08", DetectContentParseTest08);
2867 UtRegisterTest(
"DetectContentParseTest09", DetectContentParseTest09);
2868 UtRegisterTest(
"DetectContentParseTest17", DetectContentParseTest17);
2869 UtRegisterTest(
"DetectContentParseTest18", DetectContentParseTest18);
2870 UtRegisterTest(
"DetectContentParseTest19", DetectContentParseTest19);
2871 UtRegisterTest(
"DetectContentParseTest20", DetectContentParseTest20);
2872 UtRegisterTest(
"DetectContentParseTest21", DetectContentParseTest21);
2873 UtRegisterTest(
"DetectContentParseTest22", DetectContentParseTest22);
2874 UtRegisterTest(
"DetectContentParseTest23", DetectContentParseTest23);
2875 UtRegisterTest(
"DetectContentParseTest24", DetectContentParseTest24);
2876 UtRegisterTest(
"DetectContentParseTest25", DetectContentParseTest25);
2877 UtRegisterTest(
"DetectContentParseTest26", DetectContentParseTest26);
2878 UtRegisterTest(
"DetectContentParseTest27", DetectContentParseTest27);
2879 UtRegisterTest(
"DetectContentParseTest28", DetectContentParseTest28);
2880 UtRegisterTest(
"DetectContentParseTest29", DetectContentParseTest29);
2881 UtRegisterTest(
"DetectContentParseTest30", DetectContentParseTest30);
2882 UtRegisterTest(
"DetectContentParseTest31", DetectContentParseTest31);
2883 UtRegisterTest(
"DetectContentParseTest32", DetectContentParseTest32);
2884 UtRegisterTest(
"DetectContentParseTest33", DetectContentParseTest33);
2885 UtRegisterTest(
"DetectContentParseTest34", DetectContentParseTest34);
2886 UtRegisterTest(
"DetectContentParseTest35", DetectContentParseTest35);
2887 UtRegisterTest(
"DetectContentParseTest41", DetectContentParseTest41);
2888 UtRegisterTest(
"DetectContentParseTest42", DetectContentParseTest42);
2889 UtRegisterTest(
"DetectContentParseTest43", DetectContentParseTest43);
2890 UtRegisterTest(
"DetectContentParseTest44", DetectContentParseTest44);
2891 UtRegisterTest(
"DetectContentParseTest45", DetectContentParseTest45);
2895 DetectContentLongPatternMatchTest01);
2897 DetectContentLongPatternMatchTest02);
2899 DetectContentLongPatternMatchTest03);
2901 DetectContentLongPatternMatchTest04);
2903 DetectContentLongPatternMatchTest05);
2905 DetectContentLongPatternMatchTest06);
2907 DetectContentLongPatternMatchTest07);
2909 DetectContentLongPatternMatchTest08);
2911 DetectContentLongPatternMatchTest09);
2913 DetectContentLongPatternMatchTest10);
2915 DetectContentLongPatternMatchTest11);
2918 UtRegisterTest(
"SigTest41TestNegatedContent", SigTest41TestNegatedContent);
2920 SigTest41aTestNegatedContent);
2921 UtRegisterTest(
"SigTest42TestNegatedContent", SigTest42TestNegatedContent);
2922 UtRegisterTest(
"SigTest43TestNegatedContent", SigTest43TestNegatedContent);
2923 UtRegisterTest(
"SigTest44TestNegatedContent", SigTest44TestNegatedContent);
2924 UtRegisterTest(
"SigTest45TestNegatedContent", SigTest45TestNegatedContent);
2925 UtRegisterTest(
"SigTest46TestNegatedContent", SigTest46TestNegatedContent);
2926 UtRegisterTest(
"SigTest47TestNegatedContent", SigTest47TestNegatedContent);
2927 UtRegisterTest(
"SigTest48TestNegatedContent", SigTest48TestNegatedContent);
2928 UtRegisterTest(
"SigTest49TestNegatedContent", SigTest49TestNegatedContent);
2929 UtRegisterTest(
"SigTest50TestNegatedContent", SigTest50TestNegatedContent);
2930 UtRegisterTest(
"SigTest51TestNegatedContent", SigTest51TestNegatedContent);
2931 UtRegisterTest(
"SigTest52TestNegatedContent", SigTest52TestNegatedContent);
2932 UtRegisterTest(
"SigTest53TestNegatedContent", SigTest53TestNegatedContent);
2933 UtRegisterTest(
"SigTest54TestNegatedContent", SigTest54TestNegatedContent);
2934 UtRegisterTest(
"SigTest55TestNegatedContent", SigTest55TestNegatedContent);
2935 UtRegisterTest(
"SigTest56TestNegatedContent", SigTest56TestNegatedContent);
2936 UtRegisterTest(
"SigTest57TestNegatedContent", SigTest57TestNegatedContent);
2937 UtRegisterTest(
"SigTest58TestNegatedContent", SigTest58TestNegatedContent);
2938 UtRegisterTest(
"SigTest59TestNegatedContent", SigTest59TestNegatedContent);
2939 UtRegisterTest(
"SigTest60TestNegatedContent", SigTest60TestNegatedContent);
2940 UtRegisterTest(
"SigTest61TestNegatedContent", SigTest61TestNegatedContent);
2941 UtRegisterTest(
"SigTest62TestNegatedContent", SigTest62TestNegatedContent);
2942 UtRegisterTest(
"SigTest63TestNegatedContent", SigTest63TestNegatedContent);
2943 UtRegisterTest(
"SigTest64TestNegatedContent", SigTest64TestNegatedContent);
2944 UtRegisterTest(
"SigTest65TestNegatedContent", SigTest65TestNegatedContent);
2945 UtRegisterTest(
"SigTest66TestNegatedContent", SigTest66TestNegatedContent);
2946 UtRegisterTest(
"SigTest67TestNegatedContent", SigTest67TestNegatedContent);
2947 UtRegisterTest(
"SigTest68TestNegatedContent", SigTest68TestNegatedContent);
2948 UtRegisterTest(
"SigTest69TestNegatedContent", SigTest69TestNegatedContent);
2949 UtRegisterTest(
"SigTest70TestNegatedContent", SigTest70TestNegatedContent);
2950 UtRegisterTest(
"SigTest71TestNegatedContent", SigTest71TestNegatedContent);
2951 UtRegisterTest(
"SigTest72TestNegatedContent", SigTest72TestNegatedContent);
2952 UtRegisterTest(
"SigTest73TestNegatedContent", SigTest73TestNegatedContent);
2953 UtRegisterTest(
"SigTest74TestNegatedContent", SigTest74TestNegatedContent);
2954 UtRegisterTest(
"SigTest75TestNegatedContent", SigTest75TestNegatedContent);
2959 UtRegisterTest(
"DetectLongContentTest1", DetectLongContentTest1);
2960 UtRegisterTest(
"DetectLongContentTest2", DetectLongContentTest2);
2961 UtRegisterTest(
"DetectLongContentTest3", DetectLongContentTest3);