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));
86 memset(&f, 0,
sizeof(f));
87 memset(&ssn, 0,
sizeof(ssn));
107 f.
proto = IPPROTO_TCP;
121 while (b->
input != NULL) {
165 static int DetectEngineHttpServerBodyTest01(
void)
167 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
168 "Host: www.openinfosecfoundation.org\r\n"
169 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
170 "Gecko/20091221 Firefox/3.5.7\r\n"
172 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
173 "Content-Type: text/html\r\n"
174 "Content-Length: 7\r\n"
178 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
179 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
183 const char *sig =
"alert http any any -> any any "
184 "(msg:\"http server body test\"; "
185 "content:\"message\"; http_server_body; "
187 return RunTest(steps, sig, NULL);
190 static int DetectEngineHttpServerBodyTest02(
void)
192 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
193 "Host: www.openinfosecfoundation.org\r\n"
194 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
195 "Gecko/20091221 Firefox/3.5.7\r\n"
197 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
198 "Content-Type: text/html\r\n"
199 "Content-Length: 7\r\n"
203 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
204 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
208 const char *sig =
"alert http any any -> any any "
209 "(msg:\"http server body test\"; "
210 "content:\"ABC\"; http_server_body; offset:4; "
212 return RunTest(steps, sig, NULL);
215 static int DetectEngineHttpServerBodyTest03(
void)
217 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
218 "Host: www.openinfosecfoundation.org\r\n"
219 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
220 "Gecko/20091221 Firefox/3.5.7\r\n"
222 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
223 "Content-Type: text/html\r\n"
224 "Content-Length: 17\r\n"
227 uint8_t http_buf3[] =
"8901234ABC";
229 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
230 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
231 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 1 },
235 const char *sig =
"alert http any any -> any any "
236 "(msg:\"http server body test\"; "
237 "content:\"ABC\"; http_server_body; offset:14; "
239 return RunTest(steps, sig, NULL);
242 static int DetectEngineHttpServerBodyTest04(
void)
244 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
245 "Host: www.openinfosecfoundation.org\r\n"
246 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
247 "Gecko/20091221 Firefox/3.5.7\r\n"
249 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
250 "Content-Type: text/html\r\n"
251 "Content-Length: 6\r\n"
255 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
256 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
259 const char *sig =
"alert http any any -> any any "
260 "(msg:\"http server body test\"; "
261 "content:!\"abc\"; http_server_body; offset:3; "
263 return RunTest(steps, sig, NULL);
266 static int DetectEngineHttpServerBodyTest05(
void)
268 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
269 "Host: www.openinfosecfoundation.org\r\n"
270 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
271 "Gecko/20091221 Firefox/3.5.7\r\n"
273 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
274 "Content-Type: text/html\r\n"
275 "Content-Length: 6\r\n"
279 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
280 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
283 const char *sig =
"alert http any any -> any any "
284 "(msg:\"http server body test\"; "
285 "content:\"abc\"; http_server_body; depth:3; "
287 return RunTest(steps, sig, NULL);
290 static int DetectEngineHttpServerBodyTest06(
void)
292 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
293 "Host: www.openinfosecfoundation.org\r\n"
294 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
295 "Gecko/20091221 Firefox/3.5.7\r\n"
297 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
298 "Content-Type: text/html\r\n"
299 "Content-Length: 6\r\n"
303 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
304 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
307 const char *sig =
"alert http any any -> any any "
308 "(msg:\"http server body test\"; "
309 "content:!\"def\"; http_server_body; depth:3; "
311 return RunTest(steps, sig, NULL);
314 static int DetectEngineHttpServerBodyTest07(
void)
316 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
317 "Host: www.openinfosecfoundation.org\r\n"
318 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
319 "Gecko/20091221 Firefox/3.5.7\r\n"
321 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
322 "Content-Type: text/html\r\n"
323 "Content-Length: 6\r\n"
327 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
328 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
331 const char *sig =
"alert http any any -> any any "
332 "(msg:\"http server body test\"; "
333 "content:!\"def\"; http_server_body; offset:3; "
335 return RunTest(steps, sig, NULL);
338 static int DetectEngineHttpServerBodyTest08(
void)
340 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
341 "Host: www.openinfosecfoundation.org\r\n"
342 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
343 "Gecko/20091221 Firefox/3.5.7\r\n"
345 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
346 "Content-Type: text/html\r\n"
347 "Content-Length: 6\r\n"
352 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
353 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
356 const char *sig =
"alert http any any -> any any "
357 "(msg:\"http server body test\"; "
358 "content:!\"abc\"; http_server_body; depth:3; "
360 return RunTest(steps, sig, NULL);
363 static int DetectEngineHttpServerBodyTest09(
void)
365 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
366 "Host: www.openinfosecfoundation.org\r\n"
367 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
368 "Gecko/20091221 Firefox/3.5.7\r\n"
370 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
371 "Content-Type: text/html\r\n"
372 "Content-Length: 6\r\n"
376 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
377 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
380 const char *sig =
"alert http any any -> any any "
381 "(msg:\"http server body test\"; "
382 "content:\"abc\"; http_server_body; depth:3; "
383 "content:\"def\"; http_server_body; within:3; "
385 return RunTest(steps, sig, NULL);
388 static int DetectEngineHttpServerBodyTest10(
void)
390 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
391 "Host: www.openinfosecfoundation.org\r\n"
392 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
393 "Gecko/20091221 Firefox/3.5.7\r\n"
395 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
396 "Content-Type: text/html\r\n"
397 "Content-Length: 6\r\n"
401 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
402 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
405 const char *sig =
"alert http any any -> any any "
406 "(msg:\"http server body test\"; "
407 "content:\"abc\"; http_server_body; depth:3; "
408 "content:!\"xyz\"; http_server_body; within:3; "
410 return RunTest(steps, sig, NULL);
413 static int DetectEngineHttpServerBodyTest11(
void)
415 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
416 "Host: www.openinfosecfoundation.org\r\n"
417 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
418 "Gecko/20091221 Firefox/3.5.7\r\n"
420 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
421 "Content-Type: text/html\r\n"
422 "Content-Length: 6\r\n"
426 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
427 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
430 const char *sig =
"alert http any any -> any any "
431 "(msg:\"http server body test\"; "
432 "content:\"abc\"; http_server_body; depth:3; "
433 "content:\"xyz\"; http_server_body; within:3; "
435 return RunTest(steps, sig, NULL);
438 static int DetectEngineHttpServerBodyTest12(
void)
440 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
441 "Host: www.openinfosecfoundation.org\r\n"
442 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
443 "Gecko/20091221 Firefox/3.5.7\r\n"
445 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
446 "Content-Type: text/html\r\n"
447 "Content-Length: 6\r\n"
451 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
452 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
455 const char *sig =
"alert http any any -> any any "
456 "(msg:\"http server body test\"; "
457 "content:\"ab\"; http_server_body; depth:2; "
458 "content:\"ef\"; http_server_body; distance:2; "
460 return RunTest(steps, sig, NULL);
463 static int DetectEngineHttpServerBodyTest13(
void)
465 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
466 "Host: www.openinfosecfoundation.org\r\n"
467 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
468 "Gecko/20091221 Firefox/3.5.7\r\n"
470 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
471 "Content-Type: text/html\r\n"
472 "Content-Length: 6\r\n"
476 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
477 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
480 const char *sig =
"alert http any any -> any any "
481 "(msg:\"http server body test\"; "
482 "content:\"ab\"; http_server_body; depth:3; "
483 "content:!\"yz\"; http_server_body; distance:2; "
485 return RunTest(steps, sig, NULL);
488 static int DetectEngineHttpServerBodyTest14(
void)
490 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
491 "Host: www.openinfosecfoundation.org\r\n"
492 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
493 "Gecko/20091221 Firefox/3.5.7\r\n"
495 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
496 "Content-Type: text/html\r\n"
497 "Content-Length: 6\r\n"
501 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
502 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
505 const char *sig =
"alert http any any -> any any "
506 "(msg:\"http server body test\"; "
508 "content:\"ef\"; http_server_body; distance:2; "
510 return RunTest(steps, sig, NULL);
513 static int DetectEngineHttpServerBodyTest15(
void)
515 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
516 "Host: www.openinfosecfoundation.org\r\n"
517 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
518 "Gecko/20091221 Firefox/3.5.7\r\n"
520 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
521 "Content-Type: text/html\r\n"
522 "Content-Length: 6\r\n"
526 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
527 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
530 const char *sig =
"alert http any any -> any any "
531 "(msg:\"http server body test\"; "
533 "content:!\"xyz\"; http_server_body; distance:0; within:3; "
535 return RunTest(steps, sig, NULL);
538 static int DetectEngineHttpServerBodyTest16(
void)
547 request-body-limit: 0\n\
548 response-body-limit: 0\n\
550 request-body-inspect-window: 0\n\
551 response-body-inspect-window: 0\n\
552 request-body-minimal-inspect-size: 0\n\
553 response-body-minimal-inspect-size: 0\n\
555 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
556 "Host: www.openinfosecfoundation.org\r\n"
557 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
558 "Gecko/20091221 Firefox/3.5.7\r\n"
560 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
561 "Content-Type: text/html\r\n"
562 "Content-Length: 17\r\n"
565 uint8_t http_buf3[] =
"8901234ABC";
567 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
568 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
569 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 0 },
572 const char *sig =
"alert http any any -> any any ("
573 "content:\"890\"; within:3; http_server_body; "
575 return RunTest(steps, sig,
input);
578 static int DetectEngineHttpServerBodyTest17(
void)
587 request-body-limit: 0\n\
588 response-body-limit: 0\n\
590 request-body-inspect-window: 0\n\
591 response-body-inspect-window: 0\n\
592 request-body-minimal-inspect-size: 0\n\
593 response-body-minimal-inspect-size: 0\n\
595 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
596 "Host: www.openinfosecfoundation.org\r\n"
597 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
598 "Gecko/20091221 Firefox/3.5.7\r\n"
600 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
601 "Content-Type: text/html\r\n"
602 "Content-Length: 17\r\n"
605 uint8_t http_buf3[] =
"8901234ABC";
607 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
608 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
609 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 0 },
612 const char *sig =
"alert http any any -> any any ("
613 "content:\"890\"; depth:3; http_server_body; "
615 return RunTest(steps, sig,
input);
621 static int DetectEngineHttpServerBodyTest18(
void)
623 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
624 "Host: www.openinfosecfoundation.org\r\n"
625 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
626 "Gecko/20091221 Firefox/3.5.7\r\n"
629 uint8_t http_buf2[] = {
630 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
631 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'5',
'1', 0x0d, 0x0a,
632 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'E',
'n',
'c',
'o',
'd',
'i',
'n',
'g',
':',
' ',
633 'g',
'z',
'i',
'p', 0x0d, 0x0a,
635 0x1f, 0x8b, 0x08, 0x08, 0x27, 0x1e, 0xe5, 0x51, 0x00, 0x03, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74,
636 0x78, 0x74, 0x00, 0x2b, 0xc9, 0xc8, 0x2c, 0x56, 0x00, 0xa2, 0x44, 0x85, 0xb4, 0xcc, 0x9c, 0x54,
637 0x85, 0xcc, 0x3c, 0x20, 0x2b, 0x29, 0xbf, 0x42, 0x8f, 0x0b, 0x00, 0xb2, 0x7d, 0xac, 0x9b, 0x19,
642 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
643 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
646 const char *sig =
"alert http any any -> any any "
647 "(msg:\"http server body test\"; "
648 "content:\"file\"; http_server_body; "
650 return RunTest(steps, sig, NULL);
656 static int DetectEngineHttpServerBodyTest19(
void)
658 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
659 "Host: www.openinfosecfoundation.org\r\n"
660 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
661 "Gecko/20091221 Firefox/3.5.7\r\n"
664 uint8_t http_buf2[] = {
665 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
666 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'2',
'4', 0x0d, 0x0a,
667 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'E',
'n',
'c',
'o',
'd',
'i',
'n',
'g',
':',
' ',
668 'd',
'e',
'f',
'l',
'a',
't',
'e', 0x0d, 0x0a,
670 0x2b, 0xc9, 0xc8, 0x2c, 0x56, 0x00, 0xa2, 0x44, 0x85, 0xb4, 0xcc, 0x9c, 0x54, 0x85, 0xcc, 0x3c,
671 0x20, 0x2b, 0x29, 0xbf, 0x42, 0x8f, 0x0b, 0x00,
676 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
677 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
680 const char *sig =
"alert http any any -> any any "
681 "(msg:\"http server body test\"; "
682 "content:\"file\"; http_server_body; "
684 return RunTest(steps, sig, NULL);
690 static int DetectEngineHttpServerBodyTest20(
void)
692 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
693 "Host: www.openinfosecfoundation.org\r\n"
694 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
695 "Gecko/20091221 Firefox/3.5.7\r\n"
698 uint8_t http_buf2[] = {
699 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
700 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'2',
'4', 0x0d, 0x0a,
701 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'E',
'n',
'c',
'o',
'd',
'i',
'n',
'g',
':',
' ',
702 'g',
'z',
'i',
'p', 0x0d, 0x0a,
704 0x2b, 0xc9, 0xc8, 0x2c, 0x56, 0x00, 0xa2, 0x44, 0x85, 0xb4, 0xcc, 0x9c, 0x54, 0x85, 0xcc, 0x3c,
705 0x20, 0x2b, 0x29, 0xbf, 0x42, 0x8f, 0x0b, 0x00,
710 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
711 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
714 const char *sig =
"alert http any any -> any any "
715 "(msg:\"http server body test\"; "
716 "content:\"file\"; http_server_body; "
718 return RunTest(steps, sig, NULL);
724 static int DetectEngineHttpServerBodyTest21(
void)
726 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
727 "Host: www.openinfosecfoundation.org\r\n"
728 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
729 "Gecko/20091221 Firefox/3.5.7\r\n"
732 uint8_t http_buf2[] = {
733 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
734 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'5',
'1', 0x0d, 0x0a,
735 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'E',
'n',
'c',
'o',
'd',
'i',
'n',
'g',
':',
' ',
736 'd',
'e',
'f',
'l',
'a',
't',
'e', 0x0d, 0x0a,
738 0x1f, 0x8b, 0x08, 0x08, 0x27, 0x1e, 0xe5, 0x51, 0x00, 0x03, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74,
739 0x78, 0x74, 0x00, 0x2b, 0xc9, 0xc8, 0x2c, 0x56, 0x00, 0xa2, 0x44, 0x85, 0xb4, 0xcc, 0x9c, 0x54,
740 0x85, 0xcc, 0x3c, 0x20, 0x2b, 0x29, 0xbf, 0x42, 0x8f, 0x0b, 0x00, 0xb2, 0x7d, 0xac, 0x9b, 0x19,
745 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
746 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
749 const char *sig =
"alert http any any -> any any "
750 "(msg:\"http server body test\"; "
751 "content:\"file\"; http_server_body; "
753 return RunTest(steps, sig, NULL);
760 static int DetectEngineHttpServerBodyTest22(
void)
762 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
763 "Host: www.openinfosecfoundation.org\r\n"
764 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
765 "Gecko/20091221 Firefox/3.5.7\r\n"
768 uint8_t http_buf2[] = {
769 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
770 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'5',
'1', 0x0d, 0x0a,
771 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'E',
'n',
'c',
'o',
'd',
'i',
'n',
'g',
':',
' ',
772 'g',
'z',
'i',
'p', 0x0d, 0x0a,
773 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'E',
'n',
'c',
'o',
'd',
'i',
'n',
'g',
':',
' ',
774 'd',
'e',
'f',
'l',
'a',
't',
'e', 0x0d, 0x0a,
776 0x1f, 0x8b, 0x08, 0x08, 0x27, 0x1e, 0xe5, 0x51, 0x00, 0x03, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74,
777 0x78, 0x74, 0x00, 0x2b, 0xc9, 0xc8, 0x2c, 0x56, 0x00, 0xa2, 0x44, 0x85, 0xb4, 0xcc, 0x9c, 0x54,
778 0x85, 0xcc, 0x3c, 0x20, 0x2b, 0x29, 0xbf, 0x42, 0x8f, 0x0b, 0x00, 0xb2, 0x7d, 0xac, 0x9b, 0x19,
783 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
784 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
787 const char *sig =
"alert http any any -> any any "
788 "(msg:\"http server body test\"; "
789 "content:\"file\"; http_server_body; "
791 return RunTest(steps, sig, NULL);
794 static int DetectEngineHttpServerBodyFileDataTest01(
void)
796 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
797 "Host: www.openinfosecfoundation.org\r\n"
798 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
799 "Gecko/20091221 Firefox/3.5.7\r\n"
801 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
802 "Content-Type: text/html\r\n"
803 "Content-Length: 6\r\n"
807 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
808 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
811 const char *sig =
"alert http any any -> any any "
812 "(msg:\"http server body test\"; "
813 "file_data; pcre:/ab/; "
814 "content:\"ef\"; distance:2; "
816 return RunTest(steps, sig, NULL);
819 static int DetectEngineHttpServerBodyFileDataTest02(
void)
821 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
822 "Host: www.openinfosecfoundation.org\r\n"
823 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
824 "Gecko/20091221 Firefox/3.5.7\r\n"
826 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
827 "Content-Type: text/html\r\n"
828 "Content-Length: 6\r\n"
832 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
833 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
836 const char *sig =
"alert http any any -> any any "
837 "(msg:\"http server body test\"; "
838 "file_data; pcre:/abc/; "
839 "content:!\"xyz\"; distance:0; within:3; "
841 return RunTest(steps, sig, NULL);
845 static int DetectEngineHttpServerBodyFileDataTest03(
void)
854 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
855 "Host: www.openinfosecfoundation.org\r\n"
856 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
857 "Gecko/20091221 Firefox/3.5.7\r\n"
859 uint32_t http_len1 =
sizeof(http_buf1) - 1;
860 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
861 "Content-Type: text/html\r\n"
862 "Content-Length: 33\r\n"
864 "XYZ_klm_1234abcd_XYZ_klm_5678abcd";
865 uint32_t http_len2 =
sizeof(http_buf2) - 1;
868 memset(&th_v, 0,
sizeof(th_v));
870 memset(&f, 0,
sizeof(f));
871 memset(&ssn, 0,
sizeof(ssn));
878 f.
proto = IPPROTO_TCP;
898 "alert http any any -> any any "
899 "(msg:\"match on 1st\"; "
900 "file_data; content:\"XYZ\"; content:\"_klm_\"; distance:0; content:\"abcd\"; "
901 "distance:4; byte_test:4,=,1234,-8,relative,string;"
905 "alert http any any -> any any "
906 "(msg:\"match on 2nd\"; "
907 "file_data; content:\"XYZ\"; content:\"_klm_\"; distance:0; content:\"abcd\"; "
908 "distance:4; byte_test:4,=,5678,-8,relative,string;"
946 static int DetectEngineHttpServerBodyFileDataTest04(
void)
949 const char yaml[] =
"\
956 http-body-inline: yes\n\
957 response-body-minimal-inspect-size: 6\n\
958 response-body-inspect-window: 3\n\
962 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
963 "Host: www.openinfosecfoundation.org\r\n"
964 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
965 "Gecko/20091221 Firefox/3.5.7\r\n"
967 0, STREAM_TOSERVER, 0 },
968 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
969 "Content-Type: text/html\r\n"
970 "Content-Length: 6\r\n"
973 0, STREAM_TOCLIENT, 0 },
974 { (
const uint8_t *)
"cd", 0, STREAM_TOCLIENT, 1 },
975 { (
const uint8_t *)
"ef", 0, STREAM_TOCLIENT, 0 },
979 const char *sig =
"alert http any any -> any any (file_data; content:\"abcd\"; sid:1;)";
980 return RunTest(steps, sig, yaml);
983 static int DetectEngineHttpServerBodyFileDataTest05(
void)
986 const char yaml[] =
"\
993 http-body-inline: yes\n\
994 response-body-minimal-inspect-size: 6\n\
995 response-body-inspect-window: 3\n\
999 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1000 "Host: www.openinfosecfoundation.org\r\n"
1001 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1002 "Gecko/20091221 Firefox/3.5.7\r\n"
1004 0, STREAM_TOSERVER, 0 },
1005 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1006 "Content-Type: text/html\r\n"
1007 "Content-Length: 6\r\n"
1010 0, STREAM_TOCLIENT, 0 },
1011 { (
const uint8_t *)
"cd", 0, STREAM_TOCLIENT, 0 },
1012 { (
const uint8_t *)
"ef", 0, STREAM_TOCLIENT, 1 },
1016 const char *sig =
"alert http any any -> any any (file_data; content:\"abcdef\"; sid:1;)";
1017 return RunTest(steps, sig, yaml);
1020 static int DetectEngineHttpServerBodyFileDataTest06(
void)
1023 const char yaml[] =
"\
1030 http-body-inline: yes\n\
1031 response-body-minimal-inspect-size: 6\n\
1032 response-body-inspect-window: 3\n\
1036 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1037 "Host: www.openinfosecfoundation.org\r\n"
1038 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1039 "Gecko/20091221 Firefox/3.5.7\r\n"
1041 0, STREAM_TOSERVER, 0 },
1042 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1043 "Content-Type: text/html\r\n"
1044 "Content-Length: 6\r\n"
1047 0, STREAM_TOCLIENT, 0 },
1048 { (
const uint8_t *)
"cd", 0, STREAM_TOCLIENT, 0 },
1049 { (
const uint8_t *)
"ef", 0, STREAM_TOCLIENT, 1 },
1054 "alert http any any -> any any (file_data; content:\"bcdef\"; offset:1; sid:1;)";
1055 return RunTest(steps, sig, yaml);
1058 static int DetectEngineHttpServerBodyFileDataTest07(
void)
1061 const char yaml[] =
"\
1068 http-body-inline: yes\n\
1069 response-body-minimal-inspect-size: 6\n\
1070 response-body-inspect-window: 3\n\
1074 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1075 "Host: www.openinfosecfoundation.org\r\n"
1076 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1077 "Gecko/20091221 Firefox/3.5.7\r\n"
1079 0, STREAM_TOSERVER, 0 },
1080 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1081 "Content-Type: text/html\r\n"
1082 "Content-Length: 13\r\n"
1085 0, STREAM_TOCLIENT, 0 },
1086 { (
const uint8_t *)
"cd", 0, STREAM_TOCLIENT, 1 },
1087 { (
const uint8_t *)
"123456789", 0, STREAM_TOCLIENT, 0 },
1092 "alert http any any -> any any (file_data; content:\"bc\"; offset:1; depth:2; sid:1;)";
1093 return RunTest(steps, sig, yaml);
1096 static int DetectEngineHttpServerBodyFileDataTest08(
void)
1099 const char yaml[] =
"\
1106 http-body-inline: yes\n\
1107 response-body-minimal-inspect-size: 6\n\
1108 response-body-inspect-window: 3\n\
1112 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1113 "Host: www.openinfosecfoundation.org\r\n"
1114 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1115 "Gecko/20091221 Firefox/3.5.7\r\n"
1117 0, STREAM_TOSERVER, 0 },
1118 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1119 "Content-Type: text/html\r\n"
1120 "Content-Length: 14\r\n"
1123 0, STREAM_TOCLIENT, 0 },
1124 { (
const uint8_t *)
"cd", 0, STREAM_TOCLIENT, 0 },
1125 { (
const uint8_t *)
"1234567890", 0, STREAM_TOCLIENT, 1 },
1130 "alert http any any -> any any (file_data; content:\"d123456789\"; offset:3; sid:1;)";
1131 return RunTest(steps, sig, yaml);
1134 static int DetectEngineHttpServerBodyFileDataTest09(
void)
1137 const char yaml[] =
"\
1144 http-body-inline: yes\n\
1145 response-body-minimal-inspect-size: 6\n\
1146 response-body-inspect-window: 3\n\
1150 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1151 "Host: www.openinfosecfoundation.org\r\n"
1152 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1153 "Gecko/20091221 Firefox/3.5.7\r\n"
1155 0, STREAM_TOSERVER, 0 },
1156 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1157 "Content-Type: text/html\r\n"
1158 "Content-Length: 13\r\n"
1161 0, STREAM_TOCLIENT, 0 },
1162 { (
const uint8_t *)
"cd", 0, STREAM_TOCLIENT, 0 },
1163 { (
const uint8_t *)
"123456789", 0, STREAM_TOCLIENT, 1 },
1168 "alert http any any -> any any (file_data; content:\"abcd12\"; depth:6; sid:1;)";
1169 return RunTest(steps, sig, yaml);
1172 static int DetectEngineHttpServerBodyFileDataTest10(
void)
1175 const char yaml[] =
"\
1182 http-body-inline: yes\n\
1183 response-body-minimal-inspect-size: 6\n\
1184 response-body-inspect-window: 3\n\
1188 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1189 "Host: www.openinfosecfoundation.org\r\n"
1190 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1191 "Gecko/20091221 Firefox/3.5.7\r\n"
1193 0, STREAM_TOSERVER, 0 },
1194 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1195 "Content-Type: text/html\r\n"
1196 "Content-Length: 5\r\n"
1199 0, STREAM_TOCLIENT, 0 },
1200 { (
const uint8_t *)
"c", 0, STREAM_TOCLIENT, 1 },
1201 { (
const uint8_t *)
"de", 0, STREAM_TOCLIENT, 0 },
1205 const char *sig =
"alert http any any -> any any (file_data; content:\"abc\"; depth:3; sid:1;)";
1206 return RunTest(steps, sig, yaml);
1209 static int DetectEngineHttpServerBodyFileDataTest11(
void)
1212 const char yaml[] =
"\
1219 http-body-inline: yes\n\
1220 response-body-minimal-inspect-size: 6\n\
1221 response-body-inspect-window: 3\n\
1225 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1226 "Host: www.openinfosecfoundation.org\r\n"
1227 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1228 "Gecko/20091221 Firefox/3.5.7\r\n"
1230 0, STREAM_TOSERVER, 0 },
1231 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1232 "Content-Type: text/html\r\n"
1233 "Content-Length: 5\r\n"
1236 0, STREAM_TOCLIENT, 0 },
1237 { (
const uint8_t *)
"c", 0, STREAM_TOCLIENT, 0 },
1238 { (
const uint8_t *)
"de", 0, STREAM_TOCLIENT, 1 },
1242 const char *sig =
"alert http any any -> any any (file_data; content:\"bcde\"; offset:1; "
1244 return RunTest(steps, sig, yaml);
1247 static int DetectEngineHttpServerBodyFileDataTest12(
void)
1250 const char yaml[] =
"\
1257 http-body-inline: yes\n\
1258 response-body-minimal-inspect-size: 6\n\
1259 response-body-inspect-window: 3\n\
1263 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1264 "Host: www.openinfosecfoundation.org\r\n"
1265 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1266 "Gecko/20091221 Firefox/3.5.7\r\n"
1268 0, STREAM_TOSERVER, 0 },
1269 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1270 "Content-Type: text/html\r\n"
1271 "Content-Length: 13\r\n"
1274 0, STREAM_TOCLIENT, 0 },
1275 { (
const uint8_t *)
"b", 0, STREAM_TOCLIENT, 0 },
1276 { (
const uint8_t *)
"c", 0, STREAM_TOCLIENT, 0 },
1277 { (
const uint8_t *)
"d", 0, STREAM_TOCLIENT, 1 },
1278 { (
const uint8_t *)
"efghijklm", 0, STREAM_TOCLIENT, 0 },
1282 const char *sig =
"alert http any any -> any any (file_data; content:\"abcd\"; sid:1;)";
1283 return RunTest(steps, sig, yaml);
1286 static int DetectEngineHttpServerBodyFileDataTest13(
void)
1289 const char yaml[] =
"\
1296 http-body-inline: yes\n\
1297 response-body-minimal-inspect-size: 9\n\
1298 response-body-inspect-window: 12\n\
1302 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1303 "Host: www.openinfosecfoundation.org\r\n"
1304 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1305 "Gecko/20091221 Firefox/3.5.7\r\n"
1307 0, STREAM_TOSERVER, 0 },
1308 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1309 "Content-Type: text/html\r\n"
1310 "Content-Length: 13\r\n"
1313 0, STREAM_TOCLIENT, 0 },
1314 { (
const uint8_t *)
"b", 0, STREAM_TOCLIENT, 0 },
1315 { (
const uint8_t *)
"c", 0, STREAM_TOCLIENT, 0 },
1316 { (
const uint8_t *)
"d", 0, STREAM_TOCLIENT, 0 },
1317 { (
const uint8_t *)
"efghijklm", 0, STREAM_TOCLIENT, 1 },
1322 "alert http any any -> any any (file_data; content:\"abcdefghijklm\"; sid:1;)";
1323 return RunTest(steps, sig, yaml);
1326 static int DetectEngineHttpServerBodyFileDataTest14(
void)
1329 const char yaml[] =
"\
1336 http-body-inline: yes\n\
1337 response-body-minimal-inspect-size: 9\n\
1338 response-body-inspect-window: 12\n\
1342 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1343 "Host: www.openinfosecfoundation.org\r\n"
1344 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1345 "Gecko/20091221 Firefox/3.5.7\r\n"
1347 0, STREAM_TOSERVER, 0 },
1348 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1349 "Content-Type: text/html\r\n"
1350 "Content-Length: 20\r\n"
1353 0, STREAM_TOCLIENT, 0 },
1354 { (
const uint8_t *)
"abcdefghi", 0, STREAM_TOCLIENT, 1 },
1358 const char *sig =
"alert http any any -> any any (file_data; content:\"890abcdefghi\"; sid:1;)";
1359 return RunTest(steps, sig, yaml);
1362 static int DetectEngineHttpServerBodyFileDataTest15(
void)
1365 const char yaml[] =
"\
1372 http-body-inline: yes\n\
1373 response-body-minimal-inspect-size: 9\n\
1374 response-body-inspect-window: 12\n\
1378 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1379 "Host: www.openinfosecfoundation.org\r\n"
1380 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1381 "Gecko/20091221 Firefox/3.5.7\r\n"
1383 0, STREAM_TOSERVER, 0 },
1384 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1385 "Content-Type: text/html\r\n"
1386 "Content-Length: 20\r\n"
1389 0, STREAM_TOCLIENT, 0 },
1390 { (
const uint8_t *)
"abcdefghi", 0, STREAM_TOCLIENT, 0 },
1395 "alert http any any -> any any (file_data; content:\"7890ab\"; depth:6; sid:1;)";
1396 return RunTest(steps, sig, yaml);
1399 static int DetectEngineHttpServerBodyFileDataTest16(
void)
1402 const char yaml[] =
"\
1409 http-body-inline: yes\n\
1410 response-body-minimal-inspect-size: 9\n\
1411 response-body-inspect-window: 12\n\
1415 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1416 "Host: www.openinfosecfoundation.org\r\n"
1417 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1418 "Gecko/20091221 Firefox/3.5.7\r\n"
1420 0, STREAM_TOSERVER, 0 },
1421 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1422 "Content-Type: text/html\r\n"
1423 "Content-Length: 20\r\n"
1426 0, STREAM_TOCLIENT, 0 },
1427 { (
const uint8_t *)
"bbbbc", 0, STREAM_TOCLIENT, 0 },
1428 { (
const uint8_t *)
"ccccd", 0, STREAM_TOCLIENT, 0 },
1429 { (
const uint8_t *)
"dddde", 0, STREAM_TOCLIENT, 0 },
1434 "alert http any any -> any any (file_data; content:\"aabb\"; depth:4; sid:1;)";
1435 return RunTest(steps, sig, yaml);
1438 static int DetectEngineHttpServerBodyFileDataTest17(
void)
1441 const char yaml[] =
"\
1448 http-body-inline: yes\n\
1449 response-body-minimal-inspect-size: 8\n\
1450 response-body-inspect-window: 4\n\
1454 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1455 "Host: www.openinfosecfoundation.org\r\n"
1456 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1457 "Gecko/20091221 Firefox/3.5.7\r\n"
1459 0, STREAM_TOSERVER, 0 },
1460 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1461 "Content-Type: text/html\r\n"
1462 "Content-Length: 20\r\n"
1465 0, STREAM_TOCLIENT, 0 },
1466 { (
const uint8_t *)
"bbbbc", 0, STREAM_TOCLIENT, 0 },
1467 { (
const uint8_t *)
"ccccd", 0, STREAM_TOCLIENT, 0 },
1468 { (
const uint8_t *)
"dddde", 0, STREAM_TOCLIENT, 0 },
1473 "alert http any any -> any any (file_data; content:\"bbbc\"; depth:4; sid:1;)";
1474 return RunTest(steps, sig, yaml);
1477 static int DetectEngineHttpServerBodyFileDataTest18(
void)
1480 const char yaml[] =
"\
1487 http-body-inline: yes\n\
1488 response-body-minimal-inspect-size: 8\n\
1489 response-body-inspect-window: 4\n\
1493 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1494 "Host: www.openinfosecfoundation.org\r\n"
1495 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1496 "Gecko/20091221 Firefox/3.5.7\r\n"
1498 0, STREAM_TOSERVER, 0 },
1499 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1500 "Content-Type: text/html\r\n"
1501 "Content-Length: 20\r\n"
1504 0, STREAM_TOCLIENT, 0 },
1505 { (
const uint8_t *)
"bbbbc", 0, STREAM_TOCLIENT, 0 },
1506 { (
const uint8_t *)
"ccccd", 0, STREAM_TOCLIENT, 0 },
1507 { (
const uint8_t *)
"dddde", 0, STREAM_TOCLIENT, 0 },
1512 "alert http any any -> any any (file_data; content:\"bccd\"; depth:4; sid:1;)";
1513 return RunTest(steps, sig, yaml);
1515 static int DetectEngineHttpServerBodyFileDataTest19(
void)
1524 swf-decompression:\n\
1527 compress-depth: 0\n\
1528 decompress-depth: 0\n\
1530 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1531 "Host: www.openinfosecfoundation.org\r\n"
1532 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1533 "Gecko/20091221 Firefox/3.5.7\r\n"
1536 uint8_t http_buf2[] = {
1537 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
1538 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'1',
'0',
'3', 0x0d, 0x0a,
1539 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
1540 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'o',
'c',
't',
'e',
't',
'-',
's',
't',
'r',
'e',
'a',
'm', 0x0d, 0x0a,
1542 0x5a, 0x57, 0x53, 0x17, 0x5c, 0x24, 0x00, 0x00, 0xb7, 0x21, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x20,
1543 0x00, 0x00, 0x3b, 0xff, 0xfc, 0x8e, 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85,
1544 0xf5, 0x75, 0x6f, 0xd0, 0x7e, 0x61, 0x35, 0x1b, 0x1a, 0x8b, 0x16, 0x4d, 0xdf, 0x05, 0x32, 0xfe,
1545 0xa4, 0x4c, 0x46, 0x49, 0xb7, 0x7b, 0x6b, 0x75, 0xf9, 0x2b, 0x5c, 0x37, 0x29, 0x0b, 0x91, 0x37,
1546 0x01, 0x37, 0x0e, 0xe9, 0xf2, 0xe1, 0xfc, 0x9e, 0x64, 0xda, 0x6c, 0x11, 0x21, 0x33, 0xed, 0xa0,
1547 0x0e, 0x76, 0x70, 0xa0, 0xcd, 0x98, 0x2e, 0x76, 0x80, 0xf0, 0xe0, 0x59, 0x56, 0x06, 0x08, 0xe9,
1548 0xca, 0xeb, 0xa2, 0xc6, 0xdb, 0x5a, 0x86
1552 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1553 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1556 const char *sig =
"alert tcp any any -> any any "
1557 "(flow:established,from_server; "
1558 "file_data; content:\"FWS\"; "
1560 return RunTest(steps, sig,
input);
1563 static int DetectEngineHttpServerBodyFileDataTest20(
void)
1572 swf-decompression:\n\
1575 compress-depth: 0\n\
1576 decompress-depth: 0\n\
1578 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1579 "Host: www.openinfosecfoundation.org\r\n"
1580 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1581 "Gecko/20091221 Firefox/3.5.7\r\n"
1584 uint8_t http_buf2[] = {
1585 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
1586 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
1587 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
1588 '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,
1590 0x43, 0x57, 0x53, 0x0a, 0xcb, 0x6c, 0x00, 0x00, 0x78, 0xda, 0xad, 0xbd, 0x07, 0x98, 0x55, 0x55,
1591 0x9e, 0xee, 0xbd, 0x4f, 0xd8, 0xb5, 0x4e, 0x15, 0xc1, 0xc2, 0x80, 0x28, 0x86, 0xd2, 0x2e, 0x5a,
1592 0xdb, 0x46, 0xd9, 0x39, 0x38, 0xdd, 0x4e, 0x1b, 0xa8, 0x56, 0x5b, 0xc5, 0x6b, 0xe8, 0x76, 0xfa,
1593 0x0e, 0xc2, 0x8e, 0x50, 0x76, 0x51, 0xc5, 0x54, 0x15, 0x88, 0x73, 0xc3, 0xd0, 0x88, 0x39, 0x81,
1594 0x98, 0x63, 0x91, 0x93, 0x8a, 0x82, 0x89, 0x60, 0x00, 0xcc, 0xb1, 0x00, 0x01, 0x73, 0xce, 0x39,
1598 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1599 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1602 const char *sig =
"alert tcp any any -> any any "
1603 "(flow:established,from_server; "
1604 "file_data; content:\"CWS\"; "
1606 return RunTest(steps, sig,
input);
1609 static int DetectEngineHttpServerBodyFileDataTest21(
void)
1618 swf-decompression:\n\
1621 compress-depth: 0\n\
1622 decompress-depth: 0\n\
1624 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1625 "Host: www.openinfosecfoundation.org\r\n"
1626 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1627 "Gecko/20091221 Firefox/3.5.7\r\n"
1630 uint8_t http_buf2[] = {
1631 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
1632 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
1633 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
1634 '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,
1636 0x43, 0x57, 0x53, 0x0a, 0xcb, 0x6c, 0x00, 0x00, 0x78, 0xda, 0xad, 0xbd, 0x07, 0x98, 0x55, 0x55,
1637 0x9e, 0xee, 0xbd, 0x4f, 0xd8, 0xb5, 0x4e, 0x15, 0xc1, 0xc2, 0x80, 0x28, 0x86, 0xd2, 0x2e, 0x5a,
1638 0xdb, 0x46, 0xd9, 0x39, 0x38, 0xdd, 0x4e, 0x1b, 0xa8, 0x56, 0x5b, 0xc5, 0x6b, 0xe8, 0x76, 0xfa,
1639 0x0e, 0xc2, 0x8e, 0x50, 0x76, 0x51, 0xc5, 0x54, 0x15, 0x88, 0x73, 0xc3, 0xd0, 0x88, 0x39, 0x81,
1640 0x98, 0x63, 0x91, 0x93, 0x8a, 0x82, 0x89, 0x60, 0x00, 0xcc, 0xb1, 0x00, 0x01, 0x73, 0xce, 0x39,
1644 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1645 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1648 const char *sig =
"alert tcp any any -> any any "
1649 "(flow:established,from_server; "
1650 "file_data; content:\"FWS\"; "
1652 return RunTest(steps, sig,
input);
1655 static int DetectEngineHttpServerBodyFileDataTest22(
void)
1664 swf-decompression:\n\
1667 compress-depth: 0\n\
1668 decompress-depth: 0\n\
1670 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1671 "Host: www.openinfosecfoundation.org\r\n"
1672 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1673 "Gecko/20091221 Firefox/3.5.7\r\n"
1676 uint8_t http_buf2[] = {
1677 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
1678 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
1679 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
1680 '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,
1682 0x43, 0x57, 0x53, 0x0a, 0xcb, 0x6c, 0x00, 0x00, 0x78, 0xda, 0xad, 0xbd, 0x07, 0x98, 0x55, 0x55,
1683 0x9e, 0xee, 0xbd, 0x4f, 0xd8, 0xb5, 0x4e, 0x15, 0xc1, 0xc2, 0x80, 0x28, 0x86, 0xd2, 0x2e, 0x5a,
1684 0xdb, 0x46, 0xd9, 0x39, 0x38, 0xdd, 0x4e, 0x1b, 0xa8, 0x56, 0x5b, 0xc5, 0x6b, 0xe8, 0x76, 0xfa,
1685 0x0e, 0xc2, 0x8e, 0x50, 0x76, 0x51, 0xc5, 0x54, 0x15, 0x88, 0x73, 0xc3, 0xd0, 0x88, 0x39, 0x81,
1686 0x98, 0x63, 0x91, 0x93, 0x8a, 0x82, 0x89, 0x60, 0x00, 0xcc, 0xb1, 0x00, 0x01, 0x73, 0xce, 0x39,
1690 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1691 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1694 const char *sig =
"alert tcp any any -> any any "
1695 "(flow:established,from_server; "
1696 "file_data; content:\"CWS\"; "
1698 return RunTest(steps, sig,
input);
1701 static int DetectEngineHttpServerBodyFileDataTest23(
void)
1710 swf-decompression:\n\
1713 compress-depth: 0\n\
1714 decompress-depth: 0\n\
1716 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1717 "Host: www.openinfosecfoundation.org\r\n"
1718 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1719 "Gecko/20091221 Firefox/3.5.7\r\n"
1722 uint8_t http_buf2[] = {
1723 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
1724 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
1725 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
1726 '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,
1728 0x43, 0x57, 0x53, 0x01, 0xcb, 0x6c, 0x00, 0x00, 0x78, 0xda, 0xad, 0xbd, 0x07, 0x98, 0x55, 0x55,
1729 0x9e, 0xee, 0xbd, 0x4f, 0xd8, 0xb5, 0x4e, 0x15, 0xc1, 0xc2, 0x80, 0x28, 0x86, 0xd2, 0x2e, 0x5a,
1730 0xdb, 0x46, 0xd9, 0x39, 0x38, 0xdd, 0x4e, 0x1b, 0xa8, 0x56, 0x5b, 0xc5, 0x6b, 0xe8, 0x76, 0xfa,
1731 0x0e, 0xc2, 0x8e, 0x50, 0x76, 0x51, 0xc5, 0x54, 0x15, 0x88, 0x73, 0xc3, 0xd0, 0x88, 0x39, 0x81,
1732 0x98, 0x63, 0x91, 0x93, 0x8a, 0x82, 0x89, 0x60, 0x00, 0xcc, 0xb1, 0x00, 0x01, 0x73, 0xce, 0x39,
1736 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1737 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1740 const char *sig =
"alert tcp any any -> any any "
1741 "(flow:established,from_server; "
1742 "file_data; content:\"CWS\"; "
1744 return RunTest(steps, sig,
input);
1747 static int DetectEngineHttpServerBodyFileDataTest24(
void)
1756 swf-decompression:\n\
1759 compress-depth: 0\n\
1760 decompress-depth: 0\n\
1762 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1763 "Host: www.openinfosecfoundation.org\r\n"
1764 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1765 "Gecko/20091221 Firefox/3.5.7\r\n"
1767 uint8_t http_buf2[] = {
'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k',
1768 0x0d, 0x0a,
'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
1769 '1',
'0',
'3', 0x0d, 0x0a,
'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
1770 ' ',
'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'o',
'c',
't',
'e',
't',
1771 '-',
's',
't',
'r',
'e',
'a',
'm', 0x0d, 0x0a, 0x0d, 0x0a, 0x5a, 0x57, 0x53, 0x17, 0x5c,
1772 0x24, 0x00, 0x00, 0xb7, 0x21, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x20, 0x00, 0x00, 0x3b, 0xff,
1773 0xfc, 0x8e, 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85, 0xf5, 0x75, 0x6f,
1774 0xd0, 0x7e, 0x61, 0x35, 0x1b, 0x1a, 0x8b, 0x16, 0x4d, 0xdf, 0x05, 0x32, 0xfe, 0xa4, 0x4c,
1775 0x46, 0x49, 0xb7, 0x7b, 0x6b, 0x75, 0xf9, 0x2b, 0x5c, 0x37, 0x29, 0x0b, 0x91, 0x37, 0x01,
1776 0x37, 0x0e, 0xe9, 0xf2, 0xe1, 0xfc, 0x9e, 0x64, 0xda, 0x6c, 0x11, 0x21, 0x33, 0xed, 0xa0,
1777 0x0e, 0x76, 0x70, 0xa0, 0xcd, 0x98, 0x2e, 0x76, 0x80, 0xf0, 0xe0, 0x59, 0x56, 0x06, 0x08,
1778 0xe9, 0xca, 0xeb, 0xa2, 0xc6, 0xdb, 0x5a, 0x86 };
1780 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1781 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1784 const char *sig =
"alert tcp any any -> any any "
1785 "(flow:established,from_server; "
1786 "file_data; content:\"FWS\"; "
1788 return RunTest(steps, sig,
input);
1791 static int DetectEngineHttpServerBodyFileDataTest25(
void)
1800 swf-decompression:\n\
1803 compress-depth: 0\n\
1804 decompress-depth: 0\n\
1806 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1807 "Host: www.openinfosecfoundation.org\r\n"
1808 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1809 "Gecko/20091221 Firefox/3.5.7\r\n"
1811 uint8_t http_buf2[] = {
'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k',
1812 0x0d, 0x0a,
'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
1813 '1',
'0',
'3', 0x0d, 0x0a,
'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
1814 ' ',
'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'o',
'c',
't',
'e',
't',
1815 '-',
's',
't',
'r',
'e',
'a',
'm', 0x0d, 0x0a, 0x0d, 0x0a, 0x5a, 0x57, 0x53, 0x17, 0x5c,
1816 0x24, 0x00, 0x00, 0xb7, 0x21, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x20, 0x00, 0x00, 0x3b, 0xff,
1817 0xfc, 0x8e, 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85, 0xf5, 0x75, 0x6f,
1818 0xd0, 0x7e, 0x61, 0x35, 0x1b, 0x1a, 0x8b, 0x16, 0x4d, 0xdf, 0x05, 0x32, 0xfe, 0xa4, 0x4c,
1819 0x46, 0x49, 0xb7, 0x7b, 0x6b, 0x75, 0xf9, 0x2b, 0x5c, 0x37, 0x29, 0x0b, 0x91, 0x37, 0x01,
1820 0x37, 0x0e, 0xe9, 0xf2, 0xe1, 0xfc, 0x9e, 0x64, 0xda, 0x6c, 0x11, 0x21, 0x33, 0xed, 0xa0,
1821 0x0e, 0x76, 0x70, 0xa0, 0xcd, 0x98, 0x2e, 0x76, 0x80, 0xf0, 0xe0, 0x59, 0x56, 0x06, 0x08,
1822 0xe9, 0xca, 0xeb, 0xa2, 0xc6, 0xdb, 0x5a, 0x86 };
1824 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1825 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1828 const char *sig =
"alert tcp any any -> any any "
1829 "(flow:established,from_server; "
1830 "file_data; content:\"ZWS\"; "
1832 return RunTest(steps, sig,
input);
1835 static int DetectEngineHttpServerBodyFileDataTest26(
void)
1844 swf-decompression:\n\
1847 compress-depth: 0\n\
1848 decompress-depth: 0\n\
1850 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1851 "Host: www.openinfosecfoundation.org\r\n"
1852 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1853 "Gecko/20091221 Firefox/3.5.7\r\n"
1855 uint8_t http_buf2[] = {
'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k',
1856 0x0d, 0x0a,
'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
1857 '1',
'0',
'3', 0x0d, 0x0a,
'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
1858 ' ',
'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'o',
'c',
't',
'e',
't',
1859 '-',
's',
't',
'r',
'e',
'a',
'm', 0x0d, 0x0a, 0x0d, 0x0a, 0x5a, 0x57, 0x53, 0x17, 0x5c,
1860 0x24, 0x00, 0x00, 0xb7, 0x21, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x20, 0x00, 0x00, 0x3b, 0xff,
1861 0xfc, 0x8e, 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85, 0xf5, 0x75, 0x6f,
1862 0xd0, 0x7e, 0x61, 0x35, 0x1b, 0x1a, 0x8b, 0x16, 0x4d, 0xdf, 0x05, 0x32, 0xfe, 0xa4, 0x4c,
1863 0x46, 0x49, 0xb7, 0x7b, 0x6b, 0x75, 0xf9, 0x2b, 0x5c, 0x37, 0x29, 0x0b, 0x91, 0x37, 0x01,
1864 0x37, 0x0e, 0xe9, 0xf2, 0xe1, 0xfc, 0x9e, 0x64, 0xda, 0x6c, 0x11, 0x21, 0x33, 0xed, 0xa0,
1865 0x0e, 0x76, 0x70, 0xa0, 0xcd, 0x98, 0x2e, 0x76, 0x80, 0xf0, 0xe0, 0x59, 0x56, 0x06, 0x08,
1866 0xe9, 0xca, 0xeb, 0xa2, 0xc6, 0xdb, 0x5a, 0x86 };
1868 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1869 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1872 const char *sig =
"alert tcp any any -> any any "
1873 "(flow:established,from_server; "
1874 "file_data; content:\"FWS\"; "
1876 return RunTest(steps, sig,
input);
1879 static int DetectEngineHttpServerBodyFileDataTest27(
void)
1888 swf-decompression:\n\
1891 compress-depth: 0\n\
1892 decompress-depth: 0\n\
1894 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1895 "Host: www.openinfosecfoundation.org\r\n"
1896 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1897 "Gecko/20091221 Firefox/3.5.7\r\n"
1900 uint8_t http_buf2[] = {
1901 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
1902 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
1903 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
1904 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'o',
'c',
't',
'e',
't',
'-',
's',
't',
'r',
'e',
'a',
'm', 0x0d, 0x0a,
1906 0x5a, 0x57, 0x53, 0x17, 0x5c, 0x24, 0x00, 0x00, 0xb7, 0x21, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x20,
1907 0x00, 0x00, 0x3b, 0xff, 0xfc, 0x8e, 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85,
1908 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85, 0xf5, 0x75, 0x6f, 0xd0, 0x7e, 0x61,
1909 0x35, 0x1b, 0x1a, 0x8b, 0x16, 0x4d, 0xdf, 0x05, 0x32, 0xfe, 0xa4, 0x4c, 0x46, 0x49, 0xb7, 0x7b,
1910 0x6b, 0x75, 0xf9, 0x2b, 0x5c, 0x37, 0x29, 0x0b, 0x91, 0x37, 0x01, 0x37, 0x0e, 0xe9, 0xf2, 0xe1,
1914 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1915 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1918 const char *sig =
"alert tcp any any -> any any "
1919 "(flow:established,from_server; "
1920 "file_data; content:\"ZWS\"; "
1922 return RunTest(steps, sig,
input);
1925 static int DetectEngineHttpServerBodyFileDataTest28(
void)
1934 swf-decompression:\n\
1937 compress-depth: 0\n\
1938 decompress-depth: 0\n\
1940 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1941 "Host: www.openinfosecfoundation.org\r\n"
1942 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1943 "Gecko/20091221 Firefox/3.5.7\r\n"
1946 uint8_t http_buf2[] = {
1947 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
1948 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
1949 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
1950 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'o',
'c',
't',
'e',
't',
'-',
's',
't',
'r',
'e',
'a',
'm', 0x0d, 0x0a,
1952 0x5a, 0x57, 0x53, 0x01, 0x5c, 0x24, 0x00, 0x00, 0xb7, 0x21, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x20,
1953 0x00, 0x00, 0x3b, 0xff, 0xfc, 0x8e, 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85,
1954 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85, 0xf5, 0x75, 0x6f, 0xd0, 0x7e, 0x61,
1955 0x35, 0x1b, 0x1a, 0x8b, 0x16, 0x4d, 0xdf, 0x05, 0x32, 0xfe, 0xa4, 0x4c, 0x46, 0x49, 0xb7, 0x7b,
1956 0x6b, 0x75, 0xf9, 0x2b, 0x5c, 0x37, 0x29, 0x0b, 0x91, 0x37, 0x01, 0x37, 0x0e, 0xe9, 0xf2, 0xe1,
1960 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1961 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1964 const char *sig =
"alert tcp any any -> any any "
1965 "(flow:established,from_server; "
1966 "file_data; content:\"ZWS\"; "
1968 return RunTest(steps, sig,
input);
1971 static int DetectEngineHttpServerBodyFileDataTest29(
void)
1980 swf-decompression:\n\
1983 compress-depth: 1000\n\
1984 decompress-depth: 0\n\
1986 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1987 "Host: www.openinfosecfoundation.org\r\n"
1988 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1989 "Gecko/20091221 Firefox/3.5.7\r\n"
1992 uint8_t http_buf2[] = {
1993 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
1994 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
1995 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
1996 '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,
1998 0x43, 0x57, 0x53, 0x0a, 0xcb, 0x6c, 0x00, 0x00, 0x78, 0xda, 0xad, 0xbd, 0x07, 0x98, 0x55, 0x55,
1999 0x9e, 0xee, 0xbd, 0x4f, 0xd8, 0xb5, 0x4e, 0x15, 0xc1, 0xc2, 0x80, 0x28, 0x86, 0xd2, 0x2e, 0x5a,
2000 0xdb, 0x46, 0xd9, 0x39, 0x38, 0xdd, 0x4e, 0x1b, 0xa8, 0x56, 0x5b, 0xc5, 0x6b, 0xe8, 0x76, 0xfa,
2001 0x0e, 0xc2, 0x8e, 0x50, 0x76, 0x51, 0xc5, 0x54, 0x15, 0x88, 0x73, 0xc3, 0xd0, 0x88, 0x39, 0x81,
2002 0x98, 0x63, 0x91, 0x93, 0x8a, 0x82, 0x89, 0x60, 0x00, 0xcc, 0xb1, 0x00, 0x01, 0x73, 0xce, 0x39,
2006 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2007 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
2010 const char *sig =
"alert tcp any any -> any any "
2011 "(flow:established,from_server; "
2012 "file_data; content:\"FWS\"; "
2014 return RunTest(steps, sig,
input);
2021 static int DetectHttpServerBodyTest06(
void)
2023 uint8_t http_buf[] =
"GET /index.html HTTP/1.0\r\n"
2024 "Host: www.openinfosecfoundation.org\r\n"
2025 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2026 "Gecko/20091221 Firefox/3.5.7\r\n"
2028 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2029 "Content-Type: text/html\r\n"
2030 "Content-Length: 7\r\n"
2034 { (
const uint8_t *)http_buf,
sizeof(http_buf) - 1, STREAM_TOSERVER, 0 },
2035 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
2038 const char *sig =
"alert http any any -> any any "
2039 "(msg:\"http server body test\"; "
2040 "content:\"message\"; http_server_body; "
2042 return RunTest(steps, sig, NULL);
2049 static int DetectHttpServerBodyTest07(
void)
2051 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2052 "Host: www.openinfosecfoundation.org\r\n"
2053 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2054 "Gecko/20091221 Firefox/3.5.7\r\n"
2056 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2057 "Content-Type: text/html\r\n"
2058 "Content-Length: 14\r\n"
2060 uint8_t http_buf3[] =
"message";
2062 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2063 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2064 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT | STREAM_EOF, 1 },
2067 const char *sig =
"alert http any any -> any any "
2068 "(msg:\"http server body test\"; "
2069 "content:\"message\"; http_server_body; "
2071 return RunTest(steps, sig, NULL);
2078 static int DetectHttpServerBodyTest08(
void)
2080 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2081 "Host: www.openinfosecfoundation.org\r\n"
2082 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2083 "Gecko/20091221 Firefox/3.5.7\r\n"
2085 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2086 "Content-Type: text/html\r\n"
2087 "Content-Length: 14\r\n"
2090 uint8_t http_buf3[] =
"sage4u!!";
2092 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2093 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2094 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 1 },
2097 const char *sig =
"alert http any any -> any any "
2098 "(msg:\"http client body test\"; "
2099 "content:\"message\"; http_server_body; "
2101 return RunTest(steps, sig, NULL);
2108 static int DetectHttpServerBodyTest09(
void)
2110 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2111 "Host: www.openinfosecfoundation.org\r\n"
2112 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2113 "Gecko/20091221 Firefox/3.5.7\r\n"
2115 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2116 "Content-Type: text/html\r\n"
2117 "Content-Length: 14\r\n"
2120 uint8_t http_buf3[] =
"sag";
2121 uint8_t http_buf4[] =
"e4u!!";
2123 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2124 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2125 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 0 },
2126 { (
const uint8_t *)http_buf4,
sizeof(http_buf4) - 1, STREAM_TOCLIENT, 1 },
2129 const char *sig =
"alert http any any -> any any "
2130 "(msg:\"http client body test\"; "
2131 "content:\"message\"; http_server_body; "
2133 return RunTest(steps, sig, NULL);
2140 static int DetectHttpServerBodyTest10(
void)
2142 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2143 "Host: www.openinfosecfoundation.org\r\n"
2144 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2145 "Gecko/20091221 Firefox/3.5.7\r\n"
2147 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2148 "Content-Type: text/html\r\n"
2149 "Content-Length: 14\r\n"
2152 uint8_t http_buf3[] =
"sag";
2153 uint8_t http_buf4[] =
2156 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2157 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2158 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 0 },
2159 { (
const uint8_t *)http_buf4,
sizeof(http_buf4) - 1, STREAM_TOCLIENT, 1 },
2162 const char *sig =
"alert http any any -> any any "
2163 "(msg:\"http client body test\"; "
2164 "content:\"MeSSaGE\"; http_server_body; nocase; "
2166 return RunTest(steps, sig, NULL);
2173 static int DetectHttpServerBodyTest11(
void)
2175 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2176 "Host: www.openinfosecfoundation.org\r\n"
2177 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2178 "Gecko/20091221 Firefox/3.5.7\r\n"
2180 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2181 "Content-Type: text/html\r\n"
2182 "Content-Length: 14\r\n"
2184 uint8_t http_buf3[] =
"bigmessage4u!!";
2186 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2187 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2188 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 1 },
2191 const char *sig =
"alert http any any -> any any "
2192 "(msg:\"http client body test\"; "
2193 "content:!\"MaSSaGE\"; http_server_body; nocase; "
2195 return RunTest(steps, sig, NULL);
2202 static int DetectHttpServerBodyTest12(
void)
2204 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2205 "Host: www.openinfosecfoundation.org\r\n"
2206 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2207 "Gecko/20091221 Firefox/3.5.7\r\n"
2209 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2210 "Content-Type: text/html\r\n"
2211 "Content-Length: 14\r\n"
2213 uint8_t http_buf3[] =
"bigmessage4u!!";
2215 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2216 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2217 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 0 },
2220 const char *sig =
"alert http any any -> any any "
2221 "(msg:\"http client body test\"; "
2222 "content:!\"MeSSaGE\"; http_server_body; nocase; "
2224 return RunTest(steps, sig, NULL);
2227 static int DetectHttpServerBodyTest13(
void)
2229 uint8_t http_buf[] =
"GET /index.html HTTP/1.0\r\n"
2230 "Host: www.openinfosecfoundation.org\r\n"
2231 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2232 "Gecko/20091221 Firefox/3.5.7\r\n"
2234 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2235 "Content-Type: text/html\r\n"
2236 "Content-Length: 55\r\n"
2238 "longbufferabcdefghijklmnopqrstuvwxyz0123456789bufferend";
2240 { (
const uint8_t *)http_buf,
sizeof(http_buf) - 1, STREAM_TOSERVER, 0 },
2241 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
2244 const char *sig =
"alert http any any -> any any "
2245 "(msg:\"http server body test\"; "
2246 "content:\"longbufferabcdefghijklmnopqrstuvwxyz0123456789bufferend\"; "
2247 "http_server_body; "
2249 return RunTest(steps, sig, NULL);
2253 static int DetectHttpServerBodyTest14(
void)
2259 uint8_t httpbuf1[] =
"GET /index1.html HTTP/1.1\r\n"
2260 "User-Agent: Mozilla/1.0\r\n"
2261 "Host: www.openinfosecfoundation.org\r\n"
2262 "Connection: keep-alive\r\n"
2263 "Cookie: dummy1\r\n\r\n";
2264 uint32_t httplen1 =
sizeof(httpbuf1) - 1;
2265 uint8_t httpbuf2[] =
"HTTP/1.1 200 ok\r\n"
2266 "Content-Type: text/html\r\n"
2267 "Content-Length: 3\r\n"
2270 uint32_t httplen2 =
sizeof(httpbuf2) - 1;
2271 uint8_t httpbuf3[] =
"GET /index2.html HTTP/1.1\r\n"
2272 "User-Agent: Firefox/1.0\r\n"
2273 "Host: www.openinfosecfoundation.org\r\n"
2274 "Connection: keep-alive\r\n"
2275 "Cookie: dummy2\r\n\r\n";
2276 uint32_t httplen3 =
sizeof(httpbuf3) - 1;
2277 uint8_t httpbuf4[] =
"HTTP/1.1 200 ok\r\n"
2278 "Content-Type: text/html\r\n"
2279 "Content-Length: 3\r\n"
2282 uint32_t httplen4 =
sizeof(httpbuf4) - 1;
2284 memset(&th_v, 0,
sizeof(th_v));
2286 memset(&f, 0,
sizeof(f));
2287 memset(&ssn, 0,
sizeof(ssn));
2294 f.
proto = IPPROTO_TCP;
2310 "alert tcp any any -> any any (flow:established,to_client; "
2311 "content:\"one\"; http_server_body; sid:1; rev:1;)");
2314 "content:\"two\"; http_server_body; sid:2; rev:1;)");
2371 static int DetectHttpServerBodyTest15(
void)
2377 uint8_t httpbuf1[] =
"GET /index1.html HTTP/1.1\r\n"
2378 "User-Agent: Mozilla/1.0\r\n"
2379 "Host: www.openinfosecfoundation.org\r\n"
2380 "Connection: keep-alive\r\n"
2381 "Cookie: dummy1\r\n\r\n";
2382 uint32_t httplen1 =
sizeof(httpbuf1) - 1;
2383 uint8_t httpbuf2[] =
"HTTP/1.1 200 ok\r\n"
2384 "Content-Type: text/html\r\n"
2385 "Content-Length: 3\r\n"
2388 uint32_t httplen2 =
sizeof(httpbuf2) - 1;
2389 uint8_t httpbuf3[] =
"GET /index2.html HTTP/1.1\r\n"
2390 "User-Agent: Firefox/1.0\r\n"
2391 "Host: www.openinfosecfoundation.org\r\n"
2392 "Connection: keep-alive\r\n"
2393 "Cookie: dummy2\r\n\r\n";
2394 uint32_t httplen3 =
sizeof(httpbuf3) - 1;
2395 uint8_t httpbuf4[] =
"HTTP/1.1 200 ok\r\n"
2396 "Content-Type: text/html\r\n"
2397 "Content-Length: 3\r\n"
2400 uint32_t httplen4 =
sizeof(httpbuf4) - 1;
2402 memset(&th_v, 0,
sizeof(th_v));
2404 memset(&f, 0,
sizeof(f));
2405 memset(&ssn, 0,
sizeof(ssn));
2412 f.
proto = IPPROTO_TCP;
2428 "alert tcp any any -> any any (flow:established,to_client; "
2429 "content:\"one\"; http_server_body; sid:1; rev:1;)");
2432 "content:\"two\"; http_server_body; sid:2; rev:1;)");
2483 static int DetectHttpServerBodyFileDataTest01(
void)
2485 uint8_t http_buf[] =
"GET /index.html HTTP/1.0\r\n"
2486 "Host: www.openinfosecfoundation.org\r\n"
2487 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2488 "Gecko/20091221 Firefox/3.5.7\r\n"
2490 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2491 "Content-Type: text/html\r\n"
2492 "Content-Length: 7\r\n"
2496 { (
const uint8_t *)http_buf,
sizeof(http_buf) - 1, STREAM_TOSERVER, 0 },
2497 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
2500 const char *sig =
"alert http any any -> any any "
2501 "(msg:\"http server body test\"; "
2502 "file_data; content:\"message\"; "
2504 return RunTest(steps, sig, NULL);
2511 static int DetectHttpServerBodyFileDataTest02(
void)
2513 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2514 "Host: www.openinfosecfoundation.org\r\n"
2515 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2516 "Gecko/20091221 Firefox/3.5.7\r\n"
2518 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2519 "Content-Type: text/html\r\n"
2520 "Content-Length: 14\r\n"
2522 uint8_t http_buf3[] =
"message";
2524 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2525 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2526 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT | STREAM_EOF, 1 },
2529 const char *sig =
"alert http any any -> any any "
2530 "(msg:\"http server body test\"; "
2531 "file_data; content:\"message\"; "
2533 return RunTest(steps, sig, NULL);
2540 static int DetectHttpServerBodyFileDataTest03(
void)
2542 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2543 "Host: www.openinfosecfoundation.org\r\n"
2544 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2545 "Gecko/20091221 Firefox/3.5.7\r\n"
2547 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2548 "Content-Type: text/html\r\n"
2549 "Content-Length: 14\r\n"
2552 uint8_t http_buf3[] =
"sage4u!!";
2554 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2555 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2556 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 1 },
2559 const char *sig =
"alert http any any -> any any "
2560 "(msg:\"http server body test\"; "
2561 "file_data; content:\"message\"; "
2563 return RunTest(steps, sig, NULL);
2570 static int DetectHttpServerBodyFileDataTest04(
void)
2572 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2573 "Host: www.openinfosecfoundation.org\r\n"
2574 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2575 "Gecko/20091221 Firefox/3.5.7\r\n"
2577 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2578 "Content-Type: text/html\r\n"
2579 "Content-Length: 14\r\n"
2582 uint8_t http_buf3[] =
"sag";
2583 uint8_t http_buf4[] =
"e4u!!";
2585 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2586 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2587 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 0 },
2588 { (
const uint8_t *)http_buf4,
sizeof(http_buf4) - 1, STREAM_TOCLIENT, 1 },
2591 const char *sig =
"alert http any any -> any any "
2592 "(msg:\"http server body test\"; "
2593 "file_data; content:\"message\"; "
2595 return RunTest(steps, sig, NULL);
2602 static int DetectHttpServerBodyFileDataTest05(
void)
2604 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2605 "Host: www.openinfosecfoundation.org\r\n"
2606 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2607 "Gecko/20091221 Firefox/3.5.7\r\n"
2609 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2610 "Content-Type: text/html\r\n"
2611 "Content-Length: 14\r\n"
2614 uint8_t http_buf3[] =
"sag";
2615 uint8_t http_buf4[] =
"e4u!!";
2617 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2618 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2619 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 0 },
2620 { (
const uint8_t *)http_buf4,
sizeof(http_buf4) - 1, STREAM_TOCLIENT, 1 },
2623 const char *sig =
"alert http any any -> any any "
2624 "(msg:\"http client body test\"; "
2625 "file_data; content:\"MeSSaGE\"; nocase; "
2627 return RunTest(steps, sig, NULL);
2634 static int DetectHttpServerBodyFileDataTest06(
void)
2636 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2637 "Host: www.openinfosecfoundation.org\r\n"
2638 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2639 "Gecko/20091221 Firefox/3.5.7\r\n"
2641 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2642 "Content-Type: text/html\r\n"
2643 "Content-Length: 14\r\n"
2645 uint8_t http_buf3[] =
"bigmessage4u!!";
2647 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2648 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2649 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 1 },
2652 const char *sig =
"alert http any any -> any any "
2653 "(msg:\"http file_data test\"; "
2654 "file_data; content:!\"MaSSaGE\"; nocase; "
2656 return RunTest(steps, sig, NULL);
2663 static int DetectHttpServerBodyFileDataTest07(
void)
2665 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2666 "Host: www.openinfosecfoundation.org\r\n"
2667 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2668 "Gecko/20091221 Firefox/3.5.7\r\n"
2670 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2671 "Content-Type: text/html\r\n"
2672 "Content-Length: 14\r\n"
2674 uint8_t http_buf3[] =
"bigmessage4u!!";
2676 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2677 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2678 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 0 },
2681 const char *sig =
"alert http any any -> any any "
2682 "(msg:\"http file_data test\"; "
2683 "file_data; content:!\"MeSSaGE\"; nocase; "
2685 return RunTest(steps, sig, NULL);
2688 static int DetectHttpServerBodyFileDataTest08(
void)
2690 uint8_t http_buf[] =
"GET /index.html HTTP/1.0\r\n"
2691 "Host: www.openinfosecfoundation.org\r\n"
2692 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2693 "Gecko/20091221 Firefox/3.5.7\r\n"
2695 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2696 "Content-Type: text/html\r\n"
2697 "Content-Length: 55\r\n"
2699 "longbufferabcdefghijklmnopqrstuvwxyz0123456789bufferend";
2701 { (
const uint8_t *)http_buf,
sizeof(http_buf) - 1, STREAM_TOSERVER, 0 },
2702 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
2706 "alert http any any -> any any "
2707 "(msg:\"http server body test\"; "
2708 "file_data; content:\"longbufferabcdefghijklmnopqrstuvwxyz0123456789bufferend\"; "
2710 return RunTest(steps, sig, NULL);
2714 static int DetectHttpServerBodyFileDataTest09(
void)
2720 uint8_t httpbuf1[] =
"GET /index1.html HTTP/1.1\r\n"
2721 "User-Agent: Mozilla/1.0\r\n"
2722 "Host: www.openinfosecfoundation.org\r\n"
2723 "Connection: keep-alive\r\n"
2724 "Cookie: dummy1\r\n\r\n";
2725 uint32_t httplen1 =
sizeof(httpbuf1) - 1;
2726 uint8_t httpbuf2[] =
"HTTP/1.1 200 ok\r\n"
2727 "Content-Type: text/html\r\n"
2728 "Content-Length: 3\r\n"
2731 uint32_t httplen2 =
sizeof(httpbuf2) - 1;
2732 uint8_t httpbuf3[] =
"GET /index2.html HTTP/1.1\r\n"
2733 "User-Agent: Firefox/1.0\r\n"
2734 "Host: www.openinfosecfoundation.org\r\n"
2735 "Connection: keep-alive\r\n"
2736 "Cookie: dummy2\r\n\r\n";
2737 uint32_t httplen3 =
sizeof(httpbuf3) - 1;
2738 uint8_t httpbuf4[] =
"HTTP/1.1 200 ok\r\n"
2739 "Content-Type: text/html\r\n"
2740 "Content-Length: 3\r\n"
2743 uint32_t httplen4 =
sizeof(httpbuf4) - 1;
2745 memset(&th_v, 0,
sizeof(th_v));
2747 memset(&f, 0,
sizeof(f));
2748 memset(&ssn, 0,
sizeof(ssn));
2755 f.
proto = IPPROTO_TCP;
2771 "alert tcp any any -> any any (flow:established,to_client; file_data; "
2772 "content:\"one\"; sid:1; rev:1;)");
2774 s =
DetectEngineAppendSig(
de_ctx,
"alert tcp any any -> any any (flow:established,to_client; file_data; content:\"two\"; sid:2; rev:1;)");
2819 static int DetectHttpServerBodyFileDataTest10(
void)
2825 uint8_t httpbuf1[] =
"GET /index1.html HTTP/1.1\r\n"
2826 "User-Agent: Mozilla/1.0\r\n"
2827 "Host: www.openinfosecfoundation.org\r\n"
2828 "Connection: keep-alive\r\n"
2829 "Cookie: dummy1\r\n\r\n";
2830 uint32_t httplen1 =
sizeof(httpbuf1) - 1;
2831 uint8_t httpbuf2[] =
"HTTP/1.1 200 ok\r\n"
2832 "Content-Type: text/html\r\n"
2833 "Content-Length: 3\r\n"
2836 uint32_t httplen2 =
sizeof(httpbuf2) - 1;
2837 uint8_t httpbuf3[] =
"GET /index2.html HTTP/1.1\r\n"
2838 "User-Agent: Firefox/1.0\r\n"
2839 "Host: www.openinfosecfoundation.org\r\n"
2840 "Connection: keep-alive\r\n"
2841 "Cookie: dummy2\r\n\r\n";
2842 uint32_t httplen3 =
sizeof(httpbuf3) - 1;
2843 uint8_t httpbuf4[] =
"HTTP/1.1 200 ok\r\n"
2844 "Content-Type: text/html\r\n"
2845 "Content-Length: 3\r\n"
2848 uint32_t httplen4 =
sizeof(httpbuf4) - 1;
2850 memset(&th_v, 0,
sizeof(th_v));
2852 memset(&f, 0,
sizeof(f));
2853 memset(&ssn, 0,
sizeof(ssn));
2860 f.
proto = IPPROTO_TCP;
2876 "alert tcp any any -> any any (flow:established,to_client; file_data; "
2877 "content:\"one\"; sid:1; rev:1;)");
2879 s =
DetectEngineAppendSig(
de_ctx,
"alert tcp any any -> any any (flow:established,to_client; file_data; content:\"two\"; sid:2; rev:1;)");
2926 UtRegisterTest(
"DetectHttpServerBodyParserTest01", DetectHttpServerBodyParserTest01);
2927 UtRegisterTest(
"DetectHttpServerBodyParserTest02", DetectHttpServerBodyParserTest02);
2929 UtRegisterTest(
"DetectHttpServerBodyTest06", DetectHttpServerBodyTest06);
2930 UtRegisterTest(
"DetectHttpServerBodyTest07", DetectHttpServerBodyTest07);
2931 UtRegisterTest(
"DetectHttpServerBodyTest08", DetectHttpServerBodyTest08);
2932 UtRegisterTest(
"DetectHttpServerBodyTest09", DetectHttpServerBodyTest09);
2933 UtRegisterTest(
"DetectHttpServerBodyTest10", DetectHttpServerBodyTest10);
2934 UtRegisterTest(
"DetectHttpServerBodyTest11", DetectHttpServerBodyTest11);
2935 UtRegisterTest(
"DetectHttpServerBodyTest12", DetectHttpServerBodyTest12);
2936 UtRegisterTest(
"DetectHttpServerBodyTest13", DetectHttpServerBodyTest13);
2937 UtRegisterTest(
"DetectHttpServerBodyTest14", DetectHttpServerBodyTest14);
2938 UtRegisterTest(
"DetectHttpServerBodyTest15", DetectHttpServerBodyTest15);
2941 DetectHttpServerBodyFileDataTest01);
2943 DetectHttpServerBodyFileDataTest02);
2945 DetectHttpServerBodyFileDataTest03);
2947 DetectHttpServerBodyFileDataTest04);
2949 DetectHttpServerBodyFileDataTest05);
2951 DetectHttpServerBodyFileDataTest06);
2953 DetectHttpServerBodyFileDataTest07);
2955 DetectHttpServerBodyFileDataTest08);
2957 DetectHttpServerBodyFileDataTest09);
2959 DetectHttpServerBodyFileDataTest10);
2962 DetectEngineHttpServerBodyTest01);
2964 DetectEngineHttpServerBodyTest02);
2966 DetectEngineHttpServerBodyTest03);
2968 DetectEngineHttpServerBodyTest04);
2970 DetectEngineHttpServerBodyTest05);
2972 DetectEngineHttpServerBodyTest06);
2974 DetectEngineHttpServerBodyTest07);
2976 DetectEngineHttpServerBodyTest08);
2978 DetectEngineHttpServerBodyTest09);
2980 DetectEngineHttpServerBodyTest10);
2982 DetectEngineHttpServerBodyTest11);
2984 DetectEngineHttpServerBodyTest12);
2986 DetectEngineHttpServerBodyTest13);
2988 DetectEngineHttpServerBodyTest14);
2990 DetectEngineHttpServerBodyTest15);
2992 DetectEngineHttpServerBodyTest16);
2994 DetectEngineHttpServerBodyTest17);
2996 DetectEngineHttpServerBodyTest18);
2998 DetectEngineHttpServerBodyTest19);
3000 DetectEngineHttpServerBodyTest20);
3002 DetectEngineHttpServerBodyTest21);
3004 DetectEngineHttpServerBodyTest22);
3007 DetectEngineHttpServerBodyFileDataTest01);
3009 DetectEngineHttpServerBodyFileDataTest02);
3011 DetectEngineHttpServerBodyFileDataTest03);
3013 DetectEngineHttpServerBodyFileDataTest04);
3015 DetectEngineHttpServerBodyFileDataTest05);
3017 DetectEngineHttpServerBodyFileDataTest06);
3019 DetectEngineHttpServerBodyFileDataTest07);
3021 DetectEngineHttpServerBodyFileDataTest08);
3023 DetectEngineHttpServerBodyFileDataTest09);
3025 DetectEngineHttpServerBodyFileDataTest10);
3027 DetectEngineHttpServerBodyFileDataTest11);
3029 DetectEngineHttpServerBodyFileDataTest12);
3031 DetectEngineHttpServerBodyFileDataTest13);
3033 DetectEngineHttpServerBodyFileDataTest14);
3035 DetectEngineHttpServerBodyFileDataTest15);
3037 DetectEngineHttpServerBodyFileDataTest16);
3039 DetectEngineHttpServerBodyFileDataTest17);
3041 DetectEngineHttpServerBodyFileDataTest18);
3044 DetectEngineHttpServerBodyFileDataTest19);
3046 DetectEngineHttpServerBodyFileDataTest20);
3048 DetectEngineHttpServerBodyFileDataTest21);
3050 DetectEngineHttpServerBodyFileDataTest22);
3052 DetectEngineHttpServerBodyFileDataTest23);
3054 DetectEngineHttpServerBodyFileDataTest24);
3056 DetectEngineHttpServerBodyFileDataTest25);
3058 DetectEngineHttpServerBodyFileDataTest26);
3060 DetectEngineHttpServerBodyFileDataTest27);
3062 DetectEngineHttpServerBodyFileDataTest28);
3064 DetectEngineHttpServerBodyFileDataTest29);