31 #include "../suricata-common.h"
32 #include "../suricata.h"
33 #include "../flow-util.h"
35 #include "../app-layer-parser.h"
36 #include "../util-unittest.h"
37 #include "../util-unittest-helper.h"
38 #include "../app-layer.h"
39 #include "../app-layer-htp.h"
40 #include "../app-layer-protos.h"
41 #include "../detect-engine-build.h"
42 #include "../detect-engine-alert.h"
44 static int DetectEngineHttpStatCodeTest01(
void)
55 "GET /index.html HTTP/1.0\r\n"
56 "Host: www.openinfosecfoundation.org\r\n"
57 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
59 uint32_t http_len1 =
sizeof(http_buf1) - 1;
61 "HTTP/1.0 200 message\r\n"
62 "Content-Type: text/html\r\n"
63 "Content-Length: 7\r\n"
66 uint32_t http_len2 =
sizeof(http_buf2) - 1;
70 memset(&th_v, 0,
sizeof(th_v));
71 memset(&f, 0,
sizeof(f));
72 memset(&ssn, 0,
sizeof(ssn));
79 f.
proto = IPPROTO_TCP;
101 "(msg:\"http stat code test\"; "
102 "content:\"200\"; http_stat_code; "
113 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
119 if (http_state == NULL) {
120 printf(
"no http state: \n");
129 printf(
"sid 1 matched but shouldn't have\n");
136 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
145 printf(
"sid 1 didn't match but should have");
164 static int DetectEngineHttpStatCodeTest02(
void)
173 uint8_t http_buf1[] =
174 "GET /index.html HTTP/1.0\r\n"
175 "Host: www.openinfosecfoundation.org\r\n"
176 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
178 uint32_t http_len1 =
sizeof(http_buf1) - 1;
179 uint8_t http_buf2[] =
180 "HTTP/1.0 2000123 xxxxABC\r\n"
181 "Content-Type: text/html\r\n"
182 "Content-Length: 7\r\n"
185 uint32_t http_len2 =
sizeof(http_buf2) - 1;
189 memset(&th_v, 0,
sizeof(th_v));
190 memset(&f, 0,
sizeof(f));
191 memset(&ssn, 0,
sizeof(ssn));
197 f.
proto = IPPROTO_TCP;
215 "(msg:\"http stat code test\"; "
216 "content:\"123\"; http_stat_code; offset:4; "
227 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
235 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
241 if (http_state == NULL) {
242 printf(
"no http state: \n");
251 printf(
"sid 1 didn't match but should have\n");
269 static int DetectEngineHttpStatCodeTest03(
void)
280 uint8_t http_buf1[] =
281 "GET /index.html HTTP/1.0\r\n"
282 "Host: www.openinfosecfoundation.org\r\n"
283 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
285 uint32_t http_len1 =
sizeof(http_buf1) - 1;
286 uint8_t http_buf2[] =
288 uint32_t http_len2 =
sizeof(http_buf2) - 1;
289 uint8_t http_buf3[] =
291 "Content-Type: text/html\r\n"
292 "Content-Length: 17\r\n"
295 uint32_t http_len3 =
sizeof(http_buf3) - 1;
298 memset(&th_v, 0,
sizeof(th_v));
299 memset(&f, 0,
sizeof(f));
300 memset(&ssn, 0,
sizeof(ssn));
307 f.
proto = IPPROTO_TCP;
329 "(msg:\"http stat code test\"; "
330 "content:\"789\"; http_stat_code; offset:5; "
341 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
347 if (http_state == NULL) {
348 printf(
"no http state: \n");
357 printf(
"sid 1 matched but shouldn't have\n");
364 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
372 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
381 printf(
"sid 1 didn't match but should have");
400 static int DetectEngineHttpStatCodeTest04(
void)
410 uint8_t http_buf1[] =
411 "GET /index.html HTTP/1.0\r\n"
412 "Host: www.openinfosecfoundation.org\r\n"
413 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
415 uint32_t http_len1 =
sizeof(http_buf1) - 1;
416 uint8_t http_buf2[] =
417 "HTTP/1.0 200123 abcdef\r\n"
418 "Content-Type: text/html\r\n"
419 "Content-Length: 6\r\n"
422 uint32_t http_len2 =
sizeof(http_buf2) - 1;
426 memset(&th_v, 0,
sizeof(th_v));
427 memset(&f, 0,
sizeof(f));
428 memset(&ssn, 0,
sizeof(ssn));
435 f.
proto = IPPROTO_TCP;
457 "(msg:\"http stat code test\"; "
458 "content:!\"200\"; http_stat_code; offset:3; "
469 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
475 if (http_state == NULL) {
476 printf(
"no http state: \n");
485 printf(
"sid 1 matched but shouldn't have: ");
492 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
501 printf(
"sid 1 didn't match but should have: ");
520 static int DetectEngineHttpStatCodeTest05(
void)
530 uint8_t http_buf1[] =
531 "GET /index.html HTTP/1.0\r\n"
532 "Host: www.openinfosecfoundation.org\r\n"
533 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
535 uint32_t http_len1 =
sizeof(http_buf1) - 1;
536 uint8_t http_buf2[] =
537 "HTTP/1.0 200123 abcdef\r\n"
538 "Content-Type: text/html\r\n"
539 "Content-Length: 6\r\n"
542 uint32_t http_len2 =
sizeof(http_buf2) - 1;
546 memset(&th_v, 0,
sizeof(th_v));
547 memset(&f, 0,
sizeof(f));
548 memset(&ssn, 0,
sizeof(ssn));
555 f.
proto = IPPROTO_TCP;
577 "(msg:\"http stat code test\"; "
578 "content:\"200\"; http_stat_code; depth:3; "
589 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
595 if (http_state == NULL) {
596 printf(
"no http state: \n");
605 printf(
"sid 1 matched but shouldn't have: ");
612 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
621 printf(
"sid 1 didn't match but should have: ");
640 static int DetectEngineHttpStatCodeTest06(
void)
650 uint8_t http_buf1[] =
651 "GET /index.html HTTP/1.0\r\n"
652 "Host: www.openinfosecfoundation.org\r\n"
653 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
655 uint32_t http_len1 =
sizeof(http_buf1) - 1;
656 uint8_t http_buf2[] =
657 "HTTP/1.0 200123 abcdef\r\n"
658 "Content-Type: text/html\r\n"
659 "Content-Length: 6\r\n"
662 uint32_t http_len2 =
sizeof(http_buf2) - 1;
666 memset(&th_v, 0,
sizeof(th_v));
667 memset(&f, 0,
sizeof(f));
668 memset(&ssn, 0,
sizeof(ssn));
675 f.
proto = IPPROTO_TCP;
697 "(msg:\"http stat code test\"; "
698 "content:!\"123\"; http_stat_code; depth:3; "
709 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
715 if (http_state == NULL) {
716 printf(
"no http state: \n");
725 printf(
"sid 1 matched but shouldn't have: ");
732 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
741 printf(
"sid 1 didn't match but should have: ");
760 static int DetectEngineHttpStatCodeTest07(
void)
770 uint8_t http_buf1[] =
771 "GET /index.html HTTP/1.0\r\n"
772 "Host: www.openinfosecfoundation.org\r\n"
773 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
775 uint32_t http_len1 =
sizeof(http_buf1) - 1;
776 uint8_t http_buf2[] =
777 "HTTP/1.0 200123 abcdef\r\n"
778 "Content-Type: text/html\r\n"
779 "Content-Length: 6\r\n"
782 uint32_t http_len2 =
sizeof(http_buf2) - 1;
786 memset(&th_v, 0,
sizeof(th_v));
787 memset(&f, 0,
sizeof(f));
788 memset(&ssn, 0,
sizeof(ssn));
795 f.
proto = IPPROTO_TCP;
817 "(msg:\"http stat code test\"; "
818 "content:!\"123\"; http_stat_code; offset:3; "
829 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
835 if (http_state == NULL) {
836 printf(
"no http state: \n");
845 printf(
"sid 1 matched but shouldn't have: ");
852 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
861 printf(
"sid 1 matched but shouldn't have: ");
880 static int DetectEngineHttpStatCodeTest08(
void)
890 uint8_t http_buf1[] =
891 "GET /index.html HTTP/1.0\r\n"
892 "Host: www.openinfosecfoundation.org\r\n"
893 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
895 uint32_t http_len1 =
sizeof(http_buf1) - 1;
896 uint8_t http_buf2[] =
897 "HTTP/1.0 200123 abcdef\r\n"
898 "Content-Type: text/html\r\n"
899 "Content-Length: 6\r\n"
902 uint32_t http_len2 =
sizeof(http_buf2) - 1;
906 memset(&th_v, 0,
sizeof(th_v));
907 memset(&f, 0,
sizeof(f));
908 memset(&ssn, 0,
sizeof(ssn));
915 f.
proto = IPPROTO_TCP;
937 "(msg:\"http stat code test\"; "
938 "content:!\"200\"; http_stat_code; depth:3; "
949 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
955 if (http_state == NULL) {
956 printf(
"no http state: \n");
965 printf(
"sid 1 matched but shouldn't have: ");
972 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
981 printf(
"sid 1 matched but shouldn't have: ");
1000 static int DetectEngineHttpStatCodeTest09(
void)
1010 uint8_t http_buf1[] =
1011 "GET /index.html HTTP/1.0\r\n"
1012 "Host: www.openinfosecfoundation.org\r\n"
1013 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
1015 uint32_t http_len1 =
sizeof(http_buf1) - 1;
1016 uint8_t http_buf2[] =
1017 "HTTP/1.0 200123 abcdef\r\n"
1018 "Content-Type: text/html\r\n"
1019 "Content-Length: 6\r\n"
1022 uint32_t http_len2 =
sizeof(http_buf2) - 1;
1026 memset(&th_v, 0,
sizeof(th_v));
1027 memset(&f, 0,
sizeof(f));
1028 memset(&ssn, 0,
sizeof(ssn));
1035 f.
proto = IPPROTO_TCP;
1057 "(msg:\"http stat code test\"; "
1058 "content:\"200\"; http_stat_code; depth:3; "
1059 "content:\"123\"; http_stat_code; within:3; "
1070 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1076 if (http_state == NULL) {
1077 printf(
"no http state: \n");
1086 printf(
"sid 1 matched but shouldn't have: ");
1093 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
1102 printf(
"sid 1 didn't match but should have: ");
1121 static int DetectEngineHttpStatCodeTest10(
void)
1131 uint8_t http_buf1[] =
1132 "GET /index.html HTTP/1.0\r\n"
1133 "Host: www.openinfosecfoundation.org\r\n"
1134 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
1136 uint32_t http_len1 =
sizeof(http_buf1) - 1;
1137 uint8_t http_buf2[] =
1138 "HTTP/1.0 200123 abcdef\r\n"
1139 "Content-Type: text/html\r\n"
1140 "Content-Length: 6\r\n"
1143 uint32_t http_len2 =
sizeof(http_buf2) - 1;
1147 memset(&th_v, 0,
sizeof(th_v));
1148 memset(&f, 0,
sizeof(f));
1149 memset(&ssn, 0,
sizeof(ssn));
1156 f.
proto = IPPROTO_TCP;
1178 "(msg:\"http stat code test\"; "
1179 "content:\"200\"; http_stat_code; depth:3; "
1180 "content:!\"124\"; http_stat_code; within:3; "
1191 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1197 if (http_state == NULL) {
1198 printf(
"no http state: \n");
1207 printf(
"sid 1 matched but shouldn't have: ");
1214 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
1223 printf(
"sid 1 didn't match but should have: ");
1242 static int DetectEngineHttpStatCodeTest11(
void)
1252 uint8_t http_buf1[] =
1253 "GET /index.html HTTP/1.0\r\n"
1254 "Host: www.openinfosecfoundation.org\r\n"
1255 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
1257 uint32_t http_len1 =
sizeof(http_buf1) - 1;
1258 uint8_t http_buf2[] =
1259 "HTTP/1.0 200123 abcdef\r\n"
1260 "Content-Type: text/html\r\n"
1261 "Content-Length: 6\r\n"
1264 uint32_t http_len2 =
sizeof(http_buf2) - 1;
1268 memset(&th_v, 0,
sizeof(th_v));
1269 memset(&f, 0,
sizeof(f));
1270 memset(&ssn, 0,
sizeof(ssn));
1277 f.
proto = IPPROTO_TCP;
1299 "(msg:\"http stat code test\"; "
1300 "content:\"200\"; http_stat_code; depth:3; "
1301 "content:\"124\"; http_stat_code; within:3; "
1312 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1318 if (http_state == NULL) {
1319 printf(
"no http state: \n");
1328 printf(
"sid 1 matched but shouldn't have: ");
1335 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
1344 printf(
"sid 1 did match but should not have: ");
1363 static int DetectEngineHttpStatCodeTest12(
void)
1373 uint8_t http_buf1[] =
1374 "GET /index.html HTTP/1.0\r\n"
1375 "Host: www.openinfosecfoundation.org\r\n"
1376 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
1378 uint32_t http_len1 =
sizeof(http_buf1) - 1;
1379 uint8_t http_buf2[] =
1380 "HTTP/1.0 200123 abcdef\r\n"
1381 "Content-Type: text/html\r\n"
1382 "Content-Length: 6\r\n"
1385 uint32_t http_len2 =
sizeof(http_buf2) - 1;
1389 memset(&th_v, 0,
sizeof(th_v));
1390 memset(&f, 0,
sizeof(f));
1391 memset(&ssn, 0,
sizeof(ssn));
1398 f.
proto = IPPROTO_TCP;
1420 "(msg:\"http stat code test\"; "
1421 "content:\"20\"; http_stat_code; depth:2; "
1422 "content:\"23\"; http_stat_code; distance:2; "
1433 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1439 if (http_state == NULL) {
1440 printf(
"no http state: \n");
1449 printf(
"sid 1 matched but shouldn't have: ");
1456 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
1465 printf(
"sid 1 did not match but should have: ");
1484 static int DetectEngineHttpStatCodeTest13(
void)
1494 uint8_t http_buf1[] =
1495 "GET /index.html HTTP/1.0\r\n"
1496 "Host: www.openinfosecfoundation.org\r\n"
1497 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
1499 uint32_t http_len1 =
sizeof(http_buf1) - 1;
1500 uint8_t http_buf2[] =
1501 "HTTP/1.0 200123 abcdef\r\n"
1502 "Content-Type: text/html\r\n"
1503 "Content-Length: 6\r\n"
1506 uint32_t http_len2 =
sizeof(http_buf2) - 1;
1510 memset(&th_v, 0,
sizeof(th_v));
1511 memset(&f, 0,
sizeof(f));
1512 memset(&ssn, 0,
sizeof(ssn));
1519 f.
proto = IPPROTO_TCP;
1541 "(msg:\"http stat code test\"; "
1542 "content:\"20\"; http_stat_code; depth:3; "
1543 "content:!\"25\"; http_stat_code; distance:2; "
1554 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1560 if (http_state == NULL) {
1561 printf(
"no http state: \n");
1570 printf(
"sid 1 matched but shouldn't have: ");
1577 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
1586 printf(
"sid 1 did not match but should have: ");
1605 static int DetectEngineHttpStatCodeTest14(
void)
1615 uint8_t http_buf1[] =
1616 "GET /index.html HTTP/1.0\r\n"
1617 "Host: www.openinfosecfoundation.org\r\n"
1618 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
1620 uint32_t http_len1 =
sizeof(http_buf1) - 1;
1621 uint8_t http_buf2[] =
1622 "HTTP/1.0 200123 abcdef\r\n"
1623 "Content-Type: text/html\r\n"
1624 "Content-Length: 6\r\n"
1627 uint32_t http_len2 =
sizeof(http_buf2) - 1;
1631 memset(&th_v, 0,
sizeof(th_v));
1632 memset(&f, 0,
sizeof(f));
1633 memset(&ssn, 0,
sizeof(ssn));
1640 f.
proto = IPPROTO_TCP;
1662 "(msg:\"http stat code test\"; "
1664 "content:\"23\"; http_stat_code; distance:2; "
1675 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1681 if (http_state == NULL) {
1682 printf(
"no http state: \n");
1691 printf(
"sid 1 matched but shouldn't have: ");
1698 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
1707 printf(
"sid 1 did not match but should have: ");
1726 static int DetectEngineHttpStatCodeTest15(
void)
1736 uint8_t http_buf1[] =
1737 "GET /index.html HTTP/1.0\r\n"
1738 "Host: www.openinfosecfoundation.org\r\n"
1739 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
1741 uint32_t http_len1 =
sizeof(http_buf1) - 1;
1742 uint8_t http_buf2[] =
1743 "HTTP/1.0 200123 abcdef\r\n"
1744 "Content-Type: text/html\r\n"
1745 "Content-Length: 6\r\n"
1748 uint32_t http_len2 =
sizeof(http_buf2) - 1;
1752 memset(&th_v, 0,
sizeof(th_v));
1753 memset(&f, 0,
sizeof(f));
1754 memset(&ssn, 0,
sizeof(ssn));
1761 f.
proto = IPPROTO_TCP;
1783 "(msg:\"http stat code test\"; "
1785 "content:!\"124\"; http_stat_code; distance:0; within:3; "
1796 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1802 if (http_state == NULL) {
1803 printf(
"no http state: \n");
1812 printf(
"sid 1 matched but shouldn't have: ");
1819 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
1828 printf(
"sid 1 did not match but should have: ");
1848 static int DetectHttpStatCodeSigTest01(
void)
1852 uint8_t httpbuf1[] =
"POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n\r\n";
1853 uint32_t httplen1 =
sizeof(httpbuf1) - 1;
1854 uint8_t httpbuf2[] =
"HTTP/1.0 200 OK\r\n\r\n";
1855 uint32_t httplen2 =
sizeof(httpbuf2) - 1;
1864 memset(&th_v, 0,
sizeof(th_v));
1865 memset(&f, 0,
sizeof(f));
1866 memset(&ssn, 0,
sizeof(ssn));
1872 f.
proto = IPPROTO_TCP;
1885 printf(
"DetectEngineCtxInit failed: ");
1892 "\"HTTP status code\"; content:\"200\"; http_stat_code; sid:1;)");
1894 printf(
"sig parse failed: ");
1904 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1910 printf(
"toclient chunk 1 returned %" PRId32
", expected 0: ", r);
1915 if (http_state == NULL) {
1916 printf(
"no http state: ");
1924 printf(
"sid 1 didn't match but should have: ");
1932 if (det_ctx != NULL) {
1946 static int DetectHttpStatCodeSigTest02(
void)
1950 uint8_t httpbuf1[] =
"POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n\r\n";
1951 uint32_t httplen1 =
sizeof(httpbuf1) - 1;
1952 uint8_t httpbuf2[] =
"HTTP/1.0 200 OK\r\n\r\n";
1953 uint32_t httplen2 =
sizeof(httpbuf2) - 1;
1962 memset(&th_v, 0,
sizeof(th_v));
1963 memset(&f, 0,
sizeof(f));
1964 memset(&ssn, 0,
sizeof(ssn));
1970 f.
proto = IPPROTO_TCP;
1989 "\"HTTP status code\"; content:\"no\"; "
1990 "http_stat_code; sid:1;)");
1996 "Status code\"; content:\"100\";"
1997 "http_stat_code; sid:2;)");
1998 if (s->
next == NULL) {
2008 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
2015 printf(
"toclient chunk 1 returned %" PRId32
", expected 0: ", r);
2021 if (http_state == NULL) {
2022 printf(
"no http state: ");
2031 printf(
"sid 1 matched but shouldn't: ");
2035 printf(
"sid 2 match but shouldn't have: ");
2043 if (det_ctx != NULL) {
2058 static int DetectHttpStatCodeSigTest03(
void)
2062 uint8_t httpbuf1[] =
"POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n\r\n";
2063 uint32_t httplen1 =
sizeof(httpbuf1) - 1;
2064 uint8_t httpbuf2[] =
"HTTP/1.0 FAIL OK\r\n\r\n";
2065 uint32_t httplen2 =
sizeof(httpbuf2) - 1;
2074 memset(&th_v, 0,
sizeof(th_v));
2075 memset(&f, 0,
sizeof(f));
2076 memset(&ssn, 0,
sizeof(ssn));
2082 f.
proto = IPPROTO_TCP;
2101 "\"HTTP status code\"; content:\"FAIL\"; "
2102 "http_stat_code; sid:1;)");
2108 "Status code nocase\"; content:\"fail\"; nocase; "
2109 "http_stat_code; sid:2;)");
2110 if (s->
next == NULL) {
2120 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
2127 printf(
"toclient chunk 1 returned %" PRId32
", expected 0: ", r);
2133 if (http_state == NULL) {
2134 printf(
"no http state: ");
2143 printf(
"sid 1 didn't match but should have: ");
2147 printf(
"sid 2 didn't match but should have: ");
2155 if (det_ctx != NULL) {
2170 static int DetectHttpStatCodeSigTest04(
void)
2174 uint8_t httpbuf1[] =
"POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n\r\n";
2175 uint32_t httplen1 =
sizeof(httpbuf1) - 1;
2176 uint8_t httpbuf2[] =
"HTTP/1.0 200 OK\r\n\r\n";
2177 uint32_t httplen2 =
sizeof(httpbuf2) - 1;
2186 memset(&th_v, 0,
sizeof(th_v));
2187 memset(&f, 0,
sizeof(f));
2188 memset(&ssn, 0,
sizeof(ssn));
2194 f.
proto = IPPROTO_TCP;
2213 "\"HTTP status code\"; content:\"200\"; "
2214 "http_stat_code; sid:1;)");
2220 "Status code negation\"; content:!\"100\"; nocase; "
2221 "http_stat_code; sid:2;)");
2222 if (s->
next == NULL) {
2232 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
2239 printf(
"toclient chunk 1 returned %" PRId32
", expected 0: ", r);
2245 if (http_state == NULL) {
2246 printf(
"no http state: ");
2255 printf(
"sid 1 didn't match but should have: ");
2259 printf(
"sid 2 didn't match but should have: ");
2267 if (det_ctx != NULL) {
2286 DetectEngineHttpStatCodeTest01);
2288 DetectEngineHttpStatCodeTest02);
2290 DetectEngineHttpStatCodeTest03);
2292 DetectEngineHttpStatCodeTest04);
2294 DetectEngineHttpStatCodeTest05);
2296 DetectEngineHttpStatCodeTest06);
2298 DetectEngineHttpStatCodeTest07);
2300 DetectEngineHttpStatCodeTest08);
2302 DetectEngineHttpStatCodeTest09);
2304 DetectEngineHttpStatCodeTest10);
2306 DetectEngineHttpStatCodeTest11);
2308 DetectEngineHttpStatCodeTest12);
2310 DetectEngineHttpStatCodeTest13);
2312 DetectEngineHttpStatCodeTest14);
2314 DetectEngineHttpStatCodeTest15);
2316 UtRegisterTest(
"DetectHttpStatCodeSigTest01", DetectHttpStatCodeSigTest01);
2317 UtRegisterTest(
"DetectHttpStatCodeSigTest02", DetectHttpStatCodeSigTest02);
2318 UtRegisterTest(
"DetectHttpStatCodeSigTest03", DetectHttpStatCodeSigTest03);
2319 UtRegisterTest(
"DetectHttpStatCodeSigTest04", DetectHttpStatCodeSigTest04);