26#include "../suricata-common.h"
27#include "../conf-yaml-loader.h"
31#include "../detect-engine-build.h"
32#include "../detect-engine-alert.h"
37static 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));
54static 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));
75static 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) {
161static int DetectEngineHttpServerBodyTest01(
void)
163 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
164 "Host: www.openinfosecfoundation.org\r\n"
165 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
166 "Gecko/20091221 Firefox/3.5.7\r\n"
168 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
169 "Content-Type: text/html\r\n"
170 "Content-Length: 7\r\n"
174 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
175 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
179 const char *sig =
"alert http any any -> any any "
180 "(msg:\"http server body test\"; "
181 "content:\"message\"; http_server_body; "
183 return RunTest(steps, sig, NULL);
186static int DetectEngineHttpServerBodyTest02(
void)
188 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
189 "Host: www.openinfosecfoundation.org\r\n"
190 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
191 "Gecko/20091221 Firefox/3.5.7\r\n"
193 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
194 "Content-Type: text/html\r\n"
195 "Content-Length: 7\r\n"
199 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
200 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
204 const char *sig =
"alert http any any -> any any "
205 "(msg:\"http server body test\"; "
206 "content:\"ABC\"; http_server_body; offset:4; "
208 return RunTest(steps, sig, NULL);
211static int DetectEngineHttpServerBodyTest03(
void)
213 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
214 "Host: www.openinfosecfoundation.org\r\n"
215 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
216 "Gecko/20091221 Firefox/3.5.7\r\n"
218 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
219 "Content-Type: text/html\r\n"
220 "Content-Length: 17\r\n"
223 uint8_t http_buf3[] =
"8901234ABC";
225 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
226 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
227 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 1 },
231 const char *sig =
"alert http any any -> any any "
232 "(msg:\"http server body test\"; "
233 "content:\"ABC\"; http_server_body; offset:14; "
235 return RunTest(steps, sig, NULL);
238static int DetectEngineHttpServerBodyTest04(
void)
240 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
241 "Host: www.openinfosecfoundation.org\r\n"
242 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
243 "Gecko/20091221 Firefox/3.5.7\r\n"
245 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
246 "Content-Type: text/html\r\n"
247 "Content-Length: 6\r\n"
251 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
252 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
255 const char *sig =
"alert http any any -> any any "
256 "(msg:\"http server body test\"; "
257 "content:!\"abc\"; http_server_body; offset:3; "
259 return RunTest(steps, sig, NULL);
262static int DetectEngineHttpServerBodyTest05(
void)
264 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
265 "Host: www.openinfosecfoundation.org\r\n"
266 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
267 "Gecko/20091221 Firefox/3.5.7\r\n"
269 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
270 "Content-Type: text/html\r\n"
271 "Content-Length: 6\r\n"
275 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
276 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
279 const char *sig =
"alert http any any -> any any "
280 "(msg:\"http server body test\"; "
281 "content:\"abc\"; http_server_body; depth:3; "
283 return RunTest(steps, sig, NULL);
286static int DetectEngineHttpServerBodyTest06(
void)
288 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
289 "Host: www.openinfosecfoundation.org\r\n"
290 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
291 "Gecko/20091221 Firefox/3.5.7\r\n"
293 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
294 "Content-Type: text/html\r\n"
295 "Content-Length: 6\r\n"
299 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
300 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
303 const char *sig =
"alert http any any -> any any "
304 "(msg:\"http server body test\"; "
305 "content:!\"def\"; http_server_body; depth:3; "
307 return RunTest(steps, sig, NULL);
310static int DetectEngineHttpServerBodyTest07(
void)
312 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
313 "Host: www.openinfosecfoundation.org\r\n"
314 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
315 "Gecko/20091221 Firefox/3.5.7\r\n"
317 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
318 "Content-Type: text/html\r\n"
319 "Content-Length: 6\r\n"
323 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
324 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
327 const char *sig =
"alert http any any -> any any "
328 "(msg:\"http server body test\"; "
329 "content:!\"def\"; http_server_body; offset:3; "
331 return RunTest(steps, sig, NULL);
334static int DetectEngineHttpServerBodyTest08(
void)
336 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
337 "Host: www.openinfosecfoundation.org\r\n"
338 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
339 "Gecko/20091221 Firefox/3.5.7\r\n"
341 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
342 "Content-Type: text/html\r\n"
343 "Content-Length: 6\r\n"
348 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
349 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
352 const char *sig =
"alert http any any -> any any "
353 "(msg:\"http server body test\"; "
354 "content:!\"abc\"; http_server_body; depth:3; "
356 return RunTest(steps, sig, NULL);
359static int DetectEngineHttpServerBodyTest09(
void)
361 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
362 "Host: www.openinfosecfoundation.org\r\n"
363 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
364 "Gecko/20091221 Firefox/3.5.7\r\n"
366 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
367 "Content-Type: text/html\r\n"
368 "Content-Length: 6\r\n"
372 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
373 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
376 const char *sig =
"alert http any any -> any any "
377 "(msg:\"http server body test\"; "
378 "content:\"abc\"; http_server_body; depth:3; "
379 "content:\"def\"; http_server_body; within:3; "
381 return RunTest(steps, sig, NULL);
384static int DetectEngineHttpServerBodyTest10(
void)
386 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
387 "Host: www.openinfosecfoundation.org\r\n"
388 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
389 "Gecko/20091221 Firefox/3.5.7\r\n"
391 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
392 "Content-Type: text/html\r\n"
393 "Content-Length: 6\r\n"
397 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
398 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
401 const char *sig =
"alert http any any -> any any "
402 "(msg:\"http server body test\"; "
403 "content:\"abc\"; http_server_body; depth:3; "
404 "content:!\"xyz\"; http_server_body; within:3; "
406 return RunTest(steps, sig, NULL);
409static int DetectEngineHttpServerBodyTest11(
void)
411 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
412 "Host: www.openinfosecfoundation.org\r\n"
413 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
414 "Gecko/20091221 Firefox/3.5.7\r\n"
416 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
417 "Content-Type: text/html\r\n"
418 "Content-Length: 6\r\n"
422 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
423 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
426 const char *sig =
"alert http any any -> any any "
427 "(msg:\"http server body test\"; "
428 "content:\"abc\"; http_server_body; depth:3; "
429 "content:\"xyz\"; http_server_body; within:3; "
431 return RunTest(steps, sig, NULL);
434static int DetectEngineHttpServerBodyTest12(
void)
436 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
437 "Host: www.openinfosecfoundation.org\r\n"
438 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
439 "Gecko/20091221 Firefox/3.5.7\r\n"
441 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
442 "Content-Type: text/html\r\n"
443 "Content-Length: 6\r\n"
447 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
448 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
451 const char *sig =
"alert http any any -> any any "
452 "(msg:\"http server body test\"; "
453 "content:\"ab\"; http_server_body; depth:2; "
454 "content:\"ef\"; http_server_body; distance:2; "
456 return RunTest(steps, sig, NULL);
459static int DetectEngineHttpServerBodyTest13(
void)
461 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
462 "Host: www.openinfosecfoundation.org\r\n"
463 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
464 "Gecko/20091221 Firefox/3.5.7\r\n"
466 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
467 "Content-Type: text/html\r\n"
468 "Content-Length: 6\r\n"
472 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
473 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
476 const char *sig =
"alert http any any -> any any "
477 "(msg:\"http server body test\"; "
478 "content:\"ab\"; http_server_body; depth:3; "
479 "content:!\"yz\"; http_server_body; distance:2; "
481 return RunTest(steps, sig, NULL);
484static int DetectEngineHttpServerBodyTest14(
void)
486 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
487 "Host: www.openinfosecfoundation.org\r\n"
488 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
489 "Gecko/20091221 Firefox/3.5.7\r\n"
491 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
492 "Content-Type: text/html\r\n"
493 "Content-Length: 6\r\n"
497 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
498 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
501 const char *sig =
"alert http any any -> any any "
502 "(msg:\"http server body test\"; "
504 "content:\"ef\"; http_server_body; distance:2; "
506 return RunTest(steps, sig, NULL);
509static int DetectEngineHttpServerBodyTest15(
void)
511 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
512 "Host: www.openinfosecfoundation.org\r\n"
513 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
514 "Gecko/20091221 Firefox/3.5.7\r\n"
516 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
517 "Content-Type: text/html\r\n"
518 "Content-Length: 6\r\n"
522 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
523 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
526 const char *sig =
"alert http any any -> any any "
527 "(msg:\"http server body test\"; "
529 "content:!\"xyz\"; http_server_body; distance:0; within:3; "
531 return RunTest(steps, sig, NULL);
534static int DetectEngineHttpServerBodyTest16(
void)
543 request-body-limit: 0\n\
544 response-body-limit: 0\n\
546 request-body-inspect-window: 0\n\
547 response-body-inspect-window: 0\n\
548 request-body-minimal-inspect-size: 0\n\
549 response-body-minimal-inspect-size: 0\n\
551 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
552 "Host: www.openinfosecfoundation.org\r\n"
553 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
554 "Gecko/20091221 Firefox/3.5.7\r\n"
556 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
557 "Content-Type: text/html\r\n"
558 "Content-Length: 17\r\n"
561 uint8_t http_buf3[] =
"8901234ABC";
563 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
564 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
565 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 0 },
568 const char *sig =
"alert http any any -> any any ("
569 "content:\"890\"; within:3; http_server_body; "
571 return RunTest(steps, sig,
input);
574static int DetectEngineHttpServerBodyTest17(
void)
583 request-body-limit: 0\n\
584 response-body-limit: 0\n\
586 request-body-inspect-window: 0\n\
587 response-body-inspect-window: 0\n\
588 request-body-minimal-inspect-size: 0\n\
589 response-body-minimal-inspect-size: 0\n\
591 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
592 "Host: www.openinfosecfoundation.org\r\n"
593 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
594 "Gecko/20091221 Firefox/3.5.7\r\n"
596 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
597 "Content-Type: text/html\r\n"
598 "Content-Length: 17\r\n"
601 uint8_t http_buf3[] =
"8901234ABC";
603 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
604 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
605 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 0 },
608 const char *sig =
"alert http any any -> any any ("
609 "content:\"890\"; depth:3; http_server_body; "
611 return RunTest(steps, sig,
input);
617static int DetectEngineHttpServerBodyTest18(
void)
619 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
620 "Host: www.openinfosecfoundation.org\r\n"
621 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
622 "Gecko/20091221 Firefox/3.5.7\r\n"
625 uint8_t http_buf2[] = {
626 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
627 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'5',
'1', 0x0d, 0x0a,
628 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'E',
'n',
'c',
'o',
'd',
'i',
'n',
'g',
':',
' ',
629 'g',
'z',
'i',
'p', 0x0d, 0x0a,
631 0x1f, 0x8b, 0x08, 0x08, 0x27, 0x1e, 0xe5, 0x51, 0x00, 0x03, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74,
632 0x78, 0x74, 0x00, 0x2b, 0xc9, 0xc8, 0x2c, 0x56, 0x00, 0xa2, 0x44, 0x85, 0xb4, 0xcc, 0x9c, 0x54,
633 0x85, 0xcc, 0x3c, 0x20, 0x2b, 0x29, 0xbf, 0x42, 0x8f, 0x0b, 0x00, 0xb2, 0x7d, 0xac, 0x9b, 0x19,
638 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
639 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
642 const char *sig =
"alert http any any -> any any "
643 "(msg:\"http server body test\"; "
644 "content:\"file\"; http_server_body; "
646 return RunTest(steps, sig, NULL);
652static int DetectEngineHttpServerBodyTest19(
void)
654 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
655 "Host: www.openinfosecfoundation.org\r\n"
656 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
657 "Gecko/20091221 Firefox/3.5.7\r\n"
660 uint8_t http_buf2[] = {
661 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
662 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'2',
'4', 0x0d, 0x0a,
663 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'E',
'n',
'c',
'o',
'd',
'i',
'n',
'g',
':',
' ',
664 'd',
'e',
'f',
'l',
'a',
't',
'e', 0x0d, 0x0a,
666 0x2b, 0xc9, 0xc8, 0x2c, 0x56, 0x00, 0xa2, 0x44, 0x85, 0xb4, 0xcc, 0x9c, 0x54, 0x85, 0xcc, 0x3c,
667 0x20, 0x2b, 0x29, 0xbf, 0x42, 0x8f, 0x0b, 0x00,
672 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
673 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
676 const char *sig =
"alert http any any -> any any "
677 "(msg:\"http server body test\"; "
678 "content:\"file\"; http_server_body; "
680 return RunTest(steps, sig, NULL);
686static int DetectEngineHttpServerBodyTest20(
void)
688 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
689 "Host: www.openinfosecfoundation.org\r\n"
690 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
691 "Gecko/20091221 Firefox/3.5.7\r\n"
694 uint8_t http_buf2[] = {
695 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
696 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'2',
'4', 0x0d, 0x0a,
697 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'E',
'n',
'c',
'o',
'd',
'i',
'n',
'g',
':',
' ',
698 'g',
'z',
'i',
'p', 0x0d, 0x0a,
700 0x2b, 0xc9, 0xc8, 0x2c, 0x56, 0x00, 0xa2, 0x44, 0x85, 0xb4, 0xcc, 0x9c, 0x54, 0x85, 0xcc, 0x3c,
701 0x20, 0x2b, 0x29, 0xbf, 0x42, 0x8f, 0x0b, 0x00,
706 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
707 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
710 const char *sig =
"alert http any any -> any any "
711 "(msg:\"http server body test\"; "
712 "content:\"file\"; http_server_body; "
714 return RunTest(steps, sig, NULL);
720static int DetectEngineHttpServerBodyTest21(
void)
722 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
723 "Host: www.openinfosecfoundation.org\r\n"
724 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
725 "Gecko/20091221 Firefox/3.5.7\r\n"
728 uint8_t http_buf2[] = {
729 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
730 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'5',
'1', 0x0d, 0x0a,
731 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'E',
'n',
'c',
'o',
'd',
'i',
'n',
'g',
':',
' ',
732 'd',
'e',
'f',
'l',
'a',
't',
'e', 0x0d, 0x0a,
734 0x1f, 0x8b, 0x08, 0x08, 0x27, 0x1e, 0xe5, 0x51, 0x00, 0x03, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74,
735 0x78, 0x74, 0x00, 0x2b, 0xc9, 0xc8, 0x2c, 0x56, 0x00, 0xa2, 0x44, 0x85, 0xb4, 0xcc, 0x9c, 0x54,
736 0x85, 0xcc, 0x3c, 0x20, 0x2b, 0x29, 0xbf, 0x42, 0x8f, 0x0b, 0x00, 0xb2, 0x7d, 0xac, 0x9b, 0x19,
741 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
742 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
745 const char *sig =
"alert http any any -> any any "
746 "(msg:\"http server body test\"; "
747 "content:\"file\"; http_server_body; "
749 return RunTest(steps, sig, NULL);
756static int DetectEngineHttpServerBodyTest22(
void)
758 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
759 "Host: www.openinfosecfoundation.org\r\n"
760 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
761 "Gecko/20091221 Firefox/3.5.7\r\n"
764 uint8_t http_buf2[] = {
765 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
766 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'5',
'1', 0x0d, 0x0a,
767 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'E',
'n',
'c',
'o',
'd',
'i',
'n',
'g',
':',
' ',
768 'g',
'z',
'i',
'p', 0x0d, 0x0a,
769 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'E',
'n',
'c',
'o',
'd',
'i',
'n',
'g',
':',
' ',
770 'd',
'e',
'f',
'l',
'a',
't',
'e', 0x0d, 0x0a,
772 0x1f, 0x8b, 0x08, 0x08, 0x27, 0x1e, 0xe5, 0x51, 0x00, 0x03, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74,
773 0x78, 0x74, 0x00, 0x2b, 0xc9, 0xc8, 0x2c, 0x56, 0x00, 0xa2, 0x44, 0x85, 0xb4, 0xcc, 0x9c, 0x54,
774 0x85, 0xcc, 0x3c, 0x20, 0x2b, 0x29, 0xbf, 0x42, 0x8f, 0x0b, 0x00, 0xb2, 0x7d, 0xac, 0x9b, 0x19,
779 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
780 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
783 const char *sig =
"alert http any any -> any any "
784 "(msg:\"http server body test\"; "
785 "content:\"file\"; http_server_body; "
787 return RunTest(steps, sig, NULL);
790static int DetectEngineHttpServerBodyFileDataTest01(
void)
792 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
793 "Host: www.openinfosecfoundation.org\r\n"
794 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
795 "Gecko/20091221 Firefox/3.5.7\r\n"
797 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
798 "Content-Type: text/html\r\n"
799 "Content-Length: 6\r\n"
803 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
804 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
807 const char *sig =
"alert http any any -> any any "
808 "(msg:\"http server body test\"; "
809 "file_data; pcre:/ab/; "
810 "content:\"ef\"; distance:2; "
812 return RunTest(steps, sig, NULL);
815static int DetectEngineHttpServerBodyFileDataTest02(
void)
817 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
818 "Host: www.openinfosecfoundation.org\r\n"
819 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
820 "Gecko/20091221 Firefox/3.5.7\r\n"
822 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
823 "Content-Type: text/html\r\n"
824 "Content-Length: 6\r\n"
828 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
829 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
832 const char *sig =
"alert http any any -> any any "
833 "(msg:\"http server body test\"; "
834 "file_data; pcre:/abc/; "
835 "content:!\"xyz\"; distance:0; within:3; "
837 return RunTest(steps, sig, NULL);
841static int DetectEngineHttpServerBodyFileDataTest03(
void)
850 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
851 "Host: www.openinfosecfoundation.org\r\n"
852 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
853 "Gecko/20091221 Firefox/3.5.7\r\n"
855 uint32_t http_len1 =
sizeof(http_buf1) - 1;
856 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
857 "Content-Type: text/html\r\n"
858 "Content-Length: 33\r\n"
860 "XYZ_klm_1234abcd_XYZ_klm_5678abcd";
861 uint32_t http_len2 =
sizeof(http_buf2) - 1;
864 memset(&th_v, 0,
sizeof(th_v));
865 memset(&f, 0,
sizeof(f));
866 memset(&ssn, 0,
sizeof(ssn));
873 f.
proto = IPPROTO_TCP;
893 "alert http any any -> any any "
894 "(msg:\"match on 1st\"; "
895 "file_data; content:\"XYZ\"; content:\"_klm_\"; distance:0; content:\"abcd\"; "
896 "distance:4; byte_test:4,=,1234,-8,relative,string;"
900 "alert http any any -> any any "
901 "(msg:\"match on 2nd\"; "
902 "file_data; content:\"XYZ\"; content:\"_klm_\"; distance:0; content:\"abcd\"; "
903 "distance:4; byte_test:4,=,5678,-8,relative,string;"
939static int DetectEngineHttpServerBodyFileDataTest04(
void)
942 const char yaml[] =
"\
949 http-body-inline: yes\n\
950 response-body-minimal-inspect-size: 6\n\
951 response-body-inspect-window: 3\n\
955 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
956 "Host: www.openinfosecfoundation.org\r\n"
957 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
958 "Gecko/20091221 Firefox/3.5.7\r\n"
960 0, STREAM_TOSERVER, 0 },
961 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
962 "Content-Type: text/html\r\n"
963 "Content-Length: 6\r\n"
966 0, STREAM_TOCLIENT, 0 },
967 { (
const uint8_t *)
"cd", 0, STREAM_TOCLIENT, 1 },
968 { (
const uint8_t *)
"ef", 0, STREAM_TOCLIENT, 0 },
972 const char *sig =
"alert http any any -> any any (file_data; content:\"abcd\"; sid:1;)";
973 return RunTest(steps, sig, yaml);
976static int DetectEngineHttpServerBodyFileDataTest05(
void)
979 const char yaml[] =
"\
986 http-body-inline: yes\n\
987 response-body-minimal-inspect-size: 6\n\
988 response-body-inspect-window: 3\n\
992 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
993 "Host: www.openinfosecfoundation.org\r\n"
994 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
995 "Gecko/20091221 Firefox/3.5.7\r\n"
997 0, STREAM_TOSERVER, 0 },
998 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
999 "Content-Type: text/html\r\n"
1000 "Content-Length: 6\r\n"
1003 0, STREAM_TOCLIENT, 0 },
1004 { (
const uint8_t *)
"cd", 0, STREAM_TOCLIENT, 0 },
1005 { (
const uint8_t *)
"ef", 0, STREAM_TOCLIENT, 1 },
1009 const char *sig =
"alert http any any -> any any (file_data; content:\"abcdef\"; sid:1;)";
1010 return RunTest(steps, sig, yaml);
1013static int DetectEngineHttpServerBodyFileDataTest06(
void)
1016 const char yaml[] =
"\
1023 http-body-inline: yes\n\
1024 response-body-minimal-inspect-size: 6\n\
1025 response-body-inspect-window: 3\n\
1029 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1030 "Host: www.openinfosecfoundation.org\r\n"
1031 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1032 "Gecko/20091221 Firefox/3.5.7\r\n"
1034 0, STREAM_TOSERVER, 0 },
1035 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1036 "Content-Type: text/html\r\n"
1037 "Content-Length: 6\r\n"
1040 0, STREAM_TOCLIENT, 0 },
1041 { (
const uint8_t *)
"cd", 0, STREAM_TOCLIENT, 0 },
1042 { (
const uint8_t *)
"ef", 0, STREAM_TOCLIENT, 1 },
1047 "alert http any any -> any any (file_data; content:\"bcdef\"; offset:1; sid:1;)";
1048 return RunTest(steps, sig, yaml);
1051static int DetectEngineHttpServerBodyFileDataTest07(
void)
1054 const char yaml[] =
"\
1061 http-body-inline: yes\n\
1062 response-body-minimal-inspect-size: 6\n\
1063 response-body-inspect-window: 3\n\
1067 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1068 "Host: www.openinfosecfoundation.org\r\n"
1069 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1070 "Gecko/20091221 Firefox/3.5.7\r\n"
1072 0, STREAM_TOSERVER, 0 },
1073 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1074 "Content-Type: text/html\r\n"
1075 "Content-Length: 13\r\n"
1078 0, STREAM_TOCLIENT, 0 },
1079 { (
const uint8_t *)
"cd", 0, STREAM_TOCLIENT, 1 },
1080 { (
const uint8_t *)
"123456789", 0, STREAM_TOCLIENT, 0 },
1085 "alert http any any -> any any (file_data; content:\"bc\"; offset:1; depth:2; sid:1;)";
1086 return RunTest(steps, sig, yaml);
1089static int DetectEngineHttpServerBodyFileDataTest08(
void)
1092 const char yaml[] =
"\
1099 http-body-inline: yes\n\
1100 response-body-minimal-inspect-size: 6\n\
1101 response-body-inspect-window: 3\n\
1105 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1106 "Host: www.openinfosecfoundation.org\r\n"
1107 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1108 "Gecko/20091221 Firefox/3.5.7\r\n"
1110 0, STREAM_TOSERVER, 0 },
1111 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1112 "Content-Type: text/html\r\n"
1113 "Content-Length: 14\r\n"
1116 0, STREAM_TOCLIENT, 0 },
1117 { (
const uint8_t *)
"cd", 0, STREAM_TOCLIENT, 0 },
1118 { (
const uint8_t *)
"1234567890", 0, STREAM_TOCLIENT, 1 },
1123 "alert http any any -> any any (file_data; content:\"d123456789\"; offset:3; sid:1;)";
1124 return RunTest(steps, sig, yaml);
1127static int DetectEngineHttpServerBodyFileDataTest09(
void)
1130 const char yaml[] =
"\
1137 http-body-inline: yes\n\
1138 response-body-minimal-inspect-size: 6\n\
1139 response-body-inspect-window: 3\n\
1143 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1144 "Host: www.openinfosecfoundation.org\r\n"
1145 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1146 "Gecko/20091221 Firefox/3.5.7\r\n"
1148 0, STREAM_TOSERVER, 0 },
1149 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1150 "Content-Type: text/html\r\n"
1151 "Content-Length: 13\r\n"
1154 0, STREAM_TOCLIENT, 0 },
1155 { (
const uint8_t *)
"cd", 0, STREAM_TOCLIENT, 0 },
1156 { (
const uint8_t *)
"123456789", 0, STREAM_TOCLIENT, 1 },
1161 "alert http any any -> any any (file_data; content:\"abcd12\"; depth:6; sid:1;)";
1162 return RunTest(steps, sig, yaml);
1165static int DetectEngineHttpServerBodyFileDataTest10(
void)
1168 const char yaml[] =
"\
1175 http-body-inline: yes\n\
1176 response-body-minimal-inspect-size: 6\n\
1177 response-body-inspect-window: 3\n\
1181 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1182 "Host: www.openinfosecfoundation.org\r\n"
1183 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1184 "Gecko/20091221 Firefox/3.5.7\r\n"
1186 0, STREAM_TOSERVER, 0 },
1187 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1188 "Content-Type: text/html\r\n"
1189 "Content-Length: 5\r\n"
1192 0, STREAM_TOCLIENT, 0 },
1193 { (
const uint8_t *)
"c", 0, STREAM_TOCLIENT, 1 },
1194 { (
const uint8_t *)
"de", 0, STREAM_TOCLIENT, 0 },
1198 const char *sig =
"alert http any any -> any any (file_data; content:\"abc\"; depth:3; sid:1;)";
1199 return RunTest(steps, sig, yaml);
1202static int DetectEngineHttpServerBodyFileDataTest11(
void)
1205 const char yaml[] =
"\
1212 http-body-inline: yes\n\
1213 response-body-minimal-inspect-size: 6\n\
1214 response-body-inspect-window: 3\n\
1218 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1219 "Host: www.openinfosecfoundation.org\r\n"
1220 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1221 "Gecko/20091221 Firefox/3.5.7\r\n"
1223 0, STREAM_TOSERVER, 0 },
1224 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1225 "Content-Type: text/html\r\n"
1226 "Content-Length: 5\r\n"
1229 0, STREAM_TOCLIENT, 0 },
1230 { (
const uint8_t *)
"c", 0, STREAM_TOCLIENT, 0 },
1231 { (
const uint8_t *)
"de", 0, STREAM_TOCLIENT, 1 },
1235 const char *sig =
"alert http any any -> any any (file_data; content:\"bcde\"; offset:1; "
1237 return RunTest(steps, sig, yaml);
1240static int DetectEngineHttpServerBodyFileDataTest12(
void)
1243 const char yaml[] =
"\
1250 http-body-inline: yes\n\
1251 response-body-minimal-inspect-size: 6\n\
1252 response-body-inspect-window: 3\n\
1256 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1257 "Host: www.openinfosecfoundation.org\r\n"
1258 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1259 "Gecko/20091221 Firefox/3.5.7\r\n"
1261 0, STREAM_TOSERVER, 0 },
1262 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1263 "Content-Type: text/html\r\n"
1264 "Content-Length: 13\r\n"
1267 0, STREAM_TOCLIENT, 0 },
1268 { (
const uint8_t *)
"b", 0, STREAM_TOCLIENT, 0 },
1269 { (
const uint8_t *)
"c", 0, STREAM_TOCLIENT, 0 },
1270 { (
const uint8_t *)
"d", 0, STREAM_TOCLIENT, 1 },
1271 { (
const uint8_t *)
"efghijklm", 0, STREAM_TOCLIENT, 0 },
1275 const char *sig =
"alert http any any -> any any (file_data; content:\"abcd\"; sid:1;)";
1276 return RunTest(steps, sig, yaml);
1279static int DetectEngineHttpServerBodyFileDataTest13(
void)
1282 const char yaml[] =
"\
1289 http-body-inline: yes\n\
1290 response-body-minimal-inspect-size: 9\n\
1291 response-body-inspect-window: 12\n\
1295 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1296 "Host: www.openinfosecfoundation.org\r\n"
1297 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1298 "Gecko/20091221 Firefox/3.5.7\r\n"
1300 0, STREAM_TOSERVER, 0 },
1301 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1302 "Content-Type: text/html\r\n"
1303 "Content-Length: 13\r\n"
1306 0, STREAM_TOCLIENT, 0 },
1307 { (
const uint8_t *)
"b", 0, STREAM_TOCLIENT, 0 },
1308 { (
const uint8_t *)
"c", 0, STREAM_TOCLIENT, 0 },
1309 { (
const uint8_t *)
"d", 0, STREAM_TOCLIENT, 0 },
1310 { (
const uint8_t *)
"efghijklm", 0, STREAM_TOCLIENT, 1 },
1315 "alert http any any -> any any (file_data; content:\"abcdefghijklm\"; sid:1;)";
1316 return RunTest(steps, sig, yaml);
1319static int DetectEngineHttpServerBodyFileDataTest14(
void)
1322 const char yaml[] =
"\
1329 http-body-inline: yes\n\
1330 response-body-minimal-inspect-size: 9\n\
1331 response-body-inspect-window: 12\n\
1335 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1336 "Host: www.openinfosecfoundation.org\r\n"
1337 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1338 "Gecko/20091221 Firefox/3.5.7\r\n"
1340 0, STREAM_TOSERVER, 0 },
1341 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1342 "Content-Type: text/html\r\n"
1343 "Content-Length: 20\r\n"
1346 0, STREAM_TOCLIENT, 0 },
1347 { (
const uint8_t *)
"abcdefghi", 0, STREAM_TOCLIENT, 1 },
1351 const char *sig =
"alert http any any -> any any (file_data; content:\"890abcdefghi\"; sid:1;)";
1352 return RunTest(steps, sig, yaml);
1355static int DetectEngineHttpServerBodyFileDataTest15(
void)
1358 const char yaml[] =
"\
1365 http-body-inline: yes\n\
1366 response-body-minimal-inspect-size: 9\n\
1367 response-body-inspect-window: 12\n\
1371 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1372 "Host: www.openinfosecfoundation.org\r\n"
1373 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1374 "Gecko/20091221 Firefox/3.5.7\r\n"
1376 0, STREAM_TOSERVER, 0 },
1377 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1378 "Content-Type: text/html\r\n"
1379 "Content-Length: 20\r\n"
1382 0, STREAM_TOCLIENT, 0 },
1383 { (
const uint8_t *)
"abcdefghi", 0, STREAM_TOCLIENT, 0 },
1388 "alert http any any -> any any (file_data; content:\"7890ab\"; depth:6; sid:1;)";
1389 return RunTest(steps, sig, yaml);
1392static int DetectEngineHttpServerBodyFileDataTest16(
void)
1395 const char yaml[] =
"\
1402 http-body-inline: yes\n\
1403 response-body-minimal-inspect-size: 9\n\
1404 response-body-inspect-window: 12\n\
1408 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1409 "Host: www.openinfosecfoundation.org\r\n"
1410 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1411 "Gecko/20091221 Firefox/3.5.7\r\n"
1413 0, STREAM_TOSERVER, 0 },
1414 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1415 "Content-Type: text/html\r\n"
1416 "Content-Length: 20\r\n"
1419 0, STREAM_TOCLIENT, 0 },
1420 { (
const uint8_t *)
"bbbbc", 0, STREAM_TOCLIENT, 0 },
1421 { (
const uint8_t *)
"ccccd", 0, STREAM_TOCLIENT, 0 },
1422 { (
const uint8_t *)
"dddde", 0, STREAM_TOCLIENT, 0 },
1427 "alert http any any -> any any (file_data; content:\"aabb\"; depth:4; sid:1;)";
1428 return RunTest(steps, sig, yaml);
1431static int DetectEngineHttpServerBodyFileDataTest17(
void)
1434 const char yaml[] =
"\
1441 http-body-inline: yes\n\
1442 response-body-minimal-inspect-size: 8\n\
1443 response-body-inspect-window: 4\n\
1447 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1448 "Host: www.openinfosecfoundation.org\r\n"
1449 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1450 "Gecko/20091221 Firefox/3.5.7\r\n"
1452 0, STREAM_TOSERVER, 0 },
1453 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1454 "Content-Type: text/html\r\n"
1455 "Content-Length: 20\r\n"
1458 0, STREAM_TOCLIENT, 0 },
1459 { (
const uint8_t *)
"bbbbc", 0, STREAM_TOCLIENT, 0 },
1460 { (
const uint8_t *)
"ccccd", 0, STREAM_TOCLIENT, 0 },
1461 { (
const uint8_t *)
"dddde", 0, STREAM_TOCLIENT, 0 },
1466 "alert http any any -> any any (file_data; content:\"bbbc\"; depth:4; sid:1;)";
1467 return RunTest(steps, sig, yaml);
1470static int DetectEngineHttpServerBodyFileDataTest18(
void)
1473 const char yaml[] =
"\
1480 http-body-inline: yes\n\
1481 response-body-minimal-inspect-size: 8\n\
1482 response-body-inspect-window: 4\n\
1486 { (
const uint8_t *)
"GET /index.html HTTP/1.0\r\n"
1487 "Host: www.openinfosecfoundation.org\r\n"
1488 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1489 "Gecko/20091221 Firefox/3.5.7\r\n"
1491 0, STREAM_TOSERVER, 0 },
1492 { (
const uint8_t *)
"HTTP/1.0 200 ok\r\n"
1493 "Content-Type: text/html\r\n"
1494 "Content-Length: 20\r\n"
1497 0, STREAM_TOCLIENT, 0 },
1498 { (
const uint8_t *)
"bbbbc", 0, STREAM_TOCLIENT, 0 },
1499 { (
const uint8_t *)
"ccccd", 0, STREAM_TOCLIENT, 0 },
1500 { (
const uint8_t *)
"dddde", 0, STREAM_TOCLIENT, 0 },
1505 "alert http any any -> any any (file_data; content:\"bccd\"; depth:4; sid:1;)";
1506 return RunTest(steps, sig, yaml);
1508static int DetectEngineHttpServerBodyFileDataTest19(
void)
1517 swf-decompression:\n\
1520 compress-depth: 0\n\
1521 decompress-depth: 0\n\
1523 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1524 "Host: www.openinfosecfoundation.org\r\n"
1525 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1526 "Gecko/20091221 Firefox/3.5.7\r\n"
1529 uint8_t http_buf2[] = {
1530 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
1531 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'1',
'0',
'3', 0x0d, 0x0a,
1532 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
1533 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'o',
'c',
't',
'e',
't',
'-',
's',
't',
'r',
'e',
'a',
'm', 0x0d, 0x0a,
1535 0x5a, 0x57, 0x53, 0x17, 0x5c, 0x24, 0x00, 0x00, 0xb7, 0x21, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x20,
1536 0x00, 0x00, 0x3b, 0xff, 0xfc, 0x8e, 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85,
1537 0xf5, 0x75, 0x6f, 0xd0, 0x7e, 0x61, 0x35, 0x1b, 0x1a, 0x8b, 0x16, 0x4d, 0xdf, 0x05, 0x32, 0xfe,
1538 0xa4, 0x4c, 0x46, 0x49, 0xb7, 0x7b, 0x6b, 0x75, 0xf9, 0x2b, 0x5c, 0x37, 0x29, 0x0b, 0x91, 0x37,
1539 0x01, 0x37, 0x0e, 0xe9, 0xf2, 0xe1, 0xfc, 0x9e, 0x64, 0xda, 0x6c, 0x11, 0x21, 0x33, 0xed, 0xa0,
1540 0x0e, 0x76, 0x70, 0xa0, 0xcd, 0x98, 0x2e, 0x76, 0x80, 0xf0, 0xe0, 0x59, 0x56, 0x06, 0x08, 0xe9,
1541 0xca, 0xeb, 0xa2, 0xc6, 0xdb, 0x5a, 0x86
1545 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1546 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1549 const char *sig =
"alert tcp any any -> any any "
1550 "(flow:established,from_server; "
1551 "file_data; content:\"FWS\"; "
1553 return RunTest(steps, sig,
input);
1556static int DetectEngineHttpServerBodyFileDataTest20(
void)
1565 swf-decompression:\n\
1568 compress-depth: 0\n\
1569 decompress-depth: 0\n\
1571 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1572 "Host: www.openinfosecfoundation.org\r\n"
1573 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1574 "Gecko/20091221 Firefox/3.5.7\r\n"
1577 uint8_t http_buf2[] = {
1578 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
1579 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
1580 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
1581 '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,
1583 0x43, 0x57, 0x53, 0x0a, 0xcb, 0x6c, 0x00, 0x00, 0x78, 0xda, 0xad, 0xbd, 0x07, 0x98, 0x55, 0x55,
1584 0x9e, 0xee, 0xbd, 0x4f, 0xd8, 0xb5, 0x4e, 0x15, 0xc1, 0xc2, 0x80, 0x28, 0x86, 0xd2, 0x2e, 0x5a,
1585 0xdb, 0x46, 0xd9, 0x39, 0x38, 0xdd, 0x4e, 0x1b, 0xa8, 0x56, 0x5b, 0xc5, 0x6b, 0xe8, 0x76, 0xfa,
1586 0x0e, 0xc2, 0x8e, 0x50, 0x76, 0x51, 0xc5, 0x54, 0x15, 0x88, 0x73, 0xc3, 0xd0, 0x88, 0x39, 0x81,
1587 0x98, 0x63, 0x91, 0x93, 0x8a, 0x82, 0x89, 0x60, 0x00, 0xcc, 0xb1, 0x00, 0x01, 0x73, 0xce, 0x39,
1591 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1592 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1595 const char *sig =
"alert tcp any any -> any any "
1596 "(flow:established,from_server; "
1597 "file_data; content:\"CWS\"; "
1599 return RunTest(steps, sig,
input);
1602static int DetectEngineHttpServerBodyFileDataTest21(
void)
1611 swf-decompression:\n\
1614 compress-depth: 0\n\
1615 decompress-depth: 0\n\
1617 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1618 "Host: www.openinfosecfoundation.org\r\n"
1619 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1620 "Gecko/20091221 Firefox/3.5.7\r\n"
1623 uint8_t http_buf2[] = {
1624 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
1625 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
1626 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
1627 '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,
1629 0x43, 0x57, 0x53, 0x0a, 0xcb, 0x6c, 0x00, 0x00, 0x78, 0xda, 0xad, 0xbd, 0x07, 0x98, 0x55, 0x55,
1630 0x9e, 0xee, 0xbd, 0x4f, 0xd8, 0xb5, 0x4e, 0x15, 0xc1, 0xc2, 0x80, 0x28, 0x86, 0xd2, 0x2e, 0x5a,
1631 0xdb, 0x46, 0xd9, 0x39, 0x38, 0xdd, 0x4e, 0x1b, 0xa8, 0x56, 0x5b, 0xc5, 0x6b, 0xe8, 0x76, 0xfa,
1632 0x0e, 0xc2, 0x8e, 0x50, 0x76, 0x51, 0xc5, 0x54, 0x15, 0x88, 0x73, 0xc3, 0xd0, 0x88, 0x39, 0x81,
1633 0x98, 0x63, 0x91, 0x93, 0x8a, 0x82, 0x89, 0x60, 0x00, 0xcc, 0xb1, 0x00, 0x01, 0x73, 0xce, 0x39,
1637 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1638 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1641 const char *sig =
"alert tcp any any -> any any "
1642 "(flow:established,from_server; "
1643 "file_data; content:\"FWS\"; "
1645 return RunTest(steps, sig,
input);
1648static int DetectEngineHttpServerBodyFileDataTest22(
void)
1657 swf-decompression:\n\
1660 compress-depth: 0\n\
1661 decompress-depth: 0\n\
1663 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1664 "Host: www.openinfosecfoundation.org\r\n"
1665 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1666 "Gecko/20091221 Firefox/3.5.7\r\n"
1669 uint8_t http_buf2[] = {
1670 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
1671 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
1672 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
1673 '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,
1675 0x43, 0x57, 0x53, 0x0a, 0xcb, 0x6c, 0x00, 0x00, 0x78, 0xda, 0xad, 0xbd, 0x07, 0x98, 0x55, 0x55,
1676 0x9e, 0xee, 0xbd, 0x4f, 0xd8, 0xb5, 0x4e, 0x15, 0xc1, 0xc2, 0x80, 0x28, 0x86, 0xd2, 0x2e, 0x5a,
1677 0xdb, 0x46, 0xd9, 0x39, 0x38, 0xdd, 0x4e, 0x1b, 0xa8, 0x56, 0x5b, 0xc5, 0x6b, 0xe8, 0x76, 0xfa,
1678 0x0e, 0xc2, 0x8e, 0x50, 0x76, 0x51, 0xc5, 0x54, 0x15, 0x88, 0x73, 0xc3, 0xd0, 0x88, 0x39, 0x81,
1679 0x98, 0x63, 0x91, 0x93, 0x8a, 0x82, 0x89, 0x60, 0x00, 0xcc, 0xb1, 0x00, 0x01, 0x73, 0xce, 0x39,
1683 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1684 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1687 const char *sig =
"alert tcp any any -> any any "
1688 "(flow:established,from_server; "
1689 "file_data; content:\"CWS\"; "
1691 return RunTest(steps, sig,
input);
1694static int DetectEngineHttpServerBodyFileDataTest23(
void)
1703 swf-decompression:\n\
1706 compress-depth: 0\n\
1707 decompress-depth: 0\n\
1709 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1710 "Host: www.openinfosecfoundation.org\r\n"
1711 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1712 "Gecko/20091221 Firefox/3.5.7\r\n"
1715 uint8_t http_buf2[] = {
1716 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
1717 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
1718 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
1719 '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,
1721 0x43, 0x57, 0x53, 0x01, 0xcb, 0x6c, 0x00, 0x00, 0x78, 0xda, 0xad, 0xbd, 0x07, 0x98, 0x55, 0x55,
1722 0x9e, 0xee, 0xbd, 0x4f, 0xd8, 0xb5, 0x4e, 0x15, 0xc1, 0xc2, 0x80, 0x28, 0x86, 0xd2, 0x2e, 0x5a,
1723 0xdb, 0x46, 0xd9, 0x39, 0x38, 0xdd, 0x4e, 0x1b, 0xa8, 0x56, 0x5b, 0xc5, 0x6b, 0xe8, 0x76, 0xfa,
1724 0x0e, 0xc2, 0x8e, 0x50, 0x76, 0x51, 0xc5, 0x54, 0x15, 0x88, 0x73, 0xc3, 0xd0, 0x88, 0x39, 0x81,
1725 0x98, 0x63, 0x91, 0x93, 0x8a, 0x82, 0x89, 0x60, 0x00, 0xcc, 0xb1, 0x00, 0x01, 0x73, 0xce, 0x39,
1729 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1730 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1733 const char *sig =
"alert tcp any any -> any any "
1734 "(flow:established,from_server; "
1735 "file_data; content:\"CWS\"; "
1737 return RunTest(steps, sig,
input);
1740static int DetectEngineHttpServerBodyFileDataTest24(
void)
1749 swf-decompression:\n\
1752 compress-depth: 0\n\
1753 decompress-depth: 0\n\
1755 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1756 "Host: www.openinfosecfoundation.org\r\n"
1757 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1758 "Gecko/20091221 Firefox/3.5.7\r\n"
1760 uint8_t http_buf2[] = {
'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k',
1761 0x0d, 0x0a,
'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
1762 '1',
'0',
'3', 0x0d, 0x0a,
'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
1763 ' ',
'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'o',
'c',
't',
'e',
't',
1764 '-',
's',
't',
'r',
'e',
'a',
'm', 0x0d, 0x0a, 0x0d, 0x0a, 0x5a, 0x57, 0x53, 0x17, 0x5c,
1765 0x24, 0x00, 0x00, 0xb7, 0x21, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x20, 0x00, 0x00, 0x3b, 0xff,
1766 0xfc, 0x8e, 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85, 0xf5, 0x75, 0x6f,
1767 0xd0, 0x7e, 0x61, 0x35, 0x1b, 0x1a, 0x8b, 0x16, 0x4d, 0xdf, 0x05, 0x32, 0xfe, 0xa4, 0x4c,
1768 0x46, 0x49, 0xb7, 0x7b, 0x6b, 0x75, 0xf9, 0x2b, 0x5c, 0x37, 0x29, 0x0b, 0x91, 0x37, 0x01,
1769 0x37, 0x0e, 0xe9, 0xf2, 0xe1, 0xfc, 0x9e, 0x64, 0xda, 0x6c, 0x11, 0x21, 0x33, 0xed, 0xa0,
1770 0x0e, 0x76, 0x70, 0xa0, 0xcd, 0x98, 0x2e, 0x76, 0x80, 0xf0, 0xe0, 0x59, 0x56, 0x06, 0x08,
1771 0xe9, 0xca, 0xeb, 0xa2, 0xc6, 0xdb, 0x5a, 0x86 };
1773 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1774 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1777 const char *sig =
"alert tcp any any -> any any "
1778 "(flow:established,from_server; "
1779 "file_data; content:\"FWS\"; "
1781 return RunTest(steps, sig,
input);
1784static int DetectEngineHttpServerBodyFileDataTest25(
void)
1793 swf-decompression:\n\
1796 compress-depth: 0\n\
1797 decompress-depth: 0\n\
1799 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1800 "Host: www.openinfosecfoundation.org\r\n"
1801 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1802 "Gecko/20091221 Firefox/3.5.7\r\n"
1804 uint8_t http_buf2[] = {
'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k',
1805 0x0d, 0x0a,
'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
1806 '1',
'0',
'3', 0x0d, 0x0a,
'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
1807 ' ',
'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'o',
'c',
't',
'e',
't',
1808 '-',
's',
't',
'r',
'e',
'a',
'm', 0x0d, 0x0a, 0x0d, 0x0a, 0x5a, 0x57, 0x53, 0x17, 0x5c,
1809 0x24, 0x00, 0x00, 0xb7, 0x21, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x20, 0x00, 0x00, 0x3b, 0xff,
1810 0xfc, 0x8e, 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85, 0xf5, 0x75, 0x6f,
1811 0xd0, 0x7e, 0x61, 0x35, 0x1b, 0x1a, 0x8b, 0x16, 0x4d, 0xdf, 0x05, 0x32, 0xfe, 0xa4, 0x4c,
1812 0x46, 0x49, 0xb7, 0x7b, 0x6b, 0x75, 0xf9, 0x2b, 0x5c, 0x37, 0x29, 0x0b, 0x91, 0x37, 0x01,
1813 0x37, 0x0e, 0xe9, 0xf2, 0xe1, 0xfc, 0x9e, 0x64, 0xda, 0x6c, 0x11, 0x21, 0x33, 0xed, 0xa0,
1814 0x0e, 0x76, 0x70, 0xa0, 0xcd, 0x98, 0x2e, 0x76, 0x80, 0xf0, 0xe0, 0x59, 0x56, 0x06, 0x08,
1815 0xe9, 0xca, 0xeb, 0xa2, 0xc6, 0xdb, 0x5a, 0x86 };
1817 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1818 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1821 const char *sig =
"alert tcp any any -> any any "
1822 "(flow:established,from_server; "
1823 "file_data; content:\"ZWS\"; "
1825 return RunTest(steps, sig,
input);
1828static int DetectEngineHttpServerBodyFileDataTest26(
void)
1837 swf-decompression:\n\
1840 compress-depth: 0\n\
1841 decompress-depth: 0\n\
1843 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1844 "Host: www.openinfosecfoundation.org\r\n"
1845 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1846 "Gecko/20091221 Firefox/3.5.7\r\n"
1848 uint8_t http_buf2[] = {
'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k',
1849 0x0d, 0x0a,
'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
1850 '1',
'0',
'3', 0x0d, 0x0a,
'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
1851 ' ',
'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'o',
'c',
't',
'e',
't',
1852 '-',
's',
't',
'r',
'e',
'a',
'm', 0x0d, 0x0a, 0x0d, 0x0a, 0x5a, 0x57, 0x53, 0x17, 0x5c,
1853 0x24, 0x00, 0x00, 0xb7, 0x21, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x20, 0x00, 0x00, 0x3b, 0xff,
1854 0xfc, 0x8e, 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85, 0xf5, 0x75, 0x6f,
1855 0xd0, 0x7e, 0x61, 0x35, 0x1b, 0x1a, 0x8b, 0x16, 0x4d, 0xdf, 0x05, 0x32, 0xfe, 0xa4, 0x4c,
1856 0x46, 0x49, 0xb7, 0x7b, 0x6b, 0x75, 0xf9, 0x2b, 0x5c, 0x37, 0x29, 0x0b, 0x91, 0x37, 0x01,
1857 0x37, 0x0e, 0xe9, 0xf2, 0xe1, 0xfc, 0x9e, 0x64, 0xda, 0x6c, 0x11, 0x21, 0x33, 0xed, 0xa0,
1858 0x0e, 0x76, 0x70, 0xa0, 0xcd, 0x98, 0x2e, 0x76, 0x80, 0xf0, 0xe0, 0x59, 0x56, 0x06, 0x08,
1859 0xe9, 0xca, 0xeb, 0xa2, 0xc6, 0xdb, 0x5a, 0x86 };
1861 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1862 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1865 const char *sig =
"alert tcp any any -> any any "
1866 "(flow:established,from_server; "
1867 "file_data; content:\"FWS\"; "
1869 return RunTest(steps, sig,
input);
1872static int DetectEngineHttpServerBodyFileDataTest27(
void)
1881 swf-decompression:\n\
1884 compress-depth: 0\n\
1885 decompress-depth: 0\n\
1887 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1888 "Host: www.openinfosecfoundation.org\r\n"
1889 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1890 "Gecko/20091221 Firefox/3.5.7\r\n"
1893 uint8_t http_buf2[] = {
1894 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
1895 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
1896 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
1897 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'o',
'c',
't',
'e',
't',
'-',
's',
't',
'r',
'e',
'a',
'm', 0x0d, 0x0a,
1899 0x5a, 0x57, 0x53, 0x17, 0x5c, 0x24, 0x00, 0x00, 0xb7, 0x21, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x20,
1900 0x00, 0x00, 0x3b, 0xff, 0xfc, 0x8e, 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85,
1901 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85, 0xf5, 0x75, 0x6f, 0xd0, 0x7e, 0x61,
1902 0x35, 0x1b, 0x1a, 0x8b, 0x16, 0x4d, 0xdf, 0x05, 0x32, 0xfe, 0xa4, 0x4c, 0x46, 0x49, 0xb7, 0x7b,
1903 0x6b, 0x75, 0xf9, 0x2b, 0x5c, 0x37, 0x29, 0x0b, 0x91, 0x37, 0x01, 0x37, 0x0e, 0xe9, 0xf2, 0xe1,
1907 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1908 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1911 const char *sig =
"alert tcp any any -> any any "
1912 "(flow:established,from_server; "
1913 "file_data; content:\"ZWS\"; "
1915 return RunTest(steps, sig,
input);
1918static int DetectEngineHttpServerBodyFileDataTest28(
void)
1927 swf-decompression:\n\
1930 compress-depth: 0\n\
1931 decompress-depth: 0\n\
1933 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1934 "Host: www.openinfosecfoundation.org\r\n"
1935 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1936 "Gecko/20091221 Firefox/3.5.7\r\n"
1939 uint8_t http_buf2[] = {
1940 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
1941 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
1942 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
1943 'a',
'p',
'p',
'l',
'i',
'c',
'a',
't',
'i',
'o',
'n',
'/',
'o',
'c',
't',
'e',
't',
'-',
's',
't',
'r',
'e',
'a',
'm', 0x0d, 0x0a,
1945 0x5a, 0x57, 0x53, 0x01, 0x5c, 0x24, 0x00, 0x00, 0xb7, 0x21, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x20,
1946 0x00, 0x00, 0x3b, 0xff, 0xfc, 0x8e, 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85,
1947 0x19, 0xfa, 0xdf, 0xe7, 0x66, 0x08, 0xa0, 0x3d, 0x3e, 0x85, 0xf5, 0x75, 0x6f, 0xd0, 0x7e, 0x61,
1948 0x35, 0x1b, 0x1a, 0x8b, 0x16, 0x4d, 0xdf, 0x05, 0x32, 0xfe, 0xa4, 0x4c, 0x46, 0x49, 0xb7, 0x7b,
1949 0x6b, 0x75, 0xf9, 0x2b, 0x5c, 0x37, 0x29, 0x0b, 0x91, 0x37, 0x01, 0x37, 0x0e, 0xe9, 0xf2, 0xe1,
1953 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
1954 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
1957 const char *sig =
"alert tcp any any -> any any "
1958 "(flow:established,from_server; "
1959 "file_data; content:\"ZWS\"; "
1961 return RunTest(steps, sig,
input);
1964static int DetectEngineHttpServerBodyFileDataTest29(
void)
1973 swf-decompression:\n\
1976 compress-depth: 1000\n\
1977 decompress-depth: 0\n\
1979 uint8_t http_buf1[] =
"GET /file.swf HTTP/1.0\r\n"
1980 "Host: www.openinfosecfoundation.org\r\n"
1981 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
1982 "Gecko/20091221 Firefox/3.5.7\r\n"
1985 uint8_t http_buf2[] = {
1986 'H',
'T',
'T',
'P',
'/',
'1',
'.',
'1',
' ',
'2',
'0',
'0',
'o',
'k', 0x0d, 0x0a,
1987 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'L',
'e',
'n',
'g',
't',
'h',
':',
' ',
'8',
'0', 0x0d, 0x0a,
1988 'C',
'o',
'n',
't',
'e',
'n',
't',
'-',
'T',
'y',
'p',
'e',
':',
' ',
1989 '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,
1991 0x43, 0x57, 0x53, 0x0a, 0xcb, 0x6c, 0x00, 0x00, 0x78, 0xda, 0xad, 0xbd, 0x07, 0x98, 0x55, 0x55,
1992 0x9e, 0xee, 0xbd, 0x4f, 0xd8, 0xb5, 0x4e, 0x15, 0xc1, 0xc2, 0x80, 0x28, 0x86, 0xd2, 0x2e, 0x5a,
1993 0xdb, 0x46, 0xd9, 0x39, 0x38, 0xdd, 0x4e, 0x1b, 0xa8, 0x56, 0x5b, 0xc5, 0x6b, 0xe8, 0x76, 0xfa,
1994 0x0e, 0xc2, 0x8e, 0x50, 0x76, 0x51, 0xc5, 0x54, 0x15, 0x88, 0x73, 0xc3, 0xd0, 0x88, 0x39, 0x81,
1995 0x98, 0x63, 0x91, 0x93, 0x8a, 0x82, 0x89, 0x60, 0x00, 0xcc, 0xb1, 0x00, 0x01, 0x73, 0xce, 0x39,
1999 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2000 { (
const uint8_t *)http_buf2,
sizeof(http_buf2), STREAM_TOCLIENT, 1 },
2003 const char *sig =
"alert tcp any any -> any any "
2004 "(flow:established,from_server; "
2005 "file_data; content:\"FWS\"; "
2007 return RunTest(steps, sig,
input);
2014static int DetectHttpServerBodyTest06(
void)
2016 uint8_t http_buf[] =
"GET /index.html HTTP/1.0\r\n"
2017 "Host: www.openinfosecfoundation.org\r\n"
2018 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2019 "Gecko/20091221 Firefox/3.5.7\r\n"
2021 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2022 "Content-Type: text/html\r\n"
2023 "Content-Length: 7\r\n"
2027 { (
const uint8_t *)http_buf,
sizeof(http_buf) - 1, STREAM_TOSERVER, 0 },
2028 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
2031 const char *sig =
"alert http any any -> any any "
2032 "(msg:\"http server body test\"; "
2033 "content:\"message\"; http_server_body; "
2035 return RunTest(steps, sig, NULL);
2042static int DetectHttpServerBodyTest07(
void)
2044 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2045 "Host: www.openinfosecfoundation.org\r\n"
2046 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2047 "Gecko/20091221 Firefox/3.5.7\r\n"
2049 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2050 "Content-Type: text/html\r\n"
2051 "Content-Length: 14\r\n"
2053 uint8_t http_buf3[] =
"message";
2055 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2056 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2057 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT | STREAM_EOF, 1 },
2060 const char *sig =
"alert http any any -> any any "
2061 "(msg:\"http server body test\"; "
2062 "content:\"message\"; http_server_body; "
2064 return RunTest(steps, sig, NULL);
2071static int DetectHttpServerBodyTest08(
void)
2073 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2074 "Host: www.openinfosecfoundation.org\r\n"
2075 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2076 "Gecko/20091221 Firefox/3.5.7\r\n"
2078 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2079 "Content-Type: text/html\r\n"
2080 "Content-Length: 14\r\n"
2083 uint8_t http_buf3[] =
"sage4u!!";
2085 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2086 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2087 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 1 },
2090 const char *sig =
"alert http any any -> any any "
2091 "(msg:\"http client body test\"; "
2092 "content:\"message\"; http_server_body; "
2094 return RunTest(steps, sig, NULL);
2101static int DetectHttpServerBodyTest09(
void)
2103 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2104 "Host: www.openinfosecfoundation.org\r\n"
2105 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2106 "Gecko/20091221 Firefox/3.5.7\r\n"
2108 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2109 "Content-Type: text/html\r\n"
2110 "Content-Length: 14\r\n"
2113 uint8_t http_buf3[] =
"sag";
2114 uint8_t http_buf4[] =
"e4u!!";
2116 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2117 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2118 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 0 },
2119 { (
const uint8_t *)http_buf4,
sizeof(http_buf4) - 1, STREAM_TOCLIENT, 1 },
2122 const char *sig =
"alert http any any -> any any "
2123 "(msg:\"http client body test\"; "
2124 "content:\"message\"; http_server_body; "
2126 return RunTest(steps, sig, NULL);
2133static int DetectHttpServerBodyTest10(
void)
2135 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2136 "Host: www.openinfosecfoundation.org\r\n"
2137 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2138 "Gecko/20091221 Firefox/3.5.7\r\n"
2140 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2141 "Content-Type: text/html\r\n"
2142 "Content-Length: 14\r\n"
2145 uint8_t http_buf3[] =
"sag";
2146 uint8_t http_buf4[] =
2149 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2150 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2151 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 0 },
2152 { (
const uint8_t *)http_buf4,
sizeof(http_buf4) - 1, STREAM_TOCLIENT, 1 },
2155 const char *sig =
"alert http any any -> any any "
2156 "(msg:\"http client body test\"; "
2157 "content:\"MeSSaGE\"; http_server_body; nocase; "
2159 return RunTest(steps, sig, NULL);
2166static int DetectHttpServerBodyTest11(
void)
2168 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2169 "Host: www.openinfosecfoundation.org\r\n"
2170 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2171 "Gecko/20091221 Firefox/3.5.7\r\n"
2173 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2174 "Content-Type: text/html\r\n"
2175 "Content-Length: 14\r\n"
2177 uint8_t http_buf3[] =
"bigmessage4u!!";
2179 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2180 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2181 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 1 },
2184 const char *sig =
"alert http any any -> any any "
2185 "(msg:\"http client body test\"; "
2186 "content:!\"MaSSaGE\"; http_server_body; nocase; "
2188 return RunTest(steps, sig, NULL);
2195static int DetectHttpServerBodyTest12(
void)
2197 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2198 "Host: www.openinfosecfoundation.org\r\n"
2199 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2200 "Gecko/20091221 Firefox/3.5.7\r\n"
2202 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2203 "Content-Type: text/html\r\n"
2204 "Content-Length: 14\r\n"
2206 uint8_t http_buf3[] =
"bigmessage4u!!";
2208 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2209 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2210 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 0 },
2213 const char *sig =
"alert http any any -> any any "
2214 "(msg:\"http client body test\"; "
2215 "content:!\"MeSSaGE\"; http_server_body; nocase; "
2217 return RunTest(steps, sig, NULL);
2220static int DetectHttpServerBodyTest13(
void)
2222 uint8_t http_buf[] =
"GET /index.html HTTP/1.0\r\n"
2223 "Host: www.openinfosecfoundation.org\r\n"
2224 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2225 "Gecko/20091221 Firefox/3.5.7\r\n"
2227 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2228 "Content-Type: text/html\r\n"
2229 "Content-Length: 55\r\n"
2231 "longbufferabcdefghijklmnopqrstuvwxyz0123456789bufferend";
2233 { (
const uint8_t *)http_buf,
sizeof(http_buf) - 1, STREAM_TOSERVER, 0 },
2234 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
2237 const char *sig =
"alert http any any -> any any "
2238 "(msg:\"http server body test\"; "
2239 "content:\"longbufferabcdefghijklmnopqrstuvwxyz0123456789bufferend\"; "
2240 "http_server_body; "
2242 return RunTest(steps, sig, NULL);
2246static int DetectHttpServerBodyTest14(
void)
2255 uint8_t httpbuf1[] =
"GET /index1.html HTTP/1.1\r\n"
2256 "User-Agent: Mozilla/1.0\r\n"
2257 "Host: www.openinfosecfoundation.org\r\n"
2258 "Connection: keep-alive\r\n"
2259 "Cookie: dummy1\r\n\r\n";
2260 uint32_t httplen1 =
sizeof(httpbuf1) - 1;
2261 uint8_t httpbuf2[] =
"HTTP/1.1 200 ok\r\n"
2262 "Content-Type: text/html\r\n"
2263 "Content-Length: 3\r\n"
2266 uint32_t httplen2 =
sizeof(httpbuf2) - 1;
2267 uint8_t httpbuf3[] =
"GET /index2.html HTTP/1.1\r\n"
2268 "User-Agent: Firefox/1.0\r\n"
2269 "Host: www.openinfosecfoundation.org\r\n"
2270 "Connection: keep-alive\r\n"
2271 "Cookie: dummy2\r\n\r\n";
2272 uint32_t httplen3 =
sizeof(httpbuf3) - 1;
2273 uint8_t httpbuf4[] =
"HTTP/1.1 200 ok\r\n"
2274 "Content-Type: text/html\r\n"
2275 "Content-Length: 3\r\n"
2278 uint32_t httplen4 =
sizeof(httpbuf4) - 1;
2281 memset(&th_v, 0,
sizeof(th_v));
2282 memset(&f, 0,
sizeof(f));
2283 memset(&ssn, 0,
sizeof(ssn));
2289 f.
proto = IPPROTO_TCP;
2308 "content:\"one\"; http_server_body; sid:1; rev:1;)");
2310 printf(
"sig parse failed: ");
2314 "content:\"two\"; http_server_body; sid:2; rev:1;)");
2316 printf(
"sig2 parse failed: ");
2328 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
2336 printf(
"toserver chunk 2 returned %" PRId32
", expected 0: ", r);
2345 printf(
"sig 1 didn't alert (tx 1): ");
2354 printf(
"toserver chunk 3 returned %" PRId32
", expected 0: ", r);
2363 printf(
"toserver chunk 4 returned %" PRId32
", expected 0: ", r);
2372 printf(
"sig 1 alerted (tx 2): ");
2376 printf(
"sig 2 didn't alert (tx 2): ");
2382 if (htp_state == NULL) {
2383 printf(
"no http state: ");
2388 printf(
"The http app layer doesn't have 2 transactions, but it should: ");
2396 if (det_ctx != NULL) {
2409static int DetectHttpServerBodyTest15(
void)
2418 uint8_t httpbuf1[] =
"GET /index1.html HTTP/1.1\r\n"
2419 "User-Agent: Mozilla/1.0\r\n"
2420 "Host: www.openinfosecfoundation.org\r\n"
2421 "Connection: keep-alive\r\n"
2422 "Cookie: dummy1\r\n\r\n";
2423 uint32_t httplen1 =
sizeof(httpbuf1) - 1;
2424 uint8_t httpbuf2[] =
"HTTP/1.1 200 ok\r\n"
2425 "Content-Type: text/html\r\n"
2426 "Content-Length: 3\r\n"
2429 uint32_t httplen2 =
sizeof(httpbuf2) - 1;
2430 uint8_t httpbuf3[] =
"GET /index2.html HTTP/1.1\r\n"
2431 "User-Agent: Firefox/1.0\r\n"
2432 "Host: www.openinfosecfoundation.org\r\n"
2433 "Connection: keep-alive\r\n"
2434 "Cookie: dummy2\r\n\r\n";
2435 uint32_t httplen3 =
sizeof(httpbuf3) - 1;
2436 uint8_t httpbuf4[] =
"HTTP/1.1 200 ok\r\n"
2437 "Content-Type: text/html\r\n"
2438 "Content-Length: 3\r\n"
2441 uint32_t httplen4 =
sizeof(httpbuf4) - 1;
2444 memset(&th_v, 0,
sizeof(th_v));
2445 memset(&f, 0,
sizeof(f));
2446 memset(&ssn, 0,
sizeof(ssn));
2452 f.
proto = IPPROTO_TCP;
2471 "content:\"one\"; http_server_body; sid:1; rev:1;)");
2473 printf(
"sig parse failed: ");
2477 "content:\"two\"; http_server_body; sid:2; rev:1;)");
2479 printf(
"sig2 parse failed: ");
2489 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
2495 printf(
"toserver chunk 2 returned %" PRId32
", expected 0: ", r);
2502 printf(
"sig 1 didn't alert (tx 1): ");
2506 printf(
"sig 2 alerted (tx 1): ");
2513 printf(
"toserver chunk 3 returned %" PRId32
", expected 0: ", r);
2520 printf(
"toserver chunk 4 returned %" PRId32
", expected 0: ", r);
2527 printf(
"sig 1 alerted (tx 2): ");
2531 printf(
"sig 2 didn't alert (tx 2): ");
2537 if (htp_state == NULL) {
2538 printf(
"no http state: ");
2543 printf(
"The http app layer doesn't have 2 transactions, but it should: ");
2551 if (det_ctx != NULL) {
2568static int DetectHttpServerBodyFileDataTest01(
void)
2570 uint8_t http_buf[] =
"GET /index.html HTTP/1.0\r\n"
2571 "Host: www.openinfosecfoundation.org\r\n"
2572 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2573 "Gecko/20091221 Firefox/3.5.7\r\n"
2575 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2576 "Content-Type: text/html\r\n"
2577 "Content-Length: 7\r\n"
2581 { (
const uint8_t *)http_buf,
sizeof(http_buf) - 1, STREAM_TOSERVER, 0 },
2582 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
2585 const char *sig =
"alert http any any -> any any "
2586 "(msg:\"http server body test\"; "
2587 "file_data; content:\"message\"; "
2589 return RunTest(steps, sig, NULL);
2596static int DetectHttpServerBodyFileDataTest02(
void)
2598 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2599 "Host: www.openinfosecfoundation.org\r\n"
2600 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2601 "Gecko/20091221 Firefox/3.5.7\r\n"
2603 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2604 "Content-Type: text/html\r\n"
2605 "Content-Length: 14\r\n"
2607 uint8_t http_buf3[] =
"message";
2609 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2610 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2611 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT | STREAM_EOF, 1 },
2614 const char *sig =
"alert http any any -> any any "
2615 "(msg:\"http server body test\"; "
2616 "file_data; content:\"message\"; "
2618 return RunTest(steps, sig, NULL);
2625static int DetectHttpServerBodyFileDataTest03(
void)
2627 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2628 "Host: www.openinfosecfoundation.org\r\n"
2629 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2630 "Gecko/20091221 Firefox/3.5.7\r\n"
2632 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2633 "Content-Type: text/html\r\n"
2634 "Content-Length: 14\r\n"
2637 uint8_t http_buf3[] =
"sage4u!!";
2639 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2640 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2641 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 1 },
2644 const char *sig =
"alert http any any -> any any "
2645 "(msg:\"http server body test\"; "
2646 "file_data; content:\"message\"; "
2648 return RunTest(steps, sig, NULL);
2655static int DetectHttpServerBodyFileDataTest04(
void)
2657 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2658 "Host: www.openinfosecfoundation.org\r\n"
2659 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2660 "Gecko/20091221 Firefox/3.5.7\r\n"
2662 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2663 "Content-Type: text/html\r\n"
2664 "Content-Length: 14\r\n"
2667 uint8_t http_buf3[] =
"sag";
2668 uint8_t http_buf4[] =
"e4u!!";
2670 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2671 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2672 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 0 },
2673 { (
const uint8_t *)http_buf4,
sizeof(http_buf4) - 1, STREAM_TOCLIENT, 1 },
2676 const char *sig =
"alert http any any -> any any "
2677 "(msg:\"http server body test\"; "
2678 "file_data; content:\"message\"; "
2680 return RunTest(steps, sig, NULL);
2687static int DetectHttpServerBodyFileDataTest05(
void)
2689 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2690 "Host: www.openinfosecfoundation.org\r\n"
2691 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2692 "Gecko/20091221 Firefox/3.5.7\r\n"
2694 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2695 "Content-Type: text/html\r\n"
2696 "Content-Length: 14\r\n"
2699 uint8_t http_buf3[] =
"sag";
2700 uint8_t http_buf4[] =
"e4u!!";
2702 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2703 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2704 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 0 },
2705 { (
const uint8_t *)http_buf4,
sizeof(http_buf4) - 1, STREAM_TOCLIENT, 1 },
2708 const char *sig =
"alert http any any -> any any "
2709 "(msg:\"http client body test\"; "
2710 "file_data; content:\"MeSSaGE\"; nocase; "
2712 return RunTest(steps, sig, NULL);
2719static int DetectHttpServerBodyFileDataTest06(
void)
2721 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2722 "Host: www.openinfosecfoundation.org\r\n"
2723 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2724 "Gecko/20091221 Firefox/3.5.7\r\n"
2726 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2727 "Content-Type: text/html\r\n"
2728 "Content-Length: 14\r\n"
2730 uint8_t http_buf3[] =
"bigmessage4u!!";
2732 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2733 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2734 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 1 },
2737 const char *sig =
"alert http any any -> any any "
2738 "(msg:\"http file_data test\"; "
2739 "file_data; content:!\"MaSSaGE\"; nocase; "
2741 return RunTest(steps, sig, NULL);
2748static int DetectHttpServerBodyFileDataTest07(
void)
2750 uint8_t http_buf1[] =
"GET /index.html HTTP/1.0\r\n"
2751 "Host: www.openinfosecfoundation.org\r\n"
2752 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2753 "Gecko/20091221 Firefox/3.5.7\r\n"
2755 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2756 "Content-Type: text/html\r\n"
2757 "Content-Length: 14\r\n"
2759 uint8_t http_buf3[] =
"bigmessage4u!!";
2761 { (
const uint8_t *)http_buf1,
sizeof(http_buf1) - 1, STREAM_TOSERVER, 0 },
2762 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 0 },
2763 { (
const uint8_t *)http_buf3,
sizeof(http_buf3) - 1, STREAM_TOCLIENT, 0 },
2766 const char *sig =
"alert http any any -> any any "
2767 "(msg:\"http file_data test\"; "
2768 "file_data; content:!\"MeSSaGE\"; nocase; "
2770 return RunTest(steps, sig, NULL);
2773static int DetectHttpServerBodyFileDataTest08(
void)
2775 uint8_t http_buf[] =
"GET /index.html HTTP/1.0\r\n"
2776 "Host: www.openinfosecfoundation.org\r\n"
2777 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) "
2778 "Gecko/20091221 Firefox/3.5.7\r\n"
2780 uint8_t http_buf2[] =
"HTTP/1.0 200 ok\r\n"
2781 "Content-Type: text/html\r\n"
2782 "Content-Length: 55\r\n"
2784 "longbufferabcdefghijklmnopqrstuvwxyz0123456789bufferend";
2786 { (
const uint8_t *)http_buf,
sizeof(http_buf) - 1, STREAM_TOSERVER, 0 },
2787 { (
const uint8_t *)http_buf2,
sizeof(http_buf2) - 1, STREAM_TOCLIENT, 1 },
2791 "alert http any any -> any any "
2792 "(msg:\"http server body test\"; "
2793 "file_data; content:\"longbufferabcdefghijklmnopqrstuvwxyz0123456789bufferend\"; "
2795 return RunTest(steps, sig, NULL);
2799static int DetectHttpServerBodyFileDataTest09(
void)
2808 uint8_t httpbuf1[] =
"GET /index1.html HTTP/1.1\r\n"
2809 "User-Agent: Mozilla/1.0\r\n"
2810 "Host: www.openinfosecfoundation.org\r\n"
2811 "Connection: keep-alive\r\n"
2812 "Cookie: dummy1\r\n\r\n";
2813 uint32_t httplen1 =
sizeof(httpbuf1) - 1;
2814 uint8_t httpbuf2[] =
"HTTP/1.1 200 ok\r\n"
2815 "Content-Type: text/html\r\n"
2816 "Content-Length: 3\r\n"
2819 uint32_t httplen2 =
sizeof(httpbuf2) - 1;
2820 uint8_t httpbuf3[] =
"GET /index2.html HTTP/1.1\r\n"
2821 "User-Agent: Firefox/1.0\r\n"
2822 "Host: www.openinfosecfoundation.org\r\n"
2823 "Connection: keep-alive\r\n"
2824 "Cookie: dummy2\r\n\r\n";
2825 uint32_t httplen3 =
sizeof(httpbuf3) - 1;
2826 uint8_t httpbuf4[] =
"HTTP/1.1 200 ok\r\n"
2827 "Content-Type: text/html\r\n"
2828 "Content-Length: 3\r\n"
2831 uint32_t httplen4 =
sizeof(httpbuf4) - 1;
2834 memset(&th_v, 0,
sizeof(th_v));
2835 memset(&f, 0,
sizeof(f));
2836 memset(&ssn, 0,
sizeof(ssn));
2842 f.
proto = IPPROTO_TCP;
2860 s =
DetectEngineAppendSig(
de_ctx,
"alert tcp any any -> any any (flow:established,to_client; file_data; content:\"one\"; sid:1; rev:1;)");
2862 printf(
"sig parse failed: ");
2865 s =
DetectEngineAppendSig(
de_ctx,
"alert tcp any any -> any any (flow:established,to_client; file_data; content:\"two\"; sid:2; rev:1;)");
2867 printf(
"sig2 parse failed: ");
2877 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
2883 printf(
"toserver chunk 2 returned %" PRId32
", expected 0: ", r);
2890 printf(
"sig 1 didn't alert (tx 1): ");
2897 printf(
"toserver chunk 3 returned %" PRId32
", expected 0: ", r);
2904 printf(
"toserver chunk 4 returned %" PRId32
", expected 0: ", r);
2911 printf(
"sig 1 alerted (tx 2): ");
2915 printf(
"sig 2 didn't alert (tx 2): ");
2921 if (htp_state == NULL) {
2922 printf(
"no http state: ");
2927 printf(
"The http app layer doesn't have 2 transactions, but it should: ");
2935 if (det_ctx != NULL) {
2948static int DetectHttpServerBodyFileDataTest10(
void)
2957 uint8_t httpbuf1[] =
"GET /index1.html HTTP/1.1\r\n"
2958 "User-Agent: Mozilla/1.0\r\n"
2959 "Host: www.openinfosecfoundation.org\r\n"
2960 "Connection: keep-alive\r\n"
2961 "Cookie: dummy1\r\n\r\n";
2962 uint32_t httplen1 =
sizeof(httpbuf1) - 1;
2963 uint8_t httpbuf2[] =
"HTTP/1.1 200 ok\r\n"
2964 "Content-Type: text/html\r\n"
2965 "Content-Length: 3\r\n"
2968 uint32_t httplen2 =
sizeof(httpbuf2) - 1;
2969 uint8_t httpbuf3[] =
"GET /index2.html HTTP/1.1\r\n"
2970 "User-Agent: Firefox/1.0\r\n"
2971 "Host: www.openinfosecfoundation.org\r\n"
2972 "Connection: keep-alive\r\n"
2973 "Cookie: dummy2\r\n\r\n";
2974 uint32_t httplen3 =
sizeof(httpbuf3) - 1;
2975 uint8_t httpbuf4[] =
"HTTP/1.1 200 ok\r\n"
2976 "Content-Type: text/html\r\n"
2977 "Content-Length: 3\r\n"
2980 uint32_t httplen4 =
sizeof(httpbuf4) - 1;
2983 memset(&th_v, 0,
sizeof(th_v));
2984 memset(&f, 0,
sizeof(f));
2985 memset(&ssn, 0,
sizeof(ssn));
2991 f.
proto = IPPROTO_TCP;
3009 s =
DetectEngineAppendSig(
de_ctx,
"alert tcp any any -> any any (flow:established,to_client; file_data; content:\"one\"; sid:1; rev:1;)");
3011 printf(
"sig parse failed: ");
3014 s =
DetectEngineAppendSig(
de_ctx,
"alert tcp any any -> any any (flow:established,to_client; file_data; content:\"two\"; sid:2; rev:1;)");
3016 printf(
"sig2 parse failed: ");
3026 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
3032 printf(
"toserver chunk 2 returned %" PRId32
", expected 0: ", r);
3039 printf(
"sig 1 didn't alert (tx 1): ");
3046 printf(
"toserver chunk 3 returned %" PRId32
", expected 0: ", r);
3053 printf(
"toserver chunk 4 returned %" PRId32
", expected 0: ", r);
3060 printf(
"sig 1 alerted (tx 2): ");
3064 printf(
"sig 2 didn't alert (tx 2): ");
3070 if (htp_state == NULL) {
3071 printf(
"no http state: ");
3076 printf(
"The http app layer doesn't have 2 transactions, but it should: ");
3084 if (det_ctx != NULL) {
3099 UtRegisterTest(
"DetectHttpServerBodyParserTest01", DetectHttpServerBodyParserTest01);
3100 UtRegisterTest(
"DetectHttpServerBodyParserTest02", DetectHttpServerBodyParserTest02);
3102 UtRegisterTest(
"DetectHttpServerBodyTest06", DetectHttpServerBodyTest06);
3103 UtRegisterTest(
"DetectHttpServerBodyTest07", DetectHttpServerBodyTest07);
3104 UtRegisterTest(
"DetectHttpServerBodyTest08", DetectHttpServerBodyTest08);
3105 UtRegisterTest(
"DetectHttpServerBodyTest09", DetectHttpServerBodyTest09);
3106 UtRegisterTest(
"DetectHttpServerBodyTest10", DetectHttpServerBodyTest10);
3107 UtRegisterTest(
"DetectHttpServerBodyTest11", DetectHttpServerBodyTest11);
3108 UtRegisterTest(
"DetectHttpServerBodyTest12", DetectHttpServerBodyTest12);
3109 UtRegisterTest(
"DetectHttpServerBodyTest13", DetectHttpServerBodyTest13);
3110 UtRegisterTest(
"DetectHttpServerBodyTest14", DetectHttpServerBodyTest14);
3111 UtRegisterTest(
"DetectHttpServerBodyTest15", DetectHttpServerBodyTest15);
3114 DetectHttpServerBodyFileDataTest01);
3116 DetectHttpServerBodyFileDataTest02);
3118 DetectHttpServerBodyFileDataTest03);
3120 DetectHttpServerBodyFileDataTest04);
3122 DetectHttpServerBodyFileDataTest05);
3124 DetectHttpServerBodyFileDataTest06);
3126 DetectHttpServerBodyFileDataTest07);
3128 DetectHttpServerBodyFileDataTest08);
3130 DetectHttpServerBodyFileDataTest09);
3132 DetectHttpServerBodyFileDataTest10);
3135 DetectEngineHttpServerBodyTest01);
3137 DetectEngineHttpServerBodyTest02);
3139 DetectEngineHttpServerBodyTest03);
3141 DetectEngineHttpServerBodyTest04);
3143 DetectEngineHttpServerBodyTest05);
3145 DetectEngineHttpServerBodyTest06);
3147 DetectEngineHttpServerBodyTest07);
3149 DetectEngineHttpServerBodyTest08);
3151 DetectEngineHttpServerBodyTest09);
3153 DetectEngineHttpServerBodyTest10);
3155 DetectEngineHttpServerBodyTest11);
3157 DetectEngineHttpServerBodyTest12);
3159 DetectEngineHttpServerBodyTest13);
3161 DetectEngineHttpServerBodyTest14);
3163 DetectEngineHttpServerBodyTest15);
3165 DetectEngineHttpServerBodyTest16);
3167 DetectEngineHttpServerBodyTest17);
3169 DetectEngineHttpServerBodyTest18);
3171 DetectEngineHttpServerBodyTest19);
3173 DetectEngineHttpServerBodyTest20);
3175 DetectEngineHttpServerBodyTest21);
3177 DetectEngineHttpServerBodyTest22);
3180 DetectEngineHttpServerBodyFileDataTest01);
3182 DetectEngineHttpServerBodyFileDataTest02);
3184 DetectEngineHttpServerBodyFileDataTest03);
3186 DetectEngineHttpServerBodyFileDataTest04);
3188 DetectEngineHttpServerBodyFileDataTest05);
3190 DetectEngineHttpServerBodyFileDataTest06);
3192 DetectEngineHttpServerBodyFileDataTest07);
3194 DetectEngineHttpServerBodyFileDataTest08);
3196 DetectEngineHttpServerBodyFileDataTest09);
3198 DetectEngineHttpServerBodyFileDataTest10);
3200 DetectEngineHttpServerBodyFileDataTest11);
3202 DetectEngineHttpServerBodyFileDataTest12);
3204 DetectEngineHttpServerBodyFileDataTest13);
3206 DetectEngineHttpServerBodyFileDataTest14);
3208 DetectEngineHttpServerBodyFileDataTest15);
3210 DetectEngineHttpServerBodyFileDataTest16);
3212 DetectEngineHttpServerBodyFileDataTest17);
3214 DetectEngineHttpServerBodyFileDataTest18);
3217 DetectEngineHttpServerBodyFileDataTest19);
3219 DetectEngineHttpServerBodyFileDataTest20);
3221 DetectEngineHttpServerBodyFileDataTest21);
3223 DetectEngineHttpServerBodyFileDataTest22);
3225 DetectEngineHttpServerBodyFileDataTest23);
3227 DetectEngineHttpServerBodyFileDataTest24);
3229 DetectEngineHttpServerBodyFileDataTest25);
3231 DetectEngineHttpServerBodyFileDataTest26);
3233 DetectEngineHttpServerBodyFileDataTest27);
3235 DetectEngineHttpServerBodyFileDataTest28);
3237 DetectEngineHttpServerBodyFileDataTest29);
AppLayerParserThreadCtx * AppLayerParserThreadCtxAlloc(void)
Gets a new app layer protocol's parser thread context.
uint64_t AppLayerParserGetTxCnt(const Flow *f, void *alstate)
void AppLayerParserThreadCtxFree(AppLayerParserThreadCtx *tctx)
Destroys the app layer parser thread context obtained using AppLayerParserThreadCtxAlloc().
int AppLayerParserParse(ThreadVars *tv, AppLayerParserThreadCtx *alp_tctx, Flow *f, AppProto alproto, uint8_t flags, const uint8_t *input, uint32_t input_len)
int SCConfYamlLoadString(const char *string, size_t len)
Load configuration from a YAML string.
void SCConfInit(void)
Initialize the configuration system.
void SCConfCreateContextBackup(void)
Creates a backup of the conf_hash hash_table used by the conf API.
void SCConfRestoreContextBackup(void)
Restores the backup of the hash_table present in backup_conf_hash back to conf_hash.
int PacketAlertCheck(Packet *p, uint32_t sid)
Check if a certain sid alerted, this is used in the test functions.
int SigGroupBuild(DetectEngineCtx *de_ctx)
Convert the signature list into the runtime match structure.
DetectEngineCtx * DetectEngineCtxInit(void)
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
Signature * DetectEngineAppendSig(DetectEngineCtx *, const char *)
Parse and append a Signature into the Detection Engine Context signature list.
TmEcode DetectEngineThreadCtxInit(ThreadVars *tv, void *initdata, void **data)
initialize thread specific detection engine context
TmEcode DetectEngineThreadCtxDeinit(ThreadVars *tv, void *data)
void SigMatchSignatures(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p)
wrapper for old tests
#define FLOW_INITIALIZE(f)
#define FLOW_PKT_TOSERVER
#define FLOW_PKT_ESTABLISHED
#define FLOW_PKT_TOCLIENT
AppLayerParserThreadCtx * alp_tctx
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
#define FAIL_IF_NOT(expr)
Fail a test if expression evaluates to false.
#define PASS
Pass the test.
#define FAIL_IF(expr)
Fail a test if expression evaluates to true.
void HtpConfigRestoreBackup(void)
void HtpConfigCreateBackup(void)
void StreamTcpFreeConfig(bool quiet)
void StreamTcpInitConfig(bool)
To initialize the stream global configuration data.
main detection engine ctx
AppProto alproto
application level protocol
Per thread variable structure.
void EngineModeSetIDS(void)
void EngineModeSetIPS(void)
void DetectHttpServerBodyRegisterTests(void)
void UTHFreePackets(Packet **p, int numpkts)
UTHFreePackets: function to release the allocated data from UTHBuildPacket and the packet itself.
Packet * UTHBuildPacket(uint8_t *payload, uint16_t payload_len, uint8_t ipproto)
UTHBuildPacket is a wrapper that build packets with default ip and port fields.
void UTHFreePacket(Packet *p)
UTHFreePacket: function to release the allocated data from UTHBuildPacket and the packet itself.
int UTHParseSignature(const char *str, bool expect)
parser a sig and see if the expected result is correct