56 static void DetectContentRegisterTests(
void);
86 uint8_t **pstr, uint16_t *plen)
91 slen = strlen(contentstr);
95 uint8_t buffer[slen + 1];
96 strlcpy((
char *)&buffer, contentstr, slen + 1);
108 uint8_t binstr[3] =
"";
110 uint16_t bin_count = 0;
112 for (i = 0, x = 0; i < slen; i++) {
118 SCLogError(
"Incomplete hex code in content - %s. Invalidating signature.",
126 }
else if(!escape &&
str[i] ==
'\\') {
130 if (isdigit((
unsigned char)
str[i]) ||
131 str[i] ==
'A' ||
str[i] ==
'a' ||
132 str[i] ==
'B' ||
str[i] ==
'b' ||
133 str[i] ==
'C' ||
str[i] ==
'c' ||
134 str[i] ==
'D' ||
str[i] ==
'd' ||
135 str[i] ==
'E' ||
str[i] ==
'e' ||
136 str[i] ==
'F' ||
str[i] ==
'f')
140 binstr[binpos] = (char)
str[i];
144 uint8_t c = strtol((
char *)binstr, (
char **) NULL, 16) & 0xFF;
150 }
else if (
str[i] ==
' ') {
153 else if (
str[i] !=
',') {
155 "content - %s, hex %c. Invalidating signature.",
173 }
else if (
str[i] ==
'"') {
174 SCLogError(
"Invalid unescaped double quote within content section.");
183 if (bin_count % 2 != 0) {
185 "%s - %s. Invalidating signature.",
186 keyword, contentstr);
200 memcpy(ptr,
str, slen);
202 *plen = (uint16_t)slen;
214 const char *contentstr)
217 uint8_t *content = NULL;
238 spm_global_thread_ctx);
256 const char *contentstr)
268 SCLogDebug(
"DetectContentData \"cd\" is NULL");
272 if (tmpstr != NULL) {
301 if (tmprstr != NULL) {
353 SCLogError(
"content string \"%s\" incompatible with %s transform", contentstr, tstr);
415 int max_offset = 0, total_len = 0;
419 for (; sm != NULL; sm = sm->
next) {
425 SCLogDebug(
"content_len %d; negated: %s; distance: %d, offset: %d, depth: %d",
437 if (max_size < (uint64_t)check) {
448 max_offset =
MAX(max_offset, cd->
offset);
466 uint16_t max_right_edge_i;
470 uint32_t max_right_edge = max_right_edge_i;
473 if (min_dsize_required >= 0) {
474 SCLogDebug(
"min_dsize %d; max_right_edge %d", min_dsize_required, max_right_edge);
475 if ((uint32_t)min_dsize_required > max_right_edge) {
476 SCLogError(
"signature can't match as required content length %d exceeds dsize value %d",
477 min_dsize_required, max_right_edge);
500 #define VALIDATE(e) \
505 uint16_t offset_plus_pat = 0;
507 bool has_active_depth_chain =
false;
509 bool has_depth =
false;
510 bool has_ends_with =
false;
511 uint16_t ends_with_depth = 0;
513 for (
SigMatch *sm = sm_head; sm != NULL; sm = sm->
next) {
522 has_active_depth_chain =
false;
525 if (sm->prev == NULL) {
550 has_active_depth_chain =
false;
556 has_active_depth_chain =
true;
559 SCLogDebug(
"sm %p depth %u offset %u distance %d within %d", sm, cd->
depth,
568 has_active_depth_chain =
false;
572 SCLogDebug(
"no distance, reset offset_plus_pat & offset");
573 offset_plus_pat =
offset = 0;
576 SCLogDebug(
"stored: offset %u depth %u offset_plus_pat %u "
577 "has_active_depth_chain %s",
578 offset, depth, offset_plus_pat, has_active_depth_chain ?
"true" :
"false");
586 if (abs(cd->
distance) > offset_plus_pat)
595 if (has_active_depth_chain) {
597 if (depth && depth > offset_plus_pat) {
602 "distance to add: %u. depth + dist %u", dist, depth + dist);
606 depth + cd->
within + dist <= UINT16_MAX);
607 depth = cd->
depth = (uint16_t)(depth + cd->
within + dist);
616 if (cd->
depth == 0 && depth != 0) {
621 offset_plus_pat + cd->
distance <= UINT16_MAX);
627 depth + cd->
within <= UINT16_MAX);
628 depth = cd->
depth = (uint16_t)(cd->
within + depth);
632 has_ends_with =
true;
633 if (ends_with_depth == 0)
634 ends_with_depth = depth;
635 ends_with_depth =
MIN(ends_with_depth, depth);
643 cd->
offset = offset_plus_pat;
672 has_ends_with =
true;
673 if (ends_with_depth == 0)
674 ends_with_depth = depth;
675 ends_with_depth =
MIN(ends_with_depth, depth);
679 has_active_depth_chain =
false;
690 SCLogDebug(
"non-anchored PCRE not supported, reset offset_plus_pat & offset");
691 offset_plus_pat =
offset = depth = 0;
693 has_active_depth_chain =
false;
697 SCLogDebug(
"keyword not supported, reset offset_plus_pat & offset");
698 offset_plus_pat =
offset = depth = 0;
699 has_active_depth_chain =
false;
704 if (has_depth && has_ends_with) {
705 for (
SigMatch *sm = sm_head; sm != NULL; sm = sm->
next) {
710 cd->
depth = ends_with_depth;
730 static inline bool NeedsAsHex(uint8_t c)
754 if (NeedsAsHex(cd->
content[i])) {
756 snprintf(hex_str,
sizeof(hex_str),
"%s%02X", !hex ?
"|" :
" ", cd->
content[i]);
761 snprintf(p_str,
sizeof(p_str),
"%s%c", hex ?
"|" :
"", cd->
content[i]);
774 SCLogError(
"can't use multiple nocase modifiers with the same content");
798 static bool TestLastContent(
const Signature *s, uint16_t o, uint16_t d)
814 if (d != cd->
depth) {
821 #define TEST_RUN(sig, o, d) \
823 SCLogDebug("TEST_RUN start: '%s'", (sig)); \
824 DetectEngineCtx *de_ctx = DetectEngineCtxInit(); \
825 FAIL_IF_NULL(de_ctx); \
826 de_ctx->flags |= DE_QUIET; \
828 snprintf(rule, sizeof(rule), "alert tcp any any -> any any (%s sid:1; rev:1;)", (sig)); \
829 Signature *s = DetectEngineAppendSig(de_ctx, rule); \
831 SigPrepareStage1(de_ctx); \
832 bool res = TestLastContent(s, (o), (d)); \
834 DetectEngineCtxFree(de_ctx); \
841 static int DetectContentDepthTest01(
void)
844 TEST_RUN(
"content:\"abc\"; offset:1; depth:3;", 1, 4);
846 TEST_RUN(
"dsize:10; content:\"abc\";", 0, 10);
847 TEST_RUN(
"dsize:<10; content:\"abc\";", 0, 10);
848 TEST_RUN(
"dsize:5<>10; content:\"abc\";", 0, 10);
851 TEST_RUN(
"content:\"abc\"; depth:3; content:\"xyz\"; distance:0; within:3; ", 3, 6);
853 TEST_RUN(
"content:\"abc\"; offset:3; depth:3; content:\"xyz\"; distance:0; within:3; ", 6, 9);
854 TEST_RUN(
"content:\"abc\"; depth:6; content:\"xyz\"; distance:0; within:3; ", 3, 9);
857 TEST_RUN(
"content:\"abc\"; depth:3; content:\"klm\"; distance:0; within:3; content:\"xyz\"; distance:0; within:3; ", 6, 9);
859 TEST_RUN(
"content:\"abc\"; depth:3; content:\"klm\"; content:\"xyz\"; distance:0; within:3; ", 3, 0);
861 TEST_RUN(
"content:\"abc\"; depth:3; pcre:/\"klm\"/; content:\"xyz\"; distance:0; within:3; ", 0, 0);
863 TEST_RUN(
"content:\"abc\"; depth:3; pcre:/\"klm\"/R; content:\"xyz\"; distance:0; within:3; ", 3, 0);
864 TEST_RUN(
"content:\"abc\"; offset:3; depth:3; pcre:/\"klm\"/R; content:\"xyz\"; distance:0; within:3; ", 6, 0);
866 TEST_RUN(
"content:\"abc\"; depth:3; content:\"klm\"; within:3; content:\"xyz\"; within:3; ", 0, 9);
868 TEST_RUN(
"content:\"abc\"; depth:3; content:\"klm\"; distance:0; content:\"xyz\"; distance:0; ", 6, 0);
871 TEST_RUN(
"content:\"abc\"; depth:6; isdataat:!1,relative; content:\"klm\";", 0, 6);
872 TEST_RUN(
"content:\"abc\"; depth:3; content:\"klm\"; within:3; content:\"xyz\"; within:3; isdataat:!1,relative; content:\"def\"; ", 0, 9);
874 TEST_RUN(
"content:\"|03|\"; depth:1; content:\"|e0|\"; distance:4; within:1;", 5, 6);
875 TEST_RUN(
"content:\"|03|\"; depth:1; content:\"|e0|\"; distance:4; within:1; content:\"Cookie|3a|\"; distance:5; within:7;", 11, 18);
877 TEST_RUN(
"content:\"this\"; content:\"is\"; within:6; content:\"big\"; within:8; content:\"string\"; within:8;", 0, 0);
879 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);
880 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);
882 TEST_RUN(
"content:\"|0d 0a 0d 0a|\"; content:\"code=\"; distance:0;", 4, 0);
883 TEST_RUN(
"content:\"|0d 0a 0d 0a|\"; content:\"code=\"; distance:0; content:\"xploit.class\"; distance:2; within:18;", 11, 0);
885 TEST_RUN(
"content:\"|16 03|\"; depth:2; content:\"|55 04 0a|\"; distance:0;", 2, 0);
886 TEST_RUN(
"content:\"|16 03|\"; depth:2; content:\"|55 04 0a|\"; distance:0; content:\"|0d|LogMeIn, Inc.\"; distance:1; within:14;", 6, 0);
887 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);
889 TEST_RUN(
"content:\"=\"; offset:4; depth:9;", 4, 13);
892 TEST_RUN(
"content:\"=\"; offset:4; depth:9; content:\"=&\"; distance:55; within:2;", 60, 70);
895 TEST_RUN(
"content:\"0123456789\"; content:\"abcdef\"; distance:1048576;", 0, 0);
898 TEST_RUN(
"content:\"SMB\"; depth:8; content:\"|09 00|\"; distance:8; within:2;", 11, 18);
899 TEST_RUN(
"content:\"SMB\"; depth:8; content:\"|09 00|\"; distance:8; within:2; content:\"|05 "
900 "00 00|\"; distance:0;",
902 TEST_RUN(
"content:\"SMB\"; depth:8; content:\"|09 00|\"; distance:8; within:2; content:\"|05 "
903 "00 00|\"; distance:0; content:\"|0c 00|\"; distance:19; within:2;",
905 TEST_RUN(
"content:\"SMB\"; depth:8; content:\"|09 00|\"; distance:8; within:2; content:\"|05 "
906 "00 00|\"; distance:0; content:\"|0c 00|\"; distance:19; within:2; content:\"|15 00 "
907 "00 00|\"; distance:20; within:4;",
918 static void DetectContentPrintAll(
SigMatch *sm)
930 for (; first_sm != NULL; first_sm = first_sm->
next) {
932 SCLogDebug(
"Printing SigMatch DETECT_CONTENT %d", ++i);
940 static int g_file_data_buffer_id = 0;
941 static int g_dce_stub_data_buffer_id = 0;
946 static int DetectContentParseTest01 (
void)
948 const char *teststring =
"abc\\:def";
949 const char *teststringparsed =
"abc:def";
952 FAIL_IF(spm_global_thread_ctx == NULL);
955 FAIL_IF(memcmp(cd->
content, teststringparsed, strlen(teststringparsed)) != 0);
964 static int DetectContentParseTest02 (
void)
966 const char *teststring =
"abc\\;def";
967 const char *teststringparsed =
"abc;def";
970 FAIL_IF(spm_global_thread_ctx == NULL);
973 FAIL_IF(memcmp(cd->
content, teststringparsed, strlen(teststringparsed)) != 0);
982 static int DetectContentParseTest03 (
void)
984 const char *teststring =
"abc\\\"def";
985 const char *teststringparsed =
"abc\"def";
988 FAIL_IF(spm_global_thread_ctx == NULL);
991 FAIL_IF(memcmp(cd->
content, teststringparsed, strlen(teststringparsed)) != 0);
1000 static int DetectContentParseTest04 (
void)
1002 const char *teststring =
"abc\\\\def";
1003 const char *teststringparsed =
"abc\\def";
1006 FAIL_IF(spm_global_thread_ctx == NULL);
1019 static int DetectContentParseTest05 (
void)
1021 const char *teststring =
"abc\\def";
1024 FAIL_IF(spm_global_thread_ctx == NULL);
1035 static int DetectContentParseTest06 (
void)
1037 const char *teststring =
"a|42|c|44|e|46|";
1038 const char *teststringparsed =
"abcdef";
1042 FAIL_IF(spm_global_thread_ctx == NULL);
1055 static int DetectContentParseTest07 (
void)
1057 const char *teststring =
"";
1060 FAIL_IF(spm_global_thread_ctx == NULL);
1071 static int DetectContentParseTest08 (
void)
1073 const char *teststring =
"";
1076 FAIL_IF(spm_global_thread_ctx == NULL);
1093 static int DetectContentLongPatternMatchTest(uint8_t *raw_eth_pkt, uint16_t pktsize,
const char *sig,
1103 memset(&th_v, 0,
sizeof(th_v));
1122 SCLogDebug(
"---DetectContentLongPatternMatchTest---");
1142 static int DetectContentLongPatternMatchTestWrp(
const char *sig, uint32_t sid)
1149 uint8_t raw_eth_pkt[] = {
1150 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
1151 0x00,0x00,0x00,0x00,0x08,0x00,0x45,0x00,
1152 0x00,0x85,0x00,0x01,0x00,0x00,0x40,0x06,
1153 0x7c,0x70,0x7f,0x00,0x00,0x01,0x7f,0x00,
1154 0x00,0x01,0x00,0x14,0x00,0x50,0x00,0x00,
1155 0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x02,
1156 0x20,0x00,0xc9,0xad,0x00,0x00,0x48,0x69,
1157 0x2c,0x20,0x74,0x68,0x69,0x73,0x20,0x69,
1158 0x73,0x20,0x61,0x20,0x62,0x69,0x67,0x20,
1159 0x74,0x65,0x73,0x74,0x20,0x74,0x6f,0x20,
1160 0x63,0x68,0x65,0x63,0x6b,0x20,0x63,0x6f,
1161 0x6e,0x74,0x65,0x6e,0x74,0x20,0x6d,0x61,
1162 0x74,0x63,0x68,0x65,0x73,0x20,0x6f,0x66,
1163 0x20,0x73,0x70,0x6c,0x69,0x74,0x74,0x65,
1164 0x64,0x20,0x70,0x61,0x74,0x74,0x65,0x72,
1165 0x6e,0x73,0x20,0x62,0x65,0x74,0x77,0x65,
1166 0x65,0x6e,0x20,0x6d,0x75,0x6c,0x74,0x69,
1167 0x70,0x6c,0x65,0x20,0x63,0x68,0x75,0x6e,
1170 return DetectContentLongPatternMatchTest(raw_eth_pkt, (uint16_t)
sizeof(raw_eth_pkt),
1177 static int DetectContentLongPatternMatchTest01(
void)
1179 const char *sig =
"alert tcp any any -> any any (msg:\"Nothing..\";"
1180 " content:\"Hi, this is a big test\"; sid:1;)";
1181 return DetectContentLongPatternMatchTestWrp(sig, 1);
1187 static int DetectContentLongPatternMatchTest02(
void)
1189 const char *sig =
"alert tcp any any -> any any (msg:\"Nothing..\";"
1190 " content:\"Hi, this is a big test to check content matches of"
1191 " splitted patterns between multiple chunks!\"; sid:1;)";
1192 return DetectContentLongPatternMatchTestWrp(sig, 1);
1199 static int DetectContentLongPatternMatchTest03(
void)
1202 const char *sig =
"alert tcp any any -> any any (msg:\"Nothing..\";"
1203 " content:\"Hi, this is a big test to check content matches of"
1204 " splitted patterns between multiple splitted chunks!\"; sid:1;)";
1205 return (DetectContentLongPatternMatchTestWrp(sig, 1) == 0) ? 1: 0;
1211 static int DetectContentLongPatternMatchTest04(
void)
1213 const char *sig =
"alert tcp any any -> any any (msg:\"Nothing..\"; "
1214 " content:\"Hi, this is\"; depth:15 ;content:\"a big test\"; "
1215 " within:15; content:\"to check content matches of\"; "
1216 " within:30; content:\"splitted patterns\"; distance:1; "
1219 return DetectContentLongPatternMatchTestWrp(sig, 1);
1227 static int DetectContentLongPatternMatchTest05(
void)
1229 const char *sig =
"alert tcp any any -> any any (msg:\"Nothing..\"; "
1230 " content:\"Hi, this is a big\"; depth:17; "
1231 " isdataat:30, relative; "
1232 " content:\"test\"; within: 5; distance:1; "
1233 " isdataat:15, relative; "
1234 " content:\"of splitted\"; within:37; distance:15; "
1235 " isdataat:20,relative; "
1236 " content:\"patterns\"; within:9; distance:1; "
1237 " isdataat:10, relative; "
1239 return DetectContentLongPatternMatchTestWrp(sig, 1);
1247 static int DetectContentLongPatternMatchTest06(
void)
1249 const char *sig =
"alert tcp any any -> any any (msg:\"Nothing..\"; "
1250 " content:\"Hi, this is a big test to check cont\"; depth:36;"
1251 " content:\"ent matches\"; within:11; distance:0; "
1252 " content:\"of splitted patterns between multiple\"; "
1253 " within:38; distance:1; "
1254 " content:\"chunks!\"; within: 8; distance:1; "
1256 return DetectContentLongPatternMatchTestWrp(sig, 1);
1263 static int DetectContentLongPatternMatchTest07(
void)
1265 const char *sig =
"alert tcp any any -> any any (msg:\"Nothing..\"; "
1266 " content:\"chunks!\"; "
1267 " content:\"content matches\"; offset:32; depth:47; "
1268 " content:\"of splitted patterns between multiple\"; "
1269 " content:\"Hi, this is a big\"; offset:0; depth:17; "
1271 return DetectContentLongPatternMatchTestWrp(sig, 1);
1278 static int DetectContentLongPatternMatchTest08(
void)
1280 const char *sig =
"alert tcp any any -> any any (msg:\"Nothing..\"; "
1281 " content:\"ent matches\"; "
1282 " content:\"of splitted patterns between multiple\"; "
1283 " within:38; distance:1; "
1284 " content:\"chunks!\"; within: 8; distance:1; "
1285 " content:\"Hi, this is a big test to check cont\"; depth:36;"
1287 return DetectContentLongPatternMatchTestWrp(sig, 1);
1294 static int DetectContentLongPatternMatchTest09(
void)
1296 const char *sig =
"alert tcp any any -> any any (msg:\"Nothing..\"; "
1297 " content:\"ent matches\"; "
1298 " content:\"of splitted patterns between multiple\"; "
1299 " offset:47; depth:85; "
1300 " content:\"chunks!\"; within: 8; distance:1; "
1301 " content:\"Hi, this is a big test to chec\"; depth:36;"
1302 " content:\"k cont\"; distance:0; within:6;"
1304 return DetectContentLongPatternMatchTestWrp(sig, 1);
1310 static int DetectContentLongPatternMatchTest10(
void)
1312 const char *sig =
"alert tcp any any -> any any (msg:\"Nothing..\"; "
1313 " content:\"Hi, this is a big test to check \"; "
1314 " content:\"con\"; "
1316 return DetectContentLongPatternMatchTestWrp(sig, 1);
1322 static int DetectContentLongPatternMatchTest11(
void)
1324 const char *sig =
"alert tcp any any -> any any (msg:\"Nothing..\"; "
1328 return DetectContentLongPatternMatchTestWrp(sig, 1);
1331 static int DetectContentParseTest09(
void)
1334 const char *teststring =
"boo";
1338 FAIL_IF(spm_global_thread_ctx == NULL);
1351 static int DetectContentParseTest17(
void)
1354 const char *sigstr =
"alert tcp any any -> any any (msg:\"Dummy\"; "
1355 "content:\"one\"; content:\"two\"; within:2; sid:1;)";
1377 static int DetectContentParseTest18(
void)
1405 static int DetectContentParseTest19(
void)
1414 "(msg:\"Testing dce iface, stub_data with content\"; "
1415 "dce_iface:3919286a-b10c-11d0-9ba8-00c04fd92ef5; "
1417 "content:\"one\"; distance:0; sid:1;)");
1429 "alert tcp any any -> any any "
1430 "(msg:\"Testing dce iface, stub_data with contents & distance, within\"; "
1431 "dce_iface:3919286a-b10c-11d0-9ba8-00c04fd92ef5; "
1433 "content:\"one\"; distance:0; content:\"two\"; within:10; sid:2;)");
1448 "alert tcp any any -> any any "
1449 "(msg:\"Testing dce iface, stub with contents, distance, within\"; "
1450 "dce_iface:3919286a-b10c-11d0-9ba8-00c04fd92ef5; "
1452 "content:\"one\"; distance:0; "
1453 "content:\"two\"; within:10; distance:2; sid:3;)");
1468 "(msg:\"Testing content\"; "
1469 "content:\"one\"; sid:4;)");
1481 static int DetectContentParseTest20(
void)
1492 "alert udp any any -> any any "
1493 "(msg:\"test\"; content:\"\"; sid:238012;)");
1507 static int DetectContentParseTest21(
void)
1518 "alert udp any any -> any any "
1519 "(msg:\"test\"; content:\"; sid:238012;)");
1533 static int DetectContentParseTest22(
void)
1544 "alert udp any any -> any any "
1545 "(msg:\"test\"; content:\"boo; sid:238012;)");
1559 static int DetectContentParseTest23(
void)
1570 "alert udp any any -> any any "
1571 "(msg:\"test\"; content:boo\"; sid:238012;)");
1585 static int DetectContentParseTest24(
void)
1598 "alert udp any any -> any any "
1599 "(msg:\"test\"; content: !\"boo\"; sid:238012;)");
1601 printf(
"de_ctx->sig_list == NULL: ");
1608 printf(
"de_ctx->pmatch_tail == NULL || de_ctx->pmatch_tail->ctx == NULL: ");
1624 static int DetectContentParseTest25(
void)
1635 "alert udp any any -> any any "
1636 "(msg:\"test\"; content:\"|\"; sid:1;)");
1650 static int DetectContentParseTest26(
void)
1661 "alert udp any any -> any any "
1662 "(msg:\"test\"; content:\"|af\"; sid:1;)");
1676 static int DetectContentParseTest27(
void)
1687 "alert udp any any -> any any "
1688 "(msg:\"test\"; content:\"af|\"; sid:1;)");
1702 static int DetectContentParseTest28(
void)
1713 "alert udp any any -> any any "
1714 "(msg:\"test\"; content:\"|af|\"; sid:1;)");
1728 static int DetectContentParseTest29(
void)
1739 "alert udp any any -> any any "
1740 "(msg:\"test\"; content:\"aast|\"; sid:1;)");
1754 static int DetectContentParseTest30(
void)
1765 "alert udp any any -> any any "
1766 "(msg:\"test\"; content:\"aast|af\"; sid:1;)");
1780 static int DetectContentParseTest31(
void)
1791 "alert udp any any -> any any "
1792 "(msg:\"test\"; content:\"aast|af|\"; sid:1;)");
1806 static int DetectContentParseTest32(
void)
1817 "alert udp any any -> any any "
1818 "(msg:\"test\"; content:\"|af|asdf\"; sid:1;)");
1832 static int DetectContentParseTest33(
void)
1843 "alert udp any any -> any any "
1844 "(msg:\"test\"; content:\"|af|af|\"; sid:1;)");
1858 static int DetectContentParseTest34(
void)
1869 "alert udp any any -> any any "
1870 "(msg:\"test\"; content:\"|af|af|af\"; sid:1;)");
1884 static int DetectContentParseTest35(
void)
1895 "alert udp any any -> any any "
1896 "(msg:\"test\"; content:\"|af|af|af|\"; sid:1;)");
1907 static int SigTestPositiveTestContent(
const char *rule, uint8_t *buf)
1909 uint16_t buflen = strlen((
char *)buf);
1913 memset(&th_v, 0,
sizeof(th_v));
1939 static int DetectContentParseTest41(
void)
1944 char *teststring =
SCMalloc(
sizeof(
char) * (patlen + 1));
1948 for (
int i = 0; i < patlen; idx++, i++) {
1949 teststring[idx] =
'a';
1951 teststring[idx++] =
'\0';
1955 FAIL_IF(spm_global_thread_ctx == NULL);
1972 static int DetectContentParseTest42(
void)
1977 char *teststring =
SCMalloc(
sizeof(
char) * (patlen + 1));
1981 for (
int i = 0; i < patlen; idx++, i++) {
1982 teststring[idx] =
'a';
1984 teststring[idx++] =
'\0';
1988 FAIL_IF(spm_global_thread_ctx == NULL);
2002 static int DetectContentParseTest43(
void)
2007 char *teststring =
SCMalloc(
sizeof(
char) * (patlen + 1));
2011 teststring[idx++] =
'|';
2012 teststring[idx++] =
'4';
2013 teststring[idx++] =
'6';
2014 teststring[idx++] =
'|';
2015 for (
int i = 0; i < (patlen - 4); idx++, i++) {
2016 teststring[idx] =
'a';
2018 teststring[idx++] =
'\0';
2022 FAIL_IF(spm_global_thread_ctx == NULL);
2039 static int DetectContentParseTest44(
void)
2044 char *teststring =
SCMalloc(
sizeof(
char) * (patlen + 1));
2048 teststring[idx++] =
'|';
2049 teststring[idx++] =
'4';
2050 teststring[idx++] =
'6';
2051 teststring[idx++] =
'|';
2052 for (
int i = 0; i < (patlen - 4); idx++, i++) {
2053 teststring[idx] =
'a';
2055 teststring[idx++] =
'\0';
2059 FAIL_IF(spm_global_thread_ctx == NULL);
2076 static int DetectContentParseTest45(
void)
2085 "alert tcp any any -> any any "
2086 "(msg:\"test\"; content:\"|ff|\" content:\"TEST\"; sid:1;)");
2094 static int SigTestNegativeTestContent(
const char *rule, uint8_t *buf)
2096 uint16_t buflen = strlen((
char *)buf);
2101 memset(&th_v, 0,
sizeof(th_v));
2127 if (det_ctx != NULL) {
2141 static int SigTest41TestNegatedContent(
void)
2143 return SigTestPositiveTestContent(
"alert tcp any any -> any any "
2144 "(msg:\"HTTP URI cap\"; content:!\"GES\"; sid:1;)",
2146 (uint8_t *)
"GET /one/ HTTP/1.1\r\n Host: one.example.org\r\n\r\n\r\n"
2147 "GET /two/ HTTP/1.1\r\nHost: two.example.org\r\n\r\n\r\n");
2155 static int SigTest41aTestNegatedContent(
void)
2157 (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");
2166 static int SigTest42TestNegatedContent(
void)
2168 return SigTestPositiveTestContent(
2169 "alert tcp any any -> any any (content:!\"eeeeeeeeeee\"; depth:22; offset:35; sid:1;)",
2170 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff gggggggg hhhhhhhh");
2180 static int SigTest43TestNegatedContent(
void)
2182 return SigTestNegativeTestContent(
2183 "alert tcp any any -> any any (content:!\"eeeeeeeeeee\"; depth:34; offset:23; sid:1;)",
2184 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff gggggggg hhhhhhhh");
2192 static int SigTest44TestNegatedContent(
void)
2194 return SigTestPositiveTestContent(
2195 "alert tcp any any -> any any (content:!\"eeeeeeeeeee\"; offset:40; depth:35; sid:1;)",
2196 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff gggggggg hhhhhhhh");
2203 static int SigTest45TestNegatedContent(
void)
2205 return SigTestPositiveTestContent(
"alert tcp any any -> any any (content:\"aaa\"; depth:5; "
2206 "content:!\"eeeeeeeeeee\"; depth:23; sid:1;)",
2207 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff gggggggg hhhhhhhh");
2214 static int SigTest46TestNegatedContent(
void)
2216 return SigTestNegativeTestContent(
"alert tcp any any -> any any (content:\"aaaE\"; "
2217 "content:!\"eeeeeeeeeee\"; depth:23; sid:1;)",
2218 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff gggggggg hhhhhhhh");
2226 static int SigTest47TestNegatedContent(
void)
2228 return SigTestNegativeTestContent(
"alert tcp any any -> any any (content:\"aaa\"; offset:5; "
2229 "content:!\"eeeeeeeeeee\"; depth:23; sid:1;)",
2230 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff gggggggg hhhhhhhh");
2237 static int SigTest48TestNegatedContent(
void)
2239 return SigTestPositiveTestContent(
2240 "alert tcp any any -> any any (content:\"GET\"; content:!\"GES\"; within:26; sid:1;)",
2241 (uint8_t *)
"GET /one/ HTTP/1.1\r\n Host: one.example.org\r\n\r\n\r\nGET /two/ "
2242 "HTTP/1.1\r\nHost: two.example.org\r\n\r\n\r\n");
2249 static int SigTest49TestNegatedContent(
void)
2251 return SigTestNegativeTestContent(
2252 "alert tcp any any -> any any (content:\"GET\"; content:!\"Host\"; within:26; sid:1;)",
2253 (uint8_t *)
"GET /one/ HTTP/1.1\r\n Host: one.example.org\r\n\r\n\r\nGET /two/ "
2254 "HTTP/1.1\r\nHost: two.example.org\r\n\r\n\r\n");
2261 static int SigTest50TestNegatedContent(
void)
2263 return SigTestPositiveTestContent(
2264 "alert tcp any any -> any any (content:\"GET\"; content:!\"GES\"; distance:25; sid:1;)",
2265 (uint8_t *)
"GET /one/ HTTP/1.1\r\n Host: one.example.org\r\n\r\n\r\nGET /two/ "
2266 "HTTP/1.1\r\nHost: two.example.org\r\n\r\n\r\n");
2276 static int SigTest51TestNegatedContent(
void)
2278 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");
2285 static int SigTest52TestNegatedContent(
void)
2287 return SigTestNegativeTestContent(
2288 "alert tcp any any -> any any (content:\"GES\"; content:!\"BOO\"; sid:1;)",
2289 (uint8_t *)
"GET /one/ HTTP/1.1\r\n Host: one.example.org\r\n\r\n\r\nGET /two/ "
2290 "HTTP/1.1\r\nHost: two.example.org\r\n\r\n\r\n");
2297 static int SigTest53TestNegatedContent(
void)
2299 return SigTestNegativeTestContent(
2300 "alert tcp any any -> any any (content:\"aaa\"; content:!\"Ggggg\"; within:56; sid:1;)",
2301 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2308 static int SigTest54TestNegatedContent(
void)
2310 return SigTestPositiveTestContent(
"alert tcp any any -> any any (content:\"aaa\"; "
2311 "content:!\"gggggg\"; within:20; sid:1;)",
2312 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff ggggggggg hhhhhhhh");
2319 static int SigTest55TestNegatedContent(
void)
2321 return SigTestNegativeTestContent(
2322 "alert tcp any any -> any any (content:!\"aaa\"; depth:5; sid:1;)",
2323 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff gggggggg hhhhhhhh");
2330 static int SigTest56TestNegatedContent(
void)
2332 return SigTestPositiveTestContent(
2333 "alert tcp any any -> any any (content:\"aaa\"; content:\"Ggggg\"; within:56; sid:1;)",
2334 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Gggggggg hhhhhhhh");
2341 static int SigTest57TestNegatedContent(
void)
2343 return SigTestNegativeTestContent(
2344 "alert tcp any any -> any any (content:\"aaa\"; content:!\"Ggggg\"; within:56; sid:1;)",
2345 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2352 static int SigTest58TestNegatedContent(
void)
2354 return SigTestPositiveTestContent(
"alert tcp any any -> any any (content:\"aaa\"; "
2355 "content:!\"Ggggg\"; distance:57; sid:1;)",
2356 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2363 static int SigTest59TestNegatedContent(
void)
2365 return SigTestNegativeTestContent(
"alert tcp any any -> any any (content:\"aaa\"; "
2366 "content:!\"Gggg\"; distance:30; sid:1;)",
2367 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2370 static int SigTest60TestNegatedContent(
void)
2372 return SigTestNegativeTestContent(
2373 "alert tcp any any -> any any (content:!\"aaa\"; content:\"Ggggg\"; sid:1;)",
2374 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2377 static int SigTest61TestNegatedContent(
void)
2379 return SigTestPositiveTestContent(
"alert tcp any any -> any any (content:\"aaa\"; depth:10; "
2380 "content:!\"Ggggg\"; within:30; sid:1;)",
2381 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2391 static int SigTest62TestNegatedContent(
void)
2393 return SigTestNegativeTestContent(
"alert tcp any any -> any any (content:\"aaa\"; depth:10; "
2394 "content:!\"Gggggg\"; within:49; sid:1;)",
2395 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2398 static int SigTest63TestNegatedContent(
void)
2400 return SigTestNegativeTestContent(
"alert tcp any any -> any any (content:\"aaa\"; depth:10; "
2401 "content:!\"Gggggg\"; within:56; sid:1;)",
2402 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2405 static int SigTest64TestNegatedContent(
void)
2407 return SigTestPositiveTestContent(
"alert tcp any any -> any any (content:\"aaa\"; depth:10; "
2408 "content:!\"Gggggg\"; within:30; sid:1;)",
2409 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2419 static int SigTest65TestNegatedContent(
void)
2421 return SigTestNegativeTestContent(
"alert tcp any any -> any any (content:\"aaa\"; depth:10; "
2422 "content:!\"Gggggg\"; distance:0; within:49; sid:1;)",
2423 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2426 static int SigTest66TestNegatedContent(
void)
2428 return SigTestPositiveTestContent(
"alert tcp any any -> any any (content:\"aaa\"; depth:10; "
2429 "content:!\"Gggggg\"; within:30; sid:1;)",
2430 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2433 static int SigTest67TestNegatedContent(
void)
2435 return SigTestNegativeTestContent(
"alert tcp any any -> any any (content:\"aaa\"; depth:10; "
2436 "content:!\"XXXX\"; within:56; sid:1;)",
2437 (uint8_t *)
"aaa bbbb cccc XXXXdddd eeeeeeeeeee ffffffffff XXXXggggg hhhhhhhh");
2440 static int SigTest68TestNegatedContent(
void)
2442 return SigTestPositiveTestContent(
2443 "alert tcp any any -> any any (content:\"aaa\"; depth:10; content:\"cccc\"; offset:8; "
2444 "content:!\"Gggggg\"; within:28; content:\"hhhhhhhh\"; sid:1;)",
2445 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2448 static int SigTest69TestNegatedContent(
void)
2450 return SigTestNegativeTestContent(
2451 "alert tcp any any -> any any (content:\"aaa\"; depth:10; content:\"cccc\"; offset:8; "
2452 "content:!\"Gggggg\"; within:48; content:\"hhhhhhhh\"; sid:1;)",
2453 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2456 static int SigTest70TestNegatedContent(
void)
2458 return SigTestNegativeTestContent(
"alert tcp any any -> any any (content:\"aaa\"; "
2459 "content:!\"Gggggg\"; within:52; sid:1;)",
2460 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2464 static int SigTest71TestNegatedContent(
void)
2466 return SigTestNegativeTestContent(
"alert tcp any any -> any any (content:\"aaa\"; "
2467 "content:!\"Gggggg\"; within:40; distance:43; sid:1;)",
2468 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2471 static int SigTest72TestNegatedContent(
void)
2473 return SigTestNegativeTestContent(
"alert tcp any any -> any any (content:\"aaa\"; "
2474 "content:!\"Gggggg\"; within:49; distance:43; sid:1;)",
2475 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff Ggggggggg hhhhhhhh");
2478 static int SigTest73TestNegatedContent(
void)
2480 return SigTestNegativeTestContent(
"alert tcp any any -> any any (content:\"aaa\"; depth:5; "
2481 "content:!\"eeeeeeeeeee\"; depth:35; sid:1;)",
2482 (uint8_t *)
"aaa bbbb cccc dddddddd eeeeeeeeeee ffffffffff ggggggggg hhhhhhhh");
2485 static int SigTest74TestNegatedContent(
void)
2487 return SigTestPositiveTestContent(
"alert tcp any any -> any any (msg:\"HTTP URI cap\"; content:\"USER\"; content:!\"PASS\"; sid:1;)", (uint8_t *)
"USER apple");
2490 static int SigTest75TestNegatedContent(
void)
2492 return SigTestPositiveTestContent(
"alert tcp any any -> any any (msg:\"HTTP URI cap\"; content:\"USER\"; content:\"!PASS\"; sid:1;)", (uint8_t *)
"USER !PASS");
2495 static int SigTest76TestBug134(
void)
2497 uint8_t *buf = (uint8_t *)
"test detect ${IFS} in traffic";
2498 uint16_t buflen = strlen((
char *)buf);
2503 memset(&f, 0,
sizeof(
Flow));
2512 char sig[] =
"alert tcp any any -> any 515 "
2513 "(msg:\"detect IFS\"; flow:to_server,established; content:\"${IFS}\";"
2514 " depth:50; offset:0; sid:900091; rev:1;)";
2529 static int SigTest77TestBug139(
void)
2532 0x12, 0x23, 0x34, 0x35, 0x52, 0x52, 0x24, 0x42, 0x22, 0x24,
2533 0x52, 0x24, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x34 };
2534 uint16_t buflen =
sizeof(buf);
2539 char sig[] =
"alert udp any any -> any 53 (msg:\"dns testing\";"
2540 " content:\"|00 00|\"; depth:5; offset:13; sid:9436601;"
2554 static int DetectLongContentTestCommon(
const char *sig, uint32_t sid)
2557 static uint8_t pkt[739] = {
2558 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2559 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
2560 0x02, 0xd5, 0x4a, 0x18, 0x40, 0x00, 0x40, 0x06,
2561 0xd7, 0xd6, 0x0a, 0x10, 0x01, 0x0b, 0x0a, 0x10,
2562 0x01, 0x0a, 0xdb, 0x36, 0x00, 0x50, 0xca, 0xc5,
2563 0xcc, 0xd1, 0x95, 0x77, 0x0f, 0x7d, 0x80, 0x18,
2564 0x00, 0xe5, 0x77, 0x9d, 0x00, 0x00, 0x01, 0x01,
2565 0x08, 0x0a, 0x1d, 0xe0, 0x86, 0xc6, 0xfc, 0x73,
2566 0x49, 0xf3, 0x50, 0x4f, 0x53, 0x54, 0x20, 0x2f,
2567 0x20, 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e,
2568 0x31, 0x0d, 0x0a, 0x55, 0x73, 0x65, 0x72, 0x2d,
2569 0x41, 0x67, 0x65, 0x6e, 0x74, 0x3a, 0x20, 0x63,
2570 0x75, 0x72, 0x6c, 0x2f, 0x37, 0x2e, 0x33, 0x37,
2571 0x2e, 0x30, 0x0d, 0x0a, 0x48, 0x6f, 0x73, 0x74,
2572 0x3a, 0x20, 0x31, 0x30, 0x2e, 0x31, 0x36, 0x2e,
2573 0x31, 0x2e, 0x31, 0x30, 0x0d, 0x0a, 0x41, 0x63,
2574 0x63, 0x65, 0x70, 0x74, 0x3a, 0x20, 0x2a, 0x2f,
2575 0x2a, 0x0d, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65,
2576 0x6e, 0x74, 0x2d, 0x4c, 0x65, 0x6e, 0x67, 0x74,
2577 0x68, 0x3a, 0x20, 0x35, 0x32, 0x38, 0x0d, 0x0a,
2578 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d,
2579 0x54, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x61, 0x70,
2580 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f,
2581 0x6e, 0x2f, 0x78, 0x2d, 0x77, 0x77, 0x77, 0x2d,
2582 0x66, 0x6f, 0x72, 0x6d, 0x2d, 0x75, 0x72, 0x6c,
2583 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x64, 0x0d,
2584 0x0a, 0x0d, 0x0a, 0x58, 0x58, 0x58, 0x58, 0x58,
2585 0x58, 0x58, 0x58, 0x41, 0x41, 0x41, 0x41, 0x41,
2586 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2587 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2588 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2589 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2590 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2591 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2592 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2593 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2594 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2595 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2596 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2597 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2598 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2599 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2600 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2601 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2602 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2603 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2604 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2605 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2606 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2607 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2608 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2609 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2610 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2611 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2612 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2613 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2614 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2615 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2616 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2617 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2618 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2619 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2620 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2621 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2622 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2623 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2624 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2625 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2626 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2627 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2628 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2629 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2630 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2631 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2632 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2633 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2634 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2635 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2636 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2637 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2638 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2639 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2640 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2641 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2642 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2643 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2644 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2645 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2646 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2647 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2648 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
2649 0x41, 0x41, 0x41, 0x58, 0x58, 0x58, 0x58, 0x58,
2653 return DetectContentLongPatternMatchTest(pkt, (uint16_t)
sizeof(pkt), sig,
2657 static int DetectLongContentTest1(
void)
2660 const char *sig =
"alert tcp any any -> any any (msg:\"Test Rule\"; content:\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"; sid:1;)";
2662 return DetectLongContentTestCommon(sig, 1);
2665 static int DetectLongContentTest2(
void)
2668 const char *sig =
"alert tcp any any -> any any (msg:\"Test Rule\"; content:\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"; sid:1;)";
2670 return DetectLongContentTestCommon(sig, 1);
2673 static int DetectLongContentTest3(
void)
2676 const char *sig =
"alert tcp any any -> any any (msg:\"Test Rule\"; content:\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"; sid:1;)";
2678 return !DetectLongContentTestCommon(sig, 1);
2681 static int DetectBadBinContent(
void)
2688 de_ctx,
"alert tcp any any -> any any (msg:\"test\"; content:\"|a|\"; sid:1;)"));
2690 de_ctx,
"alert tcp any any -> any any (msg:\"test\"; content:\"|aa b|\"; sid:1;)"));
2692 de_ctx,
"alert tcp any any -> any any (msg:\"test\"; content:\"|aa bz|\"; sid:1;)"));
2695 de_ctx,
"alert tcp any any -> any any (msg:\"test\"; content:\"|22 2 22|\"; sid:1;)"));
2703 static void DetectContentRegisterTests(
void)
2708 UtRegisterTest(
"DetectContentDepthTest01", DetectContentDepthTest01);
2710 UtRegisterTest(
"DetectContentParseTest01", DetectContentParseTest01);
2711 UtRegisterTest(
"DetectContentParseTest02", DetectContentParseTest02);
2712 UtRegisterTest(
"DetectContentParseTest03", DetectContentParseTest03);
2713 UtRegisterTest(
"DetectContentParseTest04", DetectContentParseTest04);
2714 UtRegisterTest(
"DetectContentParseTest05", DetectContentParseTest05);
2715 UtRegisterTest(
"DetectContentParseTest06", DetectContentParseTest06);
2716 UtRegisterTest(
"DetectContentParseTest07", DetectContentParseTest07);
2717 UtRegisterTest(
"DetectContentParseTest08", DetectContentParseTest08);
2718 UtRegisterTest(
"DetectContentParseTest09", DetectContentParseTest09);
2719 UtRegisterTest(
"DetectContentParseTest17", DetectContentParseTest17);
2720 UtRegisterTest(
"DetectContentParseTest18", DetectContentParseTest18);
2721 UtRegisterTest(
"DetectContentParseTest19", DetectContentParseTest19);
2722 UtRegisterTest(
"DetectContentParseTest20", DetectContentParseTest20);
2723 UtRegisterTest(
"DetectContentParseTest21", DetectContentParseTest21);
2724 UtRegisterTest(
"DetectContentParseTest22", DetectContentParseTest22);
2725 UtRegisterTest(
"DetectContentParseTest23", DetectContentParseTest23);
2726 UtRegisterTest(
"DetectContentParseTest24", DetectContentParseTest24);
2727 UtRegisterTest(
"DetectContentParseTest25", DetectContentParseTest25);
2728 UtRegisterTest(
"DetectContentParseTest26", DetectContentParseTest26);
2729 UtRegisterTest(
"DetectContentParseTest27", DetectContentParseTest27);
2730 UtRegisterTest(
"DetectContentParseTest28", DetectContentParseTest28);
2731 UtRegisterTest(
"DetectContentParseTest29", DetectContentParseTest29);
2732 UtRegisterTest(
"DetectContentParseTest30", DetectContentParseTest30);
2733 UtRegisterTest(
"DetectContentParseTest31", DetectContentParseTest31);
2734 UtRegisterTest(
"DetectContentParseTest32", DetectContentParseTest32);
2735 UtRegisterTest(
"DetectContentParseTest33", DetectContentParseTest33);
2736 UtRegisterTest(
"DetectContentParseTest34", DetectContentParseTest34);
2737 UtRegisterTest(
"DetectContentParseTest35", DetectContentParseTest35);
2738 UtRegisterTest(
"DetectContentParseTest41", DetectContentParseTest41);
2739 UtRegisterTest(
"DetectContentParseTest42", DetectContentParseTest42);
2740 UtRegisterTest(
"DetectContentParseTest43", DetectContentParseTest43);
2741 UtRegisterTest(
"DetectContentParseTest44", DetectContentParseTest44);
2742 UtRegisterTest(
"DetectContentParseTest45", DetectContentParseTest45);
2746 DetectContentLongPatternMatchTest01);
2748 DetectContentLongPatternMatchTest02);
2750 DetectContentLongPatternMatchTest03);
2752 DetectContentLongPatternMatchTest04);
2754 DetectContentLongPatternMatchTest05);
2756 DetectContentLongPatternMatchTest06);
2758 DetectContentLongPatternMatchTest07);
2760 DetectContentLongPatternMatchTest08);
2762 DetectContentLongPatternMatchTest09);
2764 DetectContentLongPatternMatchTest10);
2766 DetectContentLongPatternMatchTest11);
2769 UtRegisterTest(
"SigTest41TestNegatedContent", SigTest41TestNegatedContent);
2771 SigTest41aTestNegatedContent);
2772 UtRegisterTest(
"SigTest42TestNegatedContent", SigTest42TestNegatedContent);
2773 UtRegisterTest(
"SigTest43TestNegatedContent", SigTest43TestNegatedContent);
2774 UtRegisterTest(
"SigTest44TestNegatedContent", SigTest44TestNegatedContent);
2775 UtRegisterTest(
"SigTest45TestNegatedContent", SigTest45TestNegatedContent);
2776 UtRegisterTest(
"SigTest46TestNegatedContent", SigTest46TestNegatedContent);
2777 UtRegisterTest(
"SigTest47TestNegatedContent", SigTest47TestNegatedContent);
2778 UtRegisterTest(
"SigTest48TestNegatedContent", SigTest48TestNegatedContent);
2779 UtRegisterTest(
"SigTest49TestNegatedContent", SigTest49TestNegatedContent);
2780 UtRegisterTest(
"SigTest50TestNegatedContent", SigTest50TestNegatedContent);
2781 UtRegisterTest(
"SigTest51TestNegatedContent", SigTest51TestNegatedContent);
2782 UtRegisterTest(
"SigTest52TestNegatedContent", SigTest52TestNegatedContent);
2783 UtRegisterTest(
"SigTest53TestNegatedContent", SigTest53TestNegatedContent);
2784 UtRegisterTest(
"SigTest54TestNegatedContent", SigTest54TestNegatedContent);
2785 UtRegisterTest(
"SigTest55TestNegatedContent", SigTest55TestNegatedContent);
2786 UtRegisterTest(
"SigTest56TestNegatedContent", SigTest56TestNegatedContent);
2787 UtRegisterTest(
"SigTest57TestNegatedContent", SigTest57TestNegatedContent);
2788 UtRegisterTest(
"SigTest58TestNegatedContent", SigTest58TestNegatedContent);
2789 UtRegisterTest(
"SigTest59TestNegatedContent", SigTest59TestNegatedContent);
2790 UtRegisterTest(
"SigTest60TestNegatedContent", SigTest60TestNegatedContent);
2791 UtRegisterTest(
"SigTest61TestNegatedContent", SigTest61TestNegatedContent);
2792 UtRegisterTest(
"SigTest62TestNegatedContent", SigTest62TestNegatedContent);
2793 UtRegisterTest(
"SigTest63TestNegatedContent", SigTest63TestNegatedContent);
2794 UtRegisterTest(
"SigTest64TestNegatedContent", SigTest64TestNegatedContent);
2795 UtRegisterTest(
"SigTest65TestNegatedContent", SigTest65TestNegatedContent);
2796 UtRegisterTest(
"SigTest66TestNegatedContent", SigTest66TestNegatedContent);
2797 UtRegisterTest(
"SigTest67TestNegatedContent", SigTest67TestNegatedContent);
2798 UtRegisterTest(
"SigTest68TestNegatedContent", SigTest68TestNegatedContent);
2799 UtRegisterTest(
"SigTest69TestNegatedContent", SigTest69TestNegatedContent);
2800 UtRegisterTest(
"SigTest70TestNegatedContent", SigTest70TestNegatedContent);
2801 UtRegisterTest(
"SigTest71TestNegatedContent", SigTest71TestNegatedContent);
2802 UtRegisterTest(
"SigTest72TestNegatedContent", SigTest72TestNegatedContent);
2803 UtRegisterTest(
"SigTest73TestNegatedContent", SigTest73TestNegatedContent);
2804 UtRegisterTest(
"SigTest74TestNegatedContent", SigTest74TestNegatedContent);
2805 UtRegisterTest(
"SigTest75TestNegatedContent", SigTest75TestNegatedContent);
2810 UtRegisterTest(
"DetectLongContentTest1", DetectLongContentTest1);
2811 UtRegisterTest(
"DetectLongContentTest2", DetectLongContentTest2);
2812 UtRegisterTest(
"DetectLongContentTest3", DetectLongContentTest3);