54static int g_dce_stub_data_buffer_id = 0;
65static int DcePayloadTest15(
void)
69 uint8_t request1[] = {
70 0x05, 0x00, 0x00, 0x03, 0x10, 0x00, 0x00, 0x00,
71 0x68, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
72 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x00,
73 0x76, 0x7e, 0x32, 0x00, 0x0f, 0x00, 0x00, 0x00,
74 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
75 0x5c, 0x00, 0x5c, 0x00, 0x31, 0x00, 0x37, 0x00,
76 0x31, 0x00, 0x2e, 0x00, 0x37, 0x00, 0x31, 0x00,
77 0x2e, 0x00, 0x38, 0x00, 0x34, 0x00, 0x2e, 0x00,
78 0x36, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00,
79 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
80 0x84, 0xf9, 0x7f, 0x01, 0x00, 0x00, 0x00, 0x00,
81 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
82 0x14, 0xfa, 0x7f, 0x01, 0x00, 0x00, 0x00, 0x00
84 uint32_t request1_len =
sizeof(request1);
94 const char *sig1 =
"alert tcp any any -> any any "
95 "(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; "
96 "byte_test:2,=,14080,0,relative,dce; sid:1;)";
97 const char *sig2 =
"alert tcp any any -> any any "
98 "(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; "
99 "byte_test:2,=,46,5,relative,dce; sid:2;)";
105 memset(&f, 0,
sizeof(
Flow));
116 f.
proto = IPPROTO_TCP;
140 STREAM_TOSERVER, request1, request1_len);
142 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
149 printf(
"sid 1 didn't match but should have for packet: ");
153 printf(
"sid 2 didn't match but should have for packet: ");
179static int DcePayloadTest16(
void)
183 uint8_t request1[] = {
184 0x05, 0x00, 0x00, 0x03, 0x10, 0x00, 0x00, 0x00,
185 0x68, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
186 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x00,
187 0x76, 0x7e, 0x32, 0x00, 0x0f, 0x00, 0x00, 0x00,
188 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
189 0x5c, 0x00, 0x5c, 0x00, 0x31, 0x00, 0x37, 0x00,
190 0x31, 0x00, 0x2e, 0x00, 0x37, 0x00, 0x31, 0x00,
191 0x2e, 0x00, 0x38, 0x00, 0x34, 0x00, 0x2e, 0x00,
192 0x36, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00,
193 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
194 0x84, 0xf9, 0x7f, 0x01, 0x00, 0x00, 0x00, 0x00,
195 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
196 0x14, 0xfa, 0x7f, 0x01, 0x00, 0x00, 0x00, 0x00
198 uint32_t request1_len =
sizeof(request1);
208 const char *sig1 =
"alert tcp any any -> any any "
209 "(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; "
210 "byte_test:2,=,55,0,relative; sid:1;)";
211 const char *sig2 =
"alert tcp any any -> any any "
212 "(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; "
213 "byte_test:2,=,11776,5,relative; sid:2;)";
219 memset(&f, 0,
sizeof(
Flow));
230 f.
proto = IPPROTO_TCP;
254 STREAM_TOSERVER, request1, request1_len);
256 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
263 printf(
"sid 1 didn't match but should have for packet: ");
267 printf(
"sid 2 didn't match but should have for packet: ");
293static int DcePayloadTest17(
void)
297 uint8_t request1[] = {
298 0x05, 0x00, 0x00, 0x03, 0x10, 0x00, 0x00, 0x00,
299 0x68, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
300 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x00,
301 0x76, 0x7e, 0x32, 0x00, 0x0f, 0x00, 0x00, 0x00,
302 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
303 0x5c, 0x00, 0x5c, 0x00, 0x31, 0x00, 0x37, 0x00,
304 0x31, 0x00, 0x2e, 0x00, 0x37, 0x00, 0x31, 0x00,
305 0x2e, 0x00, 0x38, 0x00, 0x34, 0x00, 0x2e, 0x00,
306 0x36, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00,
307 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
308 0x84, 0xf9, 0x7f, 0x01, 0x00, 0x00, 0x00, 0x00,
309 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
310 0x14, 0xfa, 0x7f, 0x01, 0x00, 0x00, 0x00, 0x00
312 uint32_t request1_len =
sizeof(request1);
322 const char *sig1 =
"alert tcp any any -> any any "
323 "(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; "
324 "byte_test:2,=,55,0,relative,big; sid:1;)";
325 const char *sig2 =
"alert tcp any any -> any any "
326 "(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; "
327 "byte_test:2,=,46,5,relative,little; sid:2;)";
333 memset(&f, 0,
sizeof(
Flow));
344 f.
proto = IPPROTO_TCP;
368 STREAM_TOSERVER, request1, request1_len);
370 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
377 printf(
"sid 1 didn't match but should have for packet: ");
381 printf(
"sid 2 didn't match but should have for packet: ");
407static int DcePayloadTest18(
void)
411 uint8_t request1[] = {
412 0x05, 0x00, 0x00, 0x03, 0x10, 0x00, 0x00, 0x00,
413 0x68, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
414 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x00,
415 0x76, 0x7e, 0x32, 0x00, 0x0f, 0x00, 0x00, 0x00,
416 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
417 0x5c, 0x00, 0x5c, 0x00, 0x31, 0x03, 0x00, 0x03,
418 0x00, 0x00, 0x2e, 0x00, 0x37, 0x00, 0x31, 0x00,
419 0x2e, 0x00, 0x38, 0x00, 0x34, 0x00, 0x2e, 0x00,
420 0x36, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00,
421 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
422 0x84, 0xf9, 0x7f, 0x01, 0x00, 0x00, 0x00, 0x00,
423 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
424 0x14, 0xfa, 0x7f, 0x01, 0x00, 0x00, 0x00, 0x00
426 uint32_t request1_len =
sizeof(request1);
436 const char *sig1 =
"alert tcp any any -> any any "
437 "(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; "
438 "byte_jump:2,0,relative,dce; byte_test:2,=,46,0,relative,dce; sid:1;)";
439 const char *sig2 =
"alert tcp any any -> any any "
440 "(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; "
441 "byte_jump:2,2,relative,dce; byte_test:2,=,14080,0,relative; sid:2;)";
447 memset(&f, 0,
sizeof(
Flow));
458 f.
proto = IPPROTO_TCP;
482 STREAM_TOSERVER, request1, request1_len);
484 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
491 printf(
"sid 1 didn't match but should have for packet: ");
495 printf(
"sid 2 didn't match but should have for packet: ");
521static int DcePayloadTest19(
void)
525 uint8_t request1[] = {
526 0x05, 0x00, 0x00, 0x03, 0x10, 0x00, 0x00, 0x00,
527 0x68, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
528 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x00,
529 0x76, 0x7e, 0x32, 0x00, 0x0f, 0x00, 0x00, 0x00,
530 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
531 0x5c, 0x00, 0x5c, 0x00, 0x31, 0x00, 0x03, 0x00,
532 0x03, 0x00, 0x2e, 0x00, 0x37, 0x00, 0x31, 0x00,
533 0x2e, 0x00, 0x38, 0x00, 0x34, 0x00, 0x2e, 0x00,
534 0x36, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00,
535 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
536 0x84, 0xf9, 0x7f, 0x01, 0x00, 0x00, 0x00, 0x00,
537 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
538 0x14, 0xfa, 0x7f, 0x01, 0x00, 0x00, 0x00, 0x00
540 uint32_t request1_len =
sizeof(request1);
550 const char *sig1 =
"alert tcp any any -> any any "
551 "(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; "
552 "byte_jump:2,0,relative; byte_test:2,=,46,0,relative,dce; sid:1;)";
553 const char *sig2 =
"alert tcp any any -> any any "
554 "(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; "
555 "byte_jump:2,2,relative; byte_test:2,=,14080,0,relative; sid:2;)";
561 memset(&f, 0,
sizeof(
Flow));
572 f.
proto = IPPROTO_TCP;
596 STREAM_TOSERVER, request1, request1_len);
598 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
605 printf(
"sid 1 didn't match but should have for packet: ");
609 printf(
"sid 2 didn't match but should have for packet: ");
635static int DcePayloadTest20(
void)
639 uint8_t request1[] = {
640 0x05, 0x00, 0x00, 0x03, 0x10, 0x00, 0x00, 0x00,
641 0x68, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
642 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x00,
643 0x76, 0x7e, 0x32, 0x00, 0x0f, 0x00, 0x00, 0x00,
644 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
645 0x5c, 0x00, 0x5c, 0x00, 0x31, 0x00, 0x03, 0x03,
646 0x00, 0x00, 0x2e, 0x00, 0x37, 0x00, 0x31, 0x00,
647 0x2e, 0x00, 0x38, 0x00, 0x34, 0x00, 0x2e, 0x00,
648 0x36, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00,
649 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
650 0x84, 0xf9, 0x7f, 0x01, 0x00, 0x00, 0x00, 0x00,
651 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
652 0x14, 0xfa, 0x7f, 0x01, 0x00, 0x00, 0x00, 0x00
654 uint32_t request1_len =
sizeof(request1);
664 const char *sig1 =
"alert tcp any any -> any any "
665 "(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; "
666 "byte_jump:2,0,relative,big; byte_test:2,=,46,0,relative,dce; sid:1;)";
667 const char *sig2 =
"alert tcp any any -> any any "
668 "(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; "
669 "byte_jump:2,2,little,relative; byte_test:2,=,14080,0,relative; sid:2;)";
675 memset(&f, 0,
sizeof(
Flow));
686 f.
proto = IPPROTO_TCP;
710 STREAM_TOSERVER, request1, request1_len);
712 printf(
"toserver chunk 1 returned %" PRId32
", expected 0: ", r);
719 printf(
"sid 1 didn't match but should have for packet: ");
723 printf(
"sid 2 didn't match but should have for packet: ");
AppLayerParserThreadCtx * AppLayerParserThreadCtxAlloc(void)
Gets a new app layer protocol's parser thread context.
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 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.
void SigCleanSignatures(DetectEngineCtx *de_ctx)
int SigGroupCleanup(DetectEngineCtx *de_ctx)
void DcePayloadRegisterTests(void)
DetectEngineCtx * DetectEngineCtxInit(void)
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
TmEcode DetectEngineThreadCtxInit(ThreadVars *tv, void *initdata, void **data)
initialize thread specific detection engine context
int DetectBufferTypeGetByName(const char *name)
TmEcode DetectEngineThreadCtxDeinit(ThreadVars *tv, void *data)
Signature * SigInit(DetectEngineCtx *de_ctx, const char *sigstr)
Parses a signature and adds it to the Detection Engine Context.
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
AppLayerParserThreadCtx * alp_tctx
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
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 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.