Project

General

Profile

Bug #58 ยป 0001-endianness-handling-update.patch

Kirby Kuehl, 01/18/2010 01:49 PM

View differences:

src/app-layer-dcerpc.c
case 25:
sstate->secondaryaddrlen |= *(p++) << 8;
if (sstate->dcerpc.packed_drep[0] == 0x01) {
bswap_16(sstate->secondaryaddrlen);
SCByteSwap16(sstate->secondaryaddrlen);
}
sstate->secondaryaddrlenleft = sstate->secondaryaddrlen;
SCLogDebug("secondaryaddrlen %u 0x%04x\n", sstate->secondaryaddrlen,
......
case 23:
sstate->opnum |= *(p++) << 8;
if (sstate->dcerpc.packed_drep[0] == 0x01) {
bswap_16(sstate->opnum);
SCByteSwap16(sstate->opnum);
}
--input_len;
break;
......
case 15:
sstate->dcerpc.call_id |= *(p++);
if (sstate->dcerpc.packed_drep[0] == 0x01) {
bswap_16(sstate->dcerpc.frag_length);
bswap_16(sstate->dcerpc.auth_length);
bswap_32(sstate->dcerpc.call_id);
SCByteSwap16(sstate->dcerpc.frag_length);
SCByteSwap16(sstate->dcerpc.auth_length);
SCByteSwap32(sstate->dcerpc.call_id);
}
--input_len;
break;
......
/* UNITTESTS */
#ifdef UNITTESTS
/** \test DCERPC Header Parsing and BIND / BIND_ACK multiple UUID handling
*/
/* set this to 1 to see problem */
#define KNOWNFAILURE 0
int DCERPCParserTest01(void) {
......
printUUID("BIND_ACK", uuid_entry);
}
#if KNOWNFAILURE
r = AppLayerParse(&f, ALPROTO_DCERPC, STREAM_TOSERVER, dcerpcrequest, requestlen, FALSE);
printf("Sending dcerpcrequest (%u)", requestlen);
r = AppLayerParse(&f, ALPROTO_DCERPC, STREAM_TOSERVER|STREAM_EOF, dcerpcrequest, requestlen, FALSE);
if (r != 0) {
printf("dcerpc header check returned %" PRId32 ", expected 0: ", r);
result = 0;
......
return result;
}
/** \test DCERPC Request decoding and opnum parsing.
*/
int DCERPCParserTest02(void) {
int result = 1;
Flow f;
uint8_t dcerpcrequest[] = {
0x05, 0x00, 0x00, 0x00, 0x10,
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x0b,
0x00, 0x09, 0x00, 0x45, 0x00, 0x2c, 0x00, 0x4d,
0x00, 0x73, 0x00, 0x53, 0x00, 0x59, 0x00, 0x2a,
0x00, 0x4a, 0x00, 0x7a, 0x00, 0x3e, 0x00, 0x58,
0x00, 0x21, 0x00, 0x4a, 0x00, 0x30, 0x00, 0x41,
0x00, 0x4b, 0x00, 0x4b, 0x00, 0x3c, 0x00, 0x48,
0x00, 0x24, 0x00, 0x38, 0x00, 0x54, 0x00, 0x60,
0x00, 0x2d, 0x00, 0x29, 0x00, 0x64, 0x00, 0x5b,
0x00, 0x77, 0x00, 0x3a, 0x00, 0x4c, 0x00, 0x24,
0x00, 0x23, 0x00, 0x66, 0x00, 0x43, 0x00, 0x68,
0x00, 0x22, 0x00, 0x55, 0x00, 0x29, 0x00, 0x2c,
0x00, 0x4f, 0x00, 0x5a, 0x00, 0x50, 0x00, 0x61,
0x00, 0x2a, 0x00, 0x6f, 0x00, 0x2f, 0x00, 0x4d,
0x00, 0x68, 0x00, 0x3a, 0x00, 0x5c, 0x00, 0x67,
0x00, 0x68, 0x00, 0x68, 0x00, 0x49, 0x00, 0x45,
0x00, 0x4c, 0x00, 0x72, 0x00, 0x53, 0x00, 0x4c,
0x00, 0x25, 0x00, 0x4d, 0x00, 0x67, 0x00, 0x2e,
0x00, 0x4f, 0x00, 0x64, 0x00, 0x61, 0x00, 0x73,
0x00, 0x24, 0x00, 0x46, 0x00, 0x35, 0x00, 0x2e,
0x00, 0x45, 0x00, 0x6f, 0x00, 0x40, 0x00, 0x41,
0x00, 0x33, 0x00, 0x38, 0x00, 0x47, 0x00, 0x71,
0x00, 0x5a, 0x00, 0x37, 0x00, 0x7a, 0x00, 0x35,
0x00, 0x6b, 0x00, 0x3c, 0x00, 0x26, 0x00, 0x37,
0x00, 0x69, 0x00, 0x75, 0x00, 0x36, 0x00, 0x37,
0x00, 0x47, 0x00, 0x21, 0x00, 0x2d, 0x00, 0x69,
0x00, 0x37, 0x00, 0x78, 0x00, 0x5f, 0x00, 0x72,
0x00, 0x4b, 0x00, 0x5c, 0x00, 0x74, 0x00, 0x3e,
0x00, 0x52, 0x00, 0x7a, 0x00, 0x49, 0x00, 0x31,
0x00, 0x5a, 0x00, 0x7b, 0x00, 0x29, 0x00, 0x3b,
0x00, 0x78, 0x00, 0x3b, 0x00, 0x55, 0x00, 0x3e,
0x00, 0x35, 0x00, 0x2b, 0x00, 0x4e, 0x00, 0x4f,
0x00, 0x59, 0x00, 0x38, 0x00, 0x2a, 0x00, 0x59,
0x00, 0x6b, 0x00, 0x42, 0x00, 0x4c, 0x00, 0x3e,
0x00, 0x6a, 0x00, 0x49, 0x00, 0x2c, 0x00, 0x79,
0x00, 0x6e, 0x00, 0x35, 0x00, 0x4f, 0x00, 0x49,
0x00, 0x55, 0x00, 0x35, 0x00, 0x61, 0x00, 0x72,
0x00, 0x77, 0x00, 0x38, 0x00, 0x32, 0x00, 0x24,
0x00, 0x46, 0x00, 0x32, 0x00, 0x32, 0x00, 0x27,
0x00, 0x64, 0x00, 0x5a, 0x00, 0x77, 0x00, 0x2e,
0x00, 0x37, 0x00, 0x77, 0x00, 0x2e, 0x00, 0x28,
0x00, 0x63, 0x00, 0x4f, 0x00, 0x67, 0x00, 0x64,
0x00, 0x39, 0x00, 0x37, 0x00, 0x31, 0x00, 0x30,
0x00, 0x28, 0x00, 0x2e, 0x00, 0x6f, 0x00, 0x3e,
0x00, 0x59, 0x00, 0x28, 0x00, 0x67, 0x00, 0x52,
0x00, 0x35, 0x00, 0x5a, 0x00, 0x7c, 0x00, 0x56,
0x00, 0x6a, 0x00, 0x5c, 0x00, 0x3c, 0x00, 0x30,
0x00, 0x59, 0x00, 0x5c, 0x00, 0x5e, 0x00, 0x38,
0x00, 0x54, 0x00, 0x5c, 0x00, 0x5b, 0x00, 0x42,
0x00, 0x62, 0x00, 0x70, 0x00, 0x34, 0x00, 0x5c,
0x00, 0x57, 0x00, 0x7a, 0x00, 0x4b, 0x00, 0x2f,
0x00, 0x6b, 0x00, 0x6a, 0x00, 0x4f, 0x00, 0x41,
0x00, 0x33, 0x00, 0x52, 0x00, 0x36, 0x00, 0x27,
0x00, 0x30, 0x00, 0x6d, 0x00, 0x4a, 0x00, 0x30,
0x00, 0x78, 0x00, 0x46, 0x00, 0x65, 0x00, 0x4e,
0x00, 0x29, 0x00, 0x66, 0x00, 0x3f, 0x00, 0x72,
0x00, 0x71, 0x00, 0x75, 0x00, 0x4c, 0x00, 0x2b,
0x00, 0x5c, 0x00, 0x46, 0x00, 0x52, 0x00, 0x7b,
0x00, 0x5c, 0x00, 0x69, 0x00, 0x66, 0x00, 0x56,
0x00, 0x31, 0x00, 0x2d, 0x00, 0x72, 0x00, 0x61,
0x00, 0x68, 0x00, 0x28, 0x00, 0x7d, 0x00, 0x58,
0x00, 0x2a, 0x00, 0x7b, 0x00, 0x28, 0x00, 0x5b,
0x00, 0x54, 0x00, 0x3a, 0x00, 0x26, 0x00, 0x52,
0x00, 0x44, 0x00, 0x60, 0x00, 0x50, 0x00, 0x65,
0x00, 0x48, 0x00, 0x7d, 0x00, 0x2a, 0x00, 0x74,
0x00, 0x49, 0x00, 0x7b, 0x00, 0x21, 0x00, 0x61,
0x00, 0x52, 0x00, 0x43, 0x00, 0x5f, 0x00, 0x5a,
0x00, 0x74, 0x00, 0x5c, 0x00, 0x62, 0x00, 0x68,
0x00, 0x6c, 0x00, 0x6c, 0x00, 0x2b, 0x00, 0x6f,
0x00, 0x7c, 0x00, 0x42, 0x00, 0x67, 0x00, 0x32,
0x00, 0x58, 0x00, 0x35, 0x00, 0x30, 0x00, 0x2f,
0x00, 0x2d, 0x00, 0x60, 0x00, 0x62, 0x00, 0x51,
0x00, 0x2a, 0x00, 0x30, 0x00, 0x31, 0x00, 0x48,
0x00, 0x5b, 0x00, 0x5b, 0x00, 0x5d, 0x00, 0x25,
0x00, 0x58, 0x00, 0x4a, 0x00, 0x76, 0x00, 0x32,
0x00, 0x62, 0x00, 0x27, 0x00, 0x42, 0x00, 0x40,
0x00, 0x53, 0x00, 0x7c, 0x00, 0x7d, 0x00, 0x50,
0x00, 0x3d, 0x00, 0x40, 0x00, 0x76, 0x00, 0x38,
0x00, 0x58, 0x00, 0x39, 0x00, 0x63, 0x00, 0x3c,
0x00, 0x5b, 0x00, 0x23, 0x00, 0x53, 0x00, 0x7a,
0x00, 0x54, 0x00, 0x74, 0x00, 0x61, 0x00, 0x76,
0x00, 0x4a, 0x00, 0x3e, 0x00, 0x33, 0x00, 0x75,
0x00, 0x66, 0x00, 0x2d, 0x00, 0x48, 0x00, 0x33,
0x00, 0x71, 0x00, 0x76, 0x00, 0x48, 0x00, 0x71,
0x00, 0x41, 0x00, 0x6f, 0x00, 0x2a, 0x00, 0x67,
0x00, 0x70, 0x00, 0x21, 0x00, 0x70, 0x00, 0x4b,
0x00, 0x52, 0x00, 0x58, 0x00, 0x68, 0x00, 0x23,
0x00, 0x39, 0x00, 0x46, 0x00, 0x4d, 0x00, 0x51,
0x00, 0x57, 0x00, 0x3a, 0x00, 0x79, 0x00, 0x7b,
0x00, 0x6c, 0x00, 0x55, 0x00, 0x33, 0x00, 0x65,
0x00, 0x49, 0x00, 0x72, 0x00, 0x30, 0x00, 0x4f,
0x00, 0x41, 0x00, 0x6e, 0x00, 0x31, 0x00, 0x4a,
0x00, 0x60, 0x00, 0x79, 0x00, 0x70, 0x00, 0x4f,
0x00, 0x58, 0x00, 0x75, 0x00, 0x44, 0x00, 0x59,
0x00, 0x58, 0x00, 0x46, 0x00, 0x3d, 0x00, 0x46,
0x00, 0x74, 0x00, 0x51, 0x00, 0x57, 0x00, 0x6e,
0x00, 0x2d, 0x00, 0x47, 0x00, 0x23, 0x00, 0x45,
0x00, 0x60, 0x00, 0x4c, 0x00, 0x72, 0x00, 0x4e,
0x00, 0x74, 0x00, 0x40, 0x00, 0x76, 0x00, 0x75,
0x00, 0x74, 0x00, 0x56, 0x00, 0x44, 0x00, 0x29,
0x00, 0x62, 0x00, 0x58, 0x00, 0x31, 0x00, 0x78,
0x00, 0x32, 0x00, 0x52, 0x00, 0x4a, 0x00, 0x6b,
0x00, 0x55, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x6f,
0x00, 0x4a, 0x00, 0x54, 0x00, 0x7d, 0x00, 0x68,
0x00, 0x3f, 0x00, 0x28, 0x00, 0x21, 0x00, 0x53,
0x00, 0x48, 0x00, 0x5a, 0x00, 0x34, 0x00, 0x36,
0x00, 0x35, 0x00, 0x64, 0x00, 0x4e, 0x00, 0x75,
0x00, 0x69, 0x00, 0x23, 0x00, 0x75, 0x00, 0x55,
0x00, 0x43, 0x00, 0x75, 0x00, 0x2f, 0x00, 0x73,
0x00, 0x62, 0x00, 0x6f, 0x00, 0x37, 0x00, 0x4e,
0x00, 0x25, 0x00, 0x25, 0x00, 0x21, 0x00, 0x3d,
0x00, 0x3c, 0x00, 0x71, 0x00, 0x3e, 0x00, 0x3f,
0x00, 0x30, 0x00, 0x36, 0x00, 0x62, 0x00, 0x63,
0x00, 0x53, 0x00, 0x54, 0x00, 0x5d, 0x00, 0x61,
0x00, 0x4c, 0x00, 0x28, 0x00, 0x2b, 0x00, 0x4c,
0x00, 0x4e, 0x00, 0x66, 0x00, 0x5f, 0x00, 0x4b,
0x00, 0x43, 0x00, 0x75, 0x00, 0x45, 0x00, 0x37,
0x00, 0x28, 0x00, 0x56, 0x00, 0x36, 0x00, 0x6a,
0x00, 0x3e, 0x00, 0x64, 0x00, 0x34, 0x00, 0x6a,
0x00, 0x7d, 0x00, 0x4a, 0x00, 0x66, 0x00, 0x7a,
0x00, 0x3e, 0x00, 0x75, 0x00, 0x38, 0x00, 0x7b,
0x00, 0x42, 0x00, 0x76, 0x00, 0x29, 0x00, 0x4c,
0x00, 0x65, 0x00, 0x2e, 0x00, 0x32, 0x00, 0x4b,
0x00, 0x2b, 0x00, 0x51, 0x00, 0x47, 0x00, 0x22,
0x00, 0x48, 0x00, 0x3d, 0x00, 0x49, 0x00, 0x44,
0x00, 0x5d, 0x00, 0x59, 0x00, 0x63, 0x00, 0x5c,
0x00, 0x24, 0x00, 0x35, 0x00, 0x34, 0x00, 0x70,
0x00, 0x69, 0x00};
uint32_t requestlen = sizeof(dcerpcrequest);
TcpSession ssn;
struct uuid_entry *uuid_entry;
memset(&f, 0, sizeof(f));
memset(&ssn, 0, sizeof(ssn));
StreamL7DataPtrInit(&ssn,StreamL7GetStorageSize());
f.protoctx = (void *)&ssn;
int r = AppLayerParse(&f, ALPROTO_DCERPC, STREAM_TOSERVER|STREAM_START, dcerpcrequest, requestlen, FALSE);
if (r != 0) {
printf("dcerpc header check returned %" PRId32 ", expected 0: ", r);
result = 0;
goto end;
}
DCERPCState *dcerpc_state = ssn.aldata[AlpGetStateIdx(ALPROTO_DCERPC)];
if (dcerpc_state == NULL) {
printf("no dcerpc state: ");
result = 0;
goto end;
}
if (dcerpc_state->dcerpc.rpc_vers != 5) {
printf("expected dcerpc version 0x05, got 0x%02x : ",
dcerpc_state->dcerpc.rpc_vers);
result = 0;
goto end;
}
if (dcerpc_state->dcerpc.type != REQUEST) {
printf("expected dcerpc type 0x%02x , got 0x%02x : ", REQUEST, dcerpc_state->dcerpc.type);
result = 0;
goto end;
}
if (dcerpc_state->dcerpc.frag_length != 1024) {
printf("expected dcerpc frag_length 0x%02x , got 0x%02x : ", 1024, dcerpc_state->dcerpc.frag_length);
result = 0;
goto end;
}
if (dcerpc_state->opnum != 9) {
printf("expected dcerpc opnum 0x%02x , got 0x%02x : ", 9, dcerpc_state->opnum);
result = 0;
goto end;
}
end:
return result;
}
/** \test Test endianness handling
*/
int DCERPCParserTest03(void) {
int result = 1;
Flow f;
uint8_t dcerpcrequest[] = {
0x05, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00,
0x0b, 0x00, 0x09, 0x45, 0x00, 0x2c, 0x00, 0x4d,
0x00, 0x73, 0x00, 0x53, 0x00, 0x59, 0x00, 0x2a,
0x00, 0x4a, 0x00, 0x7a, 0x00, 0x3e, 0x00, 0x58,
0x00, 0x21, 0x00, 0x4a, 0x00, 0x30, 0x00, 0x41,
0x00, 0x4b, 0x00, 0x4b, 0x00, 0x3c, 0x00, 0x48,
0x00, 0x24, 0x00, 0x38, 0x00, 0x54, 0x00, 0x60,
0x00, 0x2d, 0x00, 0x29, 0x00, 0x64, 0x00, 0x5b,
0x00, 0x77, 0x00, 0x3a, 0x00, 0x4c, 0x00, 0x24,
0x00, 0x23, 0x00, 0x66, 0x00, 0x43, 0x00, 0x68,
0x00, 0x22, 0x00, 0x55, 0x00, 0x29, 0x00, 0x2c,
0x00, 0x4f, 0x00, 0x5a, 0x00, 0x50, 0x00, 0x61,
0x00, 0x2a, 0x00, 0x6f, 0x00, 0x2f, 0x00, 0x4d,
0x00, 0x68, 0x00, 0x3a, 0x00, 0x5c, 0x00, 0x67,
0x00, 0x68, 0x00, 0x68, 0x00, 0x49, 0x00, 0x45,
0x00, 0x4c, 0x00, 0x72, 0x00, 0x53, 0x00, 0x4c,
0x00, 0x25, 0x00, 0x4d, 0x00, 0x67, 0x00, 0x2e,
0x00, 0x4f, 0x00, 0x64, 0x00, 0x61, 0x00, 0x73,
0x00, 0x24, 0x00, 0x46, 0x00, 0x35, 0x00, 0x2e,
0x00, 0x45, 0x00, 0x6f, 0x00, 0x40, 0x00, 0x41,
0x00, 0x33, 0x00, 0x38, 0x00, 0x47, 0x00, 0x71,
0x00, 0x5a, 0x00, 0x37, 0x00, 0x7a, 0x00, 0x35,
0x00, 0x6b, 0x00, 0x3c, 0x00, 0x26, 0x00, 0x37,
0x00, 0x69, 0x00, 0x75, 0x00, 0x36, 0x00, 0x37,
0x00, 0x47, 0x00, 0x21, 0x00, 0x2d, 0x00, 0x69,
0x00, 0x37, 0x00, 0x78, 0x00, 0x5f, 0x00, 0x72,
0x00, 0x4b, 0x00, 0x5c, 0x00, 0x74, 0x00, 0x3e,
0x00, 0x52, 0x00, 0x7a, 0x00, 0x49, 0x00, 0x31,
0x00, 0x5a, 0x00, 0x7b, 0x00, 0x29, 0x00, 0x3b,
0x00, 0x78, 0x00, 0x3b, 0x00, 0x55, 0x00, 0x3e,
0x00, 0x35, 0x00, 0x2b, 0x00, 0x4e, 0x00, 0x4f,
0x00, 0x59, 0x00, 0x38, 0x00, 0x2a, 0x00, 0x59,
0x00, 0x6b, 0x00, 0x42, 0x00, 0x4c, 0x00, 0x3e,
0x00, 0x6a, 0x00, 0x49, 0x00, 0x2c, 0x00, 0x79,
0x00, 0x6e, 0x00, 0x35, 0x00, 0x4f, 0x00, 0x49,
0x00, 0x55, 0x00, 0x35, 0x00, 0x61, 0x00, 0x72,
0x00, 0x77, 0x00, 0x38, 0x00, 0x32, 0x00, 0x24,
0x00, 0x46, 0x00, 0x32, 0x00, 0x32, 0x00, 0x27,
0x00, 0x64, 0x00, 0x5a, 0x00, 0x77, 0x00, 0x2e,
0x00, 0x37, 0x00, 0x77, 0x00, 0x2e, 0x00, 0x28,
0x00, 0x63, 0x00, 0x4f, 0x00, 0x67, 0x00, 0x64,
0x00, 0x39, 0x00, 0x37, 0x00, 0x31, 0x00, 0x30,
0x00, 0x28, 0x00, 0x2e, 0x00, 0x6f, 0x00, 0x3e,
0x00, 0x59, 0x00, 0x28, 0x00, 0x67, 0x00, 0x52,
0x00, 0x35, 0x00, 0x5a, 0x00, 0x7c, 0x00, 0x56,
0x00, 0x6a, 0x00, 0x5c, 0x00, 0x3c, 0x00, 0x30,
0x00, 0x59, 0x00, 0x5c, 0x00, 0x5e, 0x00, 0x38,
0x00, 0x54, 0x00, 0x5c, 0x00, 0x5b, 0x00, 0x42,
0x00, 0x62, 0x00, 0x70, 0x00, 0x34, 0x00, 0x5c,
0x00, 0x57, 0x00, 0x7a, 0x00, 0x4b, 0x00, 0x2f,
0x00, 0x6b, 0x00, 0x6a, 0x00, 0x4f, 0x00, 0x41,
0x00, 0x33, 0x00, 0x52, 0x00, 0x36, 0x00, 0x27,
0x00, 0x30, 0x00, 0x6d, 0x00, 0x4a, 0x00, 0x30,
0x00, 0x78, 0x00, 0x46, 0x00, 0x65, 0x00, 0x4e,
0x00, 0x29, 0x00, 0x66, 0x00, 0x3f, 0x00, 0x72,
0x00, 0x71, 0x00, 0x75, 0x00, 0x4c, 0x00, 0x2b,
0x00, 0x5c, 0x00, 0x46, 0x00, 0x52, 0x00, 0x7b,
0x00, 0x5c, 0x00, 0x69, 0x00, 0x66, 0x00, 0x56,
0x00, 0x31, 0x00, 0x2d, 0x00, 0x72, 0x00, 0x61,
0x00, 0x68, 0x00, 0x28, 0x00, 0x7d, 0x00, 0x58,
0x00, 0x2a, 0x00, 0x7b, 0x00, 0x28, 0x00, 0x5b,
0x00, 0x54, 0x00, 0x3a, 0x00, 0x26, 0x00, 0x52,
0x00, 0x44, 0x00, 0x60, 0x00, 0x50, 0x00, 0x65,
0x00, 0x48, 0x00, 0x7d, 0x00, 0x2a, 0x00, 0x74,
0x00, 0x49, 0x00, 0x7b, 0x00, 0x21, 0x00, 0x61,
0x00, 0x52, 0x00, 0x43, 0x00, 0x5f, 0x00, 0x5a,
0x00, 0x74, 0x00, 0x5c, 0x00, 0x62, 0x00, 0x68,
0x00, 0x6c, 0x00, 0x6c, 0x00, 0x2b, 0x00, 0x6f,
0x00, 0x7c, 0x00, 0x42, 0x00, 0x67, 0x00, 0x32,
0x00, 0x58, 0x00, 0x35, 0x00, 0x30, 0x00, 0x2f,
0x00, 0x2d, 0x00, 0x60, 0x00, 0x62, 0x00, 0x51,
0x00, 0x2a, 0x00, 0x30, 0x00, 0x31, 0x00, 0x48,
0x00, 0x5b, 0x00, 0x5b, 0x00, 0x5d, 0x00, 0x25,
0x00, 0x58, 0x00, 0x4a, 0x00, 0x76, 0x00, 0x32,
0x00, 0x62, 0x00, 0x27, 0x00, 0x42, 0x00, 0x40,
0x00, 0x53, 0x00, 0x7c, 0x00, 0x7d, 0x00, 0x50,
0x00, 0x3d, 0x00, 0x40, 0x00, 0x76, 0x00, 0x38,
0x00, 0x58, 0x00, 0x39, 0x00, 0x63, 0x00, 0x3c,
0x00, 0x5b, 0x00, 0x23, 0x00, 0x53, 0x00, 0x7a,
0x00, 0x54, 0x00, 0x74, 0x00, 0x61, 0x00, 0x76,
0x00, 0x4a, 0x00, 0x3e, 0x00, 0x33, 0x00, 0x75,
0x00, 0x66, 0x00, 0x2d, 0x00, 0x48, 0x00, 0x33,
0x00, 0x71, 0x00, 0x76, 0x00, 0x48, 0x00, 0x71,
0x00, 0x41, 0x00, 0x6f, 0x00, 0x2a, 0x00, 0x67,
0x00, 0x70, 0x00, 0x21, 0x00, 0x70, 0x00, 0x4b,
0x00, 0x52, 0x00, 0x58, 0x00, 0x68, 0x00, 0x23,
0x00, 0x39, 0x00, 0x46, 0x00, 0x4d, 0x00, 0x51,
0x00, 0x57, 0x00, 0x3a, 0x00, 0x79, 0x00, 0x7b,
0x00, 0x6c, 0x00, 0x55, 0x00, 0x33, 0x00, 0x65,
0x00, 0x49, 0x00, 0x72, 0x00, 0x30, 0x00, 0x4f,
0x00, 0x41, 0x00, 0x6e, 0x00, 0x31, 0x00, 0x4a,
0x00, 0x60, 0x00, 0x79, 0x00, 0x70, 0x00, 0x4f,
0x00, 0x58, 0x00, 0x75, 0x00, 0x44, 0x00, 0x59,
0x00, 0x58, 0x00, 0x46, 0x00, 0x3d, 0x00, 0x46,
0x00, 0x74, 0x00, 0x51, 0x00, 0x57, 0x00, 0x6e,
0x00, 0x2d, 0x00, 0x47, 0x00, 0x23, 0x00, 0x45,
0x00, 0x60, 0x00, 0x4c, 0x00, 0x72, 0x00, 0x4e,
0x00, 0x74, 0x00, 0x40, 0x00, 0x76, 0x00, 0x75,
0x00, 0x74, 0x00, 0x56, 0x00, 0x44, 0x00, 0x29,
0x00, 0x62, 0x00, 0x58, 0x00, 0x31, 0x00, 0x78,
0x00, 0x32, 0x00, 0x52, 0x00, 0x4a, 0x00, 0x6b,
0x00, 0x55, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x6f,
0x00, 0x4a, 0x00, 0x54, 0x00, 0x7d, 0x00, 0x68,
0x00, 0x3f, 0x00, 0x28, 0x00, 0x21, 0x00, 0x53,
0x00, 0x48, 0x00, 0x5a, 0x00, 0x34, 0x00, 0x36,
0x00, 0x35, 0x00, 0x64, 0x00, 0x4e, 0x00, 0x75,
0x00, 0x69, 0x00, 0x23, 0x00, 0x75, 0x00, 0x55,
0x00, 0x43, 0x00, 0x75, 0x00, 0x2f, 0x00, 0x73,
0x00, 0x62, 0x00, 0x6f, 0x00, 0x37, 0x00, 0x4e,
0x00, 0x25, 0x00, 0x25, 0x00, 0x21, 0x00, 0x3d,
0x00, 0x3c, 0x00, 0x71, 0x00, 0x3e, 0x00, 0x3f,
0x00, 0x30, 0x00, 0x36, 0x00, 0x62, 0x00, 0x63,
0x00, 0x53, 0x00, 0x54, 0x00, 0x5d, 0x00, 0x61,
0x00, 0x4c, 0x00, 0x28, 0x00, 0x2b, 0x00, 0x4c,
0x00, 0x4e, 0x00, 0x66, 0x00, 0x5f, 0x00, 0x4b,
0x00, 0x43, 0x00, 0x75, 0x00, 0x45, 0x00, 0x37,
0x00, 0x28, 0x00, 0x56, 0x00, 0x36, 0x00, 0x6a,
0x00, 0x3e, 0x00, 0x64, 0x00, 0x34, 0x00, 0x6a,
0x00, 0x7d, 0x00, 0x4a, 0x00, 0x66, 0x00, 0x7a,
0x00, 0x3e, 0x00, 0x75, 0x00, 0x38, 0x00, 0x7b,
0x00, 0x42, 0x00, 0x76, 0x00, 0x29, 0x00, 0x4c,
0x00, 0x65, 0x00, 0x2e, 0x00, 0x32, 0x00, 0x4b,
0x00, 0x2b, 0x00, 0x51, 0x00, 0x47, 0x00, 0x22,
0x00, 0x48, 0x00, 0x3d, 0x00, 0x49, 0x00, 0x44,
0x00, 0x5d, 0x00, 0x59, 0x00, 0x63, 0x00, 0x5c,
0x00, 0x24, 0x00, 0x35, 0x00, 0x34, 0x00, 0x70,
0x00, 0x69, 0x00};
uint32_t requestlen = sizeof(dcerpcrequest);
TcpSession ssn;
struct uuid_entry *uuid_entry;
memset(&f, 0, sizeof(f));
memset(&ssn, 0, sizeof(ssn));
StreamL7DataPtrInit(&ssn,StreamL7GetStorageSize());
f.protoctx = (void *)&ssn;
int r = AppLayerParse(&f, ALPROTO_DCERPC, STREAM_TOSERVER|STREAM_START, dcerpcrequest, requestlen, FALSE);
if (r != 0) {
printf("dcerpc header check returned %" PRId32 ", expected 0: ", r);
result = 0;
goto end;
}
DCERPCState *dcerpc_state = ssn.aldata[AlpGetStateIdx(ALPROTO_DCERPC)];
if (dcerpc_state == NULL) {
printf("no dcerpc state: ");
result = 0;
goto end;
}
if (dcerpc_state->dcerpc.packed_drep[0] != 0x01) {
printf("expected dcerpc data representation 0x01, got 0x%02x : ",
dcerpc_state->dcerpc.packed_drep[0]);
result = 0;
goto end;
}
if (dcerpc_state->dcerpc.frag_length != 1024) {
printf("expected dcerpc frag_length 0x%02x , got 0x%02x : ", 1024, dcerpc_state->dcerpc.frag_length);
result = 0;
goto end;
}
if (dcerpc_state->opnum != 9) {
printf("expected dcerpc opnum 0x%02x , got 0x%02x : ", 9, dcerpc_state->opnum);
result = 0;
goto end;
}
end:
return result;
}
void DCERPCParserRegisterTests(void) {
printf("DCERPCParserRegisterTests\n");
UtRegisterTest("DCERPCParserTest01", DCERPCParserTest01, 1);
UtRegisterTest("DCERPCParserTest02", DCERPCParserTest02, 1);
UtRegisterTest("DCERPCParserTest03", DCERPCParserTest03, 1);
}
#endif
src/app-layer-dcerpc.h
#include "app-layer-parser.h"
#include "flow.h"
#include "queue.h"
#include <byteswap.h>
#include "util-byte.h"
void RegisterDCERPCParsers(void);
void DCERPCParserTests(void);
src/util-byte.h
#define BYTE_BIG_ENDIAN 0
#define BYTE_LITTLE_ENDIAN 1
/** Wrappers for OS dependent byte swapping functions */
#ifdef OS_FREEBSD
#include <sys/endian.h>
#define SCByteSwap16(x) bswap16(x)
#define SCByteSwap32(x) bswap32(x)
#define SCByteSwap64(x) bswap64(x)
#elif OS_DARWIN
#include <libkern/OSByteOrder.h>
#define SCByteSwap16(x) OSSwapInt16(x)
#define SCByteSwap32(x) OSSwapInt32(x)
#define SCByteSwap64(x) OSSwapInt64(x)
#else
#include <byteswap.h>
#define SCByteSwap16(x) bswap_16(x)
#define SCByteSwap32(x) bswap_32(x)
#define SCByteSwap64(x) bswap_64(x)
#endif /* OS_FREEBSD */
/**
* Extract bytes from a byte string and convert to a unint64_t.
*
    (1-1/1)