52 static int DetectEngineHttpHHTest01(
void)
62 "GET /index.html HTTP/1.0\r\n"
64 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
65 uint32_t http_len =
sizeof(http_buf) - 1;
69 memset(&th_v, 0,
sizeof(th_v));
70 memset(&f, 0,
sizeof(f));
71 memset(&ssn, 0,
sizeof(ssn));
77 f.
proto = IPPROTO_TCP;
94 "(msg:\"http host header test\"; "
95 "content:\"connect\"; http_host; "
106 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
112 if (http_state == NULL) {
113 printf(
"no http state: ");
122 printf(
"sid 1 didn't match but should have: ");
148 static int DetectEngineHttpHHTest02(
void)
158 "GET /index.html HTTP/1.0\r\n"
160 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
161 uint32_t http_len =
sizeof(http_buf) - 1;
165 memset(&th_v, 0,
sizeof(th_v));
166 memset(&f, 0,
sizeof(f));
167 memset(&ssn, 0,
sizeof(ssn));
173 f.
proto = IPPROTO_TCP;
190 "(msg:\"http host header test\"; "
191 "content:\"co\"; depth:4; http_host; "
202 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
208 if (http_state == NULL) {
209 printf(
"no http state: ");
218 printf(
"sid 1 didn't match but should have: ");
244 static int DetectEngineHttpHHTest03(
void)
254 "GET /index.html HTTP/1.0\r\n"
256 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
257 uint32_t http_len =
sizeof(http_buf) - 1;
261 memset(&th_v, 0,
sizeof(th_v));
262 memset(&f, 0,
sizeof(f));
263 memset(&ssn, 0,
sizeof(ssn));
269 f.
proto = IPPROTO_TCP;
286 "(msg:\"http_host header test\"; "
287 "content:!\"ect\"; depth:4; http_host; "
298 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
304 if (http_state == NULL) {
305 printf(
"no http state: ");
314 printf(
"sid 1 didn't match but should have: ");
340 static int DetectEngineHttpHHTest04(
void)
350 "GET /index.html HTTP/1.0\r\n"
352 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
353 uint32_t http_len =
sizeof(http_buf) - 1;
357 memset(&th_v, 0,
sizeof(th_v));
358 memset(&f, 0,
sizeof(f));
359 memset(&ssn, 0,
sizeof(ssn));
365 f.
proto = IPPROTO_TCP;
382 "(msg:\"http host header test\"; "
383 "content:\"ect\"; depth:4; http_host; "
394 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
400 if (http_state == NULL) {
401 printf(
"no http state: ");
410 printf(
"sid 1 matched but shouldn't have: ");
436 static int DetectEngineHttpHHTest05(
void)
446 "GET /index.html HTTP/1.0\r\n"
448 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
449 uint32_t http_len =
sizeof(http_buf) - 1;
453 memset(&th_v, 0,
sizeof(th_v));
454 memset(&f, 0,
sizeof(f));
455 memset(&ssn, 0,
sizeof(ssn));
461 f.
proto = IPPROTO_TCP;
478 "(msg:\"http host header test\"; "
479 "content:!\"con\"; depth:4; http_host; "
490 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
496 if (http_state == NULL) {
497 printf(
"no http state: ");
506 printf(
"sid 1 matched but shouldn't have: ");
532 static int DetectEngineHttpHHTest06(
void)
542 "GET /index.html HTTP/1.0\r\n"
544 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
545 uint32_t http_len =
sizeof(http_buf) - 1;
549 memset(&th_v, 0,
sizeof(th_v));
550 memset(&f, 0,
sizeof(f));
551 memset(&ssn, 0,
sizeof(ssn));
557 f.
proto = IPPROTO_TCP;
574 "(msg:\"http host header test\"; "
575 "content:\"ect\"; offset:3; http_host; "
586 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
592 if (http_state == NULL) {
593 printf(
"no http state: ");
602 printf(
"sid 1 didn't match but should have: ");
628 static int DetectEngineHttpHHTest07(
void)
638 "GET /index.html HTTP/1.0\r\n"
640 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
641 uint32_t http_len =
sizeof(http_buf) - 1;
645 memset(&th_v, 0,
sizeof(th_v));
646 memset(&f, 0,
sizeof(f));
647 memset(&ssn, 0,
sizeof(ssn));
653 f.
proto = IPPROTO_TCP;
670 "(msg:\"http host header test\"; "
671 "content:!\"co\"; offset:3; http_host; "
682 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
688 if (http_state == NULL) {
689 printf(
"no http state: ");
698 printf(
"sid 1 didn't match but should have: ");
724 static int DetectEngineHttpHHTest08(
void)
734 "GET /index.html HTTP/1.0\r\n"
736 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
737 uint32_t http_len =
sizeof(http_buf) - 1;
741 memset(&th_v, 0,
sizeof(th_v));
742 memset(&f, 0,
sizeof(f));
743 memset(&ssn, 0,
sizeof(ssn));
749 f.
proto = IPPROTO_TCP;
766 "(msg:\"http host header test\"; "
767 "content:!\"ect\"; offset:3; http_host; "
778 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
784 if (http_state == NULL) {
785 printf(
"no http state: ");
794 printf(
"sid 1 matched but shouldn't have: ");
820 static int DetectEngineHttpHHTest09(
void)
830 "GET /index.html HTTP/1.0\r\n"
832 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
833 uint32_t http_len =
sizeof(http_buf) - 1;
837 memset(&th_v, 0,
sizeof(th_v));
838 memset(&f, 0,
sizeof(f));
839 memset(&ssn, 0,
sizeof(ssn));
845 f.
proto = IPPROTO_TCP;
862 "(msg:\"http host header test\"; "
863 "content:\"con\"; offset:3; http_host; "
874 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
880 if (http_state == NULL) {
881 printf(
"no http state: ");
890 printf(
"sid 1 matched but shouldn't have: ");
916 static int DetectEngineHttpHHTest10(
void)
926 "GET /index.html HTTP/1.0\r\n"
928 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
929 uint32_t http_len =
sizeof(http_buf) - 1;
933 memset(&th_v, 0,
sizeof(th_v));
934 memset(&f, 0,
sizeof(f));
935 memset(&ssn, 0,
sizeof(ssn));
941 f.
proto = IPPROTO_TCP;
958 "(msg:\"http_host header test\"; "
959 "content:\"co\"; http_host; "
960 "content:\"ec\"; within:4; http_host; "
971 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
977 if (http_state == NULL) {
978 printf(
"no http state: ");
987 printf(
"sid 1 didn't match but should have: ");
1013 static int DetectEngineHttpHHTest11(
void)
1022 uint8_t http_buf[] =
1023 "GET /index.html HTTP/1.0\r\n"
1025 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
1026 uint32_t http_len =
sizeof(http_buf) - 1;
1030 memset(&th_v, 0,
sizeof(th_v));
1031 memset(&f, 0,
sizeof(f));
1032 memset(&ssn, 0,
sizeof(ssn));
1038 f.
proto = IPPROTO_TCP;
1055 "(msg:\"http_host header test\"; "
1056 "content:\"co\"; http_host; "
1057 "content:!\"ec\"; within:3; http_host; "
1068 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1074 if (http_state == NULL) {
1075 printf(
"no http state: ");
1084 printf(
"sid 1 didn't match but should have: ");
1110 static int DetectEngineHttpHHTest12(
void)
1119 uint8_t http_buf[] =
1120 "GET /index.html HTTP/1.0\r\n"
1122 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
1123 uint32_t http_len =
sizeof(http_buf) - 1;
1127 memset(&th_v, 0,
sizeof(th_v));
1128 memset(&f, 0,
sizeof(f));
1129 memset(&ssn, 0,
sizeof(ssn));
1135 f.
proto = IPPROTO_TCP;
1152 "(msg:\"http_host header test\"; "
1153 "content:\"co\"; http_host; "
1154 "content:\"ec\"; within:3; http_host; "
1165 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1171 if (http_state == NULL) {
1172 printf(
"no http state: ");
1181 printf(
"sid 1 matched but shouldn't have: ");
1207 static int DetectEngineHttpHHTest13(
void)
1216 uint8_t http_buf[] =
1217 "GET /index.html HTTP/1.0\r\n"
1219 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
1220 uint32_t http_len =
sizeof(http_buf) - 1;
1224 memset(&th_v, 0,
sizeof(th_v));
1225 memset(&f, 0,
sizeof(f));
1226 memset(&ssn, 0,
sizeof(ssn));
1232 f.
proto = IPPROTO_TCP;
1249 "(msg:\"http_host header test\"; "
1250 "content:\"co\"; http_host; "
1251 "content:!\"ec\"; within:4; http_host; "
1262 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1268 if (http_state == NULL) {
1269 printf(
"no http state: ");
1278 printf(
"sid 1 matched but shouldn't have: ");
1304 static int DetectEngineHttpHHTest14(
void)
1313 uint8_t http_buf[] =
1314 "GET /index.html HTTP/1.0\r\n"
1316 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
1317 uint32_t http_len =
sizeof(http_buf) - 1;
1321 memset(&th_v, 0,
sizeof(th_v));
1322 memset(&f, 0,
sizeof(f));
1323 memset(&ssn, 0,
sizeof(ssn));
1329 f.
proto = IPPROTO_TCP;
1346 "(msg:\"http_host header test\"; "
1347 "content:\"co\"; http_host; "
1348 "content:\"ec\"; distance:2; http_host; "
1359 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1365 if (http_state == NULL) {
1366 printf(
"no http state: ");
1375 printf(
"sid 1 didn't match but should have: ");
1401 static int DetectEngineHttpHHTest15(
void)
1410 uint8_t http_buf[] =
1411 "GET /index.html HTTP/1.0\r\n"
1413 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
1414 uint32_t http_len =
sizeof(http_buf) - 1;
1418 memset(&th_v, 0,
sizeof(th_v));
1419 memset(&f, 0,
sizeof(f));
1420 memset(&ssn, 0,
sizeof(ssn));
1426 f.
proto = IPPROTO_TCP;
1443 "(msg:\"http_host header test\"; "
1444 "content:\"co\"; http_host; "
1445 "content:!\"ec\"; distance:3; http_host; "
1456 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1462 if (http_state == NULL) {
1463 printf(
"no http state: ");
1472 printf(
"sid 1 didn't match but should have: ");
1498 static int DetectEngineHttpHHTest16(
void)
1507 uint8_t http_buf[] =
1508 "GET /index.html HTTP/1.0\r\n"
1510 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
1511 uint32_t http_len =
sizeof(http_buf) - 1;
1515 memset(&th_v, 0,
sizeof(th_v));
1516 memset(&f, 0,
sizeof(f));
1517 memset(&ssn, 0,
sizeof(ssn));
1523 f.
proto = IPPROTO_TCP;
1540 "(msg:\"http_host header test\"; "
1541 "content:\"co\"; http_host; "
1542 "content:\"ec\"; distance:3; http_host; "
1553 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1559 if (http_state == NULL) {
1560 printf(
"no http state: ");
1569 printf(
"sid 1 matched but shouldn't have: ");
1595 static int DetectEngineHttpHHTest17(
void)
1604 uint8_t http_buf[] =
1605 "GET /index.html HTTP/1.0\r\n"
1607 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
1608 uint32_t http_len =
sizeof(http_buf) - 1;
1612 memset(&th_v, 0,
sizeof(th_v));
1613 memset(&f, 0,
sizeof(f));
1614 memset(&ssn, 0,
sizeof(ssn));
1620 f.
proto = IPPROTO_TCP;
1637 "(msg:\"http_host header test\"; "
1638 "content:\"co\"; http_host; "
1639 "content:!\"ec\"; distance:2; http_host; "
1650 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1656 if (http_state == NULL) {
1657 printf(
"no http state: ");
1666 printf(
"sid 1 matched but shouldn't have: ");
1688 static int DetectEngineHttpHHTest18(
void)
1697 uint8_t http_buf[] =
1698 "GET /index.html HTTP/1.0\r\n"
1699 "Host: www.kaboom.com\r\n"
1700 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
1701 uint32_t http_len =
sizeof(http_buf) - 1;
1705 memset(&th_v, 0,
sizeof(th_v));
1706 memset(&f, 0,
sizeof(f));
1707 memset(&ssn, 0,
sizeof(ssn));
1713 f.
proto = IPPROTO_TCP;
1730 "(msg:\"http_host header test\"; "
1731 "content:\"kaboom\"; http_host; "
1742 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1748 if (http_state == NULL) {
1749 printf(
"no http state: ");
1758 printf(
"sid 1 didn't match but should have: ");
1780 static int DetectEngineHttpHHTest19(
void)
1789 uint8_t http_buf[] =
1790 "GET /index.html HTTP/1.0\r\n"
1791 "Host: www.kaboom.com:8080\r\n"
1792 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
1793 uint32_t http_len =
sizeof(http_buf) - 1;
1797 memset(&th_v, 0,
sizeof(th_v));
1798 memset(&f, 0,
sizeof(f));
1799 memset(&ssn, 0,
sizeof(ssn));
1805 f.
proto = IPPROTO_TCP;
1822 "(msg:\"http_host header test\"; "
1823 "content:\"kaboom\"; http_host; "
1834 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1840 if (http_state == NULL) {
1841 printf(
"no http state: ");
1850 printf(
"sid 1 didn't match but should have: ");
1872 static int DetectEngineHttpHHTest20(
void)
1881 uint8_t http_buf[] =
1882 "GET /index.html HTTP/1.0\r\n"
1883 "Host: www.kaboom.com:8080\r\n"
1884 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
1885 uint32_t http_len =
sizeof(http_buf) - 1;
1889 memset(&th_v, 0,
sizeof(th_v));
1890 memset(&f, 0,
sizeof(f));
1891 memset(&ssn, 0,
sizeof(ssn));
1897 f.
proto = IPPROTO_TCP;
1914 "(msg:\"http_host header test\"; "
1915 "content:\"8080\"; http_host; "
1926 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
1932 if (http_state == NULL) {
1933 printf(
"no http state: ");
1942 printf(
"sid 1 matched but it shouldn't have: ");
1964 static int DetectEngineHttpHHTest21(
void)
1973 uint8_t http_buf[] =
1974 "GET http://www.kaboom.com/index.html HTTP/1.0\r\n"
1975 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
1976 uint32_t http_len =
sizeof(http_buf) - 1;
1980 memset(&th_v, 0,
sizeof(th_v));
1981 memset(&f, 0,
sizeof(f));
1982 memset(&ssn, 0,
sizeof(ssn));
1988 f.
proto = IPPROTO_TCP;
2005 "(msg:\"http_host header test\"; "
2006 "content:\"kaboom\"; http_host; "
2017 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
2023 if (http_state == NULL) {
2024 printf(
"no http state: ");
2033 printf(
"sid 1 didn't match but should have: ");
2055 static int DetectEngineHttpHHTest22(
void)
2064 uint8_t http_buf[] =
2065 "GET http://www.kaboom.com:8080/index.html HTTP/1.0\r\n"
2066 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
2067 uint32_t http_len =
sizeof(http_buf) - 1;
2071 memset(&th_v, 0,
sizeof(th_v));
2072 memset(&f, 0,
sizeof(f));
2073 memset(&ssn, 0,
sizeof(ssn));
2079 f.
proto = IPPROTO_TCP;
2096 "(msg:\"http_host header test\"; "
2097 "content:\"kaboom\"; http_host; "
2108 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
2114 if (http_state == NULL) {
2115 printf(
"no http state: ");
2124 printf(
"sid 1 didn't match but should have: ");
2146 static int DetectEngineHttpHHTest23(
void)
2155 uint8_t http_buf[] =
2156 "GET http://www.kaboom.com:8080/index.html HTTP/1.0\r\n"
2157 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
2158 uint32_t http_len =
sizeof(http_buf) - 1;
2162 memset(&th_v, 0,
sizeof(th_v));
2163 memset(&f, 0,
sizeof(f));
2164 memset(&ssn, 0,
sizeof(ssn));
2170 f.
proto = IPPROTO_TCP;
2187 "(msg:\"http_host header test\"; "
2188 "content:\"8080\"; http_host; "
2199 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
2205 if (http_state == NULL) {
2206 printf(
"no http state: ");
2215 printf(
"sid 1 matched but it shouldn't have: ");
2237 static int DetectEngineHttpHHTest24(
void)
2246 uint8_t http_buf[] =
2247 "GET http://www.kaboom.com:8080/index.html HTTP/1.0\r\n"
2248 "Host: www.rabbit.com\r\n"
2249 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
2250 uint32_t http_len =
sizeof(http_buf) - 1;
2254 memset(&th_v, 0,
sizeof(th_v));
2255 memset(&f, 0,
sizeof(f));
2256 memset(&ssn, 0,
sizeof(ssn));
2262 f.
proto = IPPROTO_TCP;
2279 "(msg:\"http_host header test\"; "
2280 "content:\"kaboom\"; http_host; "
2291 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
2297 if (http_state == NULL) {
2298 printf(
"no http state: ");
2307 printf(
"sid 1 didn't match but it should have: ");
2329 static int DetectEngineHttpHHTest25(
void)
2338 uint8_t http_buf[] =
2339 "GET http://www.kaboom.com:8080/index.html HTTP/1.0\r\n"
2340 "Host: www.rabbit.com\r\n"
2341 "User-Agent: www.onetwothreefourfivesixseven.org\r\n\r\n";
2342 uint32_t http_len =
sizeof(http_buf) - 1;
2346 memset(&th_v, 0,
sizeof(th_v));
2347 memset(&f, 0,
sizeof(f));
2348 memset(&ssn, 0,
sizeof(ssn));
2354 f.
proto = IPPROTO_TCP;
2371 "(msg:\"http_host header test\"; "
2372 "content:\"rabbit\"; http_host; "
2383 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
2389 if (http_state == NULL) {
2390 printf(
"no http state: ");
2399 printf(
"sid 1 matched but it shouldn't have: ");
2425 static int DetectHttpHHTest01(
void)
2436 "(msg:\"Testing http_host\"; "
2437 "content:\"one\"; http_host; sid:1;)");
2454 static int DetectHttpHHTest02(
void)
2465 "(msg:\"Testing http_host\"; "
2466 "content:\"one\"; http_host; sid:1;)");
2480 static int DetectHttpHHTest03(
void)
2491 "(msg:\"Testing http_host\"; "
2492 "http_host; sid:1;)");
2506 static int DetectHttpHHTest04(
void)
2517 "(msg:\"Testing http_host\"; "
2518 "content:\"one\"; rawbytes; http_host; sid:1;)");
2531 static int DetectHttpHHTest05(
void)
2542 "(msg:\"Testing http_host\"; "
2543 "content:\"one\"; http_host; sid:1;)");
2554 static int DetectHttpHHTest05a(
void)
2561 "alert tcp any any -> any any "
2562 "(content:\"ABC\"; http_host; sid:1;)");
2573 static int DetectHttpHHTest06(
void)
2582 uint8_t http_buf[] =
2583 "GET /index.html HTTP/1.0\r\n"
2584 "User-Agent: www.openinfosecfoundation.org\r\n"
2585 "Host: This is dummy message body\r\n"
2586 "Content-Type: text/html\r\n"
2588 uint32_t http_len =
sizeof(http_buf) - 1;
2592 memset(&th_v, 0,
sizeof(th_v));
2593 memset(&f, 0,
sizeof(f));
2594 memset(&ssn, 0,
sizeof(ssn));
2600 f.
proto = IPPROTO_TCP;
2618 "(msg:\"http host test\"; "
2619 "content:\"message\"; http_host; "
2630 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
2636 if (http_state == NULL) {
2637 printf(
"no http state: \n");
2646 printf(
"sid 1 didn't match but should have\n");
2667 static int DetectHttpHHTest07(
void)
2677 uint8_t http1_buf[] =
2678 "GET /index.html HTTP/1.0\r\n"
2679 "User-Agent: www.openinfosecfoundation.org\r\n"
2680 "Host: This is dummy message";
2681 uint8_t http2_buf[] =
2683 uint32_t http1_len =
sizeof(http1_buf) - 1;
2684 uint32_t http2_len =
sizeof(http2_buf) - 1;
2688 memset(&th_v, 0,
sizeof(th_v));
2689 memset(&f, 0,
sizeof(f));
2690 memset(&ssn, 0,
sizeof(ssn));
2697 f.
proto = IPPROTO_TCP;
2719 "(msg:\"http host test\"; "
2720 "content:\"message\"; http_host; "
2731 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
2737 if (http_state == NULL) {
2738 printf(
"no http state: ");
2746 printf(
"sid 1 matched on p1 but shouldn't have: ");
2753 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
2760 printf(
"sid 1 didn't match on p2 but should have: ");
2782 static int DetectHttpHHTest08(
void)
2792 uint8_t http1_buf[] =
2793 "GET /index.html HTTP/1.0\r\n"
2794 "User-Agent: www.openinfosecfoundation.org\r\n"
2795 "host: This is dummy mess";
2796 uint8_t http2_buf[] =
2798 uint32_t http1_len =
sizeof(http1_buf) - 1;
2799 uint32_t http2_len =
sizeof(http2_buf) - 1;
2803 memset(&th_v, 0,
sizeof(th_v));
2804 memset(&f, 0,
sizeof(f));
2805 memset(&ssn, 0,
sizeof(ssn));
2812 f.
proto = IPPROTO_TCP;
2834 "(msg:\"http host test\"; "
2835 "content:\"message\"; http_host; "
2846 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
2852 if (http_state == NULL) {
2853 printf(
"no http state: ");
2862 printf(
"sid 1 didn't match but should have");
2869 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
2878 printf(
"sid 1 didn't match but should have");
2900 static int DetectHttpHHTest09(
void)
2910 uint8_t http1_buf[] =
2911 "GET /index.html HTTP/1.0\r\n"
2912 "User-Agent: www.openinfosecfoundation.org\r\n"
2913 "Host: This is dummy body1";
2914 uint8_t http2_buf[] =
2915 "This is dummy message body2\r\n"
2916 "Content-Type: text/html\r\n"
2917 "Content-Length: 46\r\n"
2919 "This is dummy body1";
2920 uint32_t http1_len =
sizeof(http1_buf) - 1;
2921 uint32_t http2_len =
sizeof(http2_buf) - 1;
2925 memset(&th_v, 0,
sizeof(th_v));
2926 memset(&f, 0,
sizeof(f));
2927 memset(&ssn, 0,
sizeof(ssn));
2934 f.
proto = IPPROTO_TCP;
2956 "(msg:\"http host test\"; "
2957 "content:\"body1this\"; http_host; "
2968 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
2974 if (http_state == NULL) {
2975 printf(
"no http state: ");
2984 printf(
"sid 1 didn't match but should have");
2991 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
3000 printf(
"sid 1 didn't match but should have");
3022 static int DetectHttpHHTest10(
void)
3032 uint8_t http1_buf[] =
3033 "GET /index.html HTTP/1.0\r\n"
3034 "User-Agent: www.openinfosecfoundation.org\r\n"
3035 "Host: This is dummy bodY1";
3036 uint8_t http2_buf[] =
3037 "This is dummy message body2\r\n"
3038 "Content-Type: text/html\r\n"
3039 "Content-Length: 46\r\n"
3041 "This is dummy bodY1";
3042 uint32_t http1_len =
sizeof(http1_buf) - 1;
3043 uint32_t http2_len =
sizeof(http2_buf) - 1;
3047 memset(&th_v, 0,
sizeof(th_v));
3048 memset(&f, 0,
sizeof(f));
3049 memset(&ssn, 0,
sizeof(ssn));
3056 f.
proto = IPPROTO_TCP;
3078 "(msg:\"http host test\"; "
3079 "content:\"body1this\"; http_host; "
3090 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
3096 if (http_state == NULL) {
3097 printf(
"no http state: \n");
3106 printf(
"sid 1 didn't match but should have\n");
3113 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
3123 printf(
"sid 1 didn't match but should have");
3145 static int DetectHttpHHTest11(
void)
3154 uint8_t http_buf[] =
3155 "GET /index.html HTTP/1.0\r\n"
3156 "User-Agent: www.openinfosecfoundation.org\r\n"
3157 "Host: This is dummy message body\r\n"
3158 "Content-Type: text/html\r\n"
3160 uint32_t http_len =
sizeof(http_buf) - 1;
3164 memset(&th_v, 0,
sizeof(th_v));
3165 memset(&f, 0,
sizeof(f));
3166 memset(&ssn, 0,
sizeof(ssn));
3172 f.
proto = IPPROTO_TCP;
3190 "(msg:\"http host test\"; "
3191 "content:!\"message\"; http_host; "
3202 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
3208 if (http_state == NULL) {
3209 printf(
"no http state: ");
3218 printf(
"sid 1 matched but shouldn't have");
3239 static int DetectHttpHHTest12(
void)
3248 uint8_t http_buf[] =
3249 "GET /index.html HTTP/1.0\r\n"
3250 "User-Agent: www.openinfosecfoundation.org\r\n"
3251 "Host: This is dummy body\r\n"
3253 uint32_t http_len =
sizeof(http_buf) - 1;
3257 memset(&th_v, 0,
sizeof(th_v));
3258 memset(&f, 0,
sizeof(f));
3259 memset(&ssn, 0,
sizeof(ssn));
3265 f.
proto = IPPROTO_TCP;
3283 "(msg:\"http host test\"; "
3284 "content:!\"message\"; http_host; "
3295 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
3301 if (http_state == NULL) {
3302 printf(
"no http state: ");
3311 printf(
"sid 1 didn't match but should have");
3332 static int DetectHttpHHTest13(
void)
3341 uint8_t http_buf[] =
3342 "GET /index.html HTTP/1.0\r\n"
3343 "User-Agent: www.openinfosecfoundation.org\r\n"
3344 "Host: longbufferabcdefghijklmnopqrstuvwxyz0123456789bufferend\r\n"
3345 "Content-Type: text/html\r\n"
3347 uint32_t http_len =
sizeof(http_buf) - 1;
3351 memset(&th_v, 0,
sizeof(th_v));
3352 memset(&f, 0,
sizeof(f));
3353 memset(&ssn, 0,
sizeof(ssn));
3359 f.
proto = IPPROTO_TCP;
3377 "(msg:\"http host test\"; "
3378 "content:\"abcdefghijklmnopqrstuvwxyz0123456789\"; http_host; "
3389 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
3395 if (http_state == NULL) {
3396 printf(
"no http state: ");
3405 printf(
"sid 1 didn't match but should have");
3425 static int DetectHttpHHTest14(
void)
3434 uint8_t httpbuf1[] =
"POST / HTTP/1.1\r\n";
3435 uint8_t httpbuf2[] =
"Cookie: dummy1\r\n";
3436 uint8_t httpbuf3[] =
"Host: Body one!!\r\n\r\n";
3437 uint32_t httplen1 =
sizeof(httpbuf1) - 1;
3438 uint32_t httplen2 =
sizeof(httpbuf2) - 1;
3439 uint32_t httplen3 =
sizeof(httpbuf3) - 1;
3440 uint8_t httpbuf4[] =
"GET /?var=val HTTP/1.1\r\n";
3441 uint8_t httpbuf5[] =
"Cookie: dummy2\r\n";
3442 uint8_t httpbuf6[] =
"Host: Body two\r\n\r\n";
3443 uint32_t httplen4 =
sizeof(httpbuf4) - 1;
3444 uint32_t httplen5 =
sizeof(httpbuf5) - 1;
3445 uint32_t httplen6 =
sizeof(httpbuf6) - 1;
3448 memset(&th_v, 0,
sizeof(th_v));
3449 memset(&f, 0,
sizeof(f));
3450 memset(&ssn, 0,
sizeof(ssn));
3456 f.
proto = IPPROTO_TCP;
3474 s =
DetectEngineAppendSig(
de_ctx,
"alert tcp any any -> any any (content:\"POST\"; http_method; content:\"dummy1\"; http_cookie; content:\"body one\"; http_host; sid:1; rev:1;)");
3476 printf(
"sig parse failed: ");
3479 s =
DetectEngineAppendSig(
de_ctx,
"alert tcp any any -> any any (content:\"GET\"; http_method; content:\"dummy2\"; http_cookie; content:\"body two\"; http_host; sid:2; rev:1;)");
3481 printf(
"sig2 parse failed: ");
3491 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
3498 printf(
"sig 1 alerted: ");
3505 printf(
"toserver chunk 2 returned %" PRId32
", expected 0: ", r);
3512 printf(
"sig 1 alerted (2): ");
3519 printf(
"toserver chunk 3 returned %" PRId32
", expected 0: ", r);
3526 printf(
"sig 1 didn't alert: ");
3533 printf(
"toserver chunk 5 returned %" PRId32
", expected 0: ", r);
3540 printf(
"sig 1 alerted (4): ");
3547 printf(
"toserver chunk 6 returned %" PRId32
", expected 0: ", r);
3554 printf(
"sig 1 alerted (request 2, chunk 6): ");
3563 printf(
"toserver chunk 7 returned %" PRId32
", expected 0: ", r);
3570 printf(
"signature 2 didn't match or sig 1 matched, but shouldn't have: ");
3576 if (htp_state == NULL) {
3577 printf(
"no http state: ");
3583 printf(
"The http app layer doesn't have 2 transactions, but it should: ");
3591 if (det_ctx != NULL) {
3604 static int DetectHttpHHTest22(
void)
3614 "(content:\"one\"; content:\"two\"; http_host; "
3615 "content:\"three\"; distance:10; http_host; content:\"four\"; sid:1;)");
3617 printf(
"de_ctx->sig_list == NULL\n");
3622 printf(
"de_ctx->sig_list->sm_lists[DETECT_SM_LIST_PMATCH] == NULL\n");
3627 printf(
"de_ctx->sig_list->sm_lists[g_http_host_buffer_id] == NULL\n");
3636 cd2->flags != 0 || memcmp(cd2->content,
"four", cd2->content_len) != 0 ||
3640 memcmp(hhhd2->content,
"three", hhhd1->
content_len) != 0) {
3658 static int DetectHttpHHTest23(
void)
3668 "(content:\"one\"; http_host; pcre:/two/; "
3669 "content:\"three\"; distance:10; http_host; content:\"four\"; sid:1;)");
3671 printf(
"de_ctx->sig_list == NULL\n");
3676 printf(
"de_ctx->sig_list->sm_lists[DETECT_SM_LIST_PMATCH] == NULL\n");
3681 printf(
"de_ctx->sig_list->sm_lists[g_http_host_buffer_id] == NULL\n");
3689 if (pd1->
flags != 0 ||
3690 cd2->flags != 0 || memcmp(cd2->content,
"four", cd2->content_len) != 0 ||
3694 memcmp(hhhd2->content,
"three", hhhd1->
content_len) != 0) {
3711 static int DetectHttpHHTest24(
void)
3721 "(content:\"one\"; http_host; pcre:/two/; "
3722 "content:\"three\"; distance:10; within:15; http_host; content:\"four\"; sid:1;)");
3724 printf(
"de_ctx->sig_list == NULL\n");
3729 printf(
"de_ctx->sig_list->sm_lists[DETECT_SM_LIST_PMATCH] == NULL\n");
3734 printf(
"de_ctx->sig_list->sm_lists[g_http_host_buffer_id] == NULL\n");
3742 if (pd1->
flags != 0 ||
3743 cd2->flags != 0 || memcmp(cd2->content,
"four", cd2->content_len) != 0 ||
3747 memcmp(hhhd2->content,
"three", hhhd1->
content_len) != 0) {
3764 static int DetectHttpHHTest25(
void)
3774 "(content:\"one\"; http_host; pcre:/two/; "
3775 "content:\"three\"; distance:10; http_host; "
3776 "content:\"four\"; distance:10; sid:1;)");
3778 printf(
"de_ctx->sig_list == NULL\n");
3783 printf(
"de_ctx->sig_list->sm_lists[DETECT_SM_LIST_PMATCH] == NULL\n");
3788 printf(
"de_ctx->sig_list->sm_lists[g_http_host_buffer_id] == NULL\n");
3798 memcmp(cd2->content,
"four", cd2->content_len) != 0 ||
3802 memcmp(hhhd2->content,
"three", hhhd1->
content_len) != 0) {
3819 static int DetectHttpHHTest26(
void)
3829 "(content:\"one\"; offset:10; http_host; pcre:/two/; "
3830 "content:\"three\"; distance:10; http_host; within:10; "
3831 "content:\"four\"; distance:10; sid:1;)");
3833 printf(
"de_ctx->sig_list == NULL\n");
3838 printf(
"de_ctx->sig_list->sm_lists[DETECT_SM_LIST_PMATCH] == NULL\n");
3843 printf(
"de_ctx->sig_list->sm_lists[g_http_host_buffer_id] == NULL\n");
3853 memcmp(cd2->content,
"four", cd2->content_len) != 0 ||
3857 memcmp(hhhd2->content,
"three", hhhd1->
content_len) != 0) {
3858 printf (
"failed: http_host incorrect flags");
3875 static int DetectHttpHHTest27(
void)
3885 "(content:\"one\"; offset:10; http_host; pcre:/two/; "
3886 "content:\"three\"; distance:10; http_host; within:10; "
3887 "content:\"four\"; distance:10; sid:1;)");
3889 printf(
"de_ctx->sig_list == NULL\n");
3900 static int DetectHttpHHTest28(
void)
3910 "(content:\"one\"; http_host; pcre:/two/; "
3911 "content:\"three\"; http_host; depth:10; "
3912 "content:\"four\"; distance:10; sid:1;)");
3914 printf(
"de_ctx->sig_list == NULL\n");
3919 printf(
"de_ctx->sig_list->sm_lists[DETECT_SM_LIST_PMATCH] == NULL\n");
3924 printf(
"de_ctx->sig_list->sm_lists[g_http_host_buffer_id] == NULL\n");
3934 memcmp(cd2->content,
"four", cd2->content_len) != 0 ||
3935 hhhd1->
flags != (0) ||
3938 memcmp(hhhd2->content,
"three", hhhd1->
content_len) != 0) {
3955 static int DetectHttpHHTest29(
void)
3965 "(content:\"one\"; http_host; "
3966 "content:\"two\"; distance:0; http_host; sid:1;)");
3968 printf(
"de_ctx->sig_list == NULL\n");
3973 printf(
"de_ctx->sig_list->sm_lists[DETECT_SM_LIST_PMATCH] != NULL\n");
3978 printf(
"de_ctx->sig_list->sm_lists[g_http_host_buffer_id] == NULL\n");
3987 memcmp(hhhd2->content,
"two", hhhd1->
content_len) != 0) {
3998 static int DetectHttpHHTest30(
void)
4008 "(content:\"one\"; http_host; "
4009 "content:\"two\"; within:5; http_host; sid:1;)");
4011 printf(
"de_ctx->sig_list == NULL\n");
4016 printf(
"de_ctx->sig_list->sm_lists[DETECT_SM_LIST_PMATCH] != NULL\n");
4021 printf(
"de_ctx->sig_list->sm_lists[g_http_host_buffer_id] == NULL\n");
4030 memcmp(hhhd2->content,
"two", hhhd1->
content_len) != 0) {
4041 static int DetectHttpHHTest31(
void)
4051 "(content:\"one\"; within:5; http_host; sid:1;)");
4053 printf(
"de_ctx->sig_list == NULL\n");
4064 static int DetectHttpHHTest32(
void)
4074 "(content:\"one\"; http_host; within:5; sid:1;)");
4076 printf(
"de_ctx->sig_list != NULL\n");
4087 static int DetectHttpHHTest33(
void)
4097 "(content:\"one\"; within:5; sid:1;)");
4099 printf(
"de_ctx->sig_list == NULL\n");
4110 static int DetectHttpHHTest34(
void)
4121 "content:\"two\"; within:5; http_host; sid:1;)");
4123 printf(
"de_ctx->sig_list == NULL\n");
4128 printf(
"de_ctx->sig_list->sm_lists[DETECT_SM_LIST_PMATCH] != NULL\n");
4133 printf(
"de_ctx->sig_list->sm_lists[g_http_host_buffer_id] == NULL\n");
4137 if (
de_ctx->
sig_list->sm_lists_tail[g_http_host_buffer_id] == NULL ||
4139 de_ctx->
sig_list->sm_lists_tail[g_http_host_buffer_id]->prev == NULL ||
4149 memcmp(hhhd2->content,
"two", hhhd2->content_len) != 0) {
4160 static int DetectHttpHHTest35(
void)
4170 "(content:\"two\"; http_host; "
4171 "pcre:/one/WR; sid:1;)");
4173 printf(
"de_ctx->sig_list == NULL\n");
4178 printf(
"de_ctx->sig_list->sm_lists[DETECT_SM_LIST_PMATCH] != NULL\n");
4183 printf(
"de_ctx->sig_list->sm_lists[g_http_host_buffer_id] == NULL\n");
4187 if (
de_ctx->
sig_list->sm_lists_tail[g_http_host_buffer_id] == NULL ||
4189 de_ctx->
sig_list->sm_lists_tail[g_http_host_buffer_id]->prev == NULL ||
4210 static int DetectHttpHHTest36(
void)
4221 "content:\"two\"; distance:5; http_host; sid:1;)");
4223 printf(
"de_ctx->sig_list == NULL\n");
4228 printf(
"de_ctx->sig_list->sm_lists[DETECT_SM_LIST_PMATCH] != NULL\n");
4233 printf(
"de_ctx->sig_list->sm_lists[g_http_host_buffer_id] == NULL\n");
4237 if (
de_ctx->
sig_list->sm_lists_tail[g_http_host_buffer_id] == NULL ||
4239 de_ctx->
sig_list->sm_lists_tail[g_http_host_buffer_id]->prev == NULL ||
4249 memcmp(hhhd2->content,
"two", hhhd2->content_len) != 0) {
4264 static int DetectHttpHRHTest01(
void)
4275 "(msg:\"Testing http_raw_host\"; "
4276 "content:\"one\"; http_raw_host; sid:1;)");
4293 static int DetectHttpHRHTest02(
void)
4304 "(msg:\"Testing http_raw_host\"; "
4305 "content:\"one\"; http_raw_host; sid:1;)");
4319 static int DetectHttpHRHTest03(
void)
4330 "(msg:\"Testing http_raw_host\"; "
4331 "http_raw_host; sid:1;)");
4345 static int DetectHttpHRHTest04(
void)
4356 "(msg:\"Testing http_raw_host\"; "
4357 "content:\"one\"; rawbytes; http_raw_host; sid:1;)");
4370 static int DetectHttpHRHTest05(
void)
4381 "(msg:\"Testing http_raw_host\"; "
4382 "content:\"one\"; http_raw_host; sid:1;)");
4396 static int DetectHttpHRHTest06(
void)
4405 uint8_t http_buf[] =
4406 "GET /index.html HTTP/1.0\r\n"
4407 "User-Agent: www.openinfosecfoundation.org\r\n"
4408 "Host: This is dummy message body\r\n"
4409 "Content-Type: text/html\r\n"
4411 uint32_t http_len =
sizeof(http_buf) - 1;
4415 memset(&th_v, 0,
sizeof(th_v));
4416 memset(&f, 0,
sizeof(f));
4417 memset(&ssn, 0,
sizeof(ssn));
4423 f.
proto = IPPROTO_TCP;
4441 "(msg:\"http host test\"; "
4442 "content:\"message\"; http_raw_host; "
4453 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
4459 if (http_state == NULL) {
4460 printf(
"no http state: \n");
4469 printf(
"sid 1 didn't match but should have\n");
4490 static int DetectHttpHRHTest07(
void)
4500 uint8_t http1_buf[] =
4501 "GET /index.html HTTP/1.0\r\n"
4502 "User-Agent: www.openinfosecfoundation.org\r\n"
4503 "Host: This is dummy message";
4504 uint8_t http2_buf[] =
4506 uint32_t http1_len =
sizeof(http1_buf) - 1;
4507 uint32_t http2_len =
sizeof(http2_buf) - 1;
4511 memset(&th_v, 0,
sizeof(th_v));
4512 memset(&f, 0,
sizeof(f));
4513 memset(&ssn, 0,
sizeof(ssn));
4520 f.
proto = IPPROTO_TCP;
4542 "(msg:\"http host test\"; "
4543 "content:\"message\"; http_raw_host; "
4554 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
4560 if (http_state == NULL) {
4561 printf(
"no http state: ");
4569 printf(
"sid 1 matched on p1 but shouldn't have: ");
4576 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
4583 printf(
"sid 1 didn't match on p2 but should have: ");
4605 static int DetectHttpHRHTest08(
void)
4615 uint8_t http1_buf[] =
4616 "GET /index.html HTTP/1.0\r\n"
4617 "User-Agent: www.openinfosecfoundation.org\r\n"
4618 "host: This is dummy mess";
4619 uint8_t http2_buf[] =
4621 uint32_t http1_len =
sizeof(http1_buf) - 1;
4622 uint32_t http2_len =
sizeof(http2_buf) - 1;
4626 memset(&th_v, 0,
sizeof(th_v));
4627 memset(&f, 0,
sizeof(f));
4628 memset(&ssn, 0,
sizeof(ssn));
4635 f.
proto = IPPROTO_TCP;
4657 "(msg:\"http host test\"; "
4658 "content:\"message\"; http_raw_host; "
4669 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
4675 if (http_state == NULL) {
4676 printf(
"no http state: ");
4685 printf(
"sid 1 didn't match but should have");
4692 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
4701 printf(
"sid 1 didn't match but should have");
4723 static int DetectHttpHRHTest09(
void)
4733 uint8_t http1_buf[] =
4734 "GET /index.html HTTP/1.0\r\n"
4735 "User-Agent: www.openinfosecfoundation.org\r\n"
4736 "Host: This is dummy body1";
4737 uint8_t http2_buf[] =
4738 "This is dummy message body2\r\n"
4739 "Content-Type: text/html\r\n"
4740 "Content-Length: 46\r\n"
4742 "This is dummy body1";
4743 uint32_t http1_len =
sizeof(http1_buf) - 1;
4744 uint32_t http2_len =
sizeof(http2_buf) - 1;
4748 memset(&th_v, 0,
sizeof(th_v));
4749 memset(&f, 0,
sizeof(f));
4750 memset(&ssn, 0,
sizeof(ssn));
4757 f.
proto = IPPROTO_TCP;
4779 "(msg:\"http host test\"; "
4780 "content:\"body1This\"; http_raw_host; "
4791 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
4797 if (http_state == NULL) {
4798 printf(
"no http state: ");
4807 printf(
"sid 1 didn't match but should have");
4814 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
4823 printf(
"sid 1 didn't match but should have");
4845 static int DetectHttpHRHTest10(
void)
4855 uint8_t http1_buf[] =
4856 "GET /index.html HTTP/1.0\r\n"
4857 "User-Agent: www.openinfosecfoundation.org\r\n"
4858 "Host: This is dummy bodY1";
4859 uint8_t http2_buf[] =
4860 "This is dummy message body2\r\n"
4861 "Content-Type: text/html\r\n"
4862 "Content-Length: 46\r\n"
4864 "This is dummy bodY1";
4865 uint32_t http1_len =
sizeof(http1_buf) - 1;
4866 uint32_t http2_len =
sizeof(http2_buf) - 1;
4870 memset(&th_v, 0,
sizeof(th_v));
4871 memset(&f, 0,
sizeof(f));
4872 memset(&ssn, 0,
sizeof(ssn));
4879 f.
proto = IPPROTO_TCP;
4901 "(msg:\"http host test\"; "
4902 "content:\"bodY1This\"; http_raw_host; "
4913 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
4919 if (http_state == NULL) {
4920 printf(
"no http state: \n");
4929 printf(
"sid 1 didn't match but should have\n");
4936 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: \n", r);
4945 printf(
"sid 1 didn't match but should have");
4967 static int DetectHttpHRHTest11(
void)
4976 uint8_t http_buf[] =
4977 "GET /index.html HTTP/1.0\r\n"
4978 "User-Agent: www.openinfosecfoundation.org\r\n"
4979 "Host: This is dummy message body\r\n"
4980 "Content-Type: text/html\r\n"
4982 uint32_t http_len =
sizeof(http_buf) - 1;
4986 memset(&th_v, 0,
sizeof(th_v));
4987 memset(&f, 0,
sizeof(f));
4988 memset(&ssn, 0,
sizeof(ssn));
4994 f.
proto = IPPROTO_TCP;
5012 "(msg:\"http host test\"; "
5013 "content:!\"message\"; http_raw_host; "
5024 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
5030 if (http_state == NULL) {
5031 printf(
"no http state: ");
5040 printf(
"sid 1 matched but shouldn't have");
5061 static int DetectHttpHRHTest12(
void)
5070 uint8_t http_buf[] =
5071 "GET /index.html HTTP/1.0\r\n"
5072 "User-Agent: www.openinfosecfoundation.org\r\n"
5073 "Host: This is dummy body\r\n"
5075 uint32_t http_len =
sizeof(http_buf) - 1;
5079 memset(&th_v, 0,
sizeof(th_v));
5080 memset(&f, 0,
sizeof(f));
5081 memset(&ssn, 0,
sizeof(ssn));
5087 f.
proto = IPPROTO_TCP;
5105 "(msg:\"http host test\"; "
5106 "content:!\"message\"; http_raw_host; "
5117 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
5123 if (http_state == NULL) {
5124 printf(
"no http state: ");
5133 printf(
"sid 1 didn't match but should have");
5154 static int DetectHttpHRHTest13(
void)
5163 uint8_t http_buf[] =
5164 "GET /index.html HTTP/1.0\r\n"
5165 "User-Agent: www.openinfosecfoundation.org\r\n"
5166 "Host: longbufferabcdefghijklmnopqrstuvwxyz0123456789bufferend\r\n"
5167 "Content-Type: text/html\r\n"
5169 uint32_t http_len =
sizeof(http_buf) - 1;
5173 memset(&th_v, 0,
sizeof(th_v));
5174 memset(&f, 0,
sizeof(f));
5175 memset(&ssn, 0,
sizeof(ssn));
5181 f.
proto = IPPROTO_TCP;
5199 "(msg:\"http host test\"; "
5200 "content:\"abcdefghijklmnopqrstuvwxyz0123456789\"; http_raw_host; "
5211 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
5217 if (http_state == NULL) {
5218 printf(
"no http state: ");
5227 printf(
"sid 1 didn't match but should have");
5247 static int DetectHttpHRHTest14(
void)
5256 uint8_t httpbuf1[] =
"POST / HTTP/1.1\r\n";
5257 uint8_t httpbuf2[] =
"Cookie: dummy1\r\n";
5258 uint8_t httpbuf3[] =
"Host: Body one!!\r\n\r\n";
5259 uint32_t httplen1 =
sizeof(httpbuf1) - 1;
5260 uint32_t httplen2 =
sizeof(httpbuf2) - 1;
5261 uint32_t httplen3 =
sizeof(httpbuf3) - 1;
5262 uint8_t httpbuf4[] =
"GET /?var=val HTTP/1.1\r\n";
5263 uint8_t httpbuf5[] =
"Cookie: dummy2\r\n";
5264 uint8_t httpbuf6[] =
"Host: Body two\r\n\r\n";
5265 uint32_t httplen4 =
sizeof(httpbuf4) - 1;
5266 uint32_t httplen5 =
sizeof(httpbuf5) - 1;
5267 uint32_t httplen6 =
sizeof(httpbuf6) - 1;
5270 memset(&th_v, 0,
sizeof(th_v));
5271 memset(&f, 0,
sizeof(f));
5272 memset(&ssn, 0,
sizeof(ssn));
5278 f.
proto = IPPROTO_TCP;
5296 s =
DetectEngineAppendSig(
de_ctx,
"alert tcp any any -> any any (content:\"POST\"; http_method; content:\"dummy1\"; http_cookie; content:\"Body one\"; http_raw_host; sid:1; rev:1;)");
5298 printf(
"sig parse failed: ");
5301 s =
DetectEngineAppendSig(
de_ctx,
"alert tcp any any -> any any (content:\"GET\"; http_method; content:\"dummy2\"; http_cookie; content:\"Body two\"; http_raw_host; sid:2; rev:1;)");
5303 printf(
"sig2 parse failed: ");
5313 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
5320 printf(
"sig 1 alerted: ");
5327 printf(
"toserver chunk 2 returned %" PRId32
", expected 0: ", r);
5334 printf(
"sig 1 alerted (2): ");
5341 printf(
"toserver chunk 3 returned %" PRId32
", expected 0: ", r);
5348 printf(
"sig 1 didn't alert: ");
5355 printf(
"toserver chunk 5 returned %" PRId32
", expected 0: ", r);
5362 printf(
"sig 1 alerted (4): ");
5369 printf(
"toserver chunk 6 returned %" PRId32
", expected 0: ", r);
5376 printf(
"sig 1 alerted (request 2, chunk 6): ");
5385 printf(
"toserver chunk 7 returned %" PRId32
", expected 0: ", r);
5392 printf(
"signature 2 didn't match or sig 1 matched, but shouldn't have: ");
5398 if (htp_state == NULL) {
5399 printf(
"no http state: ");
5405 printf(
"The http app layer doesn't have 2 transactions, but it should: ");
5413 if (det_ctx != NULL) {
5426 static int DetectHttpHRHTest22(
void)
5436 "(content:\"one\"; content:\"two\"; http_raw_host; "
5437 "content:\"three\"; distance:10; http_raw_host; content:\"four\"; sid:1;)");
5439 printf(
"de_ctx->sig_list == NULL\n");
5444 printf(
"de_ctx->sig_list->sm_lists[DETECT_SM_LIST_PMATCH] == NULL\n");
5448 if (
de_ctx->
sig_list->sm_lists[g_http_raw_host_buffer_id] == NULL) {
5449 printf(
"de_ctx->sig_list->sm_lists[g_http_raw_host_buffer_id] == NULL\n");
5458 cd2->flags != 0 || memcmp(cd2->content,
"four", cd2->content_len) != 0 ||
5462 memcmp(hrhhd2->content,
"three", hrhhd1->
content_len) != 0) {
5481 static int DetectHttpHRHTest23(
void)
5491 "(content:\"one\"; http_raw_host; pcre:/two/; "
5492 "content:\"three\"; distance:10; http_raw_host; content:\"four\"; sid:1;)");
5494 printf(
"de_ctx->sig_list == NULL\n");
5499 printf(
"de_ctx->sig_list->sm_lists[DETECT_SM_LIST_PMATCH] == NULL\n");
5503 if (
de_ctx->
sig_list->sm_lists[g_http_raw_host_buffer_id] == NULL) {
5504 printf(
"de_ctx->sig_list->sm_lists[g_http_raw_host_buffer_id] == NULL\n");
5512 if (pd1->
flags != 0 ||
5513 cd2->flags != 0 || memcmp(cd2->content,
"four", cd2->content_len) != 0 ||
5517 memcmp(hrhhd2->content,
"three", hrhhd1->
content_len) != 0) {
5535 static int DetectHttpHRHTest24(
void)
5545 "(content:\"one\"; http_raw_host; pcre:/two/; "
5546 "content:\"three\"; distance:10; within:15; http_raw_host; content:\"four\"; sid:1;)");
5548 printf(
"de_ctx->sig_list == NULL\n");
5553 printf(
"de_ctx->sig_list->sm_lists[DETECT_SM_LIST_PMATCH] == NULL\n");
5557 if (
de_ctx->
sig_list->sm_lists[g_http_raw_host_buffer_id] == NULL) {
5558 printf(
"de_ctx->sig_list->sm_lists[g_http_raw_host_buffer_id] == NULL\n");
5566 if (pd1->
flags != 0 ||
5567 cd2->flags != 0 || memcmp(cd2->content,
"four", cd2->content_len) != 0 ||