52 #define PARSE_REGEX "^\\s*([0-9a-zA-Z]{8}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{12})(?:\\s*,\\s*(<|>|=|!)([0-9]{1,5}))?(?:\\s*,\\s*(any_frag))?\\s*$"
57 Flow *f, uint8_t
flags,
void *state,
void *txv,
62 static void DetectDceIfaceRegisterTests(
void);
64 static int g_dce_generic_list_id = 0;
109 Flow *f, uint8_t
flags,
void *state,
void *txv,
116 return rs_dcerpc_iface_match(txv, state, (
void *)
m);
121 if (rs_smb_tx_get_dce_iface(f->
alstate, txv, (
void *)
m) != 1) {
122 SCLogDebug(
"rs_smb_tx_get_dce_iface: didn't match");
124 SCLogDebug(
"rs_smb_tx_get_dce_iface: matched!");
150 void *did = rs_dcerpc_iface_parse(arg);
152 SCLogError(
"Error parsing dce_iface option in "
158 DetectDceIfaceFree(
de_ctx, did);
168 rs_dcerpc_iface_free(ptr);
184 static int DetectDceIfaceTestParse13(
void)
194 DCERPCState *dcerpc_state = NULL;
197 uint8_t dcerpc_bind[] = {
198 0x05, 0x00, 0x0b, 0x03, 0x10, 0x00, 0x00, 0x00,
199 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
200 0xb8, 0x10, 0xb8, 0x10, 0x00, 0x00, 0x00, 0x00,
201 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
202 0x01, 0xd0, 0x8c, 0x33, 0x44, 0x22, 0xf1, 0x31,
203 0xaa, 0xaa, 0x90, 0x00, 0x38, 0x00, 0x10, 0x03,
204 0x01, 0x00, 0x00, 0x00, 0x04, 0x5d, 0x88, 0x8a,
205 0xeb, 0x1c, 0xc9, 0x11, 0x9f, 0xe8, 0x08, 0x00,
206 0x2b, 0x10, 0x48, 0x60, 0x02, 0x00, 0x00, 0x00,
209 uint8_t dcerpc_bindack[] = {
210 0x05, 0x00, 0x0c, 0x03, 0x10, 0x00, 0x00, 0x00,
211 0x44, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
212 0xb8, 0x10, 0xb8, 0x10, 0x65, 0x8e, 0x00, 0x00,
213 0x0d, 0x00, 0x5c, 0x50, 0x49, 0x50, 0x45, 0x5c,
214 0x77, 0x69, 0x6e, 0x72, 0x65, 0x67, 0x00, 0x6d,
215 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
216 0x04, 0x5d, 0x88, 0x8a, 0xeb, 0x1c, 0xc9, 0x11,
217 0x9f, 0xe8, 0x08, 0x00, 0x2b, 0x10, 0x48, 0x60,
218 0x02, 0x00, 0x00, 0x00,
221 uint8_t dcerpc_request1[] = {
222 0x05, 0x00, 0x00, 0x03, 0x10, 0x00, 0x00, 0x00,
223 0x24, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
224 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
225 0x2c, 0xfd, 0xb5, 0x00, 0x40, 0xaa, 0x01, 0x00,
226 0x00, 0x00, 0x00, 0x02,
229 uint8_t dcerpc_response1[] = {
230 0x05, 0x00, 0x02, 0x03, 0x10, 0x00, 0x00, 0x00,
231 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
232 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
233 0x00, 0x00, 0x00, 0x00, 0xf6, 0x72, 0x28, 0x9c,
234 0xf0, 0x57, 0xd8, 0x11, 0xb0, 0x05, 0x00, 0x0c,
235 0x29, 0x87, 0xea, 0xe9, 0x00, 0x00, 0x00, 0x00,
238 uint8_t dcerpc_request2[] = {
239 0x05, 0x00, 0x00, 0x03, 0x10, 0x00, 0x00, 0x00,
240 0xa4, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
241 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00,
242 0x00, 0x00, 0x00, 0x00, 0xf6, 0x72, 0x28, 0x9c,
243 0xf0, 0x57, 0xd8, 0x11, 0xb0, 0x05, 0x00, 0x0c,
244 0x29, 0x87, 0xea, 0xe9, 0x5c, 0x00, 0x5c, 0x00,
245 0xa8, 0xb9, 0x14, 0x00, 0x2e, 0x00, 0x00, 0x00,
246 0x00, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00,
247 0x53, 0x00, 0x4f, 0x00, 0x46, 0x00, 0x54, 0x00,
248 0x57, 0x00, 0x41, 0x00, 0x52, 0x00, 0x45, 0x00,
249 0x5c, 0x00, 0x4d, 0x00, 0x69, 0x00, 0x63, 0x00,
250 0x72, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x6f, 0x00,
251 0x66, 0x00, 0x74, 0x00, 0x5c, 0x00, 0x57, 0x00,
252 0x69, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x6f, 0x00,
253 0x77, 0x00, 0x73, 0x00, 0x5c, 0x00, 0x43, 0x00,
254 0x75, 0x00, 0x72, 0x00, 0x72, 0x00, 0x65, 0x00,
255 0x6e, 0x00, 0x74, 0x00, 0x56, 0x00, 0x65, 0x00,
256 0x72, 0x00, 0x73, 0x00, 0x69, 0x00, 0x6f, 0x00,
257 0x6e, 0x00, 0x5c, 0x00, 0x52, 0x00, 0x75, 0x00,
258 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
259 0x03, 0x00, 0x00, 0x00,
262 uint8_t dcerpc_response2[] = {
263 0x05, 0x00, 0x02, 0x03, 0x10, 0x00, 0x00, 0x00,
264 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
265 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
266 0x00, 0x00, 0x00, 0x00, 0xf7, 0x72, 0x28, 0x9c,
267 0xf0, 0x57, 0xd8, 0x11, 0xb0, 0x05, 0x00, 0x0c,
268 0x29, 0x87, 0xea, 0xe9, 0x00, 0x00, 0x00, 0x00,
271 uint8_t dcerpc_request3[] = {
272 0x05, 0x00, 0x00, 0x03, 0x10, 0x00, 0x00, 0x00,
273 0x70, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
274 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00,
275 0x00, 0x00, 0x00, 0x00, 0xf7, 0x72, 0x28, 0x9c,
276 0xf0, 0x57, 0xd8, 0x11, 0xb0, 0x05, 0x00, 0x0c,
277 0x29, 0x87, 0xea, 0xe9, 0x0c, 0x00, 0x0c, 0x00,
278 0x98, 0xda, 0x14, 0x00, 0x06, 0x00, 0x00, 0x00,
279 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
280 0x4f, 0x00, 0x73, 0x00, 0x61, 0x00, 0x33, 0x00,
281 0x32, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
282 0x18, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x54, 0x00,
283 0x4f, 0x00, 0x53, 0x00, 0x41, 0x00, 0x33, 0x00,
284 0x32, 0x00, 0x2e, 0x00, 0x45, 0x00, 0x58, 0x00,
285 0x45, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
288 uint8_t dcerpc_response3[] = {
289 0x05, 0x00, 0x02, 0x03, 0x10, 0x00, 0x00, 0x00,
290 0x1c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
291 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
292 0x00, 0x00, 0x00, 0x00,
295 uint32_t dcerpc_bind_len =
sizeof(dcerpc_bind);
296 uint32_t dcerpc_bindack_len =
sizeof(dcerpc_bindack);
298 uint32_t dcerpc_request1_len =
sizeof(dcerpc_request1);
299 uint32_t dcerpc_response1_len =
sizeof(dcerpc_response1);
301 uint32_t dcerpc_request2_len =
sizeof(dcerpc_request2);
302 uint32_t dcerpc_response2_len =
sizeof(dcerpc_response2);
304 uint32_t dcerpc_request3_len =
sizeof(dcerpc_request3);
305 uint32_t dcerpc_response3_len =
sizeof(dcerpc_response3);
309 memset(&th_v, 0,
sizeof(th_v));
310 memset(&p, 0,
sizeof(p));
311 memset(&f, 0,
sizeof(f));
312 memset(&ssn, 0,
sizeof(ssn));
318 f.
proto = IPPROTO_TCP;
334 "(msg:\"DCERPC\"; dce_iface:338cd001-2244-31f1-aaaa-900038001003,=1,any_frag; sid:1;)");
344 dcerpc_bind, dcerpc_bind_len);
346 SCLogDebug(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
351 if (dcerpc_state == NULL) {
362 SCLogDebug(
"sig 1 didn't match after bind request: ");
371 SCLogDebug(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
381 SCLogDebug(
"sig 1 matched again after bind ack: ");
389 dcerpc_request1_len);
391 SCLogDebug(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
401 SCLogDebug(
"sig 1 didn't match after request1: ");
409 dcerpc_response1_len);
411 SCLogDebug(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
421 SCLogDebug(
"sig 1 matched after response1, but shouldn't: ");
429 dcerpc_request2_len);
431 SCLogDebug(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
441 SCLogDebug(
"sig 1 didn't match after request2: ");
447 dcerpc_response2_len);
449 SCLogDebug(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
459 SCLogDebug(
"sig 1 matched after response2, but shouldn't have: ");
465 dcerpc_request3_len);
467 SCLogDebug(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
477 SCLogDebug(
"sig 1 didn't match after request3: ");
483 dcerpc_response3, dcerpc_response3_len);
485 SCLogDebug(
"AppLayerParse for dcerpc failed. Returned %" PRId32, r);
495 SCLogDebug(
"sig 1 matched after response3, but shouldn't have: ");
517 static void DetectDceIfaceRegisterTests(
void)
522 UtRegisterTest(
"DetectDceIfaceTestParse13", DetectDceIfaceTestParse13, 1);