20 #include "../app-layer-htp.h"
21 #include "../conf-yaml-loader.h"
22 #include "../detect-parse.h"
23 #include "../detect-engine-content-inspection.h"
24 #include "../detect-engine-build.h"
25 #include "../pkt-var.h"
26 #include "../flow-util.h"
27 #include "../stream-tcp-reassemble.h"
28 #include "../util-unittest.h"
29 #include "../util-var-name.h"
30 #include "../util-unittest-helper.h"
32 static const char *dummy_conf_string =
36 "default-log-dir: /var/log/suricata\n"
40 " default-log-level: debug\n"
42 " default-format: \"<%t> - <%l>\"\n"
44 " default-startup-message: Your IDS has started.\n"
46 " default-output-filter:\n"
50 " - interface: console\n"
53 " - interface: file\n"
54 " filename: /var/log/suricata.log\n"
56 " - interface: syslog\n"
70 " HOME_NET: \"[192.168.0.0/16,10.8.0.0/16,127.0.0.1,2001:888:"
71 "13c5:5AFE::/64,2001:888:13c5:CAFE::/64]\"\n"
73 " EXTERNAL_NET: \"[!192.168.0.0/16,2000::/3]\"\n"
75 " HTTP_SERVERS: \"!192.168.0.0/16\"\n"
77 " SMTP_SERVERS: \"!192.168.0.0/16\"\n"
79 " SQL_SERVERS: \"!192.168.0.0/16\"\n"
83 " TELNET_SERVERS: any\n"
89 " HTTP_PORTS: \"80:81,88\"\n"
91 " SHELLCODE_PORTS: 80\n"
93 " ORACLE_PORTS: 1521\n"
98 static int SigTest01 (
void)
100 uint8_t *buf = (uint8_t *)
101 "GET /one/ HTTP/1.1\r\n"
102 "Host: one.example.org\r\n"
104 "GET /two/ HTTP/1.1\r\n"
105 "Host: two.example.org\r\n"
107 uint16_t buflen = strlen((
char *)buf);
111 char sig[] =
"alert tcp any any -> any any (msg:\"HTTP URI cap\"; content:\"GET \"; depth:4; pcre:\"/GET (?P<pkt_http_uri>.*) HTTP\\/\\d\\.\\d\\r\\n/G\"; sid:1;)";
120 if (p->http_uri.raw_size[0] == 5 &&
121 memcmp(p->http_uri.raw[0],
"/one/", 5) == 0 &&
122 p->http_uri.raw_size[1] == 5 &&
123 memcmp(p->http_uri.raw[1],
"/two/", 5) == 0)
136 static int SigTest02 (
void)
138 uint8_t *buf = (uint8_t *)
139 "GET /one/ HTTP/1.1\r\n"
140 "Host: one.example.org\r\n"
142 "GET /two/ HTTP/1.1\r\n"
143 "Host: two.example.org\r\n"
145 uint16_t buflen = strlen((
char *)buf);
147 char sig[] =
"alert tcp any any -> any any (msg:\"HTTP TEST\"; content:\"Host: one.example.org\"; offset:20; depth:41; sid:1;)";
153 static int SigTest03 (
void)
155 uint8_t *buf = (uint8_t *)
156 "GET /one/ HTTP/1.1\r\n"
157 "Host: one.example.org\r\n"
159 "GET /two/ HTTP/1.1\r\n"
160 "Host: two.example.org\r\n"
162 uint16_t buflen = strlen((
char *)buf);
168 memset(&th_v, 0,
sizeof(th_v));
179 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any any (msg:\"HTTP TEST\"; content:\"Host: one.example.org\"; offset:20; depth:39; sid:1;)");
202 static int SigTest04 (
void)
204 uint8_t *buf = (uint8_t *)
205 "GET /one/ HTTP/1.1\r\n"
206 "Host: one.example.org\r\n"
208 "GET /two/ HTTP/1.1\r\n"
209 "Host: two.example.org\r\n"
211 uint16_t buflen = strlen((
char *)buf);
218 memset(&th_v, 0,
sizeof(th_v));
229 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any any (msg:\"HTTP TEST\"; content:\"Host:\"; offset:20; depth:25; content:\"Host:\"; distance:42; within:47; sid:1;)");
252 static int SigTest05 (
void)
254 uint8_t *buf = (uint8_t *)
255 "GET /one/ HTTP/1.1\r\n"
256 "Host: one.example.org\r\n"
258 "GET /two/ HTTP/1.1\r\n"
259 "Host: two.example.org\r\n"
261 uint16_t buflen = strlen((
char *)buf);
267 memset(&th_v, 0,
sizeof(th_v));
278 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any any (msg:\"HTTP TEST\"; content:\"Host:\"; offset:20; depth:25; content:\"Host:\"; distance:48; within:52; sid:1;)");
280 printf(
"sig parse failed: ");
291 printf(
"sig matched but shouldn't have: ");
304 static int SigTest06 (
void)
306 uint8_t *buf = (uint8_t *)
307 "GET /one/ HTTP/1.1\r\n"
308 "Host: one.example.org\r\n"
310 "GET /two/ HTTP/1.1\r\n"
311 "Host: two.example.org\r\n"
313 uint16_t buflen = strlen((
char *)buf);
322 memset(&th_v, 0,
sizeof(th_v));
323 memset(&f, 0,
sizeof(f));
324 memset(&ssn, 0,
sizeof(ssn));
332 f.
proto = IPPROTO_TCP;
345 Signature *s =
DetectEngineAppendSig(
de_ctx,
"alert tcp any any -> any any (msg:\"HTTP URI cap\"; content:\"GET \"; depth:4; pcre:\"/GET (?P<pkt_http_uri>.*) HTTP\\/\\d\\.\\d\\r\\n/G\"; sid:1;)");
371 static int SigTest07 (
void)
373 uint8_t *buf = (uint8_t *)
374 "GET /one/ HTTP/1.1\r\n"
375 "Host: one.example.org\r\n"
377 "GET /two/ HTTP/1.1\r\n"
378 "Host: two.example.org\r\n"
380 uint16_t buflen = strlen((
char *)buf);
389 memset(&th_v, 0,
sizeof(th_v));
390 memset(&f, 0,
sizeof(f));
391 memset(&ssn, 0,
sizeof(ssn));
398 f.
proto = IPPROTO_TCP;
414 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any any (msg:\"HTTP URI cap\"; content:\"GET \"; depth:4; pcre:\"/GET (?P<pkt_http_uri>.*) HTTP\\/\\d\\.\\d\\r\\n/G\"; sid:1;)");
430 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
457 static int SigTest08 (
void)
459 uint8_t *buf = (uint8_t *)
460 "GET /one/ HTTP/1.0\r\n"
461 "Host: one.example.org\r\n"
463 "GET /two/ HTTP/1.0\r\n"
464 "Host: two.example.org\r\n"
466 uint16_t buflen = strlen((
char *)buf);
475 memset(&f, 0,
sizeof(
Flow));
476 memset(&th_v, 0,
sizeof(th_v));
477 memset(&ssn, 0,
sizeof(ssn));
484 f.
proto = IPPROTO_TCP;
500 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any any (msg:\"HTTP URI cap\"; content:\"GET \"; depth:4; pcre:\"/GET (?P<pkt_http_uri>.*) HTTP\\/1\\.0\\r\\n/G\"; sid:1;)");
516 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
525 printf(
"sid:1 %s, sid:2 %s: ",
545 static int SigTest09 (
void)
547 uint8_t *buf = (uint8_t *)
548 "GET /one/ HTTP/1.0\r\n"
549 "Host: one.example.org\r\n"
551 "GET /two/ HTTP/1.0\r\n"
552 "Host: two.example.org\r\n"
554 uint16_t buflen = strlen((
char *)buf);
563 memset(&th_v, 0,
sizeof(th_v));
564 memset(&f, 0,
sizeof(f));
565 memset(&ssn, 0,
sizeof(ssn));
572 f.
proto = IPPROTO_TCP;
588 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any any (msg:\"HTTP URI cap\"; content:\"GET \"; depth:4; pcre:\"/GET (?P<pkt_http_uri>.*) HTTP\\/1\\.0\\r\\n/G\"; sid:1;)");
604 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
630 static int SigTest10 (
void)
632 uint8_t *buf = (uint8_t *)
634 uint16_t buflen = strlen((
char *)buf);
643 memset(&th_v, 0,
sizeof(th_v));
644 memset(&f, 0,
sizeof(f));
645 memset(&ssn, 0,
sizeof(ssn));
651 f.
proto = IPPROTO_TCP;
668 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any any (msg:\"Long content test (1)\"; content:\"ABCD\"; depth:4; sid:1;)");
684 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
710 static int SigTest11 (
void)
712 uint8_t *buf = (uint8_t *)
713 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+";
714 uint16_t buflen = strlen((
char *)buf);
722 memset(&th_v, 0,
sizeof(th_v));
723 memset(&f, 0,
sizeof(f));
724 memset(&ssn, 0,
sizeof(ssn));
730 f.
proto = IPPROTO_TCP;
746 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any any (content:\"ABCDEFGHIJ\"; content:\"klmnop\"; content:\"1234\"; sid:1;)");
774 static int SigTest12 (
void)
776 uint8_t *buf = (uint8_t *)
777 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+";
778 uint16_t buflen = strlen((
char *)buf);
784 memset(&th_v, 0,
sizeof(th_v));
786 memset(&f, 0,
sizeof(
Flow));
801 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any any (msg:\"Content order test\"; content:\"ABCDEFGHIJ\"; content:\"klmnop\"; content:\"1234\"; sid:1;)");
829 static int SigTest13 (
void)
831 uint8_t *buf = (uint8_t *)
832 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+";
833 uint16_t buflen = strlen((
char *)buf);
839 memset(&th_v, 0,
sizeof(th_v));
841 memset(&f, 0,
sizeof(
Flow));
856 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any any (msg:\"Content order test\"; content:\"ABCDEFGHIJ\"; content:\"1234\"; content:\"klmnop\"; sid:1;)");
881 static int SigTest14 (
void)
883 uint8_t *buf = (uint8_t *)
884 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+";
885 uint16_t buflen = strlen((
char *)buf);
891 memset(&th_v, 0,
sizeof(th_v));
902 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any any (msg:\"Content order test\"; content:\"ABCDEFGHIJ\"; content:\"1234\"; content:\"klmnop\"; distance:0; sid:1;)");
926 static int SigTest15 (
void)
928 uint8_t *buf = (uint8_t *)
929 "CONNECT 213.92.8.7:31204 HTTP/1.1";
930 uint16_t buflen = strlen((
char *)buf);
938 memset(&th_v, 0,
sizeof(th_v));
943 p->
proto = IPPROTO_TCP;
957 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any !$HTTP_PORTS (msg:\"ET POLICY Inbound HTTP CONNECT Attempt on Off-Port\"; content:\"CONNECT \"; nocase; depth:8; content:\" HTTP/1.\"; nocase; within:1000; sid:2008284; rev:2;)");
983 static int SigTest16 (
void)
985 uint8_t *buf = (uint8_t *)
986 "CONNECT 213.92.8.7:31204 HTTP/1.1";
987 uint16_t buflen = strlen((
char *)buf);
993 memset(&th_v, 0,
sizeof(th_v));
994 memset(&p, 0,
sizeof(p));
1009 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any !$HTTP_PORTS (msg:\"ET POLICY Inbound HTTP CONNECT Attempt on Off-Port\"; content:\"CONNECT \"; nocase; depth:8; content:\" HTTP/1.\"; nocase; within:1000; sid:2008284; rev:2;)");
1033 static int SigTest17 (
void)
1035 uint8_t *buf = (uint8_t *)
1036 "GET /one/ HTTP/1.1\r\n"
1037 "Host: one.example.org\r\n"
1039 "GET /two/ HTTP/1.1\r\n"
1040 "Host: two.example.org\r\n"
1042 uint16_t buflen = strlen((
char *)buf);
1046 memset(&th_v, 0,
sizeof(th_v));
1059 Signature *s =
DetectEngineAppendSig(
de_ctx,
"alert tcp any any -> any $HTTP_PORTS (msg:\"HTTP host cap\"; content:\"Host:\"; pcre:\"/^Host: (?P<pkt_http_host>.*)\\r\\n/m\"; noalert; sid:1;)");
1081 static int SigTest18 (
void)
1083 uint8_t *buf = (uint8_t *)
1084 "220 (vsFTPd 2.0.5)\r\n";
1085 uint16_t buflen = strlen((
char *)buf);
1093 memset(&th_v, 0,
sizeof(th_v));
1098 p->
proto = IPPROTO_TCP;
1109 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any !21:902 -> any any (msg:\"ET MALWARE Suspicious 220 Banner on Local Port\"; content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; sid:2003055; rev:4;)");
1122 printf(
"signature shouldn't match, but did: ");
1133 static int SigTest19 (
void)
1135 uint8_t *buf = (uint8_t *)
1136 "220 (vsFTPd 2.0.5)\r\n";
1137 uint16_t buflen = strlen((
char *)buf);
1145 memset(&th_v, 0,
sizeof(th_v));
1152 p->
proto = IPPROTO_TCP;
1181 printf(
"signature didn't match, but should have: ");
1193 static int SigTest20 (
void)
1195 uint8_t *buf = (uint8_t *)
1196 "220 (vsFTPd 2.0.5)\r\n";
1197 uint16_t buflen = strlen((
char *)buf);
1205 memset(&th_v, 0,
sizeof(th_v));
1212 p->
proto = IPPROTO_TCP;
1228 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert ip $HOME_NET any -> [99.99.99.99,1.2.3.0/24,1.1.1.1,3.0.0.0/8] any (msg:\"IP-ONLY test (2)\"; sid:999; rev:1;)");
1241 printf(
"signature didn't match, but should have: ");
1254 static int SigTest21 (
void)
1257 memset(&th_v, 0,
sizeof(th_v));
1262 memset(&f, 0,
sizeof(f));
1266 uint8_t *buf1 = (uint8_t *)
"GET /one/ HTTP/1.0\r\n"
1268 uint16_t buf1len = strlen((
char *)buf1);
1271 uint8_t *buf2 = (uint8_t *)
"GET /two/ HTTP/1.0\r\n"
1273 uint16_t buf2len = strlen((
char *)buf2);
1290 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any any (msg:\"FLOWBIT SET\"; content:\"/one/\"; flowbits:set,TEST.one; flowbits:noalert; sid:1;)");
1306 printf(
"sid 1 alerted, but shouldn't: ");
1311 printf(
"sid 2 didn't alert, but should have: ");
1321 if (det_ctx != NULL) {
1332 static int SigTest22 (
void)
1335 memset(&th_v, 0,
sizeof(th_v));
1340 memset(&f, 0,
sizeof(f));
1344 uint8_t *buf1 = (uint8_t *)
"GET /one/ HTTP/1.0\r\n"
1346 uint16_t buf1len = strlen((
char *)buf1);
1354 uint8_t *buf2 = (uint8_t *)
"GET /two/ HTTP/1.0\r\n"
1356 uint16_t buf2len = strlen((
char *)buf2);
1370 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any any (msg:\"FLOWBIT SET\"; content:\"/one/\"; flowbits:set,TEST.one; flowbits:noalert; sid:1;)");
1386 printf(
"sid 1 alerted, but shouldn't: ");
1393 printf(
"sid 2 alerted, but shouldn't: ");
1407 static int SigTest23 (
void)
1410 memset(&th_v, 0,
sizeof(th_v));
1415 memset(&f, 0,
sizeof(f));
1419 uint8_t *buf1 = (uint8_t *)
"GET /one/ HTTP/1.0\r\n"
1421 uint16_t buf1len = strlen((
char *)buf1);
1429 uint8_t *buf2 = (uint8_t *)
"GET /two/ HTTP/1.0\r\n"
1431 uint16_t buf2len = strlen((
char *)buf2);
1445 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any any (msg:\"FLOWBIT SET\"; content:\"/one/\"; flowbits:toggle,TEST.one; flowbits:noalert; sid:1;)");
1461 printf(
"sid 1 alerted, but shouldn't: ");
1468 printf(
"sid 2 didn't alert, but should have: ");
1482 static int SigTest24IPV4Keyword(
void)
1484 uint8_t valid_raw_ipv4[] = {
1485 0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00,
1486 0x40, 0x01, 0xb7, 0x52, 0xc0, 0xa8, 0x01, 0x03,
1487 0xc0, 0xa8, 0x01, 0x03};
1489 uint8_t invalid_raw_ipv4[] = {
1490 0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00,
1491 0x40, 0x01, 0xb7, 0x52, 0xc0, 0xa8, 0x01, 0x03,
1492 0xc0, 0xa8, 0x01, 0x06};
1506 uint8_t *buf = (uint8_t *)
"GET /one/ HTTP/1.0\r\n"
1508 uint16_t buflen = strlen((
char *)buf);
1512 PacketSetIPV4(p1, valid_raw_ipv4);
1517 p1->
proto = IPPROTO_TCP;
1519 PacketSetIPV4(p2, invalid_raw_ipv4);
1524 p2->
proto = IPPROTO_TCP;
1534 "alert ip any any -> any any "
1535 "(content:\"/one/\"; ipv4-csum:valid; "
1536 "msg:\"ipv4-csum keyword check(1)\"; sid:1;)");
1538 printf(
"sig 1 parse: ");
1543 "alert ip any any -> any any "
1544 "(content:\"/one/\"; ipv4-csum:invalid; "
1545 "msg:\"ipv4-csum keyword check(1)\"; "
1548 printf(
"sig 2 parse: ");
1557 printf(
"signature 1 didn't match, but should have: ");
1563 printf(
"signature 2 didn't match, but should have: ");
1569 if (det_ctx != NULL) {
1580 static int SigTest25NegativeIPV4Keyword(
void)
1582 uint8_t valid_raw_ipv4[] = {
1583 0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00,
1584 0x40, 0x01, 0xb7, 0x52, 0xc0, 0xa8, 0x01, 0x03,
1585 0xc0, 0xa8, 0x01, 0x03};
1587 uint8_t invalid_raw_ipv4[] = {
1588 0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00,
1589 0x40, 0x01, 0xb7, 0x52, 0xc0, 0xa8, 0x01, 0x03,
1590 0xc0, 0xa8, 0x01, 0x06};
1604 uint8_t *buf = (uint8_t *)
"GET /one/ HTTP/1.0\r\n"
1606 uint16_t buflen = strlen((
char *)buf);
1610 PacketSetIPV4(p1, valid_raw_ipv4);
1615 p1->
proto = IPPROTO_TCP;
1617 PacketSetIPV4(p2, invalid_raw_ipv4);
1622 p2->
proto = IPPROTO_TCP;
1632 "alert ip any any -> any any "
1633 "(content:\"/one/\"; ipv4-csum:invalid; "
1634 "msg:\"ipv4-csum keyword check(1)\"; sid:1;)");
1641 "alert ip any any -> any any "
1642 "(content:\"/one/\"; ipv4-csum:valid; "
1643 "msg:\"ipv4-csum keyword check(1)\"; "
1675 static int SigTest26TCPV4Keyword(
void)
1677 uint8_t raw_ipv4[] = {
1678 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1679 0x00, 0x00, 0x00, 0x00, 0x40, 0x8e, 0x7e, 0xb2,
1680 0xc0, 0xa8, 0x01, 0x03};
1682 uint8_t valid_raw_tcp[] = {
1683 0x00, 0x50, 0x8e, 0x16, 0x0d, 0x59, 0xcd, 0x3c,
1684 0xcf, 0x0d, 0x21, 0x80, 0x50, 0x12, 0x16, 0xa0,
1685 0x4A, 0x04, 0x00, 0x00, 0x02, 0x04, 0x05, 0xb4,
1686 0x04, 0x02, 0x08, 0x0a, 0x6e, 0x18, 0x78, 0x73,
1687 0x01, 0x71, 0x74, 0xde, 0x01, 0x03, 0x03, 0x02};
1689 uint8_t invalid_raw_tcp[] = {
1690 0x00, 0x50, 0x8e, 0x16, 0x0d, 0x59, 0xcd, 0x3c,
1691 0xcf, 0x0d, 0x21, 0x80, 0x50, 0x12, 0x16, 0xa0,
1692 0xfa, 0x03, 0x00, 0x00, 0x02, 0x04, 0x05, 0xb4,
1693 0x04, 0x02, 0x08, 0x0a, 0x6e, 0x18, 0x78, 0x73,
1694 0x01, 0x71, 0x74, 0xde, 0x01, 0x03, 0x03, 0x03};
1718 PacketSetTCP(p1, (
GET_PKT_DATA(p1) +
sizeof(raw_ipv4)));
1723 p1->
proto = IPPROTO_TCP;
1726 PacketSetTCP(p2, (
GET_PKT_DATA(p2) +
sizeof(raw_ipv4)));
1731 p2->
proto = IPPROTO_TCP;
1739 "alert ip any any -> any any "
1740 "(content:\"|DE 01 03|\"; tcpv4-csum:valid; dsize:20; "
1741 "msg:\"tcpv4-csum keyword check(1)\"; sid:1;)");
1745 "alert ip any any -> any any "
1746 "(content:\"|DE 01 03|\"; tcpv4-csum:invalid; "
1747 "msg:\"tcpv4-csum keyword check(1)\"; "
1770 static int SigTest26TCPV4AndNegativeIPV4Keyword(
void)
1772 uint8_t raw_ipv4[] = {
1773 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1774 0x00, 0x00, 0x00, 0x00, 0x40, 0x8e, 0x7e, 0xb2,
1775 0xc0, 0xa8, 0x01, 0x03};
1777 uint8_t valid_raw_tcp[] = {
1778 0x00, 0x50, 0x8e, 0x16, 0x0d, 0x59, 0xcd, 0x3c,
1779 0xcf, 0x0d, 0x21, 0x80, 0x50, 0x12, 0x16, 0xa0,
1780 0x4A, 0x04, 0x00, 0x00, 0x02, 0x04, 0x05, 0xb4,
1781 0x04, 0x02, 0x08, 0x0a, 0x6e, 0x18, 0x78, 0x73,
1782 0x01, 0x71, 0x74, 0xde, 0x01, 0x03, 0x03, 0x02};
1784 uint8_t invalid_raw_tcp[] = {
1785 0x00, 0x50, 0x8e, 0x16, 0x0d, 0x59, 0xcd, 0x3c,
1786 0xcf, 0x0d, 0x21, 0x80, 0x50, 0x12, 0x16, 0xa0,
1787 0xfa, 0x03, 0x00, 0x00, 0x02, 0x04, 0x05, 0xb4,
1788 0x04, 0x02, 0x08, 0x0a, 0x6e, 0x18, 0x78, 0x73,
1789 0x01, 0x71, 0x74, 0xde, 0x01, 0x03, 0x03, 0x03};
1814 PacketSetTCP(p1, (
GET_PKT_DATA(p1) +
sizeof(raw_ipv4)));
1819 p1->
proto = IPPROTO_TCP;
1822 PacketSetTCP(p2, (
GET_PKT_DATA(p2) +
sizeof(raw_ipv4)));
1827 p2->
proto = IPPROTO_TCP;
1837 "alert ip any any -> any any "
1838 "(content:\"|DE 01 03|\"; tcpv4-csum:valid; dsize:20; "
1839 "ipv4-csum:invalid; "
1840 "msg:\"tcpv4-csum and ipv4-csum keyword check(1)\"; sid:1;)");
1846 "alert ip any any -> any any "
1847 "(content:\"|DE 01 03|\"; tcpv4-csum:invalid; "
1848 "ipv4-csum:invalid; "
1849 "msg:\"tcpv4-csum keyword check(1)\"; "
1860 printf(
"sig 1 didn't match: ");
1866 printf(
"sig 2 didn't match: ");
1882 static int SigTest26TCPV4AndIPV4Keyword(
void)
1887 uint8_t raw_ipv4[] = {
1888 0x45, 0x00, 0x00, 0x40, 0x9b, 0xa4, 0x40, 0x00,
1889 0x40, 0x06, 0xbd, 0x0a, 0xc0, 0xa8, 0xb0, 0x43,
1890 0xc0, 0xa8, 0xb0, 0x74};
1897 uint8_t valid_raw_tcp[] = {
1898 0xc1, 0x6d, 0x01, 0xbd, 0x03, 0x10, 0xd3, 0xc9,
1899 0x00, 0x00, 0x00, 0x00, 0xb0, 0x02, 0xff, 0xff,
1900 0x20, 0x09, 0x00, 0x00, 0x02, 0x04, 0x05, 0xb4,
1901 0x01, 0x03, 0x03, 0x04, 0x01, 0x01, 0x08, 0x0a,
1902 0x19, 0x69, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00,
1903 0x04, 0x02, 0x00, 0x00};
1905 uint8_t invalid_raw_tcp[] = {
1906 0xc1, 0x6d, 0x01, 0xbd, 0x03, 0x10, 0xd3, 0xc9,
1907 0x00, 0x00, 0x00, 0x00, 0xb0, 0x02, 0xff, 0xff,
1908 0x20, 0x09, 0x00, 0x00, 0x02, 0x04, 0x05, 0xb4,
1909 0x01, 0x03, 0x03, 0x04, 0x01, 0x01, 0x08, 0x0a,
1910 0x19, 0x69, 0x81, 0x7e, 0xFF, 0xAA, 0x00, 0x00,
1911 0x04, 0x02, 0x00, 0x00};
1936 PacketSetTCP(p1, (
GET_PKT_DATA(p1) +
sizeof(raw_ipv4)));
1941 p1->
proto = IPPROTO_TCP;
1944 PacketSetTCP(p2, (
GET_PKT_DATA(p2) +
sizeof(raw_ipv4)));
1949 p2->
proto = IPPROTO_TCP;
1959 "alert ip any any -> any any "
1960 "(tcpv4-csum:valid; "
1962 "msg:\"tcpv4-csum and ipv4-csum keyword check(1)\"; sid:1;)");
1968 "alert ip any any -> any any "
1969 "(tcpv4-csum:invalid; "
1971 "msg:\"tcpv4-csum and ipv4-csum keyword check(1)\"; "
1982 printf(
"sig 1 didn't match: ");
1988 printf(
"sig 2 didn't match: ");
2003 static int SigTest27NegativeTCPV4Keyword(
void)
2005 uint8_t raw_ipv4[] = {
2006 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2007 0x00, 0x00, 0x00, 0x00, 0x40, 0x8e, 0x7e, 0xb2,
2008 0xc0, 0xa8, 0x01, 0x03};
2010 uint8_t valid_raw_tcp[] = {
2011 0x00, 0x50, 0x8e, 0x16, 0x0d, 0x59, 0xcd, 0x3c,
2012 0xcf, 0x0d, 0x21, 0x80, 0x50, 0x12, 0x16, 0xa0,
2013 0xfa, 0x03, 0x00, 0x00, 0x02, 0x04, 0x05, 0xb4,
2014 0x04, 0x02, 0x08, 0x0a, 0x6e, 0x18, 0x78, 0x73,
2015 0x01, 0x71, 0x74, 0xde, 0x01, 0x03, 0x03, 0x02};
2017 uint8_t invalid_raw_tcp[] = {
2018 0x00, 0x50, 0x8e, 0x16, 0x0d, 0x59, 0xcd, 0x3c,
2019 0xcf, 0x0d, 0x21, 0x80, 0x50, 0x12, 0x16, 0xa0,
2020 0xfa, 0x03, 0x00, 0x00, 0x02, 0x04, 0x05, 0xb4,
2021 0x04, 0x02, 0x08, 0x0a, 0x6e, 0x18, 0x78, 0x73,
2022 0x01, 0x71, 0x74, 0xde, 0x01, 0x03, 0x03, 0x03};
2045 PacketSetTCP(p1, (
GET_PKT_DATA(p1) +
sizeof(raw_ipv4)));
2050 p1->
proto = IPPROTO_TCP;
2053 PacketSetTCP(p2, (
GET_PKT_DATA(p2) +
sizeof(raw_ipv4)));
2058 p2->
proto = IPPROTO_TCP;
2068 "alert tcp any any -> any any "
2069 "(content:\"|DE 01 03|\"; tcpv4-csum:invalid; dsize:20; "
2070 "msg:\"tcpv4-csum keyword check(1)\"; sid:1;)");
2076 "alert tcp any any -> any any "
2077 "(content:\"|DE 01 03|\"; tcpv4-csum:valid; dsize:20; "
2078 "msg:\"tcpv4-csum keyword check(2)\"; "
2089 printf(
"sig 1 didn't match on p1: ");
2095 printf(
"sig 2 matched on p2: ");
2110 static int SigTest28TCPV6Keyword(
void)
2112 static uint8_t valid_raw_ipv6[] = {
2113 0x00, 0x60, 0x97, 0x07, 0x69, 0xea, 0x00, 0x00,
2114 0x86, 0x05, 0x80, 0xda, 0x86, 0xdd,
2116 0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x06, 0x40,
2117 0x3f, 0xfe, 0x05, 0x07, 0x00, 0x00, 0x00, 0x01,
2118 0x02, 0x00, 0x86, 0xff, 0xfe, 0x05, 0x80, 0xda,
2119 0x3f, 0xfe, 0x05, 0x01, 0x04, 0x10, 0x00, 0x00,
2120 0x02, 0xc0, 0xdf, 0xff, 0xfe, 0x47, 0x03, 0x3e,
2122 0x03, 0xfe, 0x00, 0x16, 0xd6, 0x76, 0xf5, 0x2d,
2123 0x0c, 0x7a, 0x08, 0x77, 0x50, 0x10, 0x21, 0x5c,
2124 0xf2, 0xf1, 0x00, 0x00,
2126 0x01, 0x01, 0x08, 0x0a, 0x00, 0x08, 0xca, 0x5a,
2127 0x00, 0x01, 0x69, 0x27};
2129 static uint8_t invalid_raw_ipv6[] = {
2130 0x00, 0x60, 0x97, 0x07, 0x69, 0xea, 0x00, 0x00,
2131 0x86, 0x05, 0x80, 0xda, 0x86, 0xdd,
2133 0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x06, 0x40,
2134 0x3f, 0xfe, 0x05, 0x07, 0x00, 0x00, 0x00, 0x01,
2135 0x02, 0x00, 0x86, 0xff, 0xfe, 0x05, 0x80, 0xda,
2136 0x3f, 0xfe, 0x05, 0x01, 0x04, 0x10, 0x00, 0x00,
2137 0x02, 0xc0, 0xdf, 0xff, 0xfe, 0x47, 0x03, 0x3e,
2139 0x03, 0xfe, 0x00, 0x16, 0xd6, 0x76, 0xf5, 0x2d,
2140 0x0c, 0x7a, 0x08, 0x77, 0x50, 0x10, 0x21, 0x5c,
2141 0xc2, 0xf1, 0x00, 0x00,
2143 0x01, 0x01, 0x08, 0x0a, 0x00, 0x08, 0xca, 0x5a,
2144 0x00, 0x01, 0x69, 0x28};
2160 PacketSetIPV6(p1, valid_raw_ipv6 + 14);
2161 PacketSetTCP(p1, (valid_raw_ipv6 + 54));
2164 p1->
payload = valid_raw_ipv6 + 54 + 20;
2166 p1->
proto = IPPROTO_TCP;
2172 PacketSetIPV6(p2, invalid_raw_ipv6 + 14);
2173 PacketSetTCP(p2, (invalid_raw_ipv6 + 54));
2176 p2->
payload = invalid_raw_ipv6 + 54 + 20;
2178 p2->
proto = IPPROTO_TCP;
2192 "alert tcp any any -> any any "
2193 "(content:\"|00 01 69|\"; tcpv6-csum:valid; dsize:12; "
2194 "msg:\"tcpv6-csum keyword check(1)\"; sid:1;)");
2200 "alert tcp any any -> any any "
2201 "(content:\"|00 01 69|\"; tcpv6-csum:invalid; dsize:12; "
2202 "msg:\"tcpv6-csum keyword check(1)\"; "
2213 printf(
"sid 1 didn't match on p1: ");
2219 printf(
"sid 2 didn't match on p2: ");
2234 static int SigTest29NegativeTCPV6Keyword(
void)
2236 static uint8_t valid_raw_ipv6[] = {
2237 0x00, 0x60, 0x97, 0x07, 0x69, 0xea, 0x00, 0x00,
2238 0x86, 0x05, 0x80, 0xda, 0x86, 0xdd,
2240 0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x06, 0x40,
2241 0x3f, 0xfe, 0x05, 0x07, 0x00, 0x00, 0x00, 0x01,
2242 0x02, 0x00, 0x86, 0xff, 0xfe, 0x05, 0x80, 0xda,
2243 0x3f, 0xfe, 0x05, 0x01, 0x04, 0x10, 0x00, 0x00,
2244 0x02, 0xc0, 0xdf, 0xff, 0xfe, 0x47, 0x03, 0x3e,
2246 0x03, 0xfe, 0x00, 0x16, 0xd6, 0x76, 0xf5, 0x2d,
2247 0x0c, 0x7a, 0x08, 0x77, 0x50, 0x10, 0x21, 0x5c,
2248 0xf2, 0xf1, 0x00, 0x00,
2250 0x01, 0x01, 0x08, 0x0a, 0x00, 0x08, 0xca, 0x5a,
2251 0x00, 0x01, 0x69, 0x27};
2253 static uint8_t invalid_raw_ipv6[] = {
2254 0x00, 0x60, 0x97, 0x07, 0x69, 0xea, 0x00, 0x00,
2255 0x86, 0x05, 0x80, 0xda, 0x86, 0xdd,
2257 0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x06, 0x40,
2258 0x3f, 0xfe, 0x05, 0x07, 0x00, 0x00, 0x00, 0x01,
2259 0x02, 0x00, 0x86, 0xff, 0xfe, 0x05, 0x80, 0xda,
2260 0x3f, 0xfe, 0x05, 0x01, 0x04, 0x10, 0x00, 0x00,
2261 0x02, 0xc0, 0xdf, 0xff, 0xfe, 0x47, 0x03, 0x3e,
2263 0x03, 0xfe, 0x00, 0x16, 0xd6, 0x76, 0xf5, 0x2d,
2264 0x0c, 0x7a, 0x08, 0x77, 0x50, 0x10, 0x21, 0x5c,
2265 0xc2, 0xf1, 0x00, 0x00,
2267 0x01, 0x01, 0x08, 0x0a, 0x00, 0x08, 0xca, 0x5a,
2268 0x00, 0x01, 0x69, 0x28};
2284 PacketSetIPV6(p1, valid_raw_ipv6 + 14);
2285 PacketSetTCP(p1, valid_raw_ipv6 + 54);
2288 p1->
payload = valid_raw_ipv6 + 54 + 20;
2290 p1->
proto = IPPROTO_TCP;
2296 PacketSetIPV6(p2, invalid_raw_ipv6 + 14);
2297 PacketSetTCP(p2, invalid_raw_ipv6 + 54);
2300 p2->
payload = invalid_raw_ipv6 + 54 + 20;
2302 p2->
proto = IPPROTO_TCP;
2314 "alert tcp any any -> any any "
2315 "(content:\"|00 01 69|\"; tcpv6-csum:invalid; dsize:12; "
2316 "msg:\"tcpv6-csum keyword check(1)\"; "
2323 "alert tcp any any -> any any "
2324 "(content:\"|00 01 69|\"; tcpv6-csum:valid; dsize:12; "
2325 "msg:\"tcpv6-csum keyword check(1)\"; "
2346 if (det_ctx != NULL)
2354 static int SigTest30UDPV4Keyword(
void)
2356 uint8_t raw_ipv4[] = {
2357 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2358 0x00, 0x11, 0x00, 0x00, 0xd0, 0x43, 0xdc, 0xdc,
2359 0xc0, 0xa8, 0x01, 0x03};
2361 uint8_t valid_raw_udp[] = {
2362 0x00, 0x35, 0xcf, 0x34, 0x00, 0x55, 0x6c, 0xe0,
2363 0x83, 0xfc, 0x81, 0x80, 0x00, 0x01, 0x00, 0x01,
2364 0x00, 0x00, 0x00, 0x00, 0x07, 0x70, 0x61, 0x67,
2365 0x65, 0x61, 0x64, 0x32, 0x11, 0x67, 0x6f, 0x6f,
2366 0x67, 0x6c, 0x65, 0x73, 0x79, 0x6e, 0x64, 0x69,
2367 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x03, 0x63,
2368 0x6f, 0x6d, 0x00, 0x00, 0x1c, 0x00, 0x01, 0xc0,
2369 0x0c, 0x00, 0x05, 0x00, 0x01, 0x00, 0x01, 0x4b,
2370 0x50, 0x00, 0x12, 0x06, 0x70, 0x61, 0x67, 0x65,
2371 0x61, 0x64, 0x01, 0x6c, 0x06, 0x67, 0x6f, 0x6f,
2372 0x67, 0x6c, 0x65, 0xc0, 0x26};
2374 uint8_t invalid_raw_udp[] = {
2375 0x00, 0x35, 0xcf, 0x34, 0x00, 0x55, 0x6c, 0xe0,
2376 0x83, 0xfc, 0x81, 0x80, 0x00, 0x01, 0x00, 0x01,
2377 0x00, 0x00, 0x00, 0x00, 0x07, 0x70, 0x61, 0x67,
2378 0x65, 0x61, 0x64, 0x32, 0x11, 0x67, 0x6f, 0x6f,
2379 0x67, 0x6c, 0x65, 0x73, 0x79, 0x6e, 0x64, 0x69,
2380 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x03, 0x63,
2381 0x6f, 0x6d, 0x00, 0x00, 0x1c, 0x00, 0x01, 0xc0,
2382 0x0c, 0x00, 0x05, 0x00, 0x01, 0x00, 0x01, 0x4b,
2383 0x50, 0x00, 0x12, 0x06, 0x70, 0x61, 0x67, 0x65,
2384 0x61, 0x64, 0x01, 0x6c, 0x06, 0x67, 0x6f, 0x6f,
2385 0x67, 0x6c, 0x65, 0xc0, 0x27};
2395 uint8_t *buf = (uint8_t *)
"GET /one/ HTTP/1.0yyyyyyyyyyyyyyyy\r\n"
2396 "\r\n\r\nyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy";
2400 PacketSetIPV4(p1, raw_ipv4);
2401 PacketSetUDP(p1, valid_raw_udp);
2406 p1->
proto = IPPROTO_UDP;
2408 PacketSetIPV4(p2, raw_ipv4);
2409 PacketSetUDP(p2, invalid_raw_udp);
2414 p2->
proto = IPPROTO_UDP;
2422 "alert udp any any -> any any "
2423 "(content:\"/one/\"; udpv4-csum:valid; "
2424 "msg:\"udpv4-csum keyword check(1)\"; "
2429 "alert udp any any -> any any "
2430 "(content:\"/one/\"; udpv4-csum:invalid; "
2431 "msg:\"udpv4-csum keyword check(1)\"; "
2446 if (det_ctx != NULL)
2454 static int SigTest31NegativeUDPV4Keyword(
void)
2456 uint8_t raw_ipv4[] = {
2457 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2458 0x00, 0x00, 0x00, 0x00, 0xd0, 0x43, 0xdc, 0xdc,
2459 0xc0, 0xa8, 0x01, 0x03};
2461 uint8_t valid_raw_udp[] = {
2462 0x00, 0x35, 0xcf, 0x34, 0x00, 0x55, 0x6c, 0xe0,
2463 0x83, 0xfc, 0x81, 0x80, 0x00, 0x01, 0x00, 0x01,
2464 0x00, 0x00, 0x00, 0x00, 0x07, 0x70, 0x61, 0x67,
2465 0x65, 0x61, 0x64, 0x32, 0x11, 0x67, 0x6f, 0x6f,
2466 0x67, 0x6c, 0x65, 0x73, 0x79, 0x6e, 0x64, 0x69,
2467 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x03, 0x63,
2468 0x6f, 0x6d, 0x00, 0x00, 0x1c, 0x00, 0x01, 0xc0,
2469 0x0c, 0x00, 0x05, 0x00, 0x01, 0x00, 0x01, 0x4b,
2470 0x50, 0x00, 0x12, 0x06, 0x70, 0x61, 0x67, 0x65,
2471 0x61, 0x64, 0x01, 0x6c, 0x06, 0x67, 0x6f, 0x6f,
2472 0x67, 0x6c, 0x65, 0xc0, 0x26};
2474 uint8_t invalid_raw_udp[] = {
2475 0x00, 0x35, 0xcf, 0x34, 0x00, 0x55, 0x6c, 0xe0,
2476 0x83, 0xfc, 0x81, 0x80, 0x00, 0x01, 0x00, 0x01,
2477 0x00, 0x00, 0x00, 0x00, 0x07, 0x70, 0x61, 0x67,
2478 0x65, 0x61, 0x64, 0x32, 0x11, 0x67, 0x6f, 0x6f,
2479 0x67, 0x6c, 0x65, 0x73, 0x79, 0x6e, 0x64, 0x69,
2480 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x03, 0x63,
2481 0x6f, 0x6d, 0x00, 0x00, 0x1c, 0x00, 0x01, 0xc0,
2482 0x0c, 0x00, 0x05, 0x00, 0x01, 0x00, 0x01, 0x4b,
2483 0x50, 0x00, 0x12, 0x06, 0x70, 0x61, 0x67, 0x65,
2484 0x61, 0x64, 0x01, 0x6c, 0x06, 0x67, 0x6f, 0x6f,
2485 0x67, 0x6c, 0x65, 0xc0, 0x27};
2499 uint8_t *buf = (uint8_t *)
"GET /one/ HTTP/1.0yyyyyyyyyyyyyyyy\r\n"
2500 "\r\n\r\nyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy";
2504 PacketSetIPV4(p1, raw_ipv4);
2505 PacketSetUDP(p1, valid_raw_udp);
2510 p1->
proto = IPPROTO_UDP;
2512 PacketSetIPV4(p2, raw_ipv4);
2513 PacketSetUDP(p2, invalid_raw_udp);
2518 p2->
proto = IPPROTO_UDP;
2528 "alert udp any any -> any any "
2529 "(content:\"/one/\"; udpv4-csum:invalid; "
2530 "msg:\"udpv4-csum keyword check(1)\"; sid:1;)");
2537 "alert udp any any -> any any "
2538 "(content:\"/one/\"; udpv4-csum:valid; "
2539 "msg:\"udpv4-csum keyword check(1)\"; "
2564 if (det_ctx != NULL)
2574 static int SigTest32UDPV6Keyword(
void)
2576 static uint8_t valid_raw_ipv6[] = {
2577 0x00, 0x60, 0x97, 0x07, 0x69, 0xea, 0x00, 0x00,
2578 0x86, 0x05, 0x80, 0xda, 0x86, 0xdd, 0x60, 0x00,
2579 0x00, 0x00, 0x00, 0x14, 0x11, 0x02, 0x3f, 0xfe,
2580 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00,
2581 0x86, 0xff, 0xfe, 0x05, 0x80, 0xda, 0x3f, 0xfe,
2582 0x05, 0x01, 0x04, 0x10, 0x00, 0x00, 0x02, 0xc0,
2583 0xdf, 0xff, 0xfe, 0x47, 0x03, 0x3e, 0xa0, 0x75,
2584 0x82, 0xa0, 0x00, 0x14, 0x1a, 0xc3, 0x06, 0x02,
2585 0x00, 0x00, 0xf9, 0xc8, 0xe7, 0x36, 0x57, 0xb0,
2588 static uint8_t invalid_raw_ipv6[] = {
2589 0x00, 0x60, 0x97, 0x07, 0x69, 0xea, 0x00, 0x00,
2590 0x86, 0x05, 0x80, 0xda, 0x86, 0xdd, 0x60, 0x00,
2591 0x00, 0x00, 0x00, 0x14, 0x11, 0x02, 0x3f, 0xfe,
2592 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00,
2593 0x86, 0xff, 0xfe, 0x05, 0x80, 0xda, 0x3f, 0xfe,
2594 0x05, 0x01, 0x04, 0x10, 0x00, 0x00, 0x02, 0xc0,
2595 0xdf, 0xff, 0xfe, 0x47, 0x03, 0x3e, 0xa0, 0x75,
2596 0x82, 0xa0, 0x00, 0x14, 0x1a, 0xc3, 0x06, 0x02,
2597 0x00, 0x00, 0xf9, 0xc8, 0xe7, 0x36, 0x57, 0xb0,
2608 uint8_t *buf = (uint8_t *)
"GET /one/ HTTP\r\n"
2613 PacketSetIPV6(p1, valid_raw_ipv6 + 14);
2614 PacketSetUDP(p1, valid_raw_ipv6 + 54);
2619 p1->
proto = IPPROTO_UDP;
2621 PacketSetIPV6(p2, invalid_raw_ipv6 + 14);
2622 PacketSetUDP(p2, invalid_raw_ipv6 + 54);
2627 p2->
proto = IPPROTO_UDP;
2635 "alert udp any any -> any any "
2636 "(content:\"/one/\"; udpv6-csum:valid; "
2637 "msg:\"udpv6-csum keyword check(1)\"; sid:1;)");
2641 "alert udp any any -> any any "
2642 "(content:\"/one/\"; udpv6-csum:invalid; "
2643 "msg:\"udpv6-csum keyword check(1)\"; "
2658 if (det_ctx != NULL)
2667 static int SigTest33NegativeUDPV6Keyword(
void)
2669 static uint8_t valid_raw_ipv6[] = {
2670 0x00, 0x60, 0x97, 0x07, 0x69, 0xea, 0x00, 0x00,
2671 0x86, 0x05, 0x80, 0xda, 0x86, 0xdd, 0x60, 0x00,
2672 0x00, 0x00, 0x00, 0x14, 0x11, 0x02, 0x3f, 0xfe,
2673 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00,
2674 0x86, 0xff, 0xfe, 0x05, 0x80, 0xda, 0x3f, 0xfe,
2675 0x05, 0x01, 0x04, 0x10, 0x00, 0x00, 0x02, 0xc0,
2676 0xdf, 0xff, 0xfe, 0x47, 0x03, 0x3e, 0xa0, 0x75,
2677 0x82, 0xa0, 0x00, 0x14, 0x1a, 0xc3, 0x06, 0x02,
2678 0x00, 0x00, 0xf9, 0xc8, 0xe7, 0x36, 0x57, 0xb0,
2681 static uint8_t invalid_raw_ipv6[] = {
2682 0x00, 0x60, 0x97, 0x07, 0x69, 0xea, 0x00, 0x00,
2683 0x86, 0x05, 0x80, 0xda, 0x86, 0xdd, 0x60, 0x00,
2684 0x00, 0x00, 0x00, 0x14, 0x11, 0x02, 0x3f, 0xfe,
2685 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00,
2686 0x86, 0xff, 0xfe, 0x05, 0x80, 0xda, 0x3f, 0xfe,
2687 0x05, 0x01, 0x04, 0x10, 0x00, 0x00, 0x02, 0xc0,
2688 0xdf, 0xff, 0xfe, 0x47, 0x03, 0x3e, 0xa0, 0x75,
2689 0x82, 0xa0, 0x00, 0x14, 0x1a, 0xc3, 0x06, 0x02,
2690 0x00, 0x00, 0xf9, 0xc8, 0xe7, 0x36, 0x57, 0xb0,
2705 uint8_t *buf = (uint8_t *)
"GET /one/ HTTP\r\n"
2710 PacketSetIPV6(p1, valid_raw_ipv6 + 14);
2711 PacketSetUDP(p1, valid_raw_ipv6 + 54);
2716 p1->
proto = IPPROTO_UDP;
2718 PacketSetIPV6(p2, invalid_raw_ipv6 + 14);
2719 PacketSetUDP(p2, invalid_raw_ipv6 + 54);
2724 p2->
proto = IPPROTO_UDP;
2734 "alert udp any any -> any any "
2735 "(content:\"/one/\"; udpv6-csum:invalid; "
2736 "msg:\"udpv6-csum keyword check(1)\"; sid:1;)");
2743 "alert udp any any -> any any "
2744 "(content:\"/one/\"; udpv6-csum:valid; "
2745 "msg:\"udpv6-csum keyword check(1)\"; "
2769 if (det_ctx != NULL)
2778 static int SigTest34ICMPV4Keyword(
void)
2780 uint8_t valid_raw_ipv4[] = {
2781 0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00,
2782 0x40, 0x01, 0x3c, 0xa7, 0x7f, 0x00, 0x00, 0x01,
2783 0x7f, 0x00, 0x00, 0x01, 0x08, 0x00, 0xc3, 0x01,
2784 0x2b, 0x36, 0x00, 0x01, 0x3f, 0x16, 0x9a, 0x4a,
2785 0x41, 0x63, 0x04, 0x00, 0x08, 0x09, 0x0a, 0x0b,
2786 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13,
2787 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
2788 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
2789 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
2790 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
2791 0x34, 0x35, 0x36, 0x37};
2793 uint8_t invalid_raw_ipv4[] = {
2794 0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00,
2795 0x40, 0x01, 0x3c, 0xa7, 0x7f, 0x00, 0x00, 0x01,
2796 0x7f, 0x00, 0x00, 0x01, 0x08, 0x00, 0xc3, 0x01,
2797 0x2b, 0x36, 0x00, 0x01, 0x3f, 0x16, 0x9a, 0x4a,
2798 0x41, 0x63, 0x04, 0x00, 0x08, 0x09, 0x0a, 0x0b,
2799 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13,
2800 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
2801 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
2802 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
2803 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
2804 0x34, 0x35, 0x36, 0x38};
2818 uint8_t *buf = (uint8_t *)
"GET /one/ HTTP/1.0\r\n"
2820 uint16_t buflen = strlen((
char *)buf);
2824 IPV4Hdr *ip4h = PacketSetIPV4(p1, valid_raw_ipv4);
2831 p1->
proto = IPPROTO_ICMP;
2833 ip4h = PacketSetIPV4(p2, invalid_raw_ipv4);
2840 p2->
proto = IPPROTO_ICMP;
2850 "alert icmp any any -> any any "
2851 "(content:\"/one/\"; icmpv4-csum:valid; "
2852 "msg:\"icmpv4-csum keyword check(1)\"; sid:1;)");
2859 "alert icmp any any -> any any "
2860 "(content:\"/one/\"; icmpv4-csum:invalid; "
2861 "msg:\"icmpv4-csum keyword check(1)\"; "
2885 if (det_ctx != NULL)
2894 static int SigTest35NegativeICMPV4Keyword(
void)
2896 uint8_t valid_raw_ipv4[] = {
2897 0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00,
2898 0x40, 0x01, 0x3c, 0xa7, 0x7f, 0x00, 0x00, 0x01,
2899 0x7f, 0x00, 0x00, 0x01, 0x08, 0x00, 0xc3, 0x01,
2900 0x2b, 0x36, 0x00, 0x01, 0x3f, 0x16, 0x9a, 0x4a,
2901 0x41, 0x63, 0x04, 0x00, 0x08, 0x09, 0x0a, 0x0b,
2902 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13,
2903 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
2904 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
2905 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
2906 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
2907 0x34, 0x35, 0x36, 0x37};
2909 uint8_t invalid_raw_ipv4[] = {
2910 0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00,
2911 0x40, 0x01, 0x3c, 0xa7, 0x7f, 0x00, 0x00, 0x01,
2912 0x7f, 0x00, 0x00, 0x01, 0x08, 0x00, 0xc3, 0x01,
2913 0x2b, 0x36, 0x00, 0x01, 0x3f, 0x16, 0x9a, 0x4a,
2914 0x41, 0x63, 0x04, 0x00, 0x08, 0x09, 0x0a, 0x0b,
2915 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13,
2916 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
2917 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
2918 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
2919 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
2920 0x34, 0x35, 0x36, 0x38};
2934 uint8_t *buf = (uint8_t *)
"GET /one/ HTTP/1.0\r\n"
2936 uint16_t buflen = strlen((
char *)buf);
2940 IPV4Hdr *ip4h = PacketSetIPV4(p1, valid_raw_ipv4);
2947 p1->
proto = IPPROTO_ICMP;
2949 ip4h = PacketSetIPV4(p2, invalid_raw_ipv4);
2956 p2->
proto = IPPROTO_ICMP;
2966 "alert icmp any any -> any any "
2967 "(content:\"/one/\"; icmpv4-csum:invalid; "
2968 "msg:\"icmpv4-csum keyword check(1)\"; sid:1;)");
2975 "alert icmp any any -> any any "
2976 "(content:\"/one/\"; icmpv4-csum:valid; "
2977 "msg:\"icmpv4-csum keyword check(1)\"; "
3002 if (det_ctx != NULL)
3011 static int SigTest38(
void)
3019 uint8_t raw_eth[] = {
3020 0x00, 0x00, 0x03, 0x04, 0x00, 0x06, 0x00,
3021 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3024 uint8_t raw_ipv4[] = {
3025 0x45, 0x00, 0x00, 0x7d, 0xd8, 0xf3, 0x40, 0x00,
3026 0x40, 0x06, 0x63, 0x85, 0x7f, 0x00, 0x00, 0x01,
3027 0x7f, 0x00, 0x00, 0x01
3029 uint8_t raw_tcp[] = {
3030 0xad, 0x22, 0x04, 0x00, 0x16, 0x39, 0x72,
3031 0xe2, 0x16, 0x1f, 0x79, 0x84, 0x80, 0x18,
3032 0x01, 0x01, 0xfe, 0x71, 0x00, 0x00, 0x01,
3033 0x01, 0x08, 0x0a, 0x00, 0x22, 0xaa, 0x10,
3034 0x00, 0x22, 0xaa, 0x10
3037 0x00, 0x00, 0x00, 0x08, 0x62, 0x6f, 0x6f, 0x65,
3038 0x65, 0x6b, 0x0d, 0x0a, 0x4c, 0x45, 0x4e, 0x31,
3039 0x20, 0x38, 0x0d, 0x0a, 0x66, 0x6f, 0x30, 0x30,
3040 0x30, 0x38, 0x0d, 0x0a, 0x4c, 0x45, 0x4e, 0x32,
3041 0x20, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39,
3042 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39,
3043 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39,
3044 0x39, 0x39, 0x39, 0x0d, 0x0a, 0x41, 0x41, 0x41,
3045 0x41, 0x41, 0x41, 0x0d, 0x0a, 0x0d, 0x0a, 0x0d,
3048 uint16_t ethlen =
sizeof(raw_eth);
3049 uint16_t ipv4len =
sizeof(raw_ipv4);
3050 uint16_t tcplen =
sizeof(raw_tcp);
3051 uint16_t buflen =
sizeof(buf);
3072 SET_PKT_LEN(p1, ethlen + ipv4len + tcplen + buflen);
3074 PacketSetEthernet(p1, raw_eth);
3075 PacketSetIPV4(p1, raw_ipv4);
3076 PacketSetTCP(p1, raw_tcp);
3081 p1->
proto = IPPROTO_TCP;
3090 "alert tcp any any -> any any "
3091 "(content:\"LEN1|20|\"; "
3092 "byte_test:4,=,8,0; "
3093 "msg:\"byte_test keyword check(1)\"; sid:1;)");
3099 "alert tcp any any -> any any "
3100 "(content:\"LEN1|20|\"; "
3101 "byte_test:4,=,8,5,relative,string,dec; "
3102 "msg:\"byte_test keyword check(2)\"; sid:2;)");
3116 printf(
"sid 1 didn't alert, but should have: ");
3123 printf(
"sid 2 didn't alert, but should have: ");
3131 if (det_ctx != NULL)
3140 static int SigTest39(
void)
3144 uint8_t raw_eth[] = {
3145 0x00, 0x00, 0x03, 0x04, 0x00, 0x06, 0x00,
3146 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3149 uint8_t raw_ipv4[] = {
3150 0x45, 0x00, 0x00, 0x7d, 0xd8, 0xf3, 0x40, 0x00,
3151 0x40, 0x06, 0x63, 0x85, 0x7f, 0x00, 0x00, 0x01,
3152 0x7f, 0x00, 0x00, 0x01
3154 uint8_t raw_tcp[] = {
3155 0xad, 0x22, 0x04, 0x00, 0x16, 0x39, 0x72,
3156 0xe2, 0x16, 0x1f, 0x79, 0x84, 0x80, 0x18,
3157 0x01, 0x01, 0xfe, 0x71, 0x00, 0x00, 0x01,
3158 0x01, 0x08, 0x0a, 0x00, 0x22, 0xaa, 0x10,
3159 0x00, 0x22, 0xaa, 0x10
3162 0x00, 0x00, 0x00, 0x08, 0x62, 0x6f, 0x6f, 0x65,
3163 0x65, 0x6b, 0x0d, 0x0a, 0x4c, 0x45, 0x4e, 0x31,
3164 0x20, 0x38, 0x0d, 0x0a, 0x66, 0x30, 0x30, 0x30,
3165 0x38, 0x72, 0x0d, 0x0a, 0x4c, 0x45, 0x4e, 0x32,
3166 0x20, 0x39, 0x39, 0x4c, 0x45, 0x4e, 0x32, 0x39,
3167 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39,
3168 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39,
3169 0x39, 0x39, 0x39, 0x0d, 0x0a, 0x41, 0x41, 0x41,
3170 0x41, 0x41, 0x41, 0x0d, 0x0a, 0x0d, 0x0a, 0x0d,
3173 uint16_t ethlen =
sizeof(raw_eth);
3174 uint16_t ipv4len =
sizeof(raw_ipv4);
3175 uint16_t tcplen =
sizeof(raw_tcp);
3176 uint16_t buflen =
sizeof(buf);
3187 SET_PKT_LEN(p1, ethlen + ipv4len + tcplen + buflen);
3189 PacketSetEthernet(p1, raw_eth);
3190 PacketSetIPV4(p1, raw_ipv4);
3191 PacketSetTCP(p1, raw_tcp);
3196 p1->
proto = IPPROTO_TCP;
3203 "(content:\"LEN1|20|\"; "
3204 "byte_test:4,=,8,0; "
3206 "byte_test:6,=,0x4c454e312038,0,relative; "
3207 "msg:\"byte_jump keyword check(1)\"; sid:1;)");
3210 "(content:\"LEN1|20|\"; "
3211 "byte_test:4,=,8,4,relative,string,dec; "
3212 "byte_jump:4,4,relative,string,dec,post_offset 2; "
3213 "byte_test:4,=,0x4c454e32,0,relative; "
3214 "msg:\"byte_jump keyword check(2)\"; sid:2;)");
3236 static int SigTest36ContentAndIsdataatKeywords01 (
void)
3242 uint8_t raw_eth [] = {
3243 0x00,0x25,0x00,0x9e,0xfa,0xfe,0x00,0x02,0xcf,0x74,0xfe,0xe1,0x08,0x00,0x45,0x00
3244 ,0x01,0xcc,0xcb,0x91,0x00,0x00,0x34,0x06,0xdf,0xa8,0xd1,0x55,0xe3,0x67,0xc0,0xa8
3245 ,0x64,0x8c,0x00,0x50,0xc0,0xb7,0xd1,0x11,0xed,0x63,0x81,0xa9,0x9a,0x05,0x80,0x18
3246 ,0x00,0x75,0x0a,0xdd,0x00,0x00,0x01,0x01,0x08,0x0a,0x09,0x8a,0x06,0xd0,0x12,0x21
3247 ,0x2a,0x3b,0x48,0x54,0x54,0x50,0x2f,0x31,0x2e,0x31,0x20,0x33,0x30,0x32,0x20,0x46
3248 ,0x6f,0x75,0x6e,0x64,0x0d,0x0a,0x4c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x3a,0x20
3249 ,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x77,0x77,0x2e,0x67,0x6f,0x6f,0x67,0x6c
3250 ,0x65,0x2e,0x65,0x73,0x2f,0x0d,0x0a,0x43,0x61,0x63,0x68,0x65,0x2d,0x43,0x6f,0x6e
3251 ,0x74,0x72,0x6f,0x6c,0x3a,0x20,0x70,0x72,0x69,0x76,0x61,0x74,0x65,0x0d,0x0a,0x43
3252 ,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x54,0x79,0x70,0x65,0x3a,0x20,0x74,0x65,0x78
3253 ,0x74,0x2f,0x68,0x74,0x6d,0x6c,0x3b,0x20,0x63,0x68,0x61,0x72,0x73,0x65,0x74,0x3d
3254 ,0x55,0x54,0x46,0x2d,0x38,0x0d,0x0a,0x44,0x61,0x74,0x65,0x3a,0x20,0x4d,0x6f,0x6e
3255 ,0x2c,0x20,0x31,0x34,0x20,0x53,0x65,0x70,0x20,0x32,0x30,0x30,0x39,0x20,0x30,0x38
3256 ,0x3a,0x34,0x38,0x3a,0x33,0x31,0x20,0x47,0x4d,0x54,0x0d,0x0a,0x53,0x65,0x72,0x76
3257 ,0x65,0x72,0x3a,0x20,0x67,0x77,0x73,0x0d,0x0a,0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74
3258 ,0x2d,0x4c,0x65,0x6e,0x67,0x74,0x68,0x3a,0x20,0x32,0x31,0x38,0x0d,0x0a,0x0d,0x0a
3259 ,0x3c,0x48,0x54,0x4d,0x4c,0x3e,0x3c,0x48,0x45,0x41,0x44,0x3e,0x3c,0x6d,0x65,0x74
3260 ,0x61,0x20,0x68,0x74,0x74,0x70,0x2d,0x65,0x71,0x75,0x69,0x76,0x3d,0x22,0x63,0x6f
3261 ,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x74,0x79,0x70,0x65,0x22,0x20,0x63,0x6f,0x6e,0x74
3262 ,0x65,0x6e,0x74,0x3d,0x22,0x74,0x65,0x78,0x74,0x2f,0x68,0x74,0x6d,0x6c,0x3b,0x63
3263 ,0x68,0x61,0x72,0x73,0x65,0x74,0x3d,0x75,0x74,0x66,0x2d,0x38,0x22,0x3e,0x0a,0x3c
3264 ,0x54,0x49,0x54,0x4c,0x45,0x3e,0x33,0x30,0x32,0x20,0x4d,0x6f,0x76,0x65,0x64,0x3c
3265 ,0x2f,0x54,0x49,0x54,0x4c,0x45,0x3e,0x3c,0x2f,0x48,0x45,0x41,0x44,0x3e,0x3c,0x42
3266 ,0x4f,0x44,0x59,0x3e,0x0a,0x3c,0x48,0x31,0x3e,0x33,0x30,0x32,0x20,0x4d,0x6f,0x76
3267 ,0x65,0x64,0x3c,0x2f,0x48,0x31,0x3e,0x0a,0x54,0x68,0x65,0x20,0x64,0x6f,0x63,0x75
3268 ,0x6d,0x65,0x6e,0x74,0x20,0x68,0x61,0x73,0x20,0x6d,0x6f,0x76,0x65,0x64,0x0a,0x3c
3269 ,0x41,0x20,0x48,0x52,0x45,0x46,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77
3270 ,0x77,0x77,0x2e,0x67,0x6f,0x6f,0x67,0x6c,0x65,0x2e,0x65,0x73,0x2f,0x22,0x3e,0x68
3271 ,0x65,0x72,0x65,0x3c,0x2f,0x41,0x3e,0x2e,0x0d,0x0a,0x3c,0x2f,0x42,0x4f,0x44,0x59
3272 ,0x3e,0x3c,0x2f,0x48,0x54,0x4d,0x4c,0x3e,0x0d,0x0a };
3283 memset(&th_v, 0,
sizeof(th_v));
3296 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any any (msg:\"SigTest36ContentAndIsdataatKeywords01 \"; content:\"HTTP\"; isdataat:404, relative; sid:101;)");
3354 static int SigTest37ContentAndIsdataatKeywords02 (
void)
3360 uint8_t raw_eth [] = {
3361 0x00,0x25,0x00,0x9e,0xfa,0xfe,0x00,0x02,0xcf,0x74,0xfe,0xe1,0x08,0x00,0x45,0x00
3362 ,0x01,0xcc,0xcb,0x91,0x00,0x00,0x34,0x06,0xdf,0xa8,0xd1,0x55,0xe3,0x67,0xc0,0xa8
3363 ,0x64,0x8c,0x00,0x50,0xc0,0xb7,0xd1,0x11,0xed,0x63,0x81,0xa9,0x9a,0x05,0x80,0x18
3364 ,0x00,0x75,0x0a,0xdd,0x00,0x00,0x01,0x01,0x08,0x0a,0x09,0x8a,0x06,0xd0,0x12,0x21
3365 ,0x2a,0x3b,0x48,0x54,0x54,0x50,0x2f,0x31,0x2e,0x31,0x20,0x33,0x30,0x32,0x20,0x46
3366 ,0x6f,0x75,0x6e,0x64,0x0d,0x0a,0x4c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x3a,0x20
3367 ,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x77,0x77,0x2e,0x67,0x6f,0x6f,0x67,0x6c
3368 ,0x65,0x2e,0x65,0x73,0x2f,0x0d,0x0a,0x43,0x61,0x63,0x68,0x65,0x2d,0x43,0x6f,0x6e
3369 ,0x74,0x72,0x6f,0x6c,0x3a,0x20,0x70,0x72,0x69,0x76,0x61,0x74,0x65,0x0d,0x0a,0x43
3370 ,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x54,0x79,0x70,0x65,0x3a,0x20,0x74,0x65,0x78
3371 ,0x74,0x2f,0x68,0x74,0x6d,0x6c,0x3b,0x20,0x63,0x68,0x61,0x72,0x73,0x65,0x74,0x3d
3372 ,0x55,0x54,0x46,0x2d,0x38,0x0d,0x0a,0x44,0x61,0x74,0x65,0x3a,0x20,0x4d,0x6f,0x6e
3373 ,0x2c,0x20,0x31,0x34,0x20,0x53,0x65,0x70,0x20,0x32,0x30,0x30,0x39,0x20,0x30,0x38
3374 ,0x3a,0x34,0x38,0x3a,0x33,0x31,0x20,0x47,0x4d,0x54,0x0d,0x0a,0x53,0x65,0x72,0x76
3375 ,0x65,0x72,0x3a,0x20,0x67,0x77,0x73,0x0d,0x0a,0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74
3376 ,0x2d,0x4c,0x65,0x6e,0x67,0x74,0x68,0x3a,0x20,0x32,0x31,0x38,0x0d,0x0a,0x0d,0x0a
3377 ,0x3c,0x48,0x54,0x4d,0x4c,0x3e,0x3c,0x48,0x45,0x41,0x44,0x3e,0x3c,0x6d,0x65,0x74
3378 ,0x61,0x20,0x68,0x74,0x74,0x70,0x2d,0x65,0x71,0x75,0x69,0x76,0x3d,0x22,0x63,0x6f
3379 ,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x74,0x79,0x70,0x65,0x22,0x20,0x63,0x6f,0x6e,0x74
3380 ,0x65,0x6e,0x74,0x3d,0x22,0x74,0x65,0x78,0x74,0x2f,0x68,0x74,0x6d,0x6c,0x3b,0x63
3381 ,0x68,0x61,0x72,0x73,0x65,0x74,0x3d,0x75,0x74,0x66,0x2d,0x38,0x22,0x3e,0x0a,0x3c
3382 ,0x54,0x49,0x54,0x4c,0x45,0x3e,0x33,0x30,0x32,0x20,0x4d,0x6f,0x76,0x65,0x64,0x3c
3383 ,0x2f,0x54,0x49,0x54,0x4c,0x45,0x3e,0x3c,0x2f,0x48,0x45,0x41,0x44,0x3e,0x3c,0x42
3384 ,0x4f,0x44,0x59,0x3e,0x0a,0x3c,0x48,0x31,0x3e,0x33,0x30,0x32,0x20,0x4d,0x6f,0x76
3385 ,0x65,0x64,0x3c,0x2f,0x48,0x31,0x3e,0x0a,0x54,0x68,0x65,0x20,0x64,0x6f,0x63,0x75
3386 ,0x6d,0x65,0x6e,0x74,0x20,0x68,0x61,0x73,0x20,0x6d,0x6f,0x76,0x65,0x64,0x0a,0x3c
3387 ,0x41,0x20,0x48,0x52,0x45,0x46,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77
3388 ,0x77,0x77,0x2e,0x67,0x6f,0x6f,0x67,0x6c,0x65,0x2e,0x65,0x73,0x2f,0x22,0x3e,0x68
3389 ,0x65,0x72,0x65,0x3c,0x2f,0x41,0x3e,0x2e,0x0d,0x0a,0x3c,0x2f,0x42,0x4f,0x44,0x59
3390 ,0x3e,0x3c,0x2f,0x48,0x54,0x4d,0x4c,0x3e,0x0d,0x0a };
3401 memset(&th_v, 0,
sizeof(th_v));
3414 Signature *s =
de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any any (msg:\"SigTest37ContentAndIsdataatKeywords01 \"; content:\"HTTP\"; isdataat:500, relative; sid:101;)");
3416 printf(
"sig parse failed: ");
3422 printf(
"type not content: ");
3433 printf(
"sig matched, but should not have: ");
3476 static int SigTest40NoPacketInspection01(
void)
3479 uint8_t *buf = (uint8_t *)
3480 "220 (vsFTPd 2.0.5)\r\n";
3481 uint16_t buflen = strlen((
char *)buf);
3492 memset(&th_v, 0,
sizeof(th_v));
3493 memset(&pq, 0,
sizeof(pq));
3494 memset(&f, 0,
sizeof(f));
3495 memset(&tcphdr, 0,
sizeof(tcphdr));
3503 p->
proto = IPPROTO_TCP;
3508 PacketSetTCP(p, (uint8_t *)&tcphdr);
3520 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> 1.2.3.4 any (msg:\"No Packet Inspection Test\"; flow:to_server; sid:2; rev:1;)");
3530 Detect(&th_v, p, det_ctx);
3551 static int SigTest40NoPayloadInspection02(
void)
3554 uint8_t *buf = (uint8_t *)
3555 "220 (vsFTPd 2.0.5)\r\n";
3556 uint16_t buflen = strlen((
char *)buf);
3558 memset(&th_v, 0,
sizeof(th_v));
3567 p->
proto = IPPROTO_TCP;
3576 "alert tcp any any -> any any (msg:\"No Payload TEST\"; content:\"220 (vsFTPd 2.0.5)\"; sid:1;)");
3592 static int SigTestMemory01 (
void)
3594 uint8_t *buf = (uint8_t *)
3595 "GET /one/ HTTP/1.1\r\n"
3596 "Host: one.example.org\r\n"
3598 "GET /two/ HTTP/1.1\r\n"
3599 "Host: two.example.org\r\n"
3601 uint16_t buflen = strlen((
char *)buf);
3609 memset(&th_v, 0,
sizeof(th_v));
3614 p->
proto = IPPROTO_TCP;
3623 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any any (msg:\"HTTP URI cap\"; content:\"GET \"; depth:4; pcre:\"/GET (?P<pkt_http_uri>.*) HTTP\\/\\d\\.\\d\\r\\n/G\"; sid:1;)");
3642 static int SigTestMemory02 (
void)
3647 memset(&th_v, 0,
sizeof(th_v));
3655 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any 456 (msg:\"HTTP URI cap\"; content:\"GET \"; depth:4; pcre:\"/GET (?P<pkt_http_uri>.*) HTTP\\/\\d\\.\\d\\r\\n/G\"; sid:1;)");
3660 de_ctx->
sig_list->
next =
SigInit(
de_ctx,
"alert tcp any any -> any 1:1000 (msg:\"HTTP URI cap\"; content:\"GET \"; depth:4; pcre:\"/GET (?P<pkt_http_uri>.*) HTTP\\/\\d\\.\\d\\r\\n/G\"; sid:2;)");
3676 static int SigTestMemory03 (
void)
3681 memset(&th_v, 0,
sizeof(th_v));
3689 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> 1.2.3.4 456 (msg:\"HTTP URI cap\"; content:\"GET \"; depth:4; pcre:\"/GET (?P<pkt_http_uri>.*) HTTP\\/\\d\\.\\d\\r\\n/G\"; sid:1;)");
3694 de_ctx->
sig_list->
next =
SigInit(
de_ctx,
"alert tcp any any -> 1.2.3.3-1.2.3.6 1:1000 (msg:\"HTTP URI cap\"; content:\"GET \"; depth:4; pcre:\"/GET (?P<pkt_http_uri>.*) HTTP\\/\\d\\.\\d\\r\\n/G\"; sid:2;)");
3699 de_ctx->
sig_list->
next->
next =
SigInit(
de_ctx,
"alert tcp any any -> !1.2.3.5 1:990 (msg:\"HTTP URI cap\"; content:\"GET \"; depth:4; pcre:\"/GET (?P<pkt_http_uri>.*) HTTP\\/\\d\\.\\d\\r\\n/G\"; sid:3;)");
3715 static int SigTestContent01 (
void)
3717 uint8_t *buf = (uint8_t *)
"01234567890123456789012345678901";
3718 uint16_t buflen = strlen((
char *)buf);
3723 memset(&th_v, 0,
sizeof(th_v));
3734 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any any (msg:\"Test 32\"; content:\"01234567890123456789012345678901\"; sid:1;)");
3747 printf(
"sig 1 didn't match: ");
3759 static int SigTestContent02 (
void)
3761 uint8_t *buf = (uint8_t *)
"01234567890123456789012345678901";
3762 uint16_t buflen = strlen((
char *)buf);
3767 memset(&th_v, 0,
sizeof(th_v));
3777 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any any (msg:\"Test 32\"; content:\"01234567890123456789012345678901\"; sid:1;)");
3797 printf(
"sig 2 didn't match: ");
3800 printf(
"sig 1 didn't match: ");
3812 static int SigTestContent03 (
void)
3814 uint8_t *buf = (uint8_t *)
"01234567890123456789012345678901abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
3815 uint16_t buflen = strlen((
char *)buf);
3820 memset(&th_v, 0,
sizeof(th_v));
3831 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any any (msg:\"Test 32\"; content:\"01234567890123456789012345678901\"; content:\"abcdefghijklmnopqrstuvwxyzABCDEF\"; distance:0; sid:1;)");
3844 printf(
"sig 1 didn't match: ");
3856 static int SigTestContent04 (
void)
3858 uint8_t *buf = (uint8_t *)
"01234567890123456789012345678901abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
3859 uint16_t buflen = strlen((
char *)buf);
3864 memset(&th_v, 0,
sizeof(th_v));
3876 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any any (msg:\"Test 32\"; content:\"01234567890123456789012345678901\"; content:\"abcdefghijklmnopqrstuvwxyzABCDEF\"; distance:0; within:32; sid:1;)");
3889 printf(
"sig 1 didn't match: ");
3902 static int SigTestContent05 (
void)
3904 uint8_t *buf = (uint8_t *)
"01234567890123456789012345678901PADabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
3905 uint16_t buflen = strlen((
char *)buf);
3910 memset(&th_v, 0,
sizeof(th_v));
3916 printf(
"de_ctx == NULL: ");
3922 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any any (msg:\"Test 32\"; content:\"01234567890123456789012345678901\"; content:\"abcdefghijklmnopqrstuvwxyzABCDEF\"; distance:0; within:32; sid:1;)");
3924 printf(
"sig1 parse failed: ");
3927 de_ctx->
sig_list->
next =
SigInit(
de_ctx,
"alert tcp any any -> any any (msg:\"Test 32\"; content:\"01234567890123456789012345678901\"; content:\"abcdefghijklmnopqrstuvwxyzABCDEF\"; distance:1; within:32; sid:2;)");
3929 printf(
"sig2 parse failed: ");
3939 printf(
"sig 1 matched but shouldn't: ");
3944 printf(
"sig 2 matched but shouldn't: ");
3954 if (det_ctx != NULL) {
3963 static int SigTestContent06 (
void)
3965 uint8_t *buf = (uint8_t *)
"01234567890123456789012345678901abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
3966 uint16_t buflen = strlen((
char *)buf);
3971 memset(&th_v, 0,
sizeof(th_v));
3982 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert ip any any -> any any (msg:\"Test 32 sig1\"; content:\"01234567890123456789012345678901\"; content:\"abcdefghijklmnopqrstuvwxyzABCDEF\"; distance:0; within:32; sid:1;)");
3987 de_ctx->
sig_list->
next =
SigInit(
de_ctx,
"alert ip any any -> any any (msg:\"Test 32 sig2\"; content:\"01234567890123456789012345678901\"; content:\"abcdefg\"; sid:2;)");
4000 printf(
"sig 1 didn't match: ");
4007 printf(
"sig 2 didn't match: ");
4021 static int SigTestWithin01 (
void)
4031 uint8_t rawpkt1[] = {
4032 0x00,0x04,0x76,0xd3,0xd8,0x6a,0x00,0x24,
4033 0xe8,0x29,0xfa,0x4f,0x08,0x00,0x45,0x00,
4034 0x00,0x8c,0x95,0x50,0x00,0x00,0x40,0x06,
4035 0x2d,0x45,0xc0,0xa8,0x02,0x03,0xd0,0x45,
4036 0x24,0xe6,0x06,0xcc,0x03,0x09,0x18,0x72,
4037 0xd0,0xe3,0x1a,0xab,0x7c,0x98,0x50,0x00,
4038 0x02,0x00,0x46,0xa0,0x00,0x00,0x48,0x69,
4039 0x2c,0x20,0x74,0x68,0x69,0x73,0x20,0x69,
4040 0x73,0x20,0x61,0x20,0x62,0x69,0x67,0x20,
4041 0x74,0x65,0x73,0x74,0x20,0x74,0x6f,0x20,
4042 0x63,0x68,0x65,0x63,0x6b,0x20,0x63,0x6f,
4043 0x6e,0x74,0x65,0x6e,0x74,0x20,0x6d,0x61,
4044 0x74,0x63,0x68,0x65,0x73,0x0a,0x00,0x00,
4045 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4046 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4047 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4048 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4049 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4050 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4053 uint8_t rawpkt2[] = {
4054 0x00,0x04,0x76,0xd3,0xd8,0x6a,0x00,0x24,
4055 0xe8,0x29,0xfa,0x4f,0x08,0x00,0x45,0x00,
4056 0x00,0x8c,0x30,0x87,0x00,0x00,0x40,0x06,
4057 0x92,0x0e,0xc0,0xa8,0x02,0x03,0xd0,0x45,
4058 0x24,0xe6,0x06,0xcd,0x03,0x09,0x73,0xec,
4059 0xd5,0x35,0x14,0x7d,0x7c,0x12,0x50,0x00,
4060 0x02,0x00,0xed,0x86,0x00,0x00,0x48,0x69,
4061 0x2c,0x20,0x74,0x68,0x69,0x73,0x20,0x69,
4062 0x73,0x20,0x61,0x20,0x62,0x69,0x67,0x20,
4063 0x74,0x65,0x73,0x74,0x20,0x74,0x6f,0x20,
4064 0x63,0x68,0x65,0x63,0x6b,0x20,0x63,0x6f,
4065 0x6e,0x74,0x65,0x6e,0x74,0x20,0x6d,0x61,
4066 0x74,0x63,0x68,0x65,0x73,0x0a,0x00,0x00,
4067 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4068 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4069 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4070 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4071 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4072 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4075 uint8_t rawpkt3[] = {
4076 0x00,0x04,0x76,0xd3,0xd8,0x6a,0x00,0x24,
4077 0xe8,0x29,0xfa,0x4f,0x08,0x00,0x45,0x00,
4078 0x00,0x8c,0x57,0xd8,0x00,0x00,0x40,0x06,
4079 0x6a,0xbd,0xc0,0xa8,0x02,0x03,0xd0,0x45,
4080 0x24,0xe6,0x06,0xce,0x03,0x09,0x06,0x3d,
4081 0x02,0x22,0x2f,0x9b,0x6f,0x8f,0x50,0x00,
4082 0x02,0x00,0x1f,0xae,0x00,0x00,0x48,0x69,
4083 0x2c,0x20,0x74,0x68,0x69,0x73,0x20,0x69,
4084 0x73,0x20,0x61,0x20,0x62,0x69,0x67,0x20,
4085 0x74,0x65,0x73,0x74,0x20,0x74,0x6f,0x20,
4086 0x63,0x68,0x65,0x63,0x6b,0x20,0x63,0x6f,
4087 0x6e,0x74,0x65,0x6e,0x74,0x20,0x6d,0x61,
4088 0x74,0x63,0x68,0x65,0x73,0x0a,0x00,0x00,
4089 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4090 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4091 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4092 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4093 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4094 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4097 uint8_t rawpkt4[] = {
4098 0x00,0x04,0x76,0xd3,0xd8,0x6a,0x00,0x24,
4099 0xe8,0x29,0xfa,0x4f,0x08,0x00,0x45,0x00,
4100 0x00,0x8c,0xa7,0x2e,0x00,0x00,0x40,0x06,
4101 0x1b,0x67,0xc0,0xa8,0x02,0x03,0xd0,0x45,
4102 0x24,0xe6,0x06,0xcf,0x03,0x09,0x00,0x0e,
4103 0xdf,0x72,0x3d,0xc2,0x21,0xce,0x50,0x00,
4104 0x02,0x00,0x88,0x25,0x00,0x00,0x48,0x69,
4105 0x2c,0x20,0x74,0x68,0x69,0x73,0x20,0x69,
4106 0x73,0x20,0x61,0x20,0x62,0x69,0x67,0x20,
4107 0x74,0x65,0x73,0x74,0x20,0x74,0x6f,0x20,
4108 0x63,0x68,0x65,0x63,0x6b,0x20,0x63,0x6f,
4109 0x6e,0x74,0x65,0x6e,0x74,0x20,0x6d,0x61,
4110 0x74,0x63,0x68,0x65,0x73,0x0a,0x00,0x00,
4111 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4112 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4113 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4114 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4115 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4116 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4120 memset(&th_v, 0,
sizeof(th_v));
4133 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any any (msg:\"within test\"; content:\"Hi, this is a big test to check \"; content:\"content matches\"; distance:0; within:15; sid:556;)");
4149 printf(
"failed to match on packet 1: ");
4160 printf(
"failed to match on packet 2: ");
4171 printf(
"failed to match on packet 3: ");
4182 printf(
"failed to match on packet 4: ");
4187 uint8_t *p5buf = (uint8_t *)
"Hi, this is a big test to check content matches";
4188 uint16_t p5buflen = strlen((
char *)p5buf);
4192 printf(
"failed to match on packet 5: ");
4204 if (det_ctx != NULL)
4230 static int SigTestDepthOffset01 (
void)
4232 uint8_t *buf = (uint8_t *)
"01234567890123456789012345678901abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
4233 uint16_t buflen = strlen((
char *)buf);
4239 memset(&th_v, 0,
sizeof(th_v));
4250 de_ctx->
sig_list =
SigInit(
de_ctx,
"alert tcp any any -> any any (msg:\"depth offset\"; content:\"456\"; offset:4; depth:3; sid:1;)");
4273 static int SigTestDetectAlertCounter(
void)
4278 memset(&
tv, 0,
sizeof(
tv));
4285 "content:\"boo\"; sid:1;)");
4294 p =
UTHBuildPacket((uint8_t *)
"boo", strlen(
"boo"), IPPROTO_TCP);
4302 p =
UTHBuildPacket((uint8_t *)
"roo", strlen(
"roo"), IPPROTO_TCP);
4307 p =
UTHBuildPacket((uint8_t *)
"laboosa", strlen(
"laboosa"), IPPROTO_TCP);
4319 static int SigTestDropFlow01(
void)
4323 uint8_t http_buf1[] =
"POST /one HTTP/1.0\r\n"
4324 "User-Agent: Mozilla/1.0\r\n"
4325 "Cookie: hellocatch\r\n\r\n";
4326 uint32_t http_buf1_len =
sizeof(http_buf1) - 1;
4335 memset(&f, 0,
sizeof(
Flow));
4342 f.
proto = IPPROTO_TCP;
4358 "(msg:\"Test proto match\"; "
4392 static int SigTestDropFlow02(
void)
4397 uint8_t http_buf1[] =
"POST /one HTTP/1.0\r\n"
4398 "User-Agent: Mozilla/1.0\r\n"
4399 "Cookie: hellocatch\r\n\r\n";
4400 uint32_t http_buf1_len =
sizeof(http_buf1) - 1;
4409 memset(&f, 0,
sizeof(
Flow));
4416 f.
proto = IPPROTO_TCP;
4434 "(msg:\"Test proto match\"; uricontent:\"one\";"
4446 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
4451 if (http_state == NULL) {
4452 printf(
"no http state: ");
4460 printf(
"sig 1 didn't alert, but it should: ");
4465 printf(
"sig 1 alerted but flow was not flagged correctly: ");
4477 if (det_ctx != NULL)
4494 static int SigTestDropFlow03(
void)
4499 uint8_t http_buf1[] =
"POST /one HTTP/1.0\r\n"
4500 "User-Agent: Mozilla/1.0\r\n"
4501 "Cookie: hellocatch\r\n\r\n";
4502 uint32_t http_buf1_len =
sizeof(http_buf1) - 1;
4504 uint8_t http_buf2[] =
"POST /two HTTP/1.0\r\n"
4505 "User-Agent: Mozilla/1.0\r\n"
4506 "Cookie: hellocatch\r\n\r\n";
4507 uint32_t http_buf2_len =
sizeof(http_buf1) - 1;
4521 memset(&f, 0,
sizeof(
Flow));
4529 f.
proto = IPPROTO_TCP;
4553 "(msg:\"Test proto match\"; uricontent:\"one\";"
4562 "(msg:\"Test proto match\"; uricontent:\"two\";"
4574 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
4579 if (http_state == NULL) {
4580 printf(
"no http state: ");
4588 printf(
"sig 1 didn't alert on p1, but it should: ");
4593 printf(
"sig 1 alerted but flow was not flagged correctly: ");
4598 if (StreamTcpCheckFlowDrops(p2) == 1) {
4599 SCLogDebug(
"This flow/stream triggered a drop rule");
4600 FlowSetNoPacketInspectionFlag(p2->
flow);
4601 DecodeSetNoPacketInspectionFlag(p2);
4610 printf(
"The packet was not flagged with no-inspection: ");
4617 printf(
"toserver chunk 2 returned %" PRId32
", expected 0: ", r);
4625 printf(
"sig 1 alerted, but it should not since the no pkt inspection should be set: ");
4630 printf(
"sig 2 alerted, but it should not since the no pkt inspection should be set: ");
4635 printf(
"A \"drop\" action should be set from the flow to the packet: ");
4644 if (det_ctx != NULL)
4664 static int SigTestPorts01(
void)
4671 uint8_t payload[] =
"AAAAAAAAAAAAAAAAAA";
4684 "(content:\"AAA\"; sid:1;)");
4696 printf(
"sig 1 alerted on p1, but it should not: ");
4702 if (det_ctx != NULL)
4714 static int SigTestBug01(
void)
4721 uint8_t payload[] =
"!mymy";
4734 "(content:\"Omymy\"; nocase; sid:1;)");
4739 "(content:\"!mymy\"; nocase; sid:2;)");
4751 printf(
"sig 1 alerted on p1, but it should not: ");
4755 printf(
"sig 2 did not p1, but it should have: ");
4761 if (det_ctx != NULL)
4772 static const char *dummy_conf_string2 =
4777 " address-groups:\n"
4779 " HOME_NET: \"[10.10.10.0/24, !10.10.10.247]\"\n"
4781 " EXTERNAL_NET: \"any\"\n"
4785 " HTTP_PORTS: \"80:81,88\"\n"
4788 static int DetectAddressYamlParsing01 (
void)
4819 static const char *dummy_conf_string3 =
4824 " address-groups:\n"
4826 " HOME_NET: \"[10.10.10.0/24, !10.10.10.247/32]\"\n"
4828 " EXTERNAL_NET: \"any\"\n"
4832 " HTTP_PORTS: \"80:81,88\"\n"
4835 static int DetectAddressYamlParsing02 (
void)
4866 static const char *dummy_conf_string4 =
4871 " address-groups:\n"
4873 " HOME_NET: \"[10.10.10.0/24, !10.10.10.247/32]\"\n"
4875 " EXTERNAL_NET: \"any\"\n"
4879 " HTTP_PORTS: \"80:81,88\"\n"
4882 static int DetectAddressYamlParsing03 (
void)
4913 static const char *dummy_conf_string5 =
4918 " address-groups:\n"
4920 " HOME_NET: \"[10.196.0.0/24, !10.196.0.15]\"\n"
4922 " EXTERNAL_NET: \"any\"\n"
4926 " HTTP_PORTS: \"80:81,88\"\n"
4930 static int DetectAddressYamlParsing04 (
void)
4970 UtRegisterTest(
"SigTest05 -- distance/within mismatch", SigTest05);
4971 UtRegisterTest(
"SigTest06 -- uricontent HTTP/1.1 match test", SigTest06);
4974 UtRegisterTest(
"SigTest08 -- uricontent HTTP/1.0 match test", SigTest08);
4977 UtRegisterTest(
"SigTest10 -- long content match, longer than pkt",
4980 UtRegisterTest(
"SigTest12 -- content order matching, normal", SigTest12);
4981 UtRegisterTest(
"SigTest13 -- content order matching, diff order",
4983 UtRegisterTest(
"SigTest14 -- content order matching, distance 0",
4985 UtRegisterTest(
"SigTest15 -- port negation sig (no match)", SigTest15);
4986 UtRegisterTest(
"SigTest16 -- port negation sig (match)", SigTest16);
4987 UtRegisterTest(
"SigTest17 -- HTTP Host Pkt var capture", SigTest17);
4997 SigTest25NegativeIPV4Keyword);
5001 SigTest26TCPV4AndNegativeIPV4Keyword);
5003 SigTest26TCPV4AndIPV4Keyword);
5005 SigTest27NegativeTCPV4Keyword);
5009 SigTest29NegativeTCPV6Keyword);
5013 SigTest31NegativeUDPV4Keyword);
5017 SigTest33NegativeUDPV6Keyword);
5019 UtRegisterTest(
"SigTest34ICMPV4Keyword", SigTest34ICMPV4Keyword);
5021 SigTest35NegativeICMPV4Keyword);
5023 SigTest36ContentAndIsdataatKeywords01);
5025 SigTest37ContentAndIsdataatKeywords02);
5032 SigTest40NoPacketInspection01);
5034 SigTest40NoPayloadInspection02);
5040 UtRegisterTest(
"SigTestContent01 -- 32 byte pattern", SigTestContent01);
5041 UtRegisterTest(
"SigTestContent02 -- 32+31 byte pattern", SigTestContent02);
5042 UtRegisterTest(
"SigTestContent03 -- 32 byte pattern, x2 + distance",
5044 UtRegisterTest(
"SigTestContent04 -- 32 byte pattern, x2 + distance/within",
5046 UtRegisterTest(
"SigTestContent05 -- distance/within", SigTestContent05);
5053 UtRegisterTest(
"SigTestDetectAlertCounter", SigTestDetectAlertCounter);
5059 UtRegisterTest(
"DetectAddressYamlParsing01", DetectAddressYamlParsing01);
5060 UtRegisterTest(
"DetectAddressYamlParsing02", DetectAddressYamlParsing02);
5061 UtRegisterTest(
"DetectAddressYamlParsing03", DetectAddressYamlParsing03);
5062 UtRegisterTest(
"DetectAddressYamlParsing04", DetectAddressYamlParsing04);