53 #define PARSE_REGEX "^\\s*([0-9]{1,5}(\\s*-\\s*[0-9]{1,5}\\s*)?)(,\\s*[0-9]{1,5}(\\s*-\\s*[0-9]{1,5})?\\s*)*$"
58 Flow *f, uint8_t
flags,
void *state,
void *txv,
63 static void DetectDceOpnumRegisterTests(
void);
65 static int g_dce_generic_list_id = 0;
100 Flow *f, uint8_t
flags,
void *state,
void *txv,
106 return rs_dcerpc_opnum_match(txv, (
void *)
m);
109 if (rs_smb_tx_match_dce_opnum(txv, (
void *)
m) != 1)
130 SCLogError(
"Error parsing dce_opnum option in "
131 "signature, option needs a value");
138 void *dod = rs_dcerpc_opnum_parse(arg);
140 SCLogError(
"Error parsing dce_opnum option in "
147 DetectDceOpnumFree(
de_ctx, dod);
157 rs_dcerpc_opnum_free(ptr);
174 static int DetectDceOpnumTestParse10(
void)
184 DCERPCState *dcerpc_state = NULL;
187 uint8_t dcerpc_bind[] = {
188 0x05, 0x00, 0x0b, 0x03, 0x10, 0x00, 0x00, 0x00,
189 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
190 0xb8, 0x10, 0xb8, 0x10, 0x00, 0x00, 0x00, 0x00,
191 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
192 0x01, 0xd0, 0x8c, 0x33, 0x44, 0x22, 0xf1, 0x31,
193 0xaa, 0xaa, 0x90, 0x00, 0x38, 0x00, 0x10, 0x03,
194 0x01, 0x00, 0x00, 0x00, 0x04, 0x5d, 0x88, 0x8a,
195 0xeb, 0x1c, 0xc9, 0x11, 0x9f, 0xe8, 0x08, 0x00,
196 0x2b, 0x10, 0x48, 0x60, 0x02, 0x00, 0x00, 0x00,
199 uint8_t dcerpc_bindack[] = {
200 0x05, 0x00, 0x0c, 0x03, 0x10, 0x00, 0x00, 0x00,
201 0x44, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
202 0xb8, 0x10, 0xb8, 0x10, 0x65, 0x8e, 0x00, 0x00,
203 0x0d, 0x00, 0x5c, 0x50, 0x49, 0x50, 0x45, 0x5c,
204 0x77, 0x69, 0x6e, 0x72, 0x65, 0x67, 0x00, 0x6d,
205 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
206 0x04, 0x5d, 0x88, 0x8a, 0xeb, 0x1c, 0xc9, 0x11,
207 0x9f, 0xe8, 0x08, 0x00, 0x2b, 0x10, 0x48, 0x60,
208 0x02, 0x00, 0x00, 0x00,
211 uint8_t dcerpc_request1[] = {
212 0x05, 0x00, 0x00, 0x03, 0x10, 0x00, 0x00, 0x00,
213 0x24, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
214 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
215 0x2c, 0xfd, 0xb5, 0x00, 0x40, 0xaa, 0x01, 0x00,
216 0x00, 0x00, 0x00, 0x02,
219 uint8_t dcerpc_response1[] = {
220 0x05, 0x00, 0x02, 0x03, 0x10, 0x00, 0x00, 0x00,
221 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
222 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
223 0x00, 0x00, 0x00, 0x00, 0xf6, 0x72, 0x28, 0x9c,
224 0xf0, 0x57, 0xd8, 0x11, 0xb0, 0x05, 0x00, 0x0c,
225 0x29, 0x87, 0xea, 0xe9, 0x00, 0x00, 0x00, 0x00,
228 uint8_t dcerpc_request2[] = {
229 0x05, 0x00, 0x00, 0x03, 0x10, 0x00, 0x00, 0x00,
230 0xa4, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
231 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00,
232 0x00, 0x00, 0x00, 0x00, 0xf6, 0x72, 0x28, 0x9c,
233 0xf0, 0x57, 0xd8, 0x11, 0xb0, 0x05, 0x00, 0x0c,
234 0x29, 0x87, 0xea, 0xe9, 0x5c, 0x00, 0x5c, 0x00,
235 0xa8, 0xb9, 0x14, 0x00, 0x2e, 0x00, 0x00, 0x00,
236 0x00, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00,
237 0x53, 0x00, 0x4f, 0x00, 0x46, 0x00, 0x54, 0x00,
238 0x57, 0x00, 0x41, 0x00, 0x52, 0x00, 0x45, 0x00,
239 0x5c, 0x00, 0x4d, 0x00, 0x69, 0x00, 0x63, 0x00,
240 0x72, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x6f, 0x00,
241 0x66, 0x00, 0x74, 0x00, 0x5c, 0x00, 0x57, 0x00,
242 0x69, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x6f, 0x00,
243 0x77, 0x00, 0x73, 0x00, 0x5c, 0x00, 0x43, 0x00,
244 0x75, 0x00, 0x72, 0x00, 0x72, 0x00, 0x65, 0x00,
245 0x6e, 0x00, 0x74, 0x00, 0x56, 0x00, 0x65, 0x00,
246 0x72, 0x00, 0x73, 0x00, 0x69, 0x00, 0x6f, 0x00,
247 0x6e, 0x00, 0x5c, 0x00, 0x52, 0x00, 0x75, 0x00,
248 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
249 0x03, 0x00, 0x00, 0x00,
252 uint8_t dcerpc_response2[] = {
253 0x05, 0x00, 0x02, 0x03, 0x10, 0x00, 0x00, 0x00,
254 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
255 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
256 0x00, 0x00, 0x00, 0x00, 0xf7, 0x72, 0x28, 0x9c,
257 0xf0, 0x57, 0xd8, 0x11, 0xb0, 0x05, 0x00, 0x0c,
258 0x29, 0x87, 0xea, 0xe9, 0x00, 0x00, 0x00, 0x00,
261 uint8_t dcerpc_request3[] = {
262 0x05, 0x00, 0x00, 0x03, 0x10, 0x00, 0x00, 0x00,
263 0x70, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
264 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00,
265 0x00, 0x00, 0x00, 0x00, 0xf7, 0x72, 0x28, 0x9c,
266 0xf0, 0x57, 0xd8, 0x11, 0xb0, 0x05, 0x00, 0x0c,
267 0x29, 0x87, 0xea, 0xe9, 0x0c, 0x00, 0x0c, 0x00,
268 0x98, 0xda, 0x14, 0x00, 0x06, 0x00, 0x00, 0x00,
269 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
270 0x4f, 0x00, 0x73, 0x00, 0x61, 0x00, 0x33, 0x00,
271 0x32, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
272 0x18, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x54, 0x00,
273 0x4f, 0x00, 0x53, 0x00, 0x41, 0x00, 0x33, 0x00,
274 0x32, 0x00, 0x2e, 0x00, 0x45, 0x00, 0x58, 0x00,
275 0x45, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
278 uint8_t dcerpc_response3[] = {
279 0x05, 0x00, 0x02, 0x03, 0x10, 0x00, 0x00, 0x00,
280 0x1c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
281 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
282 0x00, 0x00, 0x00, 0x00,
285 uint32_t dcerpc_bind_len =
sizeof(dcerpc_bind);
286 uint32_t dcerpc_bindack_len =
sizeof(dcerpc_bindack);
288 uint32_t dcerpc_request1_len =
sizeof(dcerpc_request1);
289 uint32_t dcerpc_response1_len =
sizeof(dcerpc_response1);
291 uint32_t dcerpc_request2_len =
sizeof(dcerpc_request2);
292 uint32_t dcerpc_response2_len =
sizeof(dcerpc_response2);
294 uint32_t dcerpc_request3_len =
sizeof(dcerpc_request3);
295 uint32_t dcerpc_response3_len =
sizeof(dcerpc_response3);
299 memset(&th_v, 0,
sizeof(th_v));
300 memset(&f, 0,
sizeof(f));
301 memset(&ssn, 0,
sizeof(ssn));
307 f.
proto = IPPROTO_TCP;
324 "(msg:\"DCERPC\"; dce_opnum:2,15,22; sid:1;)");
335 dcerpc_bind, dcerpc_bind_len);
337 SCLogDebug(
"AppLayerParse for dcerpc bind failed. Returned %" PRId32, r);
342 if (dcerpc_state == NULL) {
353 dcerpc_bindack, dcerpc_bindack_len);
355 SCLogDebug(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
366 dcerpc_request1, dcerpc_request1_len);
368 SCLogDebug(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
378 printf(
"sig 1 didn't match, but should have: ");
386 dcerpc_response1, dcerpc_response1_len);
388 SCLogDebug(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
398 printf(
"sig 1 did match, shouldn't have on response1: ");
404 dcerpc_request2, dcerpc_request2_len);
406 SCLogDebug(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
416 printf(
"sig 1 didn't match, but should have on request2: ");
422 dcerpc_response2, dcerpc_response2_len);
424 SCLogDebug(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
434 printf(
"sig 1 did match, shouldn't have on response2: ");
440 dcerpc_request3, dcerpc_request3_len);
442 SCLogDebug(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
452 printf(
"sig 1 didn't match, but should have on request3: ");
458 dcerpc_response3, dcerpc_response3_len);
460 SCLogDebug(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
470 printf(
"sig 1 did match, shouldn't have on response2: ");
496 static int DetectDceOpnumTestParse11(
void)
506 DCERPCState *dcerpc_state = NULL;
509 uint8_t dcerpc_request1[] = {
510 0x05, 0x00, 0x00, 0x03, 0x10, 0x00, 0x00, 0x00,
511 0x24, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
512 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
513 0x2c, 0xfd, 0xb5, 0x00, 0x40, 0xaa, 0x01, 0x00,
514 0x00, 0x00, 0x00, 0x02,
517 uint8_t dcerpc_response1[] = {
518 0x05, 0x00, 0x02, 0x03, 0x10, 0x00, 0x00, 0x00,
519 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
520 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
521 0x00, 0x00, 0x00, 0x00, 0xf6, 0x72, 0x28, 0x9c,
522 0xf0, 0x57, 0xd8, 0x11, 0xb0, 0x05, 0x00, 0x0c,
523 0x29, 0x87, 0xea, 0xe9, 0x00, 0x00, 0x00, 0x00,
526 uint8_t dcerpc_request2[] = {
527 0x05, 0x00, 0x00, 0x03, 0x10, 0x00, 0x00, 0x00,
528 0xa4, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
529 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00,
530 0x00, 0x00, 0x00, 0x00, 0xf6, 0x72, 0x28, 0x9c,
531 0xf0, 0x57, 0xd8, 0x11, 0xb0, 0x05, 0x00, 0x0c,
532 0x29, 0x87, 0xea, 0xe9, 0x5c, 0x00, 0x5c, 0x00,
533 0xa8, 0xb9, 0x14, 0x00, 0x2e, 0x00, 0x00, 0x00,
534 0x00, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00,
535 0x53, 0x00, 0x4f, 0x00, 0x46, 0x00, 0x54, 0x00,
536 0x57, 0x00, 0x41, 0x00, 0x52, 0x00, 0x45, 0x00,
537 0x5c, 0x00, 0x4d, 0x00, 0x69, 0x00, 0x63, 0x00,
538 0x72, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x6f, 0x00,
539 0x66, 0x00, 0x74, 0x00, 0x5c, 0x00, 0x57, 0x00,
540 0x69, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x6f, 0x00,
541 0x77, 0x00, 0x73, 0x00, 0x5c, 0x00, 0x43, 0x00,
542 0x75, 0x00, 0x72, 0x00, 0x72, 0x00, 0x65, 0x00,
543 0x6e, 0x00, 0x74, 0x00, 0x56, 0x00, 0x65, 0x00,
544 0x72, 0x00, 0x73, 0x00, 0x69, 0x00, 0x6f, 0x00,
545 0x6e, 0x00, 0x5c, 0x00, 0x52, 0x00, 0x75, 0x00,
546 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
547 0x03, 0x00, 0x00, 0x00,
550 uint8_t dcerpc_response2[] = {
551 0x05, 0x00, 0x02, 0x03, 0x10, 0x00, 0x00, 0x00,
552 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
553 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
554 0x00, 0x00, 0x00, 0x00, 0xf7, 0x72, 0x28, 0x9c,
555 0xf0, 0x57, 0xd8, 0x11, 0xb0, 0x05, 0x00, 0x0c,
556 0x29, 0x87, 0xea, 0xe9, 0x00, 0x00, 0x00, 0x00,
559 uint8_t dcerpc_request3[] = {
560 0x05, 0x00, 0x00, 0x03, 0x10, 0x00, 0x00, 0x00,
561 0x70, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
562 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00,
563 0x00, 0x00, 0x00, 0x00, 0xf7, 0x72, 0x28, 0x9c,
564 0xf0, 0x57, 0xd8, 0x11, 0xb0, 0x05, 0x00, 0x0c,
565 0x29, 0x87, 0xea, 0xe9, 0x0c, 0x00, 0x0c, 0x00,
566 0x98, 0xda, 0x14, 0x00, 0x06, 0x00, 0x00, 0x00,
567 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
568 0x4f, 0x00, 0x73, 0x00, 0x61, 0x00, 0x33, 0x00,
569 0x32, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
570 0x18, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x54, 0x00,
571 0x4f, 0x00, 0x53, 0x00, 0x41, 0x00, 0x33, 0x00,
572 0x32, 0x00, 0x2e, 0x00, 0x45, 0x00, 0x58, 0x00,
573 0x45, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
576 uint8_t dcerpc_response3[] = {
577 0x05, 0x00, 0x02, 0x03, 0x10, 0x00, 0x00, 0x00,
578 0x1c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
579 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
580 0x00, 0x00, 0x00, 0x00,
583 uint32_t dcerpc_request1_len =
sizeof(dcerpc_request1);
584 uint32_t dcerpc_response1_len =
sizeof(dcerpc_response1);
586 uint32_t dcerpc_request2_len =
sizeof(dcerpc_request2);
587 uint32_t dcerpc_response2_len =
sizeof(dcerpc_response2);
589 uint32_t dcerpc_request3_len =
sizeof(dcerpc_request3);
590 uint32_t dcerpc_response3_len =
sizeof(dcerpc_response3);
594 memset(&th_v, 0,
sizeof(th_v));
595 memset(&f, 0,
sizeof(f));
596 memset(&ssn, 0,
sizeof(ssn));
602 f.
proto = IPPROTO_TCP;
618 "alert tcp any any -> any any "
630 dcerpc_request1, dcerpc_request1_len);
632 SCLogDebug(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
633 printf(
"AppLayerParse for dcerpcrequest1 failed. Returned %" PRId32, r);
638 if (dcerpc_state == NULL) {
640 printf(
"no dcerpc state: ");
654 dcerpc_response1, dcerpc_response1_len);
656 SCLogDebug(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
657 printf(
"AppLayerParse for dcerpcresponse1 failed. Returned %" PRId32, r);
671 dcerpc_request2, dcerpc_request2_len);
673 SCLogDebug(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
674 printf(
"AppLayerParse for dcerpcrequest2 failed. Returned %" PRId32, r);
688 dcerpc_response2, dcerpc_response2_len);
690 SCLogDebug(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
691 printf(
"AppLayerParse for dcerpcresponse2 failed. Returned %" PRId32, r);
705 dcerpc_request3, dcerpc_request3_len);
707 SCLogDebug(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
708 printf(
"AppLayerParse for dcerpc request3 failed. Returned %" PRId32, r);
722 dcerpc_response3, dcerpc_response3_len);
724 SCLogDebug(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
725 printf(
"AppLayerParse for dcerpc response3 failed. Returned %" PRId32, r);
759 static int DetectDceOpnumTestParse12(
void)
769 DCERPCState *dcerpc_state = NULL;
772 uint8_t dcerpc_bind[] = {
773 0x05, 0x00, 0x0b, 0x03, 0x10, 0x00, 0x00, 0x00,
774 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
775 0xd0, 0x16, 0xd0, 0x16, 0x00, 0x00, 0x00, 0x00,
776 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
777 0x40, 0xfd, 0x2c, 0x34, 0x6c, 0x3c, 0xce, 0x11,
778 0xa8, 0x93, 0x08, 0x00, 0x2b, 0x2e, 0x9c, 0x6d,
779 0x00, 0x00, 0x00, 0x00, 0x04, 0x5d, 0x88, 0x8a,
780 0xeb, 0x1c, 0xc9, 0x11, 0x9f, 0xe8, 0x08, 0x00,
781 0x2b, 0x10, 0x48, 0x60, 0x02, 0x00, 0x00, 0x00,
784 uint8_t dcerpc_bindack[] = {
785 0x05, 0x00, 0x0c, 0x03, 0x10, 0x00, 0x00, 0x00,
786 0x44, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
787 0xb8, 0x10, 0xb8, 0x10, 0x7d, 0xd8, 0x00, 0x00,
788 0x0d, 0x00, 0x5c, 0x70, 0x69, 0x70, 0x65, 0x5c,
789 0x6c, 0x6c, 0x73, 0x72, 0x70, 0x63, 0x00, 0x00,
790 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
791 0x04, 0x5d, 0x88, 0x8a, 0xeb, 0x1c, 0xc9, 0x11,
792 0x9f, 0xe8, 0x08, 0x00, 0x2b, 0x10, 0x48, 0x60,
793 0x02, 0x00, 0x00, 0x00,
796 uint8_t dcerpc_request1[] = {
797 0x05, 0x00, 0x00, 0x03, 0x10, 0x00, 0x00, 0x00,
798 0x9a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
799 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00,
800 0x00, 0x00, 0x00, 0x00, 0x07, 0x9f, 0x13, 0xd9,
801 0x2d, 0x97, 0xf4, 0x4a, 0xac, 0xc2, 0xbc, 0x70,
802 0xec, 0xaa, 0x9a, 0xd3, 0x01, 0x00, 0x00, 0x00,
803 0x01, 0x00, 0x00, 0x00, 0x40, 0x80, 0x40, 0x00,
804 0x44, 0x80, 0x40, 0x00, 0x01, 0x00, 0x00, 0x00,
805 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
806 0x09, 0x00, 0x00, 0x00, 0x4d, 0x6f, 0x00, 0x4e,
807 0x61, 0x6d, 0x65, 0x00, 0x35, 0x39, 0x31, 0x63,
808 0x64, 0x30, 0x35, 0x38, 0x00, 0x00, 0x00, 0x00,
809 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
810 0x17, 0x00, 0x00, 0x00, 0xd0, 0x2e, 0x08, 0x00,
811 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
812 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
813 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
814 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
815 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
819 uint8_t dcerpc_response1[] = {
820 0x05, 0x00, 0x02, 0x03, 0x10, 0x00, 0x00, 0x00,
821 0x1c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
822 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
823 0x00, 0x00, 0x00, 0x00,
826 uint8_t dcerpc_request2[] = {
827 0x05, 0x00, 0x00, 0x03, 0x10, 0x00, 0x00, 0x00,
828 0x54, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
829 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00,
830 0x00, 0x00, 0x00, 0x00, 0x07, 0x9f, 0x13, 0xd9,
831 0x2d, 0x97, 0xf4, 0x4a, 0xac, 0xc2, 0xbc, 0x70,
832 0xec, 0xaa, 0x9a, 0xd3, 0x09, 0x00, 0x00, 0x00,
833 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
834 0x4d, 0x6f, 0x00, 0x4e, 0x61, 0x6d, 0x65, 0x00,
835 0x35, 0x39, 0x31, 0x63, 0x64, 0x30, 0x35, 0x38,
836 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
837 0x4e, 0x6f, 0x6e, 0x65
840 uint8_t dcerpc_response2[] = {
841 0x05, 0x00, 0x02, 0x03, 0x10, 0x00, 0x00, 0x00,
842 0x8c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
843 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
844 0xd8, 0x17, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00,
845 0x58, 0x1d, 0x08, 0x00, 0xe8, 0x32, 0x08, 0x00,
846 0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
847 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
848 0x4d, 0x6f, 0x00, 0x4e, 0x61, 0x6d, 0x65, 0x00,
849 0x35, 0x39, 0x31, 0x63, 0x64, 0x30, 0x35, 0x38,
850 0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
851 0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
852 0xd0, 0x2e, 0x08, 0x00, 0x41, 0x41, 0x41, 0x41,
853 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
854 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
855 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
856 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
857 0x41, 0x41, 0x41, 0x41, 0x00, 0x00, 0x00, 0x00,
858 0x00, 0x00, 0x00, 0x00,
861 uint32_t dcerpc_bind_len =
sizeof(dcerpc_bind);
862 uint32_t dcerpc_bindack_len =
sizeof(dcerpc_bindack);
864 uint32_t dcerpc_request1_len =
sizeof(dcerpc_request1);
865 uint32_t dcerpc_response1_len =
sizeof(dcerpc_response1);
867 uint32_t dcerpc_request2_len =
sizeof(dcerpc_request2);
868 uint32_t dcerpc_response2_len =
sizeof(dcerpc_response2);
872 memset(&th_v, 0,
sizeof(th_v));
873 memset(&f, 0,
sizeof(f));
874 memset(&ssn, 0,
sizeof(ssn));
880 f.
proto = IPPROTO_TCP;
896 "(msg:\"DCERPC\"; dce_opnum:30, 40; sid:1;)");
904 dcerpc_bind, dcerpc_bind_len);
906 printf(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
914 if (dcerpc_state == NULL) {
915 printf(
"no dcerpc state: ");
922 printf(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
933 dcerpc_request1_len);
935 printf(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
940 if (dcerpc_state == NULL) {
941 printf(
"no dcerpc state: ");
945 if (dcerpc_state->dcerpc.dcerpcrequest.opnum != 40) {
946 printf(
"dcerpc state holding invalid opnum. Holding %d, while we are "
947 "expecting 40: ", dcerpc_state->dcerpc.dcerpcrequest.opnum);
957 printf(
"signature 1 didn't match, should have: ");
963 dcerpc_response1_len);
965 printf(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
970 if (dcerpc_state == NULL) {
971 printf(
"no dcerpc state: ");
975 if (dcerpc_state->dcerpc.dcerpcrequest.opnum != 40) {
976 printf(
"dcerpc state holding invalid opnum. Holding %d, while we are "
977 "expecting 40\n", dcerpc_state->dcerpc.dcerpcrequest.opnum);
987 printf(
"sig 1 matched on response 1, but shouldn't: ");
993 dcerpc_request2_len);
995 printf(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
1000 if (dcerpc_state == NULL) {
1001 printf(
"no dcerpc state: ");
1005 if (dcerpc_state->dcerpc.dcerpcrequest.opnum != 30) {
1006 printf(
"dcerpc state holding invalid opnum. Holding %d, while we are "
1007 "expecting 30\n", dcerpc_state->dcerpc.dcerpcrequest.opnum);
1017 printf(
"sig 1 didn't match on request 2: ");
1023 dcerpc_response2_len);
1025 printf(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
1030 if (dcerpc_state == NULL) {
1031 printf(
"no dcerpc state: ");
1035 if (dcerpc_state->dcerpc.dcerpcrequest.opnum != 30) {
1036 printf(
"dcerpc state holding invalid opnum. Holding %d, while we are "
1037 "expecting 30\n", dcerpc_state->dcerpc.dcerpcrequest.opnum);
1047 printf(
"sig 1 matched on response2, but shouldn't: ");
1073 static int DetectDceOpnumTestParse13(
void)
1083 DCERPCState *dcerpc_state = NULL;
1086 uint8_t dcerpc_request1[] = {
1087 0x05, 0x00, 0x00, 0x03, 0x10, 0x00, 0x00, 0x00,
1088 0x9a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1089 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00,
1090 0x00, 0x00, 0x00, 0x00, 0x07, 0x9f, 0x13, 0xd9,
1091 0x2d, 0x97, 0xf4, 0x4a, 0xac, 0xc2, 0xbc, 0x70,
1092 0xec, 0xaa, 0x9a, 0xd3, 0x01, 0x00, 0x00, 0x00,
1093 0x01, 0x00, 0x00, 0x00, 0x40, 0x80, 0x40, 0x00,
1094 0x44, 0x80, 0x40, 0x00, 0x01, 0x00, 0x00, 0x00,
1095 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1096 0x09, 0x00, 0x00, 0x00, 0x4d, 0x6f, 0x00, 0x4e,
1097 0x61, 0x6d, 0x65, 0x00, 0x35, 0x39, 0x31, 0x63,
1098 0x64, 0x30, 0x35, 0x38, 0x00, 0x00, 0x00, 0x00,
1099 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1100 0x17, 0x00, 0x00, 0x00, 0xd0, 0x2e, 0x08, 0x00,
1101 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
1102 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
1103 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
1104 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
1105 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
1109 uint8_t dcerpc_response1[] = {
1110 0x05, 0x00, 0x02, 0x03, 0x10, 0x00, 0x00, 0x00,
1111 0x1c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1112 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1113 0x00, 0x00, 0x00, 0x00,
1116 uint8_t dcerpc_request2[] = {
1117 0x05, 0x00, 0x00, 0x03, 0x10, 0x00, 0x00, 0x00,
1118 0x54, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1119 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00,
1120 0x00, 0x00, 0x00, 0x00, 0x07, 0x9f, 0x13, 0xd9,
1121 0x2d, 0x97, 0xf4, 0x4a, 0xac, 0xc2, 0xbc, 0x70,
1122 0xec, 0xaa, 0x9a, 0xd3, 0x09, 0x00, 0x00, 0x00,
1123 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
1124 0x4d, 0x6f, 0x00, 0x4e, 0x61, 0x6d, 0x65, 0x00,
1125 0x35, 0x39, 0x31, 0x63, 0x64, 0x30, 0x35, 0x38,
1126 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1127 0x4e, 0x6f, 0x6e, 0x65
1130 uint8_t dcerpc_response2[] = {
1131 0x05, 0x00, 0x02, 0x03, 0x10, 0x00, 0x00, 0x00,
1132 0x8c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
1133 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1134 0xd8, 0x17, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00,
1135 0x58, 0x1d, 0x08, 0x00, 0xe8, 0x32, 0x08, 0x00,
1136 0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
1137 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
1138 0x4d, 0x6f, 0x00, 0x4e, 0x61, 0x6d, 0x65, 0x00,
1139 0x35, 0x39, 0x31, 0x63, 0x64, 0x30, 0x35, 0x38,
1140 0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
1141 0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
1142 0xd0, 0x2e, 0x08, 0x00, 0x41, 0x41, 0x41, 0x41,
1143 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
1144 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
1145 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
1146 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
1147 0x41, 0x41, 0x41, 0x41, 0x00, 0x00, 0x00, 0x00,
1148 0x00, 0x00, 0x00, 0x00,
1151 uint32_t dcerpc_request1_len =
sizeof(dcerpc_request1);
1152 uint32_t dcerpc_response1_len =
sizeof(dcerpc_response1);
1154 uint32_t dcerpc_request2_len =
sizeof(dcerpc_request2);
1155 uint32_t dcerpc_response2_len =
sizeof(dcerpc_response2);
1159 memset(&th_v, 0,
sizeof(th_v));
1160 memset(&f, 0,
sizeof(f));
1161 memset(&ssn, 0,
sizeof(ssn));
1167 f.
proto = IPPROTO_TCP;
1183 "alert tcp any any -> any any "
1185 "dce_opnum:30, 40; "
1195 dcerpc_request1_len);
1197 printf(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
1202 if (dcerpc_state == NULL) {
1203 printf(
"no dcerpc state: ");
1207 if (dcerpc_state->dcerpc.dcerpcrequest.opnum != 40) {
1208 printf(
"dcerpc state holding invalid opnum after request1. Holding %d, while we are "
1209 "expecting 40\n", dcerpc_state->dcerpc.dcerpcrequest.opnum);
1223 dcerpc_response1_len);
1225 printf(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
1230 if (dcerpc_state == NULL) {
1231 printf(
"no dcerpc state: ");
1235 if (dcerpc_state->dcerpc.dcerpcrequest.opnum != 40) {
1236 printf(
"dcerpc state holding invalid opnum after response1. Holding %d, while we are "
1237 "expecting 40\n", dcerpc_state->dcerpc.dcerpcrequest.opnum);
1250 printf(
"Sending Request2\n");
1252 dcerpc_request2_len);
1254 printf(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
1259 if (dcerpc_state == NULL) {
1260 printf(
"no dcerpc state: ");
1264 if (dcerpc_state->dcerpc.dcerpcrequest.opnum != 30) {
1265 printf(
"dcerpc state holding invalid opnum after request2. Holding %d, while we are "
1266 "expecting 30\n", dcerpc_state->dcerpc.dcerpcrequest.opnum);
1280 dcerpc_response2_len);
1282 printf(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
1287 if (dcerpc_state == NULL) {
1288 printf(
"no dcerpc state: ");
1292 if (dcerpc_state->dcerpc.dcerpcrequest.opnum != 30) {
1293 printf(
"dcerpc state holding invalid opnum after response2. Holding %d, while we are "
1294 "expecting 30\n", dcerpc_state->dcerpc.dcerpcrequest.opnum);
1325 static void DetectDceOpnumRegisterTests(
void)
1330 UtRegisterTest(
"DetectDceOpnumTestParse10", DetectDceOpnumTestParse10, 1);
1331 UtRegisterTest(
"DetectDceOpnumTestParse11", DetectDceOpnumTestParse11, 1);
1332 UtRegisterTest(
"DetectDceOpnumTestParse12", DetectDceOpnumTestParse12, 1);
1333 UtRegisterTest(
"DetectDceOpnumTestParse13", DetectDceOpnumTestParse13, 1);