26 #include "../suricata-common.h"
27 #include "../conf-yaml-loader.h"
28 #include "../decode.h"
30 #include "../detect.h"
31 #include "../detect-engine-build.h"
32 #include "../detect-engine-alert.h"
37 static int DetectHttpServerBodyParserTest01(
void)
40 FAIL_IF_NOT(
UTHParseSignature(
"alert http any any -> any any (flow:to_client; content:\"abc\"; nocase; http_server_body; sid:1;)",
true));
41 FAIL_IF_NOT(
UTHParseSignature(
"alert http any any -> any any (flow:to_client; content:\"abc\"; endswith; http_server_body; sid:1;)",
true));
42 FAIL_IF_NOT(
UTHParseSignature(
"alert http any any -> any any (flow:to_client; content:\"abc\"; startswith; http_server_body; sid:1;)",
true));
43 FAIL_IF_NOT(
UTHParseSignature(
"alert http any any -> any any (flow:to_client; content:\"abc\"; startswith; endswith; http_server_body; sid:1;)",
true));
45 FAIL_IF_NOT(
UTHParseSignature(
"alert http any any -> any any (flow:to_client; content:\"abc\"; rawbytes; http_server_body; sid:1;)",
false));
54 static int DetectHttpServerBodyParserTest02(
void)
57 FAIL_IF_NOT(
UTHParseSignature(
"alert http any any -> any any (flow:to_client; http.response_body; content:\"abc\"; nocase; sid:1;)",
true));
58 FAIL_IF_NOT(
UTHParseSignature(
"alert http any any -> any any (flow:to_client; http.response_body; content:\"abc\"; endswith; sid:1;)",
true));
59 FAIL_IF_NOT(
UTHParseSignature(
"alert http any any -> any any (flow:to_client; http.response_body; content:\"abc\"; startswith; sid:1;)",
true));
60 FAIL_IF_NOT(
UTHParseSignature(
"alert http any any -> any any (flow:to_client; http.response_body; content:\"abc\"; startswith; endswith; sid:1;)",
true));
63 FAIL_IF_NOT(
UTHParseSignature(
"alert http any any -> any any (flow:to_client; http.response_body; content:\"abc\"; rawbytes; sid:1;)",
false));
75 static int RunTest(
struct TestSteps *steps,
const char *sig,
const char *yaml)
84 memset(&th_v, 0,
sizeof(th_v));
85 memset(&f, 0,
sizeof(f));
86 memset(&ssn, 0,
sizeof(ssn));
106 f.
proto = IPPROTO_TCP;
120 while (b->
input != NULL) {
164 static int DetectEngineHttpServerBodyTest01(
void)
166 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
167 "Host: www.openinfosecfoundation.org\r\n"
168 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
169 "Gecko/20091221 Firefox/3.5.7\r\n"
171 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
172 "Content-Type: text/html\r\n"
173 "Content-Length: 7\r\n"
177 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
178 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
182 const char *sig =
"alert http any any -> any any "
183 "(msg:\"http server body test\"; "
184 "content:\"message\"; http_server_body; "
186 return RunTest(steps, sig, NULL);
189 static int DetectEngineHttpServerBodyTest02(
void)
191 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
192 "Host: www.openinfosecfoundation.org\r\n"
193 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
194 "Gecko/20091221 Firefox/3.5.7\r\n"
196 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
197 "Content-Type: text/html\r\n"
198 "Content-Length: 7\r\n"
202 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
203 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
207 const char *sig =
"alert http any any -> any any "
208 "(msg:\"http server body test\"; "
209 "content:\"ABC\"; http_server_body; offset:4; "
211 return RunTest(steps, sig, NULL);
214 static int DetectEngineHttpServerBodyTest03(
void)
216 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
217 "Host: www.openinfosecfoundation.org\r\n"
218 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
219 "Gecko/20091221 Firefox/3.5.7\r\n"
221 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
222 "Content-Type: text/html\r\n"
223 "Content-Length: 17\r\n"
226 uint8_t http_buf3[] =
"8901234ABC";
228 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
229 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
230 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 1 },
234 const char *sig =
"alert http any any -> any any "
235 "(msg:\"http server body test\"; "
236 "content:\"ABC\"; http_server_body; offset:14; "
238 return RunTest(steps, sig, NULL);
241 static int DetectEngineHttpServerBodyTest04(
void)
243 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
244 "Host: www.openinfosecfoundation.org\r\n"
245 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
246 "Gecko/20091221 Firefox/3.5.7\r\n"
248 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
249 "Content-Type: text/html\r\n"
250 "Content-Length: 6\r\n"
254 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
255 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
258 const char *sig =
"alert http any any -> any any "
259 "(msg:\"http server body test\"; "
260 "content:!\"abc\"; http_server_body; offset:3; "
262 return RunTest(steps, sig, NULL);
265 static int DetectEngineHttpServerBodyTest05(
void)
267 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
268 "Host: www.openinfosecfoundation.org\r\n"
269 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
270 "Gecko/20091221 Firefox/3.5.7\r\n"
272 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
273 "Content-Type: text/html\r\n"
274 "Content-Length: 6\r\n"
278 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
279 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
282 const char *sig =
"alert http any any -> any any "
283 "(msg:\"http server body test\"; "
284 "content:\"abc\"; http_server_body; depth:3; "
286 return RunTest(steps, sig, NULL);
289 static int DetectEngineHttpServerBodyTest06(
void)
291 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
292 "Host: www.openinfosecfoundation.org\r\n"
293 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
294 "Gecko/20091221 Firefox/3.5.7\r\n"
296 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
297 "Content-Type: text/html\r\n"
298 "Content-Length: 6\r\n"
302 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
303 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
306 const char *sig =
"alert http any any -> any any "
307 "(msg:\"http server body test\"; "
308 "content:!\"def\"; http_server_body; depth:3; "
310 return RunTest(steps, sig, NULL);
313 static int DetectEngineHttpServerBodyTest07(
void)
315 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
316 "Host: www.openinfosecfoundation.org\r\n"
317 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
318 "Gecko/20091221 Firefox/3.5.7\r\n"
320 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
321 "Content-Type: text/html\r\n"
322 "Content-Length: 6\r\n"
326 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
327 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
330 const char *sig =
"alert http any any -> any any "
331 "(msg:\"http server body test\"; "
332 "content:!\"def\"; http_server_body; offset:3; "
334 return RunTest(steps, sig, NULL);
337 static int DetectEngineHttpServerBodyTest08(
void)
339 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
340 "Host: www.openinfosecfoundation.org\r\n"
341 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
342 "Gecko/20091221 Firefox/3.5.7\r\n"
344 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
345 "Content-Type: text/html\r\n"
346 "Content-Length: 6\r\n"
351 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
352 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
355 const char *sig =
"alert http any any -> any any "
356 "(msg:\"http server body test\"; "
357 "content:!\"abc\"; http_server_body; depth:3; "
359 return RunTest(steps, sig, NULL);
362 static int DetectEngineHttpServerBodyTest09(
void)
364 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
365 "Host: www.openinfosecfoundation.org\r\n"
366 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
367 "Gecko/20091221 Firefox/3.5.7\r\n"
369 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
370 "Content-Type: text/html\r\n"
371 "Content-Length: 6\r\n"
375 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
376 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
379 const char *sig =
"alert http any any -> any any "
380 "(msg:\"http server body test\"; "
381 "content:\"abc\"; http_server_body; depth:3; "
382 "content:\"def\"; http_server_body; within:3; "
384 return RunTest(steps, sig, NULL);
387 static int DetectEngineHttpServerBodyTest10(
void)
389 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
390 "Host: www.openinfosecfoundation.org\r\n"
391 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
392 "Gecko/20091221 Firefox/3.5.7\r\n"
394 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
395 "Content-Type: text/html\r\n"
396 "Content-Length: 6\r\n"
400 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
401 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
404 const char *sig =
"alert http any any -> any any "
405 "(msg:\"http server body test\"; "
406 "content:\"abc\"; http_server_body; depth:3; "
407 "content:!\"xyz\"; http_server_body; within:3; "
409 return RunTest(steps, sig, NULL);
412 static int DetectEngineHttpServerBodyTest11(
void)
414 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
415 "Host: www.openinfosecfoundation.org\r\n"
416 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
417 "Gecko/20091221 Firefox/3.5.7\r\n"
419 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
420 "Content-Type: text/html\r\n"
421 "Content-Length: 6\r\n"
425 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
426 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
429 const char *sig =
"alert http any any -> any any "
430 "(msg:\"http server body test\"; "
431 "content:\"abc\"; http_server_body; depth:3; "
432 "content:\"xyz\"; http_server_body; within:3; "
434 return RunTest(steps, sig, NULL);
437 static int DetectEngineHttpServerBodyTest12(
void)
439 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
440 "Host: www.openinfosecfoundation.org\r\n"
441 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
442 "Gecko/20091221 Firefox/3.5.7\r\n"
444 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
445 "Content-Type: text/html\r\n"
446 "Content-Length: 6\r\n"
450 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
451 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
454 const char *sig =
"alert http any any -> any any "
455 "(msg:\"http server body test\"; "
456 "content:\"ab\"; http_server_body; depth:2; "
457 "content:\"ef\"; http_server_body; distance:2; "
459 return RunTest(steps, sig, NULL);
462 static int DetectEngineHttpServerBodyTest13(
void)
464 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
465 "Host: www.openinfosecfoundation.org\r\n"
466 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
467 "Gecko/20091221 Firefox/3.5.7\r\n"
469 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
470 "Content-Type: text/html\r\n"
471 "Content-Length: 6\r\n"
475 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
476 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
479 const char *sig =
"alert http any any -> any any "
480 "(msg:\"http server body test\"; "
481 "content:\"ab\"; http_server_body; depth:3; "
482 "content:!\"yz\"; http_server_body; distance:2; "
484 return RunTest(steps, sig, NULL);
487 static int DetectEngineHttpServerBodyTest14(
void)
489 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
490 "Host: www.openinfosecfoundation.org\r\n"
491 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
492 "Gecko/20091221 Firefox/3.5.7\r\n"
494 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
495 "Content-Type: text/html\r\n"
496 "Content-Length: 6\r\n"
500 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
501 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
504 const char *sig =
"alert http any any -> any any "
505 "(msg:\"http server body test\"; "
507 "content:\"ef\"; http_server_body; distance:2; "
509 return RunTest(steps, sig, NULL);
512 static int DetectEngineHttpServerBodyTest15(
void)
514 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
515 "Host: www.openinfosecfoundation.org\r\n"
516 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
517 "Gecko/20091221 Firefox/3.5.7\r\n"
519 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
520 "Content-Type: text/html\r\n"
521 "Content-Length: 6\r\n"
525 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
526 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
529 const char *sig =
"alert http any any -> any any "
530 "(msg:\"http server body test\"; "
532 "content:!\"xyz\"; http_server_body; distance:0; within:3; "
534 return RunTest(steps, sig, NULL);
537 static int DetectEngineHttpServerBodyTest16(
void)
546 request-body-limit: 0\n\
547 response-body-limit: 0\n\
549 request-body-inspect-window: 0\n\
550 response-body-inspect-window: 0\n\
551 request-body-minimal-inspect-size: 0\n\
552 response-body-minimal-inspect-size: 0\n\
554 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
555 "Host: www.openinfosecfoundation.org\r\n"
556 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
557 "Gecko/20091221 Firefox/3.5.7\r\n"
559 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
560 "Content-Type: text/html\r\n"
561 "Content-Length: 17\r\n"
564 uint8_t http_buf3[] =
"8901234ABC";
566 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
567 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
568 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 0 },
571 const char *sig =
"alert http any any -> any any ("
572 "content:\"890\"; within:3; http_server_body; "
574 return RunTest(steps, sig,
input);
577 static int DetectEngineHttpServerBodyTest17(
void)
586 request-body-limit: 0\n\
587 response-body-limit: 0\n\
589 request-body-inspect-window: 0\n\
590 response-body-inspect-window: 0\n\
591 request-body-minimal-inspect-size: 0\n\
592 response-body-minimal-inspect-size: 0\n\
594 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
595 "Host: www.openinfosecfoundation.org\r\n"
596 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
597 "Gecko/20091221 Firefox/3.5.7\r\n"
599 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
600 "Content-Type: text/html\r\n"
601 "Content-Length: 17\r\n"
604 uint8_t http_buf3[] =
"8901234ABC";
606 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
607 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
608 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 0 },
611 const char *sig =
"alert http any any -> any any ("
612 "content:\"890\"; depth:3; http_server_body; "
614 return RunTest(steps, sig,
input);
620 static int DetectEngineHttpServerBodyTest18(
void)
622 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
623 "Host: www.openinfosecfoundation.org\r\n"
624 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
625 "Gecko/20091221 Firefox/3.5.7\r\n"
628 uint8_t http_buf2[] = {
629 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
630 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'5',
'1', 0x0d, 0x0a,
631 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'E',
'n',
'c',
'o',
'd',
'i',
'n',
'g',
':',
' ',
632 'g',
'z',
'i',
'p', 0x0d, 0x0a,
634 0x1f, 0x8b, 0x08, 0x08, 0x27, 0x1e, 0xe5, 0x51, 0x00, 0x03, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74,
635 0x78, 0x74, 0x00, 0x2b, 0xc9, 0xc8, 0x2c, 0x56, 0x00, 0xa2, 0x44, 0x85, 0xb4, 0xcc, 0x9c, 0x54,
636 0x85, 0xcc, 0x3c, 0x20, 0x2b, 0x29, 0xbf, 0x42, 0x8f, 0x0b, 0x00, 0xb2, 0x7d, 0xac, 0x9b, 0x19,
641 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
642 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
645 const char *sig =
"alert http any any -> any any "
646 "(msg:\"http server body test\"; "
647 "content:\"file\"; http_server_body; "
649 return RunTest(steps, sig, NULL);
655 static int DetectEngineHttpServerBodyTest19(
void)
657 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
658 "Host: www.openinfosecfoundation.org\r\n"
659 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
660 "Gecko/20091221 Firefox/3.5.7\r\n"
663 uint8_t http_buf2[] = {
664 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
665 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'2',
'4', 0x0d, 0x0a,
666 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'E',
'n',
'c',
'o',
'd',
'i',
'n',
'g',
':',
' ',
667 'd',
'e',
'f',
'l',
'a',
't',
'e', 0x0d, 0x0a,
669 0x2b, 0xc9, 0xc8, 0x2c, 0x56, 0x00, 0xa2, 0x44, 0x85, 0xb4, 0xcc, 0x9c, 0x54, 0x85, 0xcc, 0x3c,
670 0x20, 0x2b, 0x29, 0xbf, 0x42, 0x8f, 0x0b, 0x00,
675 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
676 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
679 const char *sig =
"alert http any any -> any any "
680 "(msg:\"http server body test\"; "
681 "content:\"file\"; http_server_body; "
683 return RunTest(steps, sig, NULL);
689 static int DetectEngineHttpServerBodyTest20(
void)
691 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
692 "Host: www.openinfosecfoundation.org\r\n"
693 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
694 "Gecko/20091221 Firefox/3.5.7\r\n"
697 uint8_t http_buf2[] = {
698 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
699 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'2',
'4', 0x0d, 0x0a,
700 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'E',
'n',
'c',
'o',
'd',
'i',
'n',
'g',
':',
' ',
701 'g',
'z',
'i',
'p', 0x0d, 0x0a,
703 0x2b, 0xc9, 0xc8, 0x2c, 0x56, 0x00, 0xa2, 0x44, 0x85, 0xb4, 0xcc, 0x9c, 0x54, 0x85, 0xcc, 0x3c,
704 0x20, 0x2b, 0x29, 0xbf, 0x42, 0x8f, 0x0b, 0x00,
709 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
710 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
713 const char *sig =
"alert http any any -> any any "
714 "(msg:\"http server body test\"; "
715 "content:\"file\"; http_server_body; "
717 return RunTest(steps, sig, NULL);
723 static int DetectEngineHttpServerBodyTest21(
void)
725 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
726 "Host: www.openinfosecfoundation.org\r\n"
727 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
728 "Gecko/20091221 Firefox/3.5.7\r\n"
731 uint8_t http_buf2[] = {
732 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
733 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'5',
'1', 0x0d, 0x0a,
734 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'E',
'n',
'c',
'o',
'd',
'i',
'n',
'g',
':',
' ',
735 'd',
'e',
'f',
'l',
'a',
't',
'e', 0x0d, 0x0a,
737 0x1f, 0x8b, 0x08, 0x08, 0x27, 0x1e, 0xe5, 0x51, 0x00, 0x03, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74,
738 0x78, 0x74, 0x00, 0x2b, 0xc9, 0xc8, 0x2c, 0x56, 0x00, 0xa2, 0x44, 0x85, 0xb4, 0xcc, 0x9c, 0x54,
739 0x85, 0xcc, 0x3c, 0x20, 0x2b, 0x29, 0xbf, 0x42, 0x8f, 0x0b, 0x00, 0xb2, 0x7d, 0xac, 0x9b, 0x19,
744 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
745 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
748 const char *sig =
"alert http any any -> any any "
749 "(msg:\"http server body test\"; "
750 "content:\"file\"; http_server_body; "
752 return RunTest(steps, sig, NULL);
759 static int DetectEngineHttpServerBodyTest22(
void)
761 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
762 "Host: www.openinfosecfoundation.org\r\n"
763 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
764 "Gecko/20091221 Firefox/3.5.7\r\n"
767 uint8_t http_buf2[] = {
768 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
769 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'5',
'1', 0x0d, 0x0a,
770 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'E',
'n',
'c',
'o',
'd',
'i',
'n',
'g',
':',
' ',
771 'g',
'z',
'i',
'p', 0x0d, 0x0a,
772 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'E',
'n',
'c',
'o',
'd',
'i',
'n',
'g',
':',
' ',
773 'd',
'e',
'f',
'l',
'a',
't',
'e', 0x0d, 0x0a,
775 0x1f, 0x8b, 0x08, 0x08, 0x27, 0x1e, 0xe5, 0x51, 0x00, 0x03, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74,
776 0x78, 0x74, 0x00, 0x2b, 0xc9, 0xc8, 0x2c, 0x56, 0x00, 0xa2, 0x44, 0x85, 0xb4, 0xcc, 0x9c, 0x54,
777 0x85, 0xcc, 0x3c, 0x20, 0x2b, 0x29, 0xbf, 0x42, 0x8f, 0x0b, 0x00, 0xb2, 0x7d, 0xac, 0x9b, 0x19,
782 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
783 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
786 const char *sig =
"alert http any any -> any any "
787 "(msg:\"http server body test\"; "
788 "content:\"file\"; http_server_body; "
790 return RunTest(steps, sig, NULL);
793 static int DetectEngineHttpServerBodyFileDataTest01(
void)
795 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
796 "Host: www.openinfosecfoundation.org\r\n"
797 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
798 "Gecko/20091221 Firefox/3.5.7\r\n"
800 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
801 "Content-Type: text/html\r\n"
802 "Content-Length: 6\r\n"
806 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
807 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
810 const char *sig =
"alert http any any -> any any "
811 "(msg:\"http server body test\"; "
812 "file_data; pcre:/ab/; "
813 "content:\"ef\"; distance:2; "
815 return RunTest(steps, sig, NULL);
818 static int DetectEngineHttpServerBodyFileDataTest02(
void)
820 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
821 "Host: www.openinfosecfoundation.org\r\n"
822 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
823 "Gecko/20091221 Firefox/3.5.7\r\n"
825 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
826 "Content-Type: text/html\r\n"
827 "Content-Length: 6\r\n"
831 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
832 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
835 const char *sig =
"alert http any any -> any any "
836 "(msg:\"http server body test\"; "
837 "file_data; pcre:/abc/; "
838 "content:!\"xyz\"; distance:0; within:3; "
840 return RunTest(steps, sig, NULL);
844 static int DetectEngineHttpServerBodyFileDataTest03(
void)
853 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
854 "Host: www.openinfosecfoundation.org\r\n"
855 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
856 "Gecko/20091221 Firefox/3.5.7\r\n"
858 uint32_t http_len1 =
sizeof(http_buf1) - 1;
859 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
860 "Content-Type: text/html\r\n"
861 "Content-Length: 33\r\n"
863 "XYZ_klm_1234abcd_XYZ_klm_5678abcd";
864 uint32_t http_len2 =
sizeof(http_buf2) - 1;
867 memset(&th_v, 0,
sizeof(th_v));
868 memset(&f, 0,
sizeof(f));
869 memset(&ssn, 0,
sizeof(ssn));
876 f.
proto = IPPROTO_TCP;
896 "alert http any any -> any any "
897 "(msg:\"match on 1st\"; "
898 "file_data; content:\"XYZ\"; content:\"_klm_\"; distance:0; content:\"abcd\"; "
899 "distance:4; byte_test:4,=,1234,-8,relative,string;"
903 "alert http any any -> any any "
904 "(msg:\"match on 2nd\"; "
905 "file_data; content:\"XYZ\"; content:\"_klm_\"; distance:0; content:\"abcd\"; "
906 "distance:4; byte_test:4,=,5678,-8,relative,string;"
944 static int DetectEngineHttpServerBodyFileDataTest04(
void)
947 const char yaml[] =
"\
954 http-body-inline: yes\n\
955 response-body-minimal-inspect-size: 6\n\
956 response-body-inspect-window: 3\n\
960 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
961 "Host: www.openinfosecfoundation.org\r\n"
962 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
963 "Gecko/20091221 Firefox/3.5.7\r\n"
965 0, STREAM_TOSERVER, 0 },
966 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
967 "Content-Type: text/html\r\n"
968 "Content-Length: 6\r\n"
971 0, STREAM_TOCLIENT, 0 },
972 { (
const uint8_t *)
"cd", 0, STREAM_TOCLIENT, 1 },
973 { (
const uint8_t *)
"ef", 0, STREAM_TOCLIENT, 0 },
977 const char *sig =
"alert http any any -> any any (file_data; content:\"abcd\"; sid:1;)";
978 return RunTest(steps, sig, yaml);
981 static int DetectEngineHttpServerBodyFileDataTest05(
void)
984 const char yaml[] =
"\
991 http-body-inline: yes\n\
992 response-body-minimal-inspect-size: 6\n\
993 response-body-inspect-window: 3\n\
997 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
998 "Host: www.openinfosecfoundation.org\r\n"
999 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1000 "Gecko/20091221 Firefox/3.5.7\r\n"
1002 0, STREAM_TOSERVER, 0 },
1003 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1004 "Content-Type: text/html\r\n"
1005 "Content-Length: 6\r\n"
1008 0, STREAM_TOCLIENT, 0 },
1009 { (
const uint8_t *)
"cd", 0, STREAM_TOCLIENT, 0 },
1010 { (
const uint8_t *)
"ef", 0, STREAM_TOCLIENT, 1 },
1014 const char *sig =
"alert http any any -> any any (file_data; content:\"abcdef\"; sid:1;)";
1015 return RunTest(steps, sig, yaml);
1018 static int DetectEngineHttpServerBodyFileDataTest06(
void)
1021 const char yaml[] =
"\
1028 http-body-inline: yes\n\
1029 response-body-minimal-inspect-size: 6\n\
1030 response-body-inspect-window: 3\n\
1034 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1035 "Host: www.openinfosecfoundation.org\r\n"
1036 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1037 "Gecko/20091221 Firefox/3.5.7\r\n"
1039 0, STREAM_TOSERVER, 0 },
1040 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1041 "Content-Type: text/html\r\n"
1042 "Content-Length: 6\r\n"
1045 0, STREAM_TOCLIENT, 0 },
1046 { (
const uint8_t *)
"cd", 0, STREAM_TOCLIENT, 0 },
1047 { (
const uint8_t *)
"ef", 0, STREAM_TOCLIENT, 1 },
1052 "alert http any any -> any any (file_data; content:\"bcdef\"; offset:1; sid:1;)";
1053 return RunTest(steps, sig, yaml);
1056 static int DetectEngineHttpServerBodyFileDataTest07(
void)
1059 const char yaml[] =
"\
1066 http-body-inline: yes\n\
1067 response-body-minimal-inspect-size: 6\n\
1068 response-body-inspect-window: 3\n\
1072 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1073 "Host: www.openinfosecfoundation.org\r\n"
1074 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1075 "Gecko/20091221 Firefox/3.5.7\r\n"
1077 0, STREAM_TOSERVER, 0 },
1078 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1079 "Content-Type: text/html\r\n"
1080 "Content-Length: 13\r\n"
1083 0, STREAM_TOCLIENT, 0 },
1084 { (
const uint8_t *)
"cd", 0, STREAM_TOCLIENT, 1 },
1085 { (
const uint8_t *)
"123456789", 0, STREAM_TOCLIENT, 0 },
1090 "alert http any any -> any any (file_data; content:\"bc\"; offset:1; depth:2; sid:1;)";
1091 return RunTest(steps, sig, yaml);
1094 static int DetectEngineHttpServerBodyFileDataTest08(
void)
1097 const char yaml[] =
"\
1104 http-body-inline: yes\n\
1105 response-body-minimal-inspect-size: 6\n\
1106 response-body-inspect-window: 3\n\
1110 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1111 "Host: www.openinfosecfoundation.org\r\n"
1112 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1113 "Gecko/20091221 Firefox/3.5.7\r\n"
1115 0, STREAM_TOSERVER, 0 },
1116 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1117 "Content-Type: text/html\r\n"
1118 "Content-Length: 14\r\n"
1121 0, STREAM_TOCLIENT, 0 },
1122 { (
const uint8_t *)
"cd", 0, STREAM_TOCLIENT, 0 },
1123 { (
const uint8_t *)
"1234567890", 0, STREAM_TOCLIENT, 1 },
1128 "alert http any any -> any any (file_data; content:\"d123456789\"; offset:3; sid:1;)";
1129 return RunTest(steps, sig, yaml);
1132 static int DetectEngineHttpServerBodyFileDataTest09(
void)
1135 const char yaml[] =
"\
1142 http-body-inline: yes\n\
1143 response-body-minimal-inspect-size: 6\n\
1144 response-body-inspect-window: 3\n\
1148 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1149 "Host: www.openinfosecfoundation.org\r\n"
1150 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1151 "Gecko/20091221 Firefox/3.5.7\r\n"
1153 0, STREAM_TOSERVER, 0 },
1154 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1155 "Content-Type: text/html\r\n"
1156 "Content-Length: 13\r\n"
1159 0, STREAM_TOCLIENT, 0 },
1160 { (
const uint8_t *)
"cd", 0, STREAM_TOCLIENT, 0 },
1161 { (
const uint8_t *)
"123456789", 0, STREAM_TOCLIENT, 1 },
1166 "alert http any any -> any any (file_data; content:\"abcd12\"; depth:6; sid:1;)";
1167 return RunTest(steps, sig, yaml);
1170 static int DetectEngineHttpServerBodyFileDataTest10(
void)
1173 const char yaml[] =
"\
1180 http-body-inline: yes\n\
1181 response-body-minimal-inspect-size: 6\n\
1182 response-body-inspect-window: 3\n\
1186 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1187 "Host: www.openinfosecfoundation.org\r\n"
1188 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1189 "Gecko/20091221 Firefox/3.5.7\r\n"
1191 0, STREAM_TOSERVER, 0 },
1192 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1193 "Content-Type: text/html\r\n"
1194 "Content-Length: 5\r\n"
1197 0, STREAM_TOCLIENT, 0 },
1198 { (
const uint8_t *)
"c", 0, STREAM_TOCLIENT, 1 },
1199 { (
const uint8_t *)
"de", 0, STREAM_TOCLIENT, 0 },
1203 const char *sig =
"alert http any any -> any any (file_data; content:\"abc\"; depth:3; sid:1;)";
1204 return RunTest(steps, sig, yaml);
1207 static int DetectEngineHttpServerBodyFileDataTest11(
void)
1210 const char yaml[] =
"\
1217 http-body-inline: yes\n\
1218 response-body-minimal-inspect-size: 6\n\
1219 response-body-inspect-window: 3\n\
1223 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1224 "Host: www.openinfosecfoundation.org\r\n"
1225 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1226 "Gecko/20091221 Firefox/3.5.7\r\n"
1228 0, STREAM_TOSERVER, 0 },
1229 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1230 "Content-Type: text/html\r\n"
1231 "Content-Length: 5\r\n"
1234 0, STREAM_TOCLIENT, 0 },
1235 { (
const uint8_t *)
"c", 0, STREAM_TOCLIENT, 0 },
1236 { (
const uint8_t *)
"de", 0, STREAM_TOCLIENT, 1 },
1240 const char *sig =
"alert http any any -> any any (file_data; content:\"bcde\"; offset:1; "
1242 return RunTest(steps, sig, yaml);
1245 static int DetectEngineHttpServerBodyFileDataTest12(
void)
1248 const char yaml[] =
"\
1255 http-body-inline: yes\n\
1256 response-body-minimal-inspect-size: 6\n\
1257 response-body-inspect-window: 3\n\
1261 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1262 "Host: www.openinfosecfoundation.org\r\n"
1263 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1264 "Gecko/20091221 Firefox/3.5.7\r\n"
1266 0, STREAM_TOSERVER, 0 },
1267 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1268 "Content-Type: text/html\r\n"
1269 "Content-Length: 13\r\n"
1272 0, STREAM_TOCLIENT, 0 },
1273 { (
const uint8_t *)
"b", 0, STREAM_TOCLIENT, 0 },
1274 { (
const uint8_t *)
"c", 0, STREAM_TOCLIENT, 0 },
1275 { (
const uint8_t *)
"d", 0, STREAM_TOCLIENT, 1 },
1276 { (
const uint8_t *)
"efghijklm", 0, STREAM_TOCLIENT, 0 },
1280 const char *sig =
"alert http any any -> any any (file_data; content:\"abcd\"; sid:1;)";
1281 return RunTest(steps, sig, yaml);
1284 static int DetectEngineHttpServerBodyFileDataTest13(
void)
1287 const char yaml[] =
"\
1294 http-body-inline: yes\n\
1295 response-body-minimal-inspect-size: 9\n\
1296 response-body-inspect-window: 12\n\
1300 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1301 "Host: www.openinfosecfoundation.org\r\n"
1302 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1303 "Gecko/20091221 Firefox/3.5.7\r\n"
1305 0, STREAM_TOSERVER, 0 },
1306 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1307 "Content-Type: text/html\r\n"
1308 "Content-Length: 13\r\n"
1311 0, STREAM_TOCLIENT, 0 },
1312 { (
const uint8_t *)
"b", 0, STREAM_TOCLIENT, 0 },
1313 { (
const uint8_t *)
"c", 0, STREAM_TOCLIENT, 0 },
1314 { (
const uint8_t *)
"d", 0, STREAM_TOCLIENT, 0 },
1315 { (
const uint8_t *)
"efghijklm", 0, STREAM_TOCLIENT, 1 },
1320 "alert http any any -> any any (file_data; content:\"abcdefghijklm\"; sid:1;)";
1321 return RunTest(steps, sig, yaml);
1324 static int DetectEngineHttpServerBodyFileDataTest14(
void)
1327 const char yaml[] =
"\
1334 http-body-inline: yes\n\
1335 response-body-minimal-inspect-size: 9\n\
1336 response-body-inspect-window: 12\n\
1340 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1341 "Host: www.openinfosecfoundation.org\r\n"
1342 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1343 "Gecko/20091221 Firefox/3.5.7\r\n"
1345 0, STREAM_TOSERVER, 0 },
1346 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1347 "Content-Type: text/html\r\n"
1348 "Content-Length: 20\r\n"
1351 0, STREAM_TOCLIENT, 0 },
1352 { (
const uint8_t *)
"abcdefghi", 0, STREAM_TOCLIENT, 1 },
1356 const char *sig =
"alert http any any -> any any (file_data; content:\"890abcdefghi\"; sid:1;)";
1357 return RunTest(steps, sig, yaml);
1360 static int DetectEngineHttpServerBodyFileDataTest15(
void)
1363 const char yaml[] =
"\
1370 http-body-inline: yes\n\
1371 response-body-minimal-inspect-size: 9\n\
1372 response-body-inspect-window: 12\n\
1376 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1377 "Host: www.openinfosecfoundation.org\r\n"
1378 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1379 "Gecko/20091221 Firefox/3.5.7\r\n"
1381 0, STREAM_TOSERVER, 0 },
1382 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1383 "Content-Type: text/html\r\n"
1384 "Content-Length: 20\r\n"
1387 0, STREAM_TOCLIENT, 0 },
1388 { (
const uint8_t *)
"abcdefghi", 0, STREAM_TOCLIENT, 0 },
1393 "alert http any any -> any any (file_data; content:\"7890ab\"; depth:6; sid:1;)";
1394 return RunTest(steps, sig, yaml);
1397 static int DetectEngineHttpServerBodyFileDataTest16(
void)
1400 const char yaml[] =
"\
1407 http-body-inline: yes\n\
1408 response-body-minimal-inspect-size: 9\n\
1409 response-body-inspect-window: 12\n\
1413 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1414 "Host: www.openinfosecfoundation.org\r\n"
1415 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1416 "Gecko/20091221 Firefox/3.5.7\r\n"
1418 0, STREAM_TOSERVER, 0 },
1419 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1420 "Content-Type: text/html\r\n"
1421 "Content-Length: 20\r\n"
1424 0, STREAM_TOCLIENT, 0 },
1425 { (
const uint8_t *)
"bbbbc", 0, STREAM_TOCLIENT, 0 },
1426 { (
const uint8_t *)
"ccccd", 0, STREAM_TOCLIENT, 0 },
1427 { (
const uint8_t *)
"dddde", 0, STREAM_TOCLIENT, 0 },
1432 "alert http any any -> any any (file_data; content:\"aabb\"; depth:4; sid:1;)";
1433 return RunTest(steps, sig, yaml);
1436 static int DetectEngineHttpServerBodyFileDataTest17(
void)
1439 const char yaml[] =
"\
1446 http-body-inline: yes\n\
1447 response-body-minimal-inspect-size: 8\n\
1448 response-body-inspect-window: 4\n\
1452 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1453 "Host: www.openinfosecfoundation.org\r\n"
1454 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1455 "Gecko/20091221 Firefox/3.5.7\r\n"
1457 0, STREAM_TOSERVER, 0 },
1458 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1459 "Content-Type: text/html\r\n"
1460 "Content-Length: 20\r\n"
1463 0, STREAM_TOCLIENT, 0 },
1464 { (
const uint8_t *)
"bbbbc", 0, STREAM_TOCLIENT, 0 },
1465 { (
const uint8_t *)
"ccccd", 0, STREAM_TOCLIENT, 0 },
1466 { (
const uint8_t *)
"dddde", 0, STREAM_TOCLIENT, 0 },
1471 "alert http any any -> any any (file_data; content:\"bbbc\"; depth:4; sid:1;)";
1472 return RunTest(steps, sig, yaml);
1475 static int DetectEngineHttpServerBodyFileDataTest18(
void)
1478 const char yaml[] =
"\
1485 http-body-inline: yes\n\
1486 response-body-minimal-inspect-size: 8\n\
1487 response-body-inspect-window: 4\n\
1491 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1492 "Host: www.openinfosecfoundation.org\r\n"
1493 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1494 "Gecko/20091221 Firefox/3.5.7\r\n"
1496 0, STREAM_TOSERVER, 0 },
1497 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1498 "Content-Type: text/html\r\n"
1499 "Content-Length: 20\r\n"
1502 0, STREAM_TOCLIENT, 0 },
1503 { (
const uint8_t *)
"bbbbc", 0, STREAM_TOCLIENT, 0 },
1504 { (
const uint8_t *)
"ccccd", 0, STREAM_TOCLIENT, 0 },
1505 { (
const uint8_t *)
"dddde", 0, STREAM_TOCLIENT, 0 },
1510 "alert http any any -> any any (file_data; content:\"bccd\"; depth:4; sid:1;)";
1511 return RunTest(steps, sig, yaml);
1513 static int DetectEngineHttpServerBodyFileDataTest19(
void)
1522 swf-decompression:\n\
1525 compress-depth: 0\n\
1526 decompress-depth: 0\n\
1528 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1529 "Host: www.openinfosecfoundation.org\r\n"
1530 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1531 "Gecko/20091221 Firefox/3.5.7\r\n"
1534 uint8_t http_buf2[] = {
1535 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
1536 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'1',
'0',
'3', 0x0d, 0x0a,
1537 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
1538 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'o',
'c',
't',
'e',
't',
'-',
's',
't',
'r',
'e',
'a',
'm', 0x0d, 0x0a,
1540 0x5a, 0x57, 0x53, 0x17, 0x5c, 0x24, 0x00, 0x00, 0xb7, 0x21, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x20,
1541 0x00, 0x00, 0x3b, 0xff, 0xfc, 0x8e, 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85,
1542 0xf5, 0x75, 0x6f, 0xd0, 0x7e, 0x61, 0x35, 0x1b, 0x1a, 0x8b, 0x16, 0x4d, 0xdf, 0x05, 0x32, 0xfe,
1543 0xa4, 0x4c, 0x46, 0x49, 0xb7, 0x7b, 0x6b, 0x75, 0xf9, 0x2b, 0x5c, 0x37, 0x29, 0x0b, 0x91, 0x37,
1544 0x01, 0x37, 0x0e, 0xe9, 0xf2, 0xe1, 0xfc, 0x9e, 0x64, 0xda, 0x6c, 0x11, 0x21, 0x33, 0xed, 0xa0,
1545 0x0e, 0x76, 0x70, 0xa0, 0xcd, 0x98, 0x2e, 0x76, 0x80, 0xf0, 0xe0, 0x59, 0x56, 0x06, 0x08, 0xe9,
1546 0xca, 0xeb, 0xa2, 0xc6, 0xdb, 0x5a, 0x86
1550 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1551 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1554 const char *sig =
"alert tcp any any -> any any "
1555 "(flow:established,from_server; "
1556 "file_data; content:\"FWS\"; "
1558 return RunTest(steps, sig,
input);
1561 static int DetectEngineHttpServerBodyFileDataTest20(
void)
1570 swf-decompression:\n\
1573 compress-depth: 0\n\
1574 decompress-depth: 0\n\
1576 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1577 "Host: www.openinfosecfoundation.org\r\n"
1578 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1579 "Gecko/20091221 Firefox/3.5.7\r\n"
1582 uint8_t http_buf2[] = {
1583 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
1584 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
1585 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
1586 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'x',
'-',
's',
'h',
'o',
'c',
'k',
'w',
'a',
'v',
'e',
'-',
'f',
'l',
'a',
's',
'h', 0x0d, 0x0a,
1588 0x43, 0x57, 0x53, 0x0a, 0xcb, 0x6c, 0x00, 0x00, 0x78, 0xda, 0xad, 0xbd, 0x07, 0x98, 0x55, 0x55,
1589 0x9e, 0xee, 0xbd, 0x4f, 0xd8, 0xb5, 0x4e, 0x15, 0xc1, 0xc2, 0x80, 0x28, 0x86, 0xd2, 0x2e, 0x5a,
1590 0xdb, 0x46, 0xd9, 0x39, 0x38, 0xdd, 0x4e, 0x1b, 0xa8, 0x56, 0x5b, 0xc5, 0x6b, 0xe8, 0x76, 0xfa,
1591 0x0e, 0xc2, 0x8e, 0x50, 0x76, 0x51, 0xc5, 0x54, 0x15, 0x88, 0x73, 0xc3, 0xd0, 0x88, 0x39, 0x81,
1592 0x98, 0x63, 0x91, 0x93, 0x8a, 0x82, 0x89, 0x60, 0x00, 0xcc, 0xb1, 0x00, 0x01, 0x73, 0xce, 0x39,
1596 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1597 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1600 const char *sig =
"alert tcp any any -> any any "
1601 "(flow:established,from_server; "
1602 "file_data; content:\"CWS\"; "
1604 return RunTest(steps, sig,
input);
1607 static int DetectEngineHttpServerBodyFileDataTest21(
void)
1616 swf-decompression:\n\
1619 compress-depth: 0\n\
1620 decompress-depth: 0\n\
1622 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1623 "Host: www.openinfosecfoundation.org\r\n"
1624 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1625 "Gecko/20091221 Firefox/3.5.7\r\n"
1628 uint8_t http_buf2[] = {
1629 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
1630 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
1631 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
1632 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'x',
'-',
's',
'h',
'o',
'c',
'k',
'w',
'a',
'v',
'e',
'-',
'f',
'l',
'a',
's',
'h', 0x0d, 0x0a,
1634 0x43, 0x57, 0x53, 0x0a, 0xcb, 0x6c, 0x00, 0x00, 0x78, 0xda, 0xad, 0xbd, 0x07, 0x98, 0x55, 0x55,
1635 0x9e, 0xee, 0xbd, 0x4f, 0xd8, 0xb5, 0x4e, 0x15, 0xc1, 0xc2, 0x80, 0x28, 0x86, 0xd2, 0x2e, 0x5a,
1636 0xdb, 0x46, 0xd9, 0x39, 0x38, 0xdd, 0x4e, 0x1b, 0xa8, 0x56, 0x5b, 0xc5, 0x6b, 0xe8, 0x76, 0xfa,
1637 0x0e, 0xc2, 0x8e, 0x50, 0x76, 0x51, 0xc5, 0x54, 0x15, 0x88, 0x73, 0xc3, 0xd0, 0x88, 0x39, 0x81,
1638 0x98, 0x63, 0x91, 0x93, 0x8a, 0x82, 0x89, 0x60, 0x00, 0xcc, 0xb1, 0x00, 0x01, 0x73, 0xce, 0x39,
1642 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1643 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1646 const char *sig =
"alert tcp any any -> any any "
1647 "(flow:established,from_server; "
1648 "file_data; content:\"FWS\"; "
1650 return RunTest(steps, sig,
input);
1653 static int DetectEngineHttpServerBodyFileDataTest22(
void)
1662 swf-decompression:\n\
1665 compress-depth: 0\n\
1666 decompress-depth: 0\n\
1668 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1669 "Host: www.openinfosecfoundation.org\r\n"
1670 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1671 "Gecko/20091221 Firefox/3.5.7\r\n"
1674 uint8_t http_buf2[] = {
1675 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
1676 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
1677 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
1678 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'x',
'-',
's',
'h',
'o',
'c',
'k',
'w',
'a',
'v',
'e',
'-',
'f',
'l',
'a',
's',
'h', 0x0d, 0x0a,
1680 0x43, 0x57, 0x53, 0x0a, 0xcb, 0x6c, 0x00, 0x00, 0x78, 0xda, 0xad, 0xbd, 0x07, 0x98, 0x55, 0x55,
1681 0x9e, 0xee, 0xbd, 0x4f, 0xd8, 0xb5, 0x4e, 0x15, 0xc1, 0xc2, 0x80, 0x28, 0x86, 0xd2, 0x2e, 0x5a,
1682 0xdb, 0x46, 0xd9, 0x39, 0x38, 0xdd, 0x4e, 0x1b, 0xa8, 0x56, 0x5b, 0xc5, 0x6b, 0xe8, 0x76, 0xfa,
1683 0x0e, 0xc2, 0x8e, 0x50, 0x76, 0x51, 0xc5, 0x54, 0x15, 0x88, 0x73, 0xc3, 0xd0, 0x88, 0x39, 0x81,
1684 0x98, 0x63, 0x91, 0x93, 0x8a, 0x82, 0x89, 0x60, 0x00, 0xcc, 0xb1, 0x00, 0x01, 0x73, 0xce, 0x39,
1688 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1689 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1692 const char *sig =
"alert tcp any any -> any any "
1693 "(flow:established,from_server; "
1694 "file_data; content:\"CWS\"; "
1696 return RunTest(steps, sig,
input);
1699 static int DetectEngineHttpServerBodyFileDataTest23(
void)
1708 swf-decompression:\n\
1711 compress-depth: 0\n\
1712 decompress-depth: 0\n\
1714 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1715 "Host: www.openinfosecfoundation.org\r\n"
1716 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1717 "Gecko/20091221 Firefox/3.5.7\r\n"
1720 uint8_t http_buf2[] = {
1721 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
1722 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
1723 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
1724 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'x',
'-',
's',
'h',
'o',
'c',
'k',
'w',
'a',
'v',
'e',
'-',
'f',
'l',
'a',
's',
'h', 0x0d, 0x0a,
1726 0x43, 0x57, 0x53, 0x01, 0xcb, 0x6c, 0x00, 0x00, 0x78, 0xda, 0xad, 0xbd, 0x07, 0x98, 0x55, 0x55,
1727 0x9e, 0xee, 0xbd, 0x4f, 0xd8, 0xb5, 0x4e, 0x15, 0xc1, 0xc2, 0x80, 0x28, 0x86, 0xd2, 0x2e, 0x5a,
1728 0xdb, 0x46, 0xd9, 0x39, 0x38, 0xdd, 0x4e, 0x1b, 0xa8, 0x56, 0x5b, 0xc5, 0x6b, 0xe8, 0x76, 0xfa,
1729 0x0e, 0xc2, 0x8e, 0x50, 0x76, 0x51, 0xc5, 0x54, 0x15, 0x88, 0x73, 0xc3, 0xd0, 0x88, 0x39, 0x81,
1730 0x98, 0x63, 0x91, 0x93, 0x8a, 0x82, 0x89, 0x60, 0x00, 0xcc, 0xb1, 0x00, 0x01, 0x73, 0xce, 0x39,
1734 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1735 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1738 const char *sig =
"alert tcp any any -> any any "
1739 "(flow:established,from_server; "
1740 "file_data; content:\"CWS\"; "
1742 return RunTest(steps, sig,
input);
1745 static int DetectEngineHttpServerBodyFileDataTest24(
void)
1754 swf-decompression:\n\
1757 compress-depth: 0\n\
1758 decompress-depth: 0\n\
1760 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1761 "Host: www.openinfosecfoundation.org\r\n"
1762 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1763 "Gecko/20091221 Firefox/3.5.7\r\n"
1765 uint8_t http_buf2[] = {
'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k',
1766 0x0d, 0x0a,
'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
1767 '1',
'0',
'3', 0x0d, 0x0a,
'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
1768 ' ',
'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'o',
'c',
't',
'e',
't',
1769 '-',
's',
't',
'r',
'e',
'a',
'm', 0x0d, 0x0a, 0x0d, 0x0a, 0x5a, 0x57, 0x53, 0x17, 0x5c,
1770 0x24, 0x00, 0x00, 0xb7, 0x21, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x20, 0x00, 0x00, 0x3b, 0xff,
1771 0xfc, 0x8e, 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85, 0xf5, 0x75, 0x6f,
1772 0xd0, 0x7e, 0x61, 0x35, 0x1b, 0x1a, 0x8b, 0x16, 0x4d, 0xdf, 0x05, 0x32, 0xfe, 0xa4, 0x4c,
1773 0x46, 0x49, 0xb7, 0x7b, 0x6b, 0x75, 0xf9, 0x2b, 0x5c, 0x37, 0x29, 0x0b, 0x91, 0x37, 0x01,
1774 0x37, 0x0e, 0xe9, 0xf2, 0xe1, 0xfc, 0x9e, 0x64, 0xda, 0x6c, 0x11, 0x21, 0x33, 0xed, 0xa0,
1775 0x0e, 0x76, 0x70, 0xa0, 0xcd, 0x98, 0x2e, 0x76, 0x80, 0xf0, 0xe0, 0x59, 0x56, 0x06, 0x08,
1776 0xe9, 0xca, 0xeb, 0xa2, 0xc6, 0xdb, 0x5a, 0x86 };
1778 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1779 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1782 const char *sig =
"alert tcp any any -> any any "
1783 "(flow:established,from_server; "
1784 "file_data; content:\"FWS\"; "
1786 return RunTest(steps, sig,
input);
1789 static int DetectEngineHttpServerBodyFileDataTest25(
void)
1798 swf-decompression:\n\
1801 compress-depth: 0\n\
1802 decompress-depth: 0\n\
1804 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1805 "Host: www.openinfosecfoundation.org\r\n"
1806 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1807 "Gecko/20091221 Firefox/3.5.7\r\n"
1809 uint8_t http_buf2[] = {
'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k',
1810 0x0d, 0x0a,
'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
1811 '1',
'0',
'3', 0x0d, 0x0a,
'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
1812 ' ',
'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'o',
'c',
't',
'e',
't',
1813 '-',
's',
't',
'r',
'e',
'a',
'm', 0x0d, 0x0a, 0x0d, 0x0a, 0x5a, 0x57, 0x53, 0x17, 0x5c,
1814 0x24, 0x00, 0x00, 0xb7, 0x21, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x20, 0x00, 0x00, 0x3b, 0xff,
1815 0xfc, 0x8e, 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85, 0xf5, 0x75, 0x6f,
1816 0xd0, 0x7e, 0x61, 0x35, 0x1b, 0x1a, 0x8b, 0x16, 0x4d, 0xdf, 0x05, 0x32, 0xfe, 0xa4, 0x4c,
1817 0x46, 0x49, 0xb7, 0x7b, 0x6b, 0x75, 0xf9, 0x2b, 0x5c, 0x37, 0x29, 0x0b, 0x91, 0x37, 0x01,
1818 0x37, 0x0e, 0xe9, 0xf2, 0xe1, 0xfc, 0x9e, 0x64, 0xda, 0x6c, 0x11, 0x21, 0x33, 0xed, 0xa0,
1819 0x0e, 0x76, 0x70, 0xa0, 0xcd, 0x98, 0x2e, 0x76, 0x80, 0xf0, 0xe0, 0x59, 0x56, 0x06, 0x08,
1820 0xe9, 0xca, 0xeb, 0xa2, 0xc6, 0xdb, 0x5a, 0x86 };
1822 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1823 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1826 const char *sig =
"alert tcp any any -> any any "
1827 "(flow:established,from_server; "
1828 "file_data; content:\"ZWS\"; "
1830 return RunTest(steps, sig,
input);
1833 static int DetectEngineHttpServerBodyFileDataTest26(
void)
1842 swf-decompression:\n\
1845 compress-depth: 0\n\
1846 decompress-depth: 0\n\
1848 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1849 "Host: www.openinfosecfoundation.org\r\n"
1850 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1851 "Gecko/20091221 Firefox/3.5.7\r\n"
1853 uint8_t http_buf2[] = {
'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k',
1854 0x0d, 0x0a,
'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
1855 '1',
'0',
'3', 0x0d, 0x0a,
'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
1856 ' ',
'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'o',
'c',
't',
'e',
't',
1857 '-',
's',
't',
'r',
'e',
'a',
'm', 0x0d, 0x0a, 0x0d, 0x0a, 0x5a, 0x57, 0x53, 0x17, 0x5c,
1858 0x24, 0x00, 0x00, 0xb7, 0x21, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x20, 0x00, 0x00, 0x3b, 0xff,
1859 0xfc, 0x8e, 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85, 0xf5, 0x75, 0x6f,
1860 0xd0, 0x7e, 0x61, 0x35, 0x1b, 0x1a, 0x8b, 0x16, 0x4d, 0xdf, 0x05, 0x32, 0xfe, 0xa4, 0x4c,
1861 0x46, 0x49, 0xb7, 0x7b, 0x6b, 0x75, 0xf9, 0x2b, 0x5c, 0x37, 0x29, 0x0b, 0x91, 0x37, 0x01,
1862 0x37, 0x0e, 0xe9, 0xf2, 0xe1, 0xfc, 0x9e, 0x64, 0xda, 0x6c, 0x11, 0x21, 0x33, 0xed, 0xa0,
1863 0x0e, 0x76, 0x70, 0xa0, 0xcd, 0x98, 0x2e, 0x76, 0x80, 0xf0, 0xe0, 0x59, 0x56, 0x06, 0x08,
1864 0xe9, 0xca, 0xeb, 0xa2, 0xc6, 0xdb, 0x5a, 0x86 };
1866 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1867 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1870 const char *sig =
"alert tcp any any -> any any "
1871 "(flow:established,from_server; "
1872 "file_data; content:\"FWS\"; "
1874 return RunTest(steps, sig,
input);
1877 static int DetectEngineHttpServerBodyFileDataTest27(
void)
1886 swf-decompression:\n\
1889 compress-depth: 0\n\
1890 decompress-depth: 0\n\
1892 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1893 "Host: www.openinfosecfoundation.org\r\n"
1894 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1895 "Gecko/20091221 Firefox/3.5.7\r\n"
1898 uint8_t http_buf2[] = {
1899 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
1900 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
1901 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
1902 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'o',
'c',
't',
'e',
't',
'-',
's',
't',
'r',
'e',
'a',
'm', 0x0d, 0x0a,
1904 0x5a, 0x57, 0x53, 0x17, 0x5c, 0x24, 0x00, 0x00, 0xb7, 0x21, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x20,
1905 0x00, 0x00, 0x3b, 0xff, 0xfc, 0x8e, 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85,
1906 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85, 0xf5, 0x75, 0x6f, 0xd0, 0x7e, 0x61,
1907 0x35, 0x1b, 0x1a, 0x8b, 0x16, 0x4d, 0xdf, 0x05, 0x32, 0xfe, 0xa4, 0x4c, 0x46, 0x49, 0xb7, 0x7b,
1908 0x6b, 0x75, 0xf9, 0x2b, 0x5c, 0x37, 0x29, 0x0b, 0x91, 0x37, 0x01, 0x37, 0x0e, 0xe9, 0xf2, 0xe1,
1912 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1913 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1916 const char *sig =
"alert tcp any any -> any any "
1917 "(flow:established,from_server; "
1918 "file_data; content:\"ZWS\"; "
1920 return RunTest(steps, sig,
input);
1923 static int DetectEngineHttpServerBodyFileDataTest28(
void)
1932 swf-decompression:\n\
1935 compress-depth: 0\n\
1936 decompress-depth: 0\n\
1938 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1939 "Host: www.openinfosecfoundation.org\r\n"
1940 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1941 "Gecko/20091221 Firefox/3.5.7\r\n"
1944 uint8_t http_buf2[] = {
1945 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
1946 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
1947 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
1948 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'o',
'c',
't',
'e',
't',
'-',
's',
't',
'r',
'e',
'a',
'm', 0x0d, 0x0a,
1950 0x5a, 0x57, 0x53, 0x01, 0x5c, 0x24, 0x00, 0x00, 0xb7, 0x21, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x20,
1951 0x00, 0x00, 0x3b, 0xff, 0xfc, 0x8e, 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85,
1952 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85, 0xf5, 0x75, 0x6f, 0xd0, 0x7e, 0x61,
1953 0x35, 0x1b, 0x1a, 0x8b, 0x16, 0x4d, 0xdf, 0x05, 0x32, 0xfe, 0xa4, 0x4c, 0x46, 0x49, 0xb7, 0x7b,
1954 0x6b, 0x75, 0xf9, 0x2b, 0x5c, 0x37, 0x29, 0x0b, 0x91, 0x37, 0x01, 0x37, 0x0e, 0xe9, 0xf2, 0xe1,
1958 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1959 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1962 const char *sig =
"alert tcp any any -> any any "
1963 "(flow:established,from_server; "
1964 "file_data; content:\"ZWS\"; "
1966 return RunTest(steps, sig,
input);
1969 static int DetectEngineHttpServerBodyFileDataTest29(
void)
1978 swf-decompression:\n\
1981 compress-depth: 1000\n\
1982 decompress-depth: 0\n\
1984 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1985 "Host: www.openinfosecfoundation.org\r\n"
1986 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1987 "Gecko/20091221 Firefox/3.5.7\r\n"
1990 uint8_t http_buf2[] = {
1991 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
1992 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
1993 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
1994 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'x',
'-',
's',
'h',
'o',
'c',
'k',
'w',
'a',
'v',
'e',
'-',
'f',
'l',
'a',
's',
'h', 0x0d, 0x0a,
1996 0x43, 0x57, 0x53, 0x0a, 0xcb, 0x6c, 0x00, 0x00, 0x78, 0xda, 0xad, 0xbd, 0x07, 0x98, 0x55, 0x55,
1997 0x9e, 0xee, 0xbd, 0x4f, 0xd8, 0xb5, 0x4e, 0x15, 0xc1, 0xc2, 0x80, 0x28, 0x86, 0xd2, 0x2e, 0x5a,
1998 0xdb, 0x46, 0xd9, 0x39, 0x38, 0xdd, 0x4e, 0x1b, 0xa8, 0x56, 0x5b, 0xc5, 0x6b, 0xe8, 0x76, 0xfa,
1999 0x0e, 0xc2, 0x8e, 0x50, 0x76, 0x51, 0xc5, 0x54, 0x15, 0x88, 0x73, 0xc3, 0xd0, 0x88, 0x39, 0x81,
2000 0x98, 0x63, 0x91, 0x93, 0x8a, 0x82, 0x89, 0x60, 0x00, 0xcc, 0xb1, 0x00, 0x01, 0x73, 0xce, 0x39,
2004 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2005 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
2008 const char *sig =
"alert tcp any any -> any any "
2009 "(flow:established,from_server; "
2010 "file_data; content:\"FWS\"; "
2012 return RunTest(steps, sig,
input);
2019 static int DetectHttpServerBodyTest06(
void)
2021 uint8_t http_buf[] =
"GET /index.html HTTP/1.0\r\n"
2022 "Host: www.openinfosecfoundation.org\r\n"
2023 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2024 "Gecko/20091221 Firefox/3.5.7\r\n"
2026 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2027 "Content-Type: text/html\r\n"
2028 "Content-Length: 7\r\n"
2032 { (
const uint8_t *)http_buf,
sizeof(http_buf) - 1, STREAM_TOSERVER, 0 },
2033 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
2036 const char *sig =
"alert http any any -> any any "
2037 "(msg:\"http server body test\"; "
2038 "content:\"message\"; http_server_body; "
2040 return RunTest(steps, sig, NULL);
2047 static int DetectHttpServerBodyTest07(
void)
2049 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2050 "Host: www.openinfosecfoundation.org\r\n"
2051 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2052 "Gecko/20091221 Firefox/3.5.7\r\n"
2054 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2055 "Content-Type: text/html\r\n"
2056 "Content-Length: 14\r\n"
2058 uint8_t http_buf3[] =
"message";
2060 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2061 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2062 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT | STREAM_EOF, 1 },
2065 const char *sig =
"alert http any any -> any any "
2066 "(msg:\"http server body test\"; "
2067 "content:\"message\"; http_server_body; "
2069 return RunTest(steps, sig, NULL);
2076 static int DetectHttpServerBodyTest08(
void)
2078 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2079 "Host: www.openinfosecfoundation.org\r\n"
2080 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2081 "Gecko/20091221 Firefox/3.5.7\r\n"
2083 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2084 "Content-Type: text/html\r\n"
2085 "Content-Length: 14\r\n"
2088 uint8_t http_buf3[] =
"sage4u!!";
2090 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2091 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2092 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 1 },
2095 const char *sig =
"alert http any any -> any any "
2096 "(msg:\"http client body test\"; "
2097 "content:\"message\"; http_server_body; "
2099 return RunTest(steps, sig, NULL);
2106 static int DetectHttpServerBodyTest09(
void)
2108 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2109 "Host: www.openinfosecfoundation.org\r\n"
2110 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2111 "Gecko/20091221 Firefox/3.5.7\r\n"
2113 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2114 "Content-Type: text/html\r\n"
2115 "Content-Length: 14\r\n"
2118 uint8_t http_buf3[] =
"sag";
2119 uint8_t http_buf4[] =
"e4u!!";
2121 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2122 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2123 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 0 },
2124 { (
const uint8_t *)http_buf4,
sizeof(http_buf4) - 1, STREAM_TOCLIENT, 1 },
2127 const char *sig =
"alert http any any -> any any "
2128 "(msg:\"http client body test\"; "
2129 "content:\"message\"; http_server_body; "
2131 return RunTest(steps, sig, NULL);
2138 static int DetectHttpServerBodyTest10(
void)
2140 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2141 "Host: www.openinfosecfoundation.org\r\n"
2142 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2143 "Gecko/20091221 Firefox/3.5.7\r\n"
2145 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2146 "Content-Type: text/html\r\n"
2147 "Content-Length: 14\r\n"
2150 uint8_t http_buf3[] =
"sag";
2151 uint8_t http_buf4[] =
2154 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2155 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2156 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 0 },
2157 { (
const uint8_t *)http_buf4,
sizeof(http_buf4) - 1, STREAM_TOCLIENT, 1 },
2160 const char *sig =
"alert http any any -> any any "
2161 "(msg:\"http client body test\"; "
2162 "content:\"MeSSaGE\"; http_server_body; nocase; "
2164 return RunTest(steps, sig, NULL);
2171 static int DetectHttpServerBodyTest11(
void)
2173 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2174 "Host: www.openinfosecfoundation.org\r\n"
2175 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2176 "Gecko/20091221 Firefox/3.5.7\r\n"
2178 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2179 "Content-Type: text/html\r\n"
2180 "Content-Length: 14\r\n"
2182 uint8_t http_buf3[] =
"bigmessage4u!!";
2184 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2185 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2186 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 1 },
2189 const char *sig =
"alert http any any -> any any "
2190 "(msg:\"http client body test\"; "
2191 "content:!\"MaSSaGE\"; http_server_body; nocase; "
2193 return RunTest(steps, sig, NULL);
2200 static int DetectHttpServerBodyTest12(
void)
2202 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2203 "Host: www.openinfosecfoundation.org\r\n"
2204 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2205 "Gecko/20091221 Firefox/3.5.7\r\n"
2207 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2208 "Content-Type: text/html\r\n"
2209 "Content-Length: 14\r\n"
2211 uint8_t http_buf3[] =
"bigmessage4u!!";
2213 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2214 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2215 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 0 },
2218 const char *sig =
"alert http any any -> any any "
2219 "(msg:\"http client body test\"; "
2220 "content:!\"MeSSaGE\"; http_server_body; nocase; "
2222 return RunTest(steps, sig, NULL);
2225 static int DetectHttpServerBodyTest13(
void)
2227 uint8_t http_buf[] =
"GET /index.html HTTP/1.0\r\n"
2228 "Host: www.openinfosecfoundation.org\r\n"
2229 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2230 "Gecko/20091221 Firefox/3.5.7\r\n"
2232 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2233 "Content-Type: text/html\r\n"
2234 "Content-Length: 55\r\n"
2236 "longbufferabcdefghijklmnopqrstuvwxyz0123456789bufferend";
2238 { (
const uint8_t *)http_buf,
sizeof(http_buf) - 1, STREAM_TOSERVER, 0 },
2239 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
2242 const char *sig =
"alert http any any -> any any "
2243 "(msg:\"http server body test\"; "
2244 "content:\"longbufferabcdefghijklmnopqrstuvwxyz0123456789bufferend\"; "
2245 "http_server_body; "
2247 return RunTest(steps, sig, NULL);
2251 static int DetectHttpServerBodyTest14(
void)
2257 uint8_t httpbuf1[] =
"GET /index1.html HTTP/1.1\r\n"
2258 "User-Agent: Mozilla/1.0\r\n"
2259 "Host: www.openinfosecfoundation.org\r\n"
2260 "Connection: keep-alive\r\n"
2261 "Cookie: dummy1\r\n\r\n";
2262 uint32_t httplen1 =
sizeof(httpbuf1) - 1;
2263 uint8_t httpbuf2[] =
"HTTP/1.1 200 ok\r\n"
2264 "Content-Type: text/html\r\n"
2265 "Content-Length: 3\r\n"
2268 uint32_t httplen2 =
sizeof(httpbuf2) - 1;
2269 uint8_t httpbuf3[] =
"GET /index2.html HTTP/1.1\r\n"
2270 "User-Agent: Firefox/1.0\r\n"
2271 "Host: www.openinfosecfoundation.org\r\n"
2272 "Connection: keep-alive\r\n"
2273 "Cookie: dummy2\r\n\r\n";
2274 uint32_t httplen3 =
sizeof(httpbuf3) - 1;
2275 uint8_t httpbuf4[] =
"HTTP/1.1 200 ok\r\n"
2276 "Content-Type: text/html\r\n"
2277 "Content-Length: 3\r\n"
2280 uint32_t httplen4 =
sizeof(httpbuf4) - 1;
2282 memset(&th_v, 0,
sizeof(th_v));
2283 memset(&f, 0,
sizeof(f));
2284 memset(&ssn, 0,
sizeof(ssn));
2291 f.
proto = IPPROTO_TCP;
2307 "alert tcp any any -> any any (flow:established,to_client; "
2308 "content:\"one\"; http_server_body; sid:1; rev:1;)");
2311 "content:\"two\"; http_server_body; sid:2; rev:1;)");
2368 static int DetectHttpServerBodyTest15(
void)
2374 uint8_t httpbuf1[] =
"GET /index1.html HTTP/1.1\r\n"
2375 "User-Agent: Mozilla/1.0\r\n"
2376 "Host: www.openinfosecfoundation.org\r\n"
2377 "Connection: keep-alive\r\n"
2378 "Cookie: dummy1\r\n\r\n";
2379 uint32_t httplen1 =
sizeof(httpbuf1) - 1;
2380 uint8_t httpbuf2[] =
"HTTP/1.1 200 ok\r\n"
2381 "Content-Type: text/html\r\n"
2382 "Content-Length: 3\r\n"
2385 uint32_t httplen2 =
sizeof(httpbuf2) - 1;
2386 uint8_t httpbuf3[] =
"GET /index2.html HTTP/1.1\r\n"
2387 "User-Agent: Firefox/1.0\r\n"
2388 "Host: www.openinfosecfoundation.org\r\n"
2389 "Connection: keep-alive\r\n"
2390 "Cookie: dummy2\r\n\r\n";
2391 uint32_t httplen3 =
sizeof(httpbuf3) - 1;
2392 uint8_t httpbuf4[] =
"HTTP/1.1 200 ok\r\n"
2393 "Content-Type: text/html\r\n"
2394 "Content-Length: 3\r\n"
2397 uint32_t httplen4 =
sizeof(httpbuf4) - 1;
2399 memset(&th_v, 0,
sizeof(th_v));
2400 memset(&f, 0,
sizeof(f));
2401 memset(&ssn, 0,
sizeof(ssn));
2408 f.
proto = IPPROTO_TCP;
2424 "alert tcp any any -> any any (flow:established,to_client; "
2425 "content:\"one\"; http_server_body; sid:1; rev:1;)");
2428 "content:\"two\"; http_server_body; sid:2; rev:1;)");
2479 static int DetectHttpServerBodyFileDataTest01(
void)
2481 uint8_t http_buf[] =
"GET /index.html HTTP/1.0\r\n"
2482 "Host: www.openinfosecfoundation.org\r\n"
2483 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2484 "Gecko/20091221 Firefox/3.5.7\r\n"
2486 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2487 "Content-Type: text/html\r\n"
2488 "Content-Length: 7\r\n"
2492 { (
const uint8_t *)http_buf,
sizeof(http_buf) - 1, STREAM_TOSERVER, 0 },
2493 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
2496 const char *sig =
"alert http any any -> any any "
2497 "(msg:\"http server body test\"; "
2498 "file_data; content:\"message\"; "
2500 return RunTest(steps, sig, NULL);
2507 static int DetectHttpServerBodyFileDataTest02(
void)
2509 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2510 "Host: www.openinfosecfoundation.org\r\n"
2511 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2512 "Gecko/20091221 Firefox/3.5.7\r\n"
2514 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2515 "Content-Type: text/html\r\n"
2516 "Content-Length: 14\r\n"
2518 uint8_t http_buf3[] =
"message";
2520 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2521 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2522 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT | STREAM_EOF, 1 },
2525 const char *sig =
"alert http any any -> any any "
2526 "(msg:\"http server body test\"; "
2527 "file_data; content:\"message\"; "
2529 return RunTest(steps, sig, NULL);
2536 static int DetectHttpServerBodyFileDataTest03(
void)
2538 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2539 "Host: www.openinfosecfoundation.org\r\n"
2540 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2541 "Gecko/20091221 Firefox/3.5.7\r\n"
2543 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2544 "Content-Type: text/html\r\n"
2545 "Content-Length: 14\r\n"
2548 uint8_t http_buf3[] =
"sage4u!!";
2550 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2551 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2552 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 1 },
2555 const char *sig =
"alert http any any -> any any "
2556 "(msg:\"http server body test\"; "
2557 "file_data; content:\"message\"; "
2559 return RunTest(steps, sig, NULL);
2566 static int DetectHttpServerBodyFileDataTest04(
void)
2568 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2569 "Host: www.openinfosecfoundation.org\r\n"
2570 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2571 "Gecko/20091221 Firefox/3.5.7\r\n"
2573 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2574 "Content-Type: text/html\r\n"
2575 "Content-Length: 14\r\n"
2578 uint8_t http_buf3[] =
"sag";
2579 uint8_t http_buf4[] =
"e4u!!";
2581 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2582 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2583 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 0 },
2584 { (
const uint8_t *)http_buf4,
sizeof(http_buf4) - 1, STREAM_TOCLIENT, 1 },
2587 const char *sig =
"alert http any any -> any any "
2588 "(msg:\"http server body test\"; "
2589 "file_data; content:\"message\"; "
2591 return RunTest(steps, sig, NULL);
2598 static int DetectHttpServerBodyFileDataTest05(
void)
2600 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2601 "Host: www.openinfosecfoundation.org\r\n"
2602 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2603 "Gecko/20091221 Firefox/3.5.7\r\n"
2605 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2606 "Content-Type: text/html\r\n"
2607 "Content-Length: 14\r\n"
2610 uint8_t http_buf3[] =
"sag";
2611 uint8_t http_buf4[] =
"e4u!!";
2613 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2614 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2615 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 0 },
2616 { (
const uint8_t *)http_buf4,
sizeof(http_buf4) - 1, STREAM_TOCLIENT, 1 },
2619 const char *sig =
"alert http any any -> any any "
2620 "(msg:\"http client body test\"; "
2621 "file_data; content:\"MeSSaGE\"; nocase; "
2623 return RunTest(steps, sig, NULL);
2630 static int DetectHttpServerBodyFileDataTest06(
void)
2632 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2633 "Host: www.openinfosecfoundation.org\r\n"
2634 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2635 "Gecko/20091221 Firefox/3.5.7\r\n"
2637 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2638 "Content-Type: text/html\r\n"
2639 "Content-Length: 14\r\n"
2641 uint8_t http_buf3[] =
"bigmessage4u!!";
2643 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2644 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2645 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 1 },
2648 const char *sig =
"alert http any any -> any any "
2649 "(msg:\"http file_data test\"; "
2650 "file_data; content:!\"MaSSaGE\"; nocase; "
2652 return RunTest(steps, sig, NULL);
2659 static int DetectHttpServerBodyFileDataTest07(
void)
2661 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2662 "Host: www.openinfosecfoundation.org\r\n"
2663 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2664 "Gecko/20091221 Firefox/3.5.7\r\n"
2666 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2667 "Content-Type: text/html\r\n"
2668 "Content-Length: 14\r\n"
2670 uint8_t http_buf3[] =
"bigmessage4u!!";
2672 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2673 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2674 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 0 },
2677 const char *sig =
"alert http any any -> any any "
2678 "(msg:\"http file_data test\"; "
2679 "file_data; content:!\"MeSSaGE\"; nocase; "
2681 return RunTest(steps, sig, NULL);
2684 static int DetectHttpServerBodyFileDataTest08(
void)
2686 uint8_t http_buf[] =
"GET /index.html HTTP/1.0\r\n"
2687 "Host: www.openinfosecfoundation.org\r\n"
2688 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2689 "Gecko/20091221 Firefox/3.5.7\r\n"
2691 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2692 "Content-Type: text/html\r\n"
2693 "Content-Length: 55\r\n"
2695 "longbufferabcdefghijklmnopqrstuvwxyz0123456789bufferend";
2697 { (
const uint8_t *)http_buf,
sizeof(http_buf) - 1, STREAM_TOSERVER, 0 },
2698 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
2702 "alert http any any -> any any "
2703 "(msg:\"http server body test\"; "
2704 "file_data; content:\"longbufferabcdefghijklmnopqrstuvwxyz0123456789bufferend\"; "
2706 return RunTest(steps, sig, NULL);
2710 static int DetectHttpServerBodyFileDataTest09(
void)
2716 uint8_t httpbuf1[] =
"GET /index1.html HTTP/1.1\r\n"
2717 "User-Agent: Mozilla/1.0\r\n"
2718 "Host: www.openinfosecfoundation.org\r\n"
2719 "Connection: keep-alive\r\n"
2720 "Cookie: dummy1\r\n\r\n";
2721 uint32_t httplen1 =
sizeof(httpbuf1) - 1;
2722 uint8_t httpbuf2[] =
"HTTP/1.1 200 ok\r\n"
2723 "Content-Type: text/html\r\n"
2724 "Content-Length: 3\r\n"
2727 uint32_t httplen2 =
sizeof(httpbuf2) - 1;
2728 uint8_t httpbuf3[] =
"GET /index2.html HTTP/1.1\r\n"
2729 "User-Agent: Firefox/1.0\r\n"
2730 "Host: www.openinfosecfoundation.org\r\n"
2731 "Connection: keep-alive\r\n"
2732 "Cookie: dummy2\r\n\r\n";
2733 uint32_t httplen3 =
sizeof(httpbuf3) - 1;
2734 uint8_t httpbuf4[] =
"HTTP/1.1 200 ok\r\n"
2735 "Content-Type: text/html\r\n"
2736 "Content-Length: 3\r\n"
2739 uint32_t httplen4 =
sizeof(httpbuf4) - 1;
2741 memset(&th_v, 0,
sizeof(th_v));
2742 memset(&f, 0,
sizeof(f));
2743 memset(&ssn, 0,
sizeof(ssn));
2750 f.
proto = IPPROTO_TCP;
2766 "alert tcp any any -> any any (flow:established,to_client; file_data; "
2767 "content:\"one\"; sid:1; rev:1;)");
2769 s =
DetectEngineAppendSig(
de_ctx,
"alert tcp any any -> any any (flow:established,to_client; file_data; content:\"two\"; sid:2; rev:1;)");
2814 static int DetectHttpServerBodyFileDataTest10(
void)
2820 uint8_t httpbuf1[] =
"GET /index1.html HTTP/1.1\r\n"
2821 "User-Agent: Mozilla/1.0\r\n"
2822 "Host: www.openinfosecfoundation.org\r\n"
2823 "Connection: keep-alive\r\n"
2824 "Cookie: dummy1\r\n\r\n";
2825 uint32_t httplen1 =
sizeof(httpbuf1) - 1;
2826 uint8_t httpbuf2[] =
"HTTP/1.1 200 ok\r\n"
2827 "Content-Type: text/html\r\n"
2828 "Content-Length: 3\r\n"
2831 uint32_t httplen2 =
sizeof(httpbuf2) - 1;
2832 uint8_t httpbuf3[] =
"GET /index2.html HTTP/1.1\r\n"
2833 "User-Agent: Firefox/1.0\r\n"
2834 "Host: www.openinfosecfoundation.org\r\n"
2835 "Connection: keep-alive\r\n"
2836 "Cookie: dummy2\r\n\r\n";
2837 uint32_t httplen3 =
sizeof(httpbuf3) - 1;
2838 uint8_t httpbuf4[] =
"HTTP/1.1 200 ok\r\n"
2839 "Content-Type: text/html\r\n"
2840 "Content-Length: 3\r\n"
2843 uint32_t httplen4 =
sizeof(httpbuf4) - 1;
2845 memset(&th_v, 0,
sizeof(th_v));
2846 memset(&f, 0,
sizeof(f));
2847 memset(&ssn, 0,
sizeof(ssn));
2854 f.
proto = IPPROTO_TCP;
2870 "alert tcp any any -> any any (flow:established,to_client; file_data; "
2871 "content:\"one\"; sid:1; rev:1;)");
2873 s =
DetectEngineAppendSig(
de_ctx,
"alert tcp any any -> any any (flow:established,to_client; file_data; content:\"two\"; sid:2; rev:1;)");
2920 UtRegisterTest(
"DetectHttpServerBodyParserTest01", DetectHttpServerBodyParserTest01);
2921 UtRegisterTest(
"DetectHttpServerBodyParserTest02", DetectHttpServerBodyParserTest02);
2923 UtRegisterTest(
"DetectHttpServerBodyTest06", DetectHttpServerBodyTest06);
2924 UtRegisterTest(
"DetectHttpServerBodyTest07", DetectHttpServerBodyTest07);
2925 UtRegisterTest(
"DetectHttpServerBodyTest08", DetectHttpServerBodyTest08);
2926 UtRegisterTest(
"DetectHttpServerBodyTest09", DetectHttpServerBodyTest09);
2927 UtRegisterTest(
"DetectHttpServerBodyTest10", DetectHttpServerBodyTest10);
2928 UtRegisterTest(
"DetectHttpServerBodyTest11", DetectHttpServerBodyTest11);
2929 UtRegisterTest(
"DetectHttpServerBodyTest12", DetectHttpServerBodyTest12);
2930 UtRegisterTest(
"DetectHttpServerBodyTest13", DetectHttpServerBodyTest13);
2931 UtRegisterTest(
"DetectHttpServerBodyTest14", DetectHttpServerBodyTest14);
2932 UtRegisterTest(
"DetectHttpServerBodyTest15", DetectHttpServerBodyTest15);
2935 DetectHttpServerBodyFileDataTest01);
2937 DetectHttpServerBodyFileDataTest02);
2939 DetectHttpServerBodyFileDataTest03);
2941 DetectHttpServerBodyFileDataTest04);
2943 DetectHttpServerBodyFileDataTest05);
2945 DetectHttpServerBodyFileDataTest06);
2947 DetectHttpServerBodyFileDataTest07);
2949 DetectHttpServerBodyFileDataTest08);
2951 DetectHttpServerBodyFileDataTest09);
2953 DetectHttpServerBodyFileDataTest10);
2956 DetectEngineHttpServerBodyTest01);
2958 DetectEngineHttpServerBodyTest02);
2960 DetectEngineHttpServerBodyTest03);
2962 DetectEngineHttpServerBodyTest04);
2964 DetectEngineHttpServerBodyTest05);
2966 DetectEngineHttpServerBodyTest06);
2968 DetectEngineHttpServerBodyTest07);
2970 DetectEngineHttpServerBodyTest08);
2972 DetectEngineHttpServerBodyTest09);
2974 DetectEngineHttpServerBodyTest10);
2976 DetectEngineHttpServerBodyTest11);
2978 DetectEngineHttpServerBodyTest12);
2980 DetectEngineHttpServerBodyTest13);
2982 DetectEngineHttpServerBodyTest14);
2984 DetectEngineHttpServerBodyTest15);
2986 DetectEngineHttpServerBodyTest16);
2988 DetectEngineHttpServerBodyTest17);
2990 DetectEngineHttpServerBodyTest18);
2992 DetectEngineHttpServerBodyTest19);
2994 DetectEngineHttpServerBodyTest20);
2996 DetectEngineHttpServerBodyTest21);
2998 DetectEngineHttpServerBodyTest22);
3001 DetectEngineHttpServerBodyFileDataTest01);
3003 DetectEngineHttpServerBodyFileDataTest02);
3005 DetectEngineHttpServerBodyFileDataTest03);
3007 DetectEngineHttpServerBodyFileDataTest04);
3009 DetectEngineHttpServerBodyFileDataTest05);
3011 DetectEngineHttpServerBodyFileDataTest06);
3013 DetectEngineHttpServerBodyFileDataTest07);
3015 DetectEngineHttpServerBodyFileDataTest08);
3017 DetectEngineHttpServerBodyFileDataTest09);
3019 DetectEngineHttpServerBodyFileDataTest10);
3021 DetectEngineHttpServerBodyFileDataTest11);
3023 DetectEngineHttpServerBodyFileDataTest12);
3025 DetectEngineHttpServerBodyFileDataTest13);
3027 DetectEngineHttpServerBodyFileDataTest14);
3029 DetectEngineHttpServerBodyFileDataTest15);
3031 DetectEngineHttpServerBodyFileDataTest16);
3033 DetectEngineHttpServerBodyFileDataTest17);
3035 DetectEngineHttpServerBodyFileDataTest18);
3038 DetectEngineHttpServerBodyFileDataTest19);
3040 DetectEngineHttpServerBodyFileDataTest20);
3042 DetectEngineHttpServerBodyFileDataTest21);
3044 DetectEngineHttpServerBodyFileDataTest22);
3046 DetectEngineHttpServerBodyFileDataTest23);
3048 DetectEngineHttpServerBodyFileDataTest24);
3050 DetectEngineHttpServerBodyFileDataTest25);
3052 DetectEngineHttpServerBodyFileDataTest26);
3054 DetectEngineHttpServerBodyFileDataTest27);
3056 DetectEngineHttpServerBodyFileDataTest28);
3058 DetectEngineHttpServerBodyFileDataTest29);