26 #include "../suricata-common.h"
27 #include "../conf-yaml-loader.h"
28 #include "../decode.h"
30 #include "../detect.h"
31 #include "../detect-engine-build.h"
32 #include "../detect-engine-alert.h"
37 static int DetectHttpServerBodyParserTest01(
void)
40 FAIL_IF_NOT(
UTHParseSignature(
"alert http any any -> any any (flow:to_client; content:\"abc\"; nocase; http_server_body; sid:1;)",
true));
41 FAIL_IF_NOT(
UTHParseSignature(
"alert http any any -> any any (flow:to_client; content:\"abc\"; endswith; http_server_body; sid:1;)",
true));
42 FAIL_IF_NOT(
UTHParseSignature(
"alert http any any -> any any (flow:to_client; content:\"abc\"; startswith; http_server_body; sid:1;)",
true));
43 FAIL_IF_NOT(
UTHParseSignature(
"alert http any any -> any any (flow:to_client; content:\"abc\"; startswith; endswith; http_server_body; sid:1;)",
true));
45 FAIL_IF_NOT(
UTHParseSignature(
"alert http any any -> any any (flow:to_client; content:\"abc\"; rawbytes; http_server_body; sid:1;)",
false));
54 static int DetectHttpServerBodyParserTest02(
void)
57 FAIL_IF_NOT(
UTHParseSignature(
"alert http any any -> any any (flow:to_client; http.response_body; content:\"abc\"; nocase; sid:1;)",
true));
58 FAIL_IF_NOT(
UTHParseSignature(
"alert http any any -> any any (flow:to_client; http.response_body; content:\"abc\"; endswith; sid:1;)",
true));
59 FAIL_IF_NOT(
UTHParseSignature(
"alert http any any -> any any (flow:to_client; http.response_body; content:\"abc\"; startswith; sid:1;)",
true));
60 FAIL_IF_NOT(
UTHParseSignature(
"alert http any any -> any any (flow:to_client; http.response_body; content:\"abc\"; startswith; endswith; sid:1;)",
true));
63 FAIL_IF_NOT(
UTHParseSignature(
"alert http any any -> any any (flow:to_client; http.response_body; content:\"abc\"; rawbytes; sid:1;)",
false));
75 static int RunTest(
struct TestSteps *steps,
const char *sig,
const char *yaml)
84 memset(&th_v, 0,
sizeof(th_v));
85 memset(&f, 0,
sizeof(f));
86 memset(&ssn, 0,
sizeof(ssn));
106 f.
proto = IPPROTO_TCP;
120 while (b->
input != NULL) {
160 static int DetectEngineHttpServerBodyTest01(
void)
170 uint8_t http_buf1[] =
171 "GET /index.html HTTP/1.0\r\n"
172 "Host: www.openinfosecfoundation.org\r\n"
173 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
175 uint32_t http_len1 =
sizeof(http_buf1) - 1;
176 uint8_t http_buf2[] =
177 "HTTP/1.0 200 ok\r\n"
178 "Content-Type: text/html\r\n"
179 "Content-Length: 7\r\n"
182 uint32_t http_len2 =
sizeof(http_buf2) - 1;
186 memset(&th_v, 0,
sizeof(th_v));
187 memset(&f, 0,
sizeof(f));
188 memset(&ssn, 0,
sizeof(ssn));
195 f.
proto = IPPROTO_TCP;
217 "(msg:\"http server body test\"; "
218 "content:\"message\"; http_server_body; "
229 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
235 if (http_state == NULL) {
236 printf(
"no http state: \n");
245 printf(
"sid 1 matched but shouldn't have\n");
252 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
261 printf(
"sid 1 didn't match but should have");
280 static int DetectEngineHttpServerBodyTest02(
void)
289 uint8_t http_buf1[] =
290 "GET /index.html HTTP/1.0\r\n"
291 "Host: www.openinfosecfoundation.org\r\n"
292 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
294 uint32_t http_len1 =
sizeof(http_buf1) - 1;
295 uint8_t http_buf2[] =
296 "HTTP/1.0 200 ok\r\n"
297 "Content-Type: text/html\r\n"
298 "Content-Length: 7\r\n"
301 uint32_t http_len2 =
sizeof(http_buf2) - 1;
305 memset(&th_v, 0,
sizeof(th_v));
306 memset(&f, 0,
sizeof(f));
307 memset(&ssn, 0,
sizeof(ssn));
313 f.
proto = IPPROTO_TCP;
331 "(msg:\"http server body test\"; "
332 "content:\"ABC\"; http_server_body; offset:4; "
343 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
351 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
357 if (http_state == NULL) {
358 printf(
"no http state: \n");
367 printf(
"sid 1 didn't match but should have\n");
385 static int DetectEngineHttpServerBodyTest03(
void)
396 uint8_t http_buf1[] =
397 "GET /index.html HTTP/1.0\r\n"
398 "Host: www.openinfosecfoundation.org\r\n"
399 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
401 uint32_t http_len1 =
sizeof(http_buf1) - 1;
402 uint8_t http_buf2[] =
403 "HTTP/1.0 200 ok\r\n"
404 "Content-Type: text/html\r\n"
405 "Content-Length: 17\r\n"
408 uint32_t http_len2 =
sizeof(http_buf2) - 1;
409 uint8_t http_buf3[] =
411 uint32_t http_len3 =
sizeof(http_buf3) - 1;
414 memset(&th_v, 0,
sizeof(th_v));
415 memset(&f, 0,
sizeof(f));
416 memset(&ssn, 0,
sizeof(ssn));
423 f.
proto = IPPROTO_TCP;
445 "(msg:\"http server body test\"; "
446 "content:\"ABC\"; http_server_body; offset:14; "
457 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
463 if (http_state == NULL) {
464 printf(
"no http state: \n");
473 printf(
"sid 1 matched but shouldn't have\n");
480 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
488 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
497 printf(
"sid 1 didn't match but should have");
516 static int DetectEngineHttpServerBodyTest04(
void)
526 uint8_t http_buf1[] =
527 "GET /index.html HTTP/1.0\r\n"
528 "Host: www.openinfosecfoundation.org\r\n"
529 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
531 uint32_t http_len1 =
sizeof(http_buf1) - 1;
532 uint8_t http_buf2[] =
533 "HTTP/1.0 200 ok\r\n"
534 "Content-Type: text/html\r\n"
535 "Content-Length: 6\r\n"
538 uint32_t http_len2 =
sizeof(http_buf2) - 1;
542 memset(&th_v, 0,
sizeof(th_v));
543 memset(&f, 0,
sizeof(f));
544 memset(&ssn, 0,
sizeof(ssn));
551 f.
proto = IPPROTO_TCP;
573 "(msg:\"http server body test\"; "
574 "content:!\"abc\"; http_server_body; offset:3; "
585 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
591 if (http_state == NULL) {
592 printf(
"no http state: \n");
601 printf(
"sid 1 matched but shouldn't have: ");
608 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
617 printf(
"sid 1 didn't match but should have: ");
636 static int DetectEngineHttpServerBodyTest05(
void)
646 uint8_t http_buf1[] =
647 "GET /index.html HTTP/1.0\r\n"
648 "Host: www.openinfosecfoundation.org\r\n"
649 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
651 uint32_t http_len1 =
sizeof(http_buf1) - 1;
652 uint8_t http_buf2[] =
653 "HTTP/1.0 200 ok\r\n"
654 "Content-Type: text/html\r\n"
655 "Content-Length: 6\r\n"
658 uint32_t http_len2 =
sizeof(http_buf2) - 1;
662 memset(&th_v, 0,
sizeof(th_v));
663 memset(&f, 0,
sizeof(f));
664 memset(&ssn, 0,
sizeof(ssn));
671 f.
proto = IPPROTO_TCP;
693 "(msg:\"http server body test\"; "
694 "content:\"abc\"; http_server_body; depth:3; "
705 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
711 if (http_state == NULL) {
712 printf(
"no http state: \n");
721 printf(
"sid 1 matched but shouldn't have: ");
728 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
737 printf(
"sid 1 didn't match but should have: ");
756 static int DetectEngineHttpServerBodyTest06(
void)
766 uint8_t http_buf1[] =
767 "GET /index.html HTTP/1.0\r\n"
768 "Host: www.openinfosecfoundation.org\r\n"
769 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
771 uint32_t http_len1 =
sizeof(http_buf1) - 1;
772 uint8_t http_buf2[] =
773 "HTTP/1.0 200 ok\r\n"
774 "Content-Type: text/html\r\n"
775 "Content-Length: 6\r\n"
778 uint32_t http_len2 =
sizeof(http_buf2) - 1;
782 memset(&th_v, 0,
sizeof(th_v));
783 memset(&f, 0,
sizeof(f));
784 memset(&ssn, 0,
sizeof(ssn));
791 f.
proto = IPPROTO_TCP;
813 "(msg:\"http server body test\"; "
814 "content:!\"def\"; http_server_body; depth:3; "
825 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
831 if (http_state == NULL) {
832 printf(
"no http state: \n");
841 printf(
"sid 1 matched but shouldn't have: ");
848 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
857 printf(
"sid 1 didn't match but should have: ");
876 static int DetectEngineHttpServerBodyTest07(
void)
886 uint8_t http_buf1[] =
887 "GET /index.html HTTP/1.0\r\n"
888 "Host: www.openinfosecfoundation.org\r\n"
889 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
891 uint32_t http_len1 =
sizeof(http_buf1) - 1;
892 uint8_t http_buf2[] =
893 "HTTP/1.0 200 ok\r\n"
894 "Content-Type: text/html\r\n"
895 "Content-Length: 6\r\n"
898 uint32_t http_len2 =
sizeof(http_buf2) - 1;
902 memset(&th_v, 0,
sizeof(th_v));
903 memset(&f, 0,
sizeof(f));
904 memset(&ssn, 0,
sizeof(ssn));
911 f.
proto = IPPROTO_TCP;
933 "(msg:\"http server body test\"; "
934 "content:!\"def\"; http_server_body; offset:3; "
945 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
951 if (http_state == NULL) {
952 printf(
"no http state: \n");
961 printf(
"sid 1 matched but shouldn't have: ");
968 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
977 printf(
"sid 1 matched but shouldn't have: ");
996 static int DetectEngineHttpServerBodyTest08(
void)
1006 uint8_t http_buf1[] =
1007 "GET /index.html HTTP/1.0\r\n"
1008 "Host: www.openinfosecfoundation.org\r\n"
1009 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
1011 uint32_t http_len1 =
sizeof(http_buf1) - 1;
1012 uint8_t http_buf2[] =
1013 "HTTP/1.0 200 ok\r\n"
1014 "Content-Type: text/html\r\n"
1015 "Content-Length: 6\r\n"
1018 uint32_t http_len2 =
sizeof(http_buf2) - 1;
1022 memset(&th_v, 0,
sizeof(th_v));
1023 memset(&f, 0,
sizeof(f));
1024 memset(&ssn, 0,
sizeof(ssn));
1031 f.
proto = IPPROTO_TCP;
1053 "(msg:\"http server body test\"; "
1054 "content:!\"abc\"; http_server_body; depth:3; "
1065 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1071 if (http_state == NULL) {
1072 printf(
"no http state: \n");
1081 printf(
"sid 1 matched but shouldn't have: ");
1088 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
1097 printf(
"sid 1 matched but shouldn't have: ");
1116 static int DetectEngineHttpServerBodyTest09(
void)
1126 uint8_t http_buf1[] =
1127 "GET /index.html HTTP/1.0\r\n"
1128 "Host: www.openinfosecfoundation.org\r\n"
1129 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
1131 uint32_t http_len1 =
sizeof(http_buf1) - 1;
1132 uint8_t http_buf2[] =
1133 "HTTP/1.0 200 ok\r\n"
1134 "Content-Type: text/html\r\n"
1135 "Content-Length: 6\r\n"
1138 uint32_t http_len2 =
sizeof(http_buf2) - 1;
1142 memset(&th_v, 0,
sizeof(th_v));
1143 memset(&f, 0,
sizeof(f));
1144 memset(&ssn, 0,
sizeof(ssn));
1151 f.
proto = IPPROTO_TCP;
1173 "(msg:\"http server body test\"; "
1174 "content:\"abc\"; http_server_body; depth:3; "
1175 "content:\"def\"; http_server_body; within:3; "
1186 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1192 if (http_state == NULL) {
1193 printf(
"no http state: \n");
1202 printf(
"sid 1 matched but shouldn't have: ");
1209 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
1218 printf(
"sid 1 didn't match but should have: ");
1237 static int DetectEngineHttpServerBodyTest10(
void)
1247 uint8_t http_buf1[] =
1248 "GET /index.html HTTP/1.0\r\n"
1249 "Host: www.openinfosecfoundation.org\r\n"
1250 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
1252 uint32_t http_len1 =
sizeof(http_buf1) - 1;
1253 uint8_t http_buf2[] =
1254 "HTTP/1.0 200 ok\r\n"
1255 "Content-Type: text/html\r\n"
1256 "Content-Length: 6\r\n"
1259 uint32_t http_len2 =
sizeof(http_buf2) - 1;
1263 memset(&th_v, 0,
sizeof(th_v));
1264 memset(&f, 0,
sizeof(f));
1265 memset(&ssn, 0,
sizeof(ssn));
1272 f.
proto = IPPROTO_TCP;
1294 "(msg:\"http server body test\"; "
1295 "content:\"abc\"; http_server_body; depth:3; "
1296 "content:!\"xyz\"; http_server_body; within:3; "
1307 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1313 if (http_state == NULL) {
1314 printf(
"no http state: \n");
1323 printf(
"sid 1 matched but shouldn't have: ");
1330 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
1339 printf(
"sid 1 didn't match but should have: ");
1358 static int DetectEngineHttpServerBodyTest11(
void)
1368 uint8_t http_buf1[] =
1369 "GET /index.html HTTP/1.0\r\n"
1370 "Host: www.openinfosecfoundation.org\r\n"
1371 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
1373 uint32_t http_len1 =
sizeof(http_buf1) - 1;
1374 uint8_t http_buf2[] =
1375 "HTTP/1.0 200 ok\r\n"
1376 "Content-Type: text/html\r\n"
1377 "Content-Length: 6\r\n"
1380 uint32_t http_len2 =
sizeof(http_buf2) - 1;
1384 memset(&th_v, 0,
sizeof(th_v));
1385 memset(&f, 0,
sizeof(f));
1386 memset(&ssn, 0,
sizeof(ssn));
1393 f.
proto = IPPROTO_TCP;
1415 "(msg:\"http server body test\"; "
1416 "content:\"abc\"; http_server_body; depth:3; "
1417 "content:\"xyz\"; http_server_body; within:3; "
1428 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1434 if (http_state == NULL) {
1435 printf(
"no http state: \n");
1444 printf(
"sid 1 matched but shouldn't have: ");
1451 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
1460 printf(
"sid 1 did match but should not have: ");
1479 static int DetectEngineHttpServerBodyTest12(
void)
1489 uint8_t http_buf1[] =
1490 "GET /index.html HTTP/1.0\r\n"
1491 "Host: www.openinfosecfoundation.org\r\n"
1492 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
1494 uint32_t http_len1 =
sizeof(http_buf1) - 1;
1495 uint8_t http_buf2[] =
1496 "HTTP/1.0 200 ok\r\n"
1497 "Content-Type: text/html\r\n"
1498 "Content-Length: 6\r\n"
1501 uint32_t http_len2 =
sizeof(http_buf2) - 1;
1505 memset(&th_v, 0,
sizeof(th_v));
1506 memset(&f, 0,
sizeof(f));
1507 memset(&ssn, 0,
sizeof(ssn));
1514 f.
proto = IPPROTO_TCP;
1536 "(msg:\"http server body test\"; "
1537 "content:\"ab\"; http_server_body; depth:2; "
1538 "content:\"ef\"; http_server_body; distance:2; "
1549 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1555 if (http_state == NULL) {
1556 printf(
"no http state: \n");
1565 printf(
"sid 1 matched but shouldn't have: ");
1572 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
1581 printf(
"sid 1 did not match but should have: ");
1600 static int DetectEngineHttpServerBodyTest13(
void)
1610 uint8_t http_buf1[] =
1611 "GET /index.html HTTP/1.0\r\n"
1612 "Host: www.openinfosecfoundation.org\r\n"
1613 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
1615 uint32_t http_len1 =
sizeof(http_buf1) - 1;
1616 uint8_t http_buf2[] =
1617 "HTTP/1.0 200 ok\r\n"
1618 "Content-Type: text/html\r\n"
1619 "Content-Length: 6\r\n"
1622 uint32_t http_len2 =
sizeof(http_buf2) - 1;
1626 memset(&th_v, 0,
sizeof(th_v));
1627 memset(&f, 0,
sizeof(f));
1628 memset(&ssn, 0,
sizeof(ssn));
1635 f.
proto = IPPROTO_TCP;
1657 "(msg:\"http server body test\"; "
1658 "content:\"ab\"; http_server_body; depth:3; "
1659 "content:!\"yz\"; http_server_body; distance:2; "
1670 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1676 if (http_state == NULL) {
1677 printf(
"no http state: \n");
1686 printf(
"sid 1 matched but shouldn't have: ");
1693 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
1702 printf(
"sid 1 did not match but should have: ");
1721 static int DetectEngineHttpServerBodyTest14(
void)
1731 uint8_t http_buf1[] =
1732 "GET /index.html HTTP/1.0\r\n"
1733 "Host: www.openinfosecfoundation.org\r\n"
1734 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
1736 uint32_t http_len1 =
sizeof(http_buf1) - 1;
1737 uint8_t http_buf2[] =
1738 "HTTP/1.0 200 ok\r\n"
1739 "Content-Type: text/html\r\n"
1740 "Content-Length: 6\r\n"
1743 uint32_t http_len2 =
sizeof(http_buf2) - 1;
1747 memset(&th_v, 0,
sizeof(th_v));
1748 memset(&f, 0,
sizeof(f));
1749 memset(&ssn, 0,
sizeof(ssn));
1756 f.
proto = IPPROTO_TCP;
1778 "(msg:\"http server body test\"; "
1780 "content:\"ef\"; http_server_body; distance:2; "
1791 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1797 if (http_state == NULL) {
1798 printf(
"no http state: \n");
1807 printf(
"sid 1 matched but shouldn't have: ");
1814 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
1823 printf(
"sid 1 did not match but should have: ");
1842 static int DetectEngineHttpServerBodyTest15(
void)
1852 uint8_t http_buf1[] =
1853 "GET /index.html HTTP/1.0\r\n"
1854 "Host: www.openinfosecfoundation.org\r\n"
1855 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
1857 uint32_t http_len1 =
sizeof(http_buf1) - 1;
1858 uint8_t http_buf2[] =
1859 "HTTP/1.0 200 ok\r\n"
1860 "Content-Type: text/html\r\n"
1861 "Content-Length: 6\r\n"
1864 uint32_t http_len2 =
sizeof(http_buf2) - 1;
1868 memset(&th_v, 0,
sizeof(th_v));
1869 memset(&f, 0,
sizeof(f));
1870 memset(&ssn, 0,
sizeof(ssn));
1877 f.
proto = IPPROTO_TCP;
1899 "(msg:\"http server body test\"; "
1901 "content:!\"xyz\"; http_server_body; distance:0; within:3; "
1912 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1918 if (http_state == NULL) {
1919 printf(
"no http state: \n");
1928 printf(
"sid 1 matched but shouldn't have: ");
1935 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
1944 printf(
"sid 1 did not match but should have: ");
1963 static int DetectEngineHttpServerBodyTest16(
void)
1972 request-body-limit: 0\n\
1973 response-body-limit: 0\n\
1975 request-body-inspect-window: 0\n\
1976 response-body-inspect-window: 0\n\
1977 request-body-minimal-inspect-size: 0\n\
1978 response-body-minimal-inspect-size: 0\n\
1997 uint8_t http_buf1[] =
1998 "GET /index.html HTTP/1.0\r\n"
1999 "Host: www.openinfosecfoundation.org\r\n"
2000 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
2002 uint32_t http_len1 =
sizeof(http_buf1) - 1;
2003 uint8_t http_buf2[] =
2004 "HTTP/1.0 200 ok\r\n"
2005 "Content-Type: text/html\r\n"
2006 "Content-Length: 17\r\n"
2009 uint32_t http_len2 =
sizeof(http_buf2) - 1;
2010 uint8_t http_buf3[] =
2012 uint32_t http_len3 =
sizeof(http_buf3) - 1;
2015 memset(&th_v, 0,
sizeof(th_v));
2016 memset(&f, 0,
sizeof(f));
2017 memset(&ssn, 0,
sizeof(ssn));
2024 f.
proto = IPPROTO_TCP;
2046 "(msg:\"http server body test\"; "
2047 "content:\"890\"; within:3; http_server_body; "
2058 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
2064 if (http_state == NULL) {
2065 printf(
"no http state: \n");
2074 printf(
"sid 1 matched but shouldn't have\n");
2081 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
2090 printf(
"sid 1 matched but shouldn't have\n");
2097 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
2106 printf(
"sid 1 matched but shouldn't have\n");
2129 static int DetectEngineHttpServerBodyTest17(
void)
2138 request-body-limit: 0\n\
2139 response-body-limit: 0\n\
2141 request-body-inspect-window: 0\n\
2142 response-body-inspect-window: 0\n\
2143 request-body-minimal-inspect-size: 0\n\
2144 response-body-minimal-inspect-size: 0\n\
2162 uint8_t http_buf1[] =
2163 "GET /index.html HTTP/1.0\r\n"
2164 "Host: www.openinfosecfoundation.org\r\n"
2165 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
2167 uint32_t http_len1 =
sizeof(http_buf1) - 1;
2168 uint8_t http_buf2[] =
2169 "HTTP/1.0 200 ok\r\n"
2170 "Content-Type: text/html\r\n"
2171 "Content-Length: 17\r\n"
2174 uint32_t http_len2 =
sizeof(http_buf2) - 1;
2175 uint8_t http_buf3[] =
2177 uint32_t http_len3 =
sizeof(http_buf3) - 1;
2180 memset(&th_v, 0,
sizeof(th_v));
2181 memset(&f, 0,
sizeof(f));
2182 memset(&ssn, 0,
sizeof(ssn));
2189 f.
proto = IPPROTO_TCP;
2209 "content:\"890\"; depth:3; http_server_body; "
2262 static int DetectEngineHttpServerBodyTest18(
void)
2272 uint8_t http_buf1[] =
2273 "GET /index.html HTTP/1.0\r\n"
2274 "Host: www.openinfosecfoundation.org\r\n"
2275 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
2277 uint32_t http_len1 =
sizeof(http_buf1) - 1;
2278 uint8_t http_buf2[] = {
2279 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
2280 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'5',
'1', 0x0d, 0x0a,
2281 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'E',
'n',
'c',
'o',
'd',
'i',
'n',
'g',
':',
' ',
'g',
'z',
'i',
'p', 0x0d, 0x0a,
2283 0x1f, 0x8b, 0x08, 0x08, 0x27, 0x1e, 0xe5, 0x51,
2284 0x00, 0x03, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74,
2285 0x78, 0x74, 0x00, 0x2b, 0xc9, 0xc8, 0x2c, 0x56,
2286 0x00, 0xa2, 0x44, 0x85, 0xb4, 0xcc, 0x9c, 0x54,
2287 0x85, 0xcc, 0x3c, 0x20, 0x2b, 0x29, 0xbf, 0x42,
2288 0x8f, 0x0b, 0x00, 0xb2, 0x7d, 0xac, 0x9b, 0x19,
2291 uint32_t http_len2 =
sizeof(http_buf2);
2295 memset(&th_v, 0,
sizeof(th_v));
2296 memset(&f, 0,
sizeof(f));
2297 memset(&ssn, 0,
sizeof(ssn));
2304 f.
proto = IPPROTO_TCP;
2326 "(msg:\"http server body test\"; "
2327 "content:\"file\"; http_server_body; "
2338 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
2344 if (http_state == NULL) {
2345 printf(
"no http state: \n");
2354 printf(
"sid 1 matched but shouldn't have\n");
2361 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
2370 printf(
"sid 1 didn't match but should have");
2392 static int DetectEngineHttpServerBodyTest19(
void)
2402 uint8_t http_buf1[] =
2403 "GET /index.html HTTP/1.0\r\n"
2404 "Host: www.openinfosecfoundation.org\r\n"
2405 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
2407 uint32_t http_len1 =
sizeof(http_buf1) - 1;
2408 uint8_t http_buf2[] = {
2409 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
2410 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'2',
'4', 0x0d, 0x0a,
2411 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'E',
'n',
'c',
'o',
'd',
'i',
'n',
'g',
':',
' ',
'd',
'e',
'f',
'l',
'a',
't',
'e', 0x0d, 0x0a,
2413 0x2b, 0xc9, 0xc8, 0x2c, 0x56,
2414 0x00, 0xa2, 0x44, 0x85, 0xb4, 0xcc, 0x9c, 0x54,
2415 0x85, 0xcc, 0x3c, 0x20, 0x2b, 0x29, 0xbf, 0x42,
2419 uint32_t http_len2 =
sizeof(http_buf2);
2423 memset(&th_v, 0,
sizeof(th_v));
2424 memset(&f, 0,
sizeof(f));
2425 memset(&ssn, 0,
sizeof(ssn));
2432 f.
proto = IPPROTO_TCP;
2454 "(msg:\"http server body test\"; "
2455 "content:\"file\"; http_server_body; "
2466 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
2472 if (http_state == NULL) {
2473 printf(
"no http state: \n");
2482 printf(
"sid 1 matched but shouldn't have\n");
2489 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
2498 printf(
"sid 1 didn't match but should have");
2520 static int DetectEngineHttpServerBodyTest20(
void)
2530 uint8_t http_buf1[] =
2531 "GET /index.html HTTP/1.0\r\n"
2532 "Host: www.openinfosecfoundation.org\r\n"
2533 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
2535 uint32_t http_len1 =
sizeof(http_buf1) - 1;
2536 uint8_t http_buf2[] = {
2537 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
2538 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'2',
'4', 0x0d, 0x0a,
2539 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'E',
'n',
'c',
'o',
'd',
'i',
'n',
'g',
':',
' ',
'g',
'z',
'i',
'p', 0x0d, 0x0a,
2541 0x2b, 0xc9, 0xc8, 0x2c, 0x56,
2542 0x00, 0xa2, 0x44, 0x85, 0xb4, 0xcc, 0x9c, 0x54,
2543 0x85, 0xcc, 0x3c, 0x20, 0x2b, 0x29, 0xbf, 0x42,
2547 uint32_t http_len2 =
sizeof(http_buf2);
2551 memset(&th_v, 0,
sizeof(th_v));
2552 memset(&f, 0,
sizeof(f));
2553 memset(&ssn, 0,
sizeof(ssn));
2560 f.
proto = IPPROTO_TCP;
2582 "(msg:\"http server body test\"; "
2583 "content:\"file\"; http_server_body; "
2594 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
2600 if (http_state == NULL) {
2601 printf(
"no http state: \n");
2610 printf(
"sid 1 matched but shouldn't have\n");
2617 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
2625 #ifdef HAVE_HTP_CONFIG_SET_RESPONSE_DECOMPRESSION_LAYER_LIMIT
2647 static int DetectEngineHttpServerBodyTest21(
void)
2657 uint8_t http_buf1[] =
2658 "GET /index.html HTTP/1.0\r\n"
2659 "Host: www.openinfosecfoundation.org\r\n"
2660 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
2662 uint32_t http_len1 =
sizeof(http_buf1) - 1;
2663 uint8_t http_buf2[] = {
2664 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
2665 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'5',
'1', 0x0d, 0x0a,
2666 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'E',
'n',
'c',
'o',
'd',
'i',
'n',
'g',
':',
' ',
'd',
'e',
'f',
'l',
'a',
't',
'e', 0x0d, 0x0a,
2668 0x1f, 0x8b, 0x08, 0x08, 0x27, 0x1e, 0xe5, 0x51,
2669 0x00, 0x03, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74,
2670 0x78, 0x74, 0x00, 0x2b, 0xc9, 0xc8, 0x2c, 0x56,
2671 0x00, 0xa2, 0x44, 0x85, 0xb4, 0xcc, 0x9c, 0x54,
2672 0x85, 0xcc, 0x3c, 0x20, 0x2b, 0x29, 0xbf, 0x42,
2673 0x8f, 0x0b, 0x00, 0xb2, 0x7d, 0xac, 0x9b, 0x19,
2676 uint32_t http_len2 =
sizeof(http_buf2);
2680 memset(&th_v, 0,
sizeof(th_v));
2681 memset(&f, 0,
sizeof(f));
2682 memset(&ssn, 0,
sizeof(ssn));
2689 f.
proto = IPPROTO_TCP;
2711 "(msg:\"http server body test\"; "
2712 "content:\"file\"; http_server_body; "
2723 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
2729 if (http_state == NULL) {
2730 printf(
"no http state: \n");
2739 printf(
"sid 1 matched but shouldn't have\n");
2746 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
2754 #ifdef HAVE_HTP_CONFIG_SET_RESPONSE_DECOMPRESSION_LAYER_LIMIT
2777 static int DetectEngineHttpServerBodyTest22(
void)
2787 uint8_t http_buf1[] =
2788 "GET /index.html HTTP/1.0\r\n"
2789 "Host: www.openinfosecfoundation.org\r\n"
2790 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
2792 uint32_t http_len1 =
sizeof(http_buf1) - 1;
2793 uint8_t http_buf2[] = {
2794 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
2795 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'5',
'1', 0x0d, 0x0a,
2796 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'E',
'n',
'c',
'o',
'd',
'i',
'n',
'g',
':',
' ',
'g',
'z',
'i',
'p', 0x0d, 0x0a,
2797 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'E',
'n',
'c',
'o',
'd',
'i',
'n',
'g',
':',
' ',
'd',
'e',
'f',
'l',
'a',
't',
'e', 0x0d, 0x0a,
2799 0x1f, 0x8b, 0x08, 0x08, 0x27, 0x1e, 0xe5, 0x51,
2800 0x00, 0x03, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74,
2801 0x78, 0x74, 0x00, 0x2b, 0xc9, 0xc8, 0x2c, 0x56,
2802 0x00, 0xa2, 0x44, 0x85, 0xb4, 0xcc, 0x9c, 0x54,
2803 0x85, 0xcc, 0x3c, 0x20, 0x2b, 0x29, 0xbf, 0x42,
2804 0x8f, 0x0b, 0x00, 0xb2, 0x7d, 0xac, 0x9b, 0x19,
2807 uint32_t http_len2 =
sizeof(http_buf2);
2811 memset(&th_v, 0,
sizeof(th_v));
2812 memset(&f, 0,
sizeof(f));
2813 memset(&ssn, 0,
sizeof(ssn));
2820 f.
proto = IPPROTO_TCP;
2842 "(msg:\"http server body test\"; "
2843 "content:\"file\"; http_server_body; "
2854 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
2860 if (http_state == NULL) {
2861 printf(
"no http state: \n");
2870 printf(
"sid 1 matched but shouldn't have: ");
2877 printf(
"toserver chunk 2 returned %" PRId32
", expected 0: \n", r);
2885 #ifdef HAVE_HTP_CONFIG_SET_RESPONSE_DECOMPRESSION_LAYER_LIMIT
2904 static int DetectEngineHttpServerBodyFileDataTest01(
void)
2914 uint8_t http_buf1[] =
2915 "GET /index.html HTTP/1.0\r\n"
2916 "Host: www.openinfosecfoundation.org\r\n"
2917 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
2919 uint32_t http_len1 =
sizeof(http_buf1) - 1;
2920 uint8_t http_buf2[] =
2921 "HTTP/1.0 200 ok\r\n"
2922 "Content-Type: text/html\r\n"
2923 "Content-Length: 6\r\n"
2926 uint32_t http_len2 =
sizeof(http_buf2) - 1;
2930 memset(&th_v, 0,
sizeof(th_v));
2931 memset(&f, 0,
sizeof(f));
2932 memset(&ssn, 0,
sizeof(ssn));
2939 f.
proto = IPPROTO_TCP;
2961 "(msg:\"http server body test\"; "
2962 "file_data; pcre:/ab/; "
2963 "content:\"ef\"; distance:2; "
2974 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
2980 if (http_state == NULL) {
2981 printf(
"no http state: \n");
2990 printf(
"sid 1 matched but shouldn't have: ");
2997 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
3006 printf(
"sid 1 did not match but should have: ");
3025 static int DetectEngineHttpServerBodyFileDataTest02(
void)
3035 uint8_t http_buf1[] =
3036 "GET /index.html HTTP/1.0\r\n"
3037 "Host: www.openinfosecfoundation.org\r\n"
3038 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
3040 uint32_t http_len1 =
sizeof(http_buf1) - 1;
3041 uint8_t http_buf2[] =
3042 "HTTP/1.0 200 ok\r\n"
3043 "Content-Type: text/html\r\n"
3044 "Content-Length: 6\r\n"
3047 uint32_t http_len2 =
sizeof(http_buf2) - 1;
3051 memset(&th_v, 0,
sizeof(th_v));
3052 memset(&f, 0,
sizeof(f));
3053 memset(&ssn, 0,
sizeof(ssn));
3060 f.
proto = IPPROTO_TCP;
3082 "(msg:\"http server body test\"; "
3083 "file_data; pcre:/abc/; "
3084 "content:!\"xyz\"; distance:0; within:3; "
3095 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
3101 if (http_state == NULL) {
3102 printf(
"no http state: \n");
3111 printf(
"sid 1 matched but shouldn't have: ");
3118 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
3127 printf(
"sid 1 did not match but should have: ");
3147 static int DetectEngineHttpServerBodyFileDataTest03(
void)
3156 uint8_t http_buf1[] =
3157 "GET /index.html HTTP/1.0\r\n"
3158 "Host: www.openinfosecfoundation.org\r\n"
3159 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
3161 uint32_t http_len1 =
sizeof(http_buf1) - 1;
3162 uint8_t http_buf2[] =
3163 "HTTP/1.0 200 ok\r\n"
3164 "Content-Type: text/html\r\n"
3165 "Content-Length: 33\r\n"
3167 "XYZ_klm_1234abcd_XYZ_klm_5678abcd";
3168 uint32_t http_len2 =
sizeof(http_buf2) - 1;
3171 memset(&th_v, 0,
sizeof(th_v));
3172 memset(&f, 0,
sizeof(f));
3173 memset(&ssn, 0,
sizeof(ssn));
3180 f.
proto = IPPROTO_TCP;
3200 "alert http any any -> any any "
3201 "(msg:\"match on 1st\"; "
3202 "file_data; content:\"XYZ\"; content:\"_klm_\"; distance:0; content:\"abcd\"; "
3203 "distance:4; byte_test:4,=,1234,-8,relative,string;"
3207 "alert http any any -> any any "
3208 "(msg:\"match on 2nd\"; "
3209 "file_data; content:\"XYZ\"; content:\"_klm_\"; distance:0; content:\"abcd\"; "
3210 "distance:4; byte_test:4,=,5678,-8,relative,string;"
3246 static int DetectEngineHttpServerBodyFileDataTest04(
void)
3249 const char yaml[] =
"\
3256 http-body-inline: yes\n\
3257 response-body-minimal-inspect-size: 6\n\
3258 response-body-inspect-window: 3\n\
3262 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
3263 "Host: www.openinfosecfoundation.org\r\n"
3264 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
3266 0, STREAM_TOSERVER, 0 },
3267 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
3268 "Content-Type: text/html\r\n"
3269 "Content-Length: 6\r\n"
3272 0, STREAM_TOCLIENT, 0 },
3273 { (
const uint8_t *)
"cd",
3274 0, STREAM_TOCLIENT, 1 },
3275 { (
const uint8_t *)
"ef",
3276 0, STREAM_TOCLIENT, 0 },
3280 const char *sig =
"alert http any any -> any any (file_data; content:\"abcd\"; sid:1;)";
3281 return RunTest(steps, sig, yaml);
3284 static int DetectEngineHttpServerBodyFileDataTest05(
void)
3287 const char yaml[] =
"\
3294 http-body-inline: yes\n\
3295 response-body-minimal-inspect-size: 6\n\
3296 response-body-inspect-window: 3\n\
3300 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
3301 "Host: www.openinfosecfoundation.org\r\n"
3302 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
3304 0, STREAM_TOSERVER, 0 },
3305 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
3306 "Content-Type: text/html\r\n"
3307 "Content-Length: 6\r\n"
3310 0, STREAM_TOCLIENT, 0 },
3311 { (
const uint8_t *)
"cd",
3312 0, STREAM_TOCLIENT, 0 },
3313 { (
const uint8_t *)
"ef",
3314 0, STREAM_TOCLIENT, 1 },
3318 const char *sig =
"alert http any any -> any any (file_data; content:\"abcdef\"; sid:1;)";
3319 return RunTest(steps, sig, yaml);
3322 static int DetectEngineHttpServerBodyFileDataTest06(
void)
3325 const char yaml[] =
"\
3332 http-body-inline: yes\n\
3333 response-body-minimal-inspect-size: 6\n\
3334 response-body-inspect-window: 3\n\
3338 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
3339 "Host: www.openinfosecfoundation.org\r\n"
3340 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
3342 0, STREAM_TOSERVER, 0 },
3343 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
3344 "Content-Type: text/html\r\n"
3345 "Content-Length: 6\r\n"
3348 0, STREAM_TOCLIENT, 0 },
3349 { (
const uint8_t *)
"cd",
3350 0, STREAM_TOCLIENT, 0 },
3351 { (
const uint8_t *)
"ef",
3352 0, STREAM_TOCLIENT, 1 },
3356 const char *sig =
"alert http any any -> any any (file_data; content:\"bcdef\"; offset:1; sid:1;)";
3357 return RunTest(steps, sig, yaml);
3360 static int DetectEngineHttpServerBodyFileDataTest07(
void)
3363 const char yaml[] =
"\
3370 http-body-inline: yes\n\
3371 response-body-minimal-inspect-size: 6\n\
3372 response-body-inspect-window: 3\n\
3376 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
3377 "Host: www.openinfosecfoundation.org\r\n"
3378 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
3380 0, STREAM_TOSERVER, 0 },
3381 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
3382 "Content-Type: text/html\r\n"
3383 "Content-Length: 13\r\n"
3386 0, STREAM_TOCLIENT, 0 },
3387 { (
const uint8_t *)
"cd",
3388 0, STREAM_TOCLIENT, 1 },
3389 { (
const uint8_t *)
"123456789",
3390 0, STREAM_TOCLIENT, 0 },
3394 const char *sig =
"alert http any any -> any any (file_data; content:\"bc\"; offset:1; depth:2; sid:1;)";
3395 return RunTest(steps, sig, yaml);
3398 static int DetectEngineHttpServerBodyFileDataTest08(
void)
3401 const char yaml[] =
"\
3408 http-body-inline: yes\n\
3409 response-body-minimal-inspect-size: 6\n\
3410 response-body-inspect-window: 3\n\
3414 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
3415 "Host: www.openinfosecfoundation.org\r\n"
3416 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
3418 0, STREAM_TOSERVER, 0 },
3419 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
3420 "Content-Type: text/html\r\n"
3421 "Content-Length: 14\r\n"
3424 0, STREAM_TOCLIENT, 0 },
3425 { (
const uint8_t *)
"cd",
3426 0, STREAM_TOCLIENT, 0 },
3427 { (
const uint8_t *)
"1234567890",
3428 0, STREAM_TOCLIENT, 1 },
3432 const char *sig =
"alert http any any -> any any (file_data; content:\"d123456789\"; offset:3; sid:1;)";
3433 return RunTest(steps, sig, yaml);
3436 static int DetectEngineHttpServerBodyFileDataTest09(
void)
3439 const char yaml[] =
"\
3446 http-body-inline: yes\n\
3447 response-body-minimal-inspect-size: 6\n\
3448 response-body-inspect-window: 3\n\
3452 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
3453 "Host: www.openinfosecfoundation.org\r\n"
3454 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
3456 0, STREAM_TOSERVER, 0 },
3457 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
3458 "Content-Type: text/html\r\n"
3459 "Content-Length: 13\r\n"
3462 0, STREAM_TOCLIENT, 0 },
3463 { (
const uint8_t *)
"cd",
3464 0, STREAM_TOCLIENT, 0 },
3465 { (
const uint8_t *)
"123456789",
3466 0, STREAM_TOCLIENT, 1 },
3470 const char *sig =
"alert http any any -> any any (file_data; content:\"abcd12\"; depth:6; sid:1;)";
3471 return RunTest(steps, sig, yaml);
3474 static int DetectEngineHttpServerBodyFileDataTest10(
void)
3477 const char yaml[] =
"\
3484 http-body-inline: yes\n\
3485 response-body-minimal-inspect-size: 6\n\
3486 response-body-inspect-window: 3\n\
3490 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
3491 "Host: www.openinfosecfoundation.org\r\n"
3492 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
3494 0, STREAM_TOSERVER, 0 },
3495 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
3496 "Content-Type: text/html\r\n"
3497 "Content-Length: 5\r\n"
3500 0, STREAM_TOCLIENT, 0 },
3501 { (
const uint8_t *)
"c",
3502 0, STREAM_TOCLIENT, 1 },
3503 { (
const uint8_t *)
"de",
3504 0, STREAM_TOCLIENT, 0 },
3508 const char *sig =
"alert http any any -> any any (file_data; content:\"abc\"; depth:3; sid:1;)";
3509 return RunTest(steps, sig, yaml);
3512 static int DetectEngineHttpServerBodyFileDataTest11(
void)
3515 const char yaml[] =
"\
3522 http-body-inline: yes\n\
3523 response-body-minimal-inspect-size: 6\n\
3524 response-body-inspect-window: 3\n\
3528 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
3529 "Host: www.openinfosecfoundation.org\r\n"
3530 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
3532 0, STREAM_TOSERVER, 0 },
3533 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
3534 "Content-Type: text/html\r\n"
3535 "Content-Length: 5\r\n"
3538 0, STREAM_TOCLIENT, 0 },
3539 { (
const uint8_t *)
"c",
3540 0, STREAM_TOCLIENT, 0 },
3541 { (
const uint8_t *)
"de",
3542 0, STREAM_TOCLIENT, 1 },
3546 const char *sig =
"alert http any any -> any any (file_data; content:\"bcde\"; offset:1; depth:4; sid:1;)";
3547 return RunTest(steps, sig, yaml);
3550 static int DetectEngineHttpServerBodyFileDataTest12(
void)
3553 const char yaml[] =
"\
3560 http-body-inline: yes\n\
3561 response-body-minimal-inspect-size: 6\n\
3562 response-body-inspect-window: 3\n\
3566 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
3567 "Host: www.openinfosecfoundation.org\r\n"
3568 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
3570 0, STREAM_TOSERVER, 0 },
3571 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
3572 "Content-Type: text/html\r\n"
3573 "Content-Length: 13\r\n"
3576 0, STREAM_TOCLIENT, 0 },
3577 { (
const uint8_t *)
"b",
3578 0, STREAM_TOCLIENT, 0 },
3579 { (
const uint8_t *)
"c",
3580 0, STREAM_TOCLIENT, 0 },
3581 { (
const uint8_t *)
"d",
3582 0, STREAM_TOCLIENT, 1 },
3583 { (
const uint8_t *)
"efghijklm",
3584 0, STREAM_TOCLIENT, 0 },
3588 const char *sig =
"alert http any any -> any any (file_data; content:\"abcd\"; sid:1;)";
3589 return RunTest(steps, sig, yaml);
3592 static int DetectEngineHttpServerBodyFileDataTest13(
void)
3595 const char yaml[] =
"\
3602 http-body-inline: yes\n\
3603 response-body-minimal-inspect-size: 9\n\
3604 response-body-inspect-window: 12\n\
3608 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
3609 "Host: www.openinfosecfoundation.org\r\n"
3610 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
3612 0, STREAM_TOSERVER, 0 },
3613 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
3614 "Content-Type: text/html\r\n"
3615 "Content-Length: 13\r\n"
3618 0, STREAM_TOCLIENT, 0 },
3619 { (
const uint8_t *)
"b",
3620 0, STREAM_TOCLIENT, 0 },
3621 { (
const uint8_t *)
"c",
3622 0, STREAM_TOCLIENT, 0 },
3623 { (
const uint8_t *)
"d",
3624 0, STREAM_TOCLIENT, 0 },
3625 { (
const uint8_t *)
"efghijklm",
3626 0, STREAM_TOCLIENT, 1 },
3630 const char *sig =
"alert http any any -> any any (file_data; content:\"abcdefghijklm\"; sid:1;)";
3631 return RunTest(steps, sig, yaml);
3634 static int DetectEngineHttpServerBodyFileDataTest14(
void)
3637 const char yaml[] =
"\
3644 http-body-inline: yes\n\
3645 response-body-minimal-inspect-size: 9\n\
3646 response-body-inspect-window: 12\n\
3650 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
3651 "Host: www.openinfosecfoundation.org\r\n"
3652 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
3654 0, STREAM_TOSERVER, 0 },
3655 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
3656 "Content-Type: text/html\r\n"
3657 "Content-Length: 20\r\n"
3660 0, STREAM_TOCLIENT, 0 },
3661 { (
const uint8_t *)
"abcdefghi",
3662 0, STREAM_TOCLIENT, 1 },
3666 const char *sig =
"alert http any any -> any any (file_data; content:\"890abcdefghi\"; sid:1;)";
3667 return RunTest(steps, sig, yaml);
3670 static int DetectEngineHttpServerBodyFileDataTest15(
void)
3673 const char yaml[] =
"\
3680 http-body-inline: yes\n\
3681 response-body-minimal-inspect-size: 9\n\
3682 response-body-inspect-window: 12\n\
3686 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
3687 "Host: www.openinfosecfoundation.org\r\n"
3688 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
3690 0, STREAM_TOSERVER, 0 },
3691 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
3692 "Content-Type: text/html\r\n"
3693 "Content-Length: 20\r\n"
3696 0, STREAM_TOCLIENT, 0 },
3697 { (
const uint8_t *)
"abcdefghi",
3698 0, STREAM_TOCLIENT, 0 },
3702 const char *sig =
"alert http any any -> any any (file_data; content:\"7890ab\"; depth:6; sid:1;)";
3703 return RunTest(steps, sig, yaml);
3706 static int DetectEngineHttpServerBodyFileDataTest16(
void)
3709 const char yaml[] =
"\
3716 http-body-inline: yes\n\
3717 response-body-minimal-inspect-size: 9\n\
3718 response-body-inspect-window: 12\n\
3722 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
3723 "Host: www.openinfosecfoundation.org\r\n"
3724 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
3726 0, STREAM_TOSERVER, 0 },
3727 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
3728 "Content-Type: text/html\r\n"
3729 "Content-Length: 20\r\n"
3732 0, STREAM_TOCLIENT, 0 },
3733 { (
const uint8_t *)
"bbbbc",
3734 0, STREAM_TOCLIENT, 0 },
3735 { (
const uint8_t *)
"ccccd",
3736 0, STREAM_TOCLIENT, 0 },
3737 { (
const uint8_t *)
"dddde",
3738 0, STREAM_TOCLIENT, 0 },
3742 const char *sig =
"alert http any any -> any any (file_data; content:\"aabb\"; depth:4; sid:1;)";
3743 return RunTest(steps, sig, yaml);
3746 static int DetectEngineHttpServerBodyFileDataTest17(
void)
3749 const char yaml[] =
"\
3756 http-body-inline: yes\n\
3757 response-body-minimal-inspect-size: 8\n\
3758 response-body-inspect-window: 4\n\
3762 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
3763 "Host: www.openinfosecfoundation.org\r\n"
3764 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
3766 0, STREAM_TOSERVER, 0 },
3767 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
3768 "Content-Type: text/html\r\n"
3769 "Content-Length: 20\r\n"
3772 0, STREAM_TOCLIENT, 0 },
3773 { (
const uint8_t *)
"bbbbc",
3774 0, STREAM_TOCLIENT, 0 },
3775 { (
const uint8_t *)
"ccccd",
3776 0, STREAM_TOCLIENT, 0 },
3777 { (
const uint8_t *)
"dddde",
3778 0, STREAM_TOCLIENT, 0 },
3782 const char *sig =
"alert http any any -> any any (file_data; content:\"bbbc\"; depth:4; sid:1;)";
3783 return RunTest(steps, sig, yaml);
3786 static int DetectEngineHttpServerBodyFileDataTest18(
void)
3789 const char yaml[] =
"\
3796 http-body-inline: yes\n\
3797 response-body-minimal-inspect-size: 8\n\
3798 response-body-inspect-window: 4\n\
3802 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
3803 "Host: www.openinfosecfoundation.org\r\n"
3804 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
3806 0, STREAM_TOSERVER, 0 },
3807 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
3808 "Content-Type: text/html\r\n"
3809 "Content-Length: 20\r\n"
3812 0, STREAM_TOCLIENT, 0 },
3813 { (
const uint8_t *)
"bbbbc",
3814 0, STREAM_TOCLIENT, 0 },
3815 { (
const uint8_t *)
"ccccd",
3816 0, STREAM_TOCLIENT, 0 },
3817 { (
const uint8_t *)
"dddde",
3818 0, STREAM_TOCLIENT, 0 },
3822 const char *sig =
"alert http any any -> any any (file_data; content:\"bccd\"; depth:4; sid:1;)";
3823 return RunTest(steps, sig, yaml);
3825 static int DetectEngineHttpServerBodyFileDataTest19(
void)
3834 swf-decompression:\n\
3837 compress-depth: 0\n\
3838 decompress-depth: 0\n\
3853 uint8_t http_buf1[] =
3854 "GET /file.swf HTTP/1.0\r\n"
3855 "Host: www.openinfosecfoundation.org\r\n"
3856 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
3858 uint32_t http_len1 =
sizeof(http_buf1) - 1;
3859 uint8_t http_buf2[] = {
3860 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
3861 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
3862 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
3863 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'x',
'-',
's',
'h',
'o',
'c',
'k',
'w',
'a',
'v',
'e',
'-',
'f',
'l',
'a',
's',
'h', 0x0d, 0x0a,
3865 0x43, 0x57, 0x53, 0x0a, 0xcb, 0x6c, 0x00, 0x00, 0x78, 0xda, 0xad, 0xbd, 0x07, 0x98, 0x55, 0x55,
3866 0x9e, 0xee, 0xbd, 0x4f, 0xd8, 0xb5, 0x4e, 0x15, 0xc1, 0xc2, 0x80, 0x28, 0x86, 0xd2, 0x2e, 0x5a,
3867 0xdb, 0x46, 0xd9, 0x39, 0x38, 0xdd, 0x4e, 0x1b, 0xa8, 0x56, 0x5b, 0xc5, 0x6b, 0xe8, 0x76, 0xfa,
3868 0x0e, 0xc2, 0x8e, 0x50, 0x76, 0x51, 0xc5, 0x54, 0x15, 0x88, 0x73, 0xc3, 0xd0, 0x88, 0x39, 0x81,
3869 0x98, 0x63, 0x91, 0x93, 0x8a, 0x82, 0x89, 0x60, 0x00, 0xcc, 0xb1, 0x00, 0x01, 0x73, 0xce, 0x39,
3871 uint32_t http_len2 =
sizeof(http_buf2);
3875 memset(&th_v, 0,
sizeof(th_v));
3876 memset(&f, 0,
sizeof(f));
3877 memset(&ssn, 0,
sizeof(ssn));
3884 f.
proto = IPPROTO_TCP;
3905 "(flow:established,from_server; "
3906 "file_data; content:\"FWS\"; "
3949 static int DetectEngineHttpServerBodyFileDataTest20(
void)
3958 swf-decompression:\n\
3961 compress-depth: 0\n\
3962 decompress-depth: 0\n\
3980 uint8_t http_buf1[] =
3981 "GET /file.swf HTTP/1.0\r\n"
3982 "Host: www.openinfosecfoundation.org\r\n"
3983 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
3985 uint32_t http_len1 =
sizeof(http_buf1) - 1;
3986 uint8_t http_buf2[] = {
3987 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
3988 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
3989 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
3990 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'x',
'-',
's',
'h',
'o',
'c',
'k',
'w',
'a',
'v',
'e',
'-',
'f',
'l',
'a',
's',
'h', 0x0d, 0x0a,
3992 0x43, 0x57, 0x53, 0x0a, 0xcb, 0x6c, 0x00, 0x00, 0x78, 0xda, 0xad, 0xbd, 0x07, 0x98, 0x55, 0x55,
3993 0x9e, 0xee, 0xbd, 0x4f, 0xd8, 0xb5, 0x4e, 0x15, 0xc1, 0xc2, 0x80, 0x28, 0x86, 0xd2, 0x2e, 0x5a,
3994 0xdb, 0x46, 0xd9, 0x39, 0x38, 0xdd, 0x4e, 0x1b, 0xa8, 0x56, 0x5b, 0xc5, 0x6b, 0xe8, 0x76, 0xfa,
3995 0x0e, 0xc2, 0x8e, 0x50, 0x76, 0x51, 0xc5, 0x54, 0x15, 0x88, 0x73, 0xc3, 0xd0, 0x88, 0x39, 0x81,
3996 0x98, 0x63, 0x91, 0x93, 0x8a, 0x82, 0x89, 0x60, 0x00, 0xcc, 0xb1, 0x00, 0x01, 0x73, 0xce, 0x39,
3998 uint32_t http_len2 =
sizeof(http_buf2);
4002 memset(&th_v, 0,
sizeof(th_v));
4003 memset(&f, 0,
sizeof(f));
4004 memset(&ssn, 0,
sizeof(ssn));
4011 f.
proto = IPPROTO_TCP;
4032 "(flow:established,from_server; "
4033 "file_data; content:\"CWS\"; "
4076 static int DetectEngineHttpServerBodyFileDataTest21(
void)
4085 swf-decompression:\n\
4088 compress-depth: 0\n\
4089 decompress-depth: 0\n\
4107 uint8_t http_buf1[] =
4108 "GET /file.swf HTTP/1.0\r\n"
4109 "Host: www.openinfosecfoundation.org\r\n"
4110 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
4112 uint32_t http_len1 =
sizeof(http_buf1) - 1;
4113 uint8_t http_buf2[] = {
4114 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
4115 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
4116 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
4117 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'x',
'-',
's',
'h',
'o',
'c',
'k',
'w',
'a',
'v',
'e',
'-',
'f',
'l',
'a',
's',
'h', 0x0d, 0x0a,
4119 0x43, 0x57, 0x53, 0x0a, 0xcb, 0x6c, 0x00, 0x00, 0x78, 0xda, 0xad, 0xbd, 0x07, 0x98, 0x55, 0x55,
4120 0x9e, 0xee, 0xbd, 0x4f, 0xd8, 0xb5, 0x4e, 0x15, 0xc1, 0xc2, 0x80, 0x28, 0x86, 0xd2, 0x2e, 0x5a,
4121 0xdb, 0x46, 0xd9, 0x39, 0x38, 0xdd, 0x4e, 0x1b, 0xa8, 0x56, 0x5b, 0xc5, 0x6b, 0xe8, 0x76, 0xfa,
4122 0x0e, 0xc2, 0x8e, 0x50, 0x76, 0x51, 0xc5, 0x54, 0x15, 0x88, 0x73, 0xc3, 0xd0, 0x88, 0x39, 0x81,
4123 0x98, 0x63, 0x91, 0x93, 0x8a, 0x82, 0x89, 0x60, 0x00, 0xcc, 0xb1, 0x00, 0x01, 0x73, 0xce, 0x39,
4125 uint32_t http_len2 =
sizeof(http_buf2);
4129 memset(&th_v, 0,
sizeof(th_v));
4130 memset(&f, 0,
sizeof(f));
4131 memset(&ssn, 0,
sizeof(ssn));
4138 f.
proto = IPPROTO_TCP;
4159 "(flow:established,from_server; "
4160 "file_data; content:\"FWS\"; "
4203 static int DetectEngineHttpServerBodyFileDataTest22(
void)
4212 swf-decompression:\n\
4215 compress-depth: 0\n\
4216 decompress-depth: 0\n\
4234 uint8_t http_buf1[] =
4235 "GET /file.swf HTTP/1.0\r\n"
4236 "Host: www.openinfosecfoundation.org\r\n"
4237 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
4239 uint32_t http_len1 =
sizeof(http_buf1) - 1;
4240 uint8_t http_buf2[] = {
4241 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
4242 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
4243 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
4244 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'x',
'-',
's',
'h',
'o',
'c',
'k',
'w',
'a',
'v',
'e',
'-',
'f',
'l',
'a',
's',
'h', 0x0d, 0x0a,
4246 0x43, 0x57, 0x53, 0x0a, 0xcb, 0x6c, 0x00, 0x00, 0x78, 0xda, 0xad, 0xbd, 0x07, 0x98, 0x55, 0x55,
4247 0x9e, 0xee, 0xbd, 0x4f, 0xd8, 0xb5, 0x4e, 0x15, 0xc1, 0xc2, 0x80, 0x28, 0x86, 0xd2, 0x2e, 0x5a,
4248 0xdb, 0x46, 0xd9, 0x39, 0x38, 0xdd, 0x4e, 0x1b, 0xa8, 0x56, 0x5b, 0xc5, 0x6b, 0xe8, 0x76, 0xfa,
4249 0x0e, 0xc2, 0x8e, 0x50, 0x76, 0x51, 0xc5, 0x54, 0x15, 0x88, 0x73, 0xc3, 0xd0, 0x88, 0x39, 0x81,
4250 0x98, 0x63, 0x91, 0x93, 0x8a, 0x82, 0x89, 0x60, 0x00, 0xcc, 0xb1, 0x00, 0x01, 0x73, 0xce, 0x39,
4252 uint32_t http_len2 =
sizeof(http_buf2);
4256 memset(&th_v, 0,
sizeof(th_v));
4257 memset(&f, 0,
sizeof(f));
4258 memset(&ssn, 0,
sizeof(ssn));
4265 f.
proto = IPPROTO_TCP;
4286 "(flow:established,from_server; "
4287 "file_data; content:\"CWS\"; "
4330 static int DetectEngineHttpServerBodyFileDataTest23(
void)
4339 swf-decompression:\n\
4342 compress-depth: 0\n\
4343 decompress-depth: 0\n\
4361 uint8_t http_buf1[] =
4362 "GET /file.swf HTTP/1.0\r\n"
4363 "Host: www.openinfosecfoundation.org\r\n"
4364 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
4366 uint32_t http_len1 =
sizeof(http_buf1) - 1;
4367 uint8_t http_buf2[] = {
4368 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
4369 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
4370 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
4371 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'x',
'-',
's',
'h',
'o',
'c',
'k',
'w',
'a',
'v',
'e',
'-',
'f',
'l',
'a',
's',
'h', 0x0d, 0x0a,
4373 0x43, 0x57, 0x53, 0x01, 0xcb, 0x6c, 0x00, 0x00, 0x78, 0xda, 0xad, 0xbd, 0x07, 0x98, 0x55, 0x55,
4374 0x9e, 0xee, 0xbd, 0x4f, 0xd8, 0xb5, 0x4e, 0x15, 0xc1, 0xc2, 0x80, 0x28, 0x86, 0xd2, 0x2e, 0x5a,
4375 0xdb, 0x46, 0xd9, 0x39, 0x38, 0xdd, 0x4e, 0x1b, 0xa8, 0x56, 0x5b, 0xc5, 0x6b, 0xe8, 0x76, 0xfa,
4376 0x0e, 0xc2, 0x8e, 0x50, 0x76, 0x51, 0xc5, 0x54, 0x15, 0x88, 0x73, 0xc3, 0xd0, 0x88, 0x39, 0x81,
4377 0x98, 0x63, 0x91, 0x93, 0x8a, 0x82, 0x89, 0x60, 0x00, 0xcc, 0xb1, 0x00, 0x01, 0x73, 0xce, 0x39,
4379 uint32_t http_len2 =
sizeof(http_buf2);
4383 memset(&th_v, 0,
sizeof(th_v));
4384 memset(&f, 0,
sizeof(f));
4385 memset(&ssn, 0,
sizeof(ssn));
4392 f.
proto = IPPROTO_TCP;
4413 "(flow:established,from_server; "
4414 "file_data; content:\"CWS\"; "
4457 static int DetectEngineHttpServerBodyFileDataTest24(
void)
4466 swf-decompression:\n\
4469 compress-depth: 0\n\
4470 decompress-depth: 0\n\
4488 uint8_t http_buf1[] =
4489 "GET /file.swf HTTP/1.0\r\n"
4490 "Host: www.openinfosecfoundation.org\r\n"
4491 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
4493 uint32_t http_len1 =
sizeof(http_buf1) - 1;
4494 uint8_t http_buf2[] = {
4495 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
4496 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'1',
'0',
'3', 0x0d, 0x0a,
4497 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
4498 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'o',
'c',
't',
'e',
't',
'-',
's',
't',
'r',
'e',
'a',
'm', 0x0d, 0x0a,
4500 0x5a, 0x57, 0x53, 0x17, 0x5c, 0x24, 0x00, 0x00, 0xb7, 0x21, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x20,
4501 0x00, 0x00, 0x3b, 0xff, 0xfc, 0x8e, 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85,
4502 0xf5, 0x75, 0x6f, 0xd0, 0x7e, 0x61, 0x35, 0x1b, 0x1a, 0x8b, 0x16, 0x4d, 0xdf, 0x05, 0x32, 0xfe,
4503 0xa4, 0x4c, 0x46, 0x49, 0xb7, 0x7b, 0x6b, 0x75, 0xf9, 0x2b, 0x5c, 0x37, 0x29, 0x0b, 0x91, 0x37,
4504 0x01, 0x37, 0x0e, 0xe9, 0xf2, 0xe1, 0xfc, 0x9e, 0x64, 0xda, 0x6c, 0x11, 0x21, 0x33, 0xed, 0xa0,
4505 0x0e, 0x76, 0x70, 0xa0, 0xcd, 0x98, 0x2e, 0x76, 0x80, 0xf0, 0xe0, 0x59, 0x56, 0x06, 0x08, 0xe9,
4506 0xca, 0xeb, 0xa2, 0xc6, 0xdb, 0x5a, 0x86
4508 uint32_t http_len2 =
sizeof(http_buf2);
4512 memset(&th_v, 0,
sizeof(th_v));
4513 memset(&f, 0,
sizeof(f));
4514 memset(&ssn, 0,
sizeof(ssn));
4521 f.
proto = IPPROTO_TCP;
4543 "(flow:established,from_server; "
4544 "file_data; content:\"FWS\"; "
4587 static int DetectEngineHttpServerBodyFileDataTest25(
void)
4596 swf-decompression:\n\
4599 compress-depth: 0\n\
4600 decompress-depth: 0\n\
4618 uint8_t http_buf1[] =
4619 "GET /file.swf HTTP/1.0\r\n"
4620 "Host: www.openinfosecfoundation.org\r\n"
4621 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
4623 uint32_t http_len1 =
sizeof(http_buf1) - 1;
4624 uint8_t http_buf2[] = {
4625 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
4626 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'1',
'0',
'3', 0x0d, 0x0a,
4627 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
4628 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'o',
'c',
't',
'e',
't',
'-',
's',
't',
'r',
'e',
'a',
'm', 0x0d, 0x0a,
4630 0x5a, 0x57, 0x53, 0x17, 0x5c, 0x24, 0x00, 0x00, 0xb7, 0x21, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x20, 0x00, 0x00, 0x3b, 0xff, 0xfc, 0x8e, 0x19,
4631 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85, 0xf5, 0x75, 0x6f, 0xd0, 0x7e, 0x61, 0x35, 0x1b, 0x1a, 0x8b, 0x16, 0x4d, 0xdf, 0x05,
4632 0x32, 0xfe, 0xa4, 0x4c, 0x46, 0x49, 0xb7, 0x7b, 0x6b, 0x75, 0xf9, 0x2b, 0x5c, 0x37, 0x29, 0x0b, 0x91, 0x37, 0x01, 0x37, 0x0e, 0xe9, 0xf2,
4633 0xe1, 0xfc, 0x9e, 0x64, 0xda, 0x6c, 0x11, 0x21, 0x33, 0xed, 0xa0, 0x0e, 0x76, 0x70, 0xa0, 0xcd, 0x98, 0x2e, 0x76, 0x80, 0xf0, 0xe0, 0x59,
4634 0x56, 0x06, 0x08, 0xe9, 0xca, 0xeb, 0xa2, 0xc6, 0xdb, 0x5a, 0x86
4636 uint32_t http_len2 =
sizeof(http_buf2);
4640 memset(&th_v, 0,
sizeof(th_v));
4641 memset(&f, 0,
sizeof(f));
4642 memset(&ssn, 0,
sizeof(ssn));
4649 f.
proto = IPPROTO_TCP;
4670 "(flow:established,from_server; "
4671 "file_data; content:\"ZWS\"; "
4714 static int DetectEngineHttpServerBodyFileDataTest26(
void)
4723 swf-decompression:\n\
4726 compress-depth: 0\n\
4727 decompress-depth: 0\n\
4745 uint8_t http_buf1[] =
4746 "GET /file.swf HTTP/1.0\r\n"
4747 "Host: www.openinfosecfoundation.org\r\n"
4748 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
4750 uint32_t http_len1 =
sizeof(http_buf1) - 1;
4751 uint8_t http_buf2[] = {
4752 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
4753 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'1',
'0',
'3', 0x0d, 0x0a,
4754 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
4755 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'o',
'c',
't',
'e',
't',
'-',
's',
't',
'r',
'e',
'a',
'm', 0x0d, 0x0a,
4757 0x5a, 0x57, 0x53, 0x17, 0x5c, 0x24, 0x00, 0x00, 0xb7, 0x21, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x20,
4758 0x00, 0x00, 0x3b, 0xff, 0xfc, 0x8e, 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85,
4759 0xf5, 0x75, 0x6f, 0xd0, 0x7e, 0x61, 0x35, 0x1b, 0x1a, 0x8b, 0x16, 0x4d, 0xdf, 0x05, 0x32, 0xfe,
4760 0xa4, 0x4c, 0x46, 0x49, 0xb7, 0x7b, 0x6b, 0x75, 0xf9, 0x2b, 0x5c, 0x37, 0x29, 0x0b, 0x91, 0x37,
4761 0x01, 0x37, 0x0e, 0xe9, 0xf2, 0xe1, 0xfc, 0x9e, 0x64, 0xda, 0x6c, 0x11, 0x21, 0x33, 0xed, 0xa0,
4762 0x0e, 0x76, 0x70, 0xa0, 0xcd, 0x98, 0x2e, 0x76, 0x80, 0xf0, 0xe0, 0x59, 0x56, 0x06, 0x08, 0xe9,
4763 0xca, 0xeb, 0xa2, 0xc6, 0xdb, 0x5a, 0x86
4765 uint32_t http_len2 =
sizeof(http_buf2);
4769 memset(&th_v, 0,
sizeof(th_v));
4770 memset(&f, 0,
sizeof(f));
4771 memset(&ssn, 0,
sizeof(ssn));
4778 f.
proto = IPPROTO_TCP;
4799 "(flow:established,from_server; "
4800 "file_data; content:\"FWS\"; "
4843 static int DetectEngineHttpServerBodyFileDataTest27(
void)
4852 swf-decompression:\n\
4855 compress-depth: 0\n\
4856 decompress-depth: 0\n\
4874 uint8_t http_buf1[] =
4875 "GET /file.swf HTTP/1.0\r\n"
4876 "Host: www.openinfosecfoundation.org\r\n"
4877 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
4879 uint32_t http_len1 =
sizeof(http_buf1) - 1;
4880 uint8_t http_buf2[] = {
4881 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
4882 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
4883 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
4884 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'o',
'c',
't',
'e',
't',
'-',
's',
't',
'r',
'e',
'a',
'm', 0x0d, 0x0a,
4886 0x5a, 0x57, 0x53, 0x17, 0x5c, 0x24, 0x00, 0x00, 0xb7, 0x21, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x20,
4887 0x00, 0x00, 0x3b, 0xff, 0xfc, 0x8e, 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85,
4888 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85, 0xf5, 0x75, 0x6f, 0xd0, 0x7e, 0x61,
4889 0x35, 0x1b, 0x1a, 0x8b, 0x16, 0x4d, 0xdf, 0x05, 0x32, 0xfe, 0xa4, 0x4c, 0x46, 0x49, 0xb7, 0x7b,
4890 0x6b, 0x75, 0xf9, 0x2b, 0x5c, 0x37, 0x29, 0x0b, 0x91, 0x37, 0x01, 0x37, 0x0e, 0xe9, 0xf2, 0xe1,
4892 uint32_t http_len2 =
sizeof(http_buf2);
4896 memset(&th_v, 0,
sizeof(th_v));
4897 memset(&f, 0,
sizeof(f));
4898 memset(&ssn, 0,
sizeof(ssn));
4905 f.
proto = IPPROTO_TCP;
4926 "(flow:established,from_server; "
4927 "file_data; content:\"ZWS\"; "
4970 static int DetectEngineHttpServerBodyFileDataTest28(
void)
4979 swf-decompression:\n\
4982 compress-depth: 0\n\
4983 decompress-depth: 0\n\
5001 uint8_t http_buf1[] =
5002 "GET /file.swf HTTP/1.0\r\n"
5003 "Host: www.openinfosecfoundation.org\r\n"
5004 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
5006 uint32_t http_len1 =
sizeof(http_buf1) - 1;
5007 uint8_t http_buf2[] = {
5008 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
5009 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
5010 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
5011 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'o',
'c',
't',
'e',
't',
'-',
's',
't',
'r',
'e',
'a',
'm', 0x0d, 0x0a,
5013 0x5a, 0x57, 0x53, 0x01, 0x5c, 0x24, 0x00, 0x00, 0xb7, 0x21, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x20,
5014 0x00, 0x00, 0x3b, 0xff, 0xfc, 0x8e, 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85,
5015 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85, 0xf5, 0x75, 0x6f, 0xd0, 0x7e, 0x61,
5016 0x35, 0x1b, 0x1a, 0x8b, 0x16, 0x4d, 0xdf, 0x05, 0x32, 0xfe, 0xa4, 0x4c, 0x46, 0x49, 0xb7, 0x7b,
5017 0x6b, 0x75, 0xf9, 0x2b, 0x5c, 0x37, 0x29, 0x0b, 0x91, 0x37, 0x01, 0x37, 0x0e, 0xe9, 0xf2, 0xe1,
5019 uint32_t http_len2 =
sizeof(http_buf2);
5023 memset(&th_v, 0,
sizeof(th_v));
5024 memset(&f, 0,
sizeof(f));
5025 memset(&ssn, 0,
sizeof(ssn));
5032 f.
proto = IPPROTO_TCP;
5053 "(flow:established,from_server; "
5054 "file_data; content:\"ZWS\"; "
5097 static int DetectEngineHttpServerBodyFileDataTest29(
void)
5106 swf-decompression:\n\
5109 compress-depth: 1000\n\
5110 decompress-depth: 0\n\
5127 uint8_t http_buf1[] =
5128 "GET /file.swf HTTP/1.0\r\n"
5129 "Host: www.openinfosecfoundation.org\r\n"
5130 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
5132 uint32_t http_len1 =
sizeof(http_buf1) - 1;
5133 uint8_t http_buf2[] = {
5134 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
5135 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
5136 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
5137 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'x',
'-',
's',
'h',
'o',
'c',
'k',
'w',
'a',
'v',
'e',
'-',
'f',
'l',
'a',
's',
'h', 0x0d, 0x0a,
5139 0x43, 0x57, 0x53, 0x0a, 0xcb, 0x6c, 0x00, 0x00, 0x78, 0xda, 0xad, 0xbd, 0x07, 0x98, 0x55, 0x55,
5140 0x9e, 0xee, 0xbd, 0x4f, 0xd8, 0xb5, 0x4e, 0x15, 0xc1, 0xc2, 0x80, 0x28, 0x86, 0xd2, 0x2e, 0x5a,
5141 0xdb, 0x46, 0xd9, 0x39, 0x38, 0xdd, 0x4e, 0x1b, 0xa8, 0x56, 0x5b, 0xc5, 0x6b, 0xe8, 0x76, 0xfa,
5142 0x0e, 0xc2, 0x8e, 0x50, 0x76, 0x51, 0xc5, 0x54, 0x15, 0x88, 0x73, 0xc3, 0xd0, 0x88, 0x39, 0x81,
5143 0x98, 0x63, 0x91, 0x93, 0x8a, 0x82, 0x89, 0x60, 0x00, 0xcc, 0xb1, 0x00, 0x01, 0x73, 0xce, 0x39,
5145 uint32_t http_len2 =
sizeof(http_buf2);
5149 memset(&th_v, 0,
sizeof(th_v));
5150 memset(&f, 0,
sizeof(f));
5151 memset(&ssn, 0,
sizeof(ssn));
5158 f.
proto = IPPROTO_TCP;
5179 "(flow:established,from_server; "
5180 "file_data; content:\"FWS\"; "
5227 static int DetectHttpServerBodyTest06(
void)
5236 uint8_t http_buf[] =
5237 "GET /index.html HTTP/1.0\r\n"
5238 "Host: www.openinfosecfoundation.org\r\n"
5239 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
5241 uint32_t http_len =
sizeof(http_buf) - 1;
5242 uint8_t http_buf2[] =
5243 "HTTP/1.0 200 ok\r\n"
5244 "Content-Type: text/html\r\n"
5245 "Content-Length: 7\r\n"
5248 uint32_t http_len2 =
sizeof(http_buf2) - 1;
5252 memset(&th_v, 0,
sizeof(th_v));
5253 memset(&f, 0,
sizeof(f));
5254 memset(&ssn, 0,
sizeof(ssn));
5260 f.
proto = IPPROTO_TCP;
5278 "(msg:\"http server body test\"; "
5279 "content:\"message\"; http_server_body; "
5288 STREAM_TOSERVER | STREAM_START | STREAM_EOF, http_buf, http_len);
5290 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
5295 STREAM_TOCLIENT | STREAM_START | STREAM_EOF, http_buf2, http_len2);
5297 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
5303 if (http_state == NULL) {
5304 printf(
"no http state: \n");
5313 printf(
"sid 1 didn't match but should have: ");
5334 static int DetectHttpServerBodyTest07(
void)
5344 uint8_t http_buf1[] =
5345 "GET /index.html HTTP/1.0\r\n"
5346 "Host: www.openinfosecfoundation.org\r\n"
5347 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
5349 uint32_t http_len1 =
sizeof(http_buf1) - 1;
5350 uint8_t http_buf2[] =
5351 "HTTP/1.0 200 ok\r\n"
5352 "Content-Type: text/html\r\n"
5353 "Content-Length: 14\r\n"
5355 uint32_t http_len2 =
sizeof(http_buf2) - 1;
5356 uint8_t http_buf3[] =
5358 uint32_t http_len3 =
sizeof(http_buf3) - 1;
5362 memset(&th_v, 0,
sizeof(th_v));
5363 memset(&f, 0,
sizeof(f));
5364 memset(&ssn, 0,
sizeof(ssn));
5371 f.
proto = IPPROTO_TCP;
5394 "(msg:\"http server body test\"; "
5395 "content:\"message\"; http_server_body; "
5404 http_buf1, http_len1);
5406 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
5411 http_buf2, http_len2);
5413 printf(
"toserver chunk 2 returned %" PRId32
", expected 0: ", r);
5418 if (http_state == NULL) {
5419 printf(
"no http state: ");
5427 printf(
"sid 1 matched on chunk2 but shouldn't have: ");
5434 printf(
"toserver chunk 3 returned %" PRId32
", expected 0: ", r);
5441 printf(
"sid 1 didn't match on p2 (chunk3) but should have: ");
5463 static int DetectHttpServerBodyTest08(
void)
5473 uint8_t http_buf1[] =
5474 "GET /index.html HTTP/1.0\r\n"
5475 "Host: www.openinfosecfoundation.org\r\n"
5476 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n"
5478 uint32_t http_len1 =
sizeof(http_buf1) - 1;
5479 uint8_t http_buf2[] =
5480 "HTTP/1.0 200 ok\r\n"
5481 "Content-Type: text/html\r\n"
5482 "Content-Length: 14\r\n"
5485 uint32_t http_len2 =
sizeof(http_buf2) - 1;
5486 uint8_t http_buf3[] =
5488 uint32_t http_len3 =
sizeof(http_buf3) - 1;
5492 memset(&th_v, 0,
sizeof(th_v));
5493 memset(&f, 0,
sizeof(f));
5494 memset(&ssn, 0,
sizeof(ssn));
5501 f.
proto = IPPROTO_TCP;