Project

General

Profile

Bug #79 » 0001-smb-writeandx-dcerpc-over-smb.patch

Kirby Kuehl, 02/06/2010 10:03 AM

View differences:

src/app-layer-dcerpc.c
*/
void printUUID(char *type, struct uuid_entry *uuid) {
uint8_t i = 0;
if (uuid == NULL) {
return;
}
printf("%s UUID [%2u] %s ", type, uuid->ctxid,
(uuid->result == 0) ? "Accepted" : "Rejected");
for (i = 0; i < 16; i++) {
src/app-layer-smb.c
sstate->andx.andxcommand = *p;
sstate->andx.andxoffset = *(p + 2);
sstate->andx.andxoffset |= *(p + 3) << 8;
sstate->andx.datalength = *(p + 18);
sstate->andx.datalength |= *(p + 19) << 8;
sstate->andx.datalength |= *(p + 20) << 16;
sstate->andx.datalength |= *(p + 21) << 24;
sstate->andx.datalengthhigh = *(p + 18);
sstate->andx.datalengthhigh |= *(p + 19) << 8;
sstate->andx.datalength = *(p + 20);
sstate->andx.datalength |= *(p + 21) << 8;
sstate->andx.dataoffset = *(p + 22);
sstate->andx.dataoffset |= *(p + 23) << 8;
sstate->andx.dataoffset |= (uint64_t) *(p + 24) << 56;
......
break;
case 18:
// DataLengthHigh 1
sstate->andx.datalength = *(p++) << 16;
sstate->andx.datalengthhigh = *(p++);
if (!(--input_len))
break;
case 19:
// DataLengthHigh 2
sstate->andx.datalength |= *(p++) << 24;
sstate->andx.datalengthhigh |= *(p++) << 8;
if (!(--input_len))
break;
case 20:
// DataLength 1
sstate->andx.datalength |= *(p++) << 8;
sstate->andx.datalength = *(p++);
if (!(--input_len))
break;
case 21:
// DataLength 2
sstate->andx.datalength |= *(p++);
sstate->andx.datalength |= *(p++) << 8;
if (!(--input_len))
break;
case 22:
......
SCReturnUInt((uint32_t)(p - input));
}
while ((uint32_t) ((sstate->bytesprocessed - NBSS_HDR_LEN) + (p - input))
< sstate->andx.dataoffset && sstate->bytecount.bytecount--
< sstate->andx.dataoffset && sstate->bytecount.bytecountleft--
&& input_len--) {
SCLogDebug("0x%02x ", *p);
p++;
}
if ((uint32_t) ((sstate->bytesprocessed - NBSS_HDR_LEN) + (p - input))
......
SMBState *sstate = (SMBState *) smb_state;
uint32_t parsed = 0;
if (sstate->andx.paddingparsed) {
parsed = DCERPCParser(&sstate->dcerpc, input, input_len);
sstate->bytesprocessed += parsed;
sstate->bytecount.bytecount -= parsed;
input_len -= parsed;
parsed = DCERPCParser(&sstate->dcerpc, input, input_len);
sstate->bytesprocessed += parsed;
sstate->bytecount.bytecountleft -= parsed;
input_len -= parsed;
}
SCReturnUInt(parsed);
}
......
if (input_len) {
SMBState *sstate = (SMBState *) smb_state;
sstate->wordcount.wordcount = *(input) * 2;
sstate->wordcount.wordcountleft = sstate->wordcount.wordcount;
sstate->bytesprocessed++;
sstate->bytecount.bytecountbytes = 0;
sstate->andx.isandx = isAndX(sstate);
......
if (input_len && sstate->bytesprocessed == NBSS_HDR_LEN + SMB_HDR_LEN + 2
+ sstate->wordcount.wordcount) {
sstate->bytecount.bytecount |= *(p++) << 8;
sstate->bytecount.bytecountleft = sstate->bytecount.bytecount;
sstate->bytesprocessed++;
SCLogDebug("Bytecount %u", sstate->bytecount.bytecount);
--input_len;
......
output);
parsed += retval;
input_len -= retval;
sstate->wordcount.wordcountleft -= retval;
SCLogDebug("SMB_COM_READ_ANDX %u bytes at offset %"PRIu64"\n", sstate->andx.datalength, sstate->andx.dataoffset);
SCReturnUInt(retval);
} else if (((sstate->smb.flags & SMB_FLAGS_SERVER_TO_REDIR) == 0)
&& sstate->smb.command == SMB_COM_WRITE_ANDX) {
......
input_len, output);
parsed += retval;
input_len -= retval;
sstate->wordcount.wordcountleft -= retval;
SCLogDebug("SMB_COM_WRITE_ANDX %u bytes at offset %"PRIu64"\n", sstate->andx.datalength, sstate->andx.dataoffset);
SCReturnUInt(retval);
} else if (sstate->smb.command == SMB_COM_TRANSACTION) {
retval = SMBParseTransact(f, sstate, pstate, input + parsed, input_len,
output);
parsed += retval;
input_len -= retval;
SCReturnUInt(retval);
retval = SMBParseTransact(f, sstate, pstate, input + parsed, input_len,
output);
parsed += retval;
input_len -= retval;
sstate->wordcount.wordcountleft -= retval;
SCLogDebug("SMB_COM_TRANSACTION %u bytes at offset %"PRIu64"\n", sstate->andx.datalength, sstate->andx.dataoffset);
SCReturnUInt(retval);
} else { /* Generic WordCount Handler */
while (sstate->wordcount.wordcount-- && input_len--) {
SCLogDebug("0x%02x ", *p);
while (sstate->wordcount.wordcountleft-- && input_len--) {
SCLogDebug("0x%02x wordcount %u/%u input_len %u", *p,
sstate->wordcount.wordcountleft,
sstate->wordcount.wordcount, input_len);
p++;
}
sstate->bytesprocessed += (p - input);
......
input_len -= retval;
}
if (sstate->andx.datalength) {
if (sstate->andx.datalength && input_len) {
retval = DataParser(sstate, pstate, input + parsed, input_len,
output);
parsed += retval;
......
SCReturnUInt(retval);
}
while (sstate->bytecount.bytecount && input_len) {
SCLogDebug("0x%02x bytecount %u input_len %u", *p,
while (sstate->bytecount.bytecountleft-- && input_len--) {
SCLogDebug("0x%02x bytecount %u/%u input_len %u", *p,
sstate->bytecount.bytecountleft,
sstate->bytecount.bytecount, input_len);
p++;
sstate->bytecount.bytecount--;
input_len--;
}
sstate->bytesprocessed += (p - input);
SCReturnUInt((uint32_t)(p - input));
......
SMBState *sstate = (SMBState *) smb_state;
long int retval = 0;
long int parsed = 0;
if (pstate == NULL)
SCReturnInt(-1);
while (sstate->bytesprocessed < NBSS_HDR_LEN) {
retval
= NBSSParseHeader(f, smb_state, pstate, input, input_len,
......
}
while (input_len && (sstate->bytesprocessed >= NBSS_HDR_LEN
+ SMB_HDR_LEN + 3 + sstate->wordcount.wordcount
&& sstate->bytesprocessed < NBSS_HDR_LEN + SMB_HDR_LEN + 3
+ SMB_HDR_LEN + 3 + sstate->wordcount.wordcount)
&& (sstate->bytesprocessed < NBSS_HDR_LEN + SMB_HDR_LEN + 3
+ sstate->wordcount.wordcount
+ sstate->bytecount.bytecount)) {
retval = SMBParseByteCount(f, smb_state, pstate,
input + parsed, input_len, output);
if (retval) {
......
break;
}
pstate->parse_field = 0;
pstate->flags |= APP_LAYER_PARSER_DONE;
SCReturnInt(1);
}
......
end:
return result;
}
int SMBParserTest03(void) {
int result = 1;
Flow f;
uint8_t smbbuf1[] = {
0x00, 0x00, 0x07, 0x57, 0xff, 0x53, 0x4d, 0x42,
0x2f, 0x00, 0x00, 0x00, 0x00, 0x18, 0x01, 0x20,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x7f, 0x13,
0x01, 0x08, 0xc9, 0x29, 0x0e, 0xff, 0x00, 0x00,
0x00, 0x00, 0x40, 0x55, 0x01, 0x00, 0x00, 0xff,
0xff, 0xff, 0xff, 0x08, 0x00, 0x0e, 0x00, 0x00,
0x00, 0x0e, 0x00, 0x49, 0x07, 0x00, 0x00, 0x00,
0x00, 0x18, 0x07, 0xcc, 0x1b, 0x19, 0xb8, 0x75,
0x2c, 0x85, 0x52, 0x39, 0x72, 0xfa, 0x9c, 0x5f,
0x5a, 0xb7, 0x59, 0xa1, 0x83, 0xba, 0x87, 0xd3,
0xc3, 0xbf, 0xf4, 0x5d, 0x08, 0x32, 0x22, 0x33,
0x2e, 0x62, 0x46, 0x4d, 0x03, 0x48, 0x1f, 0xea,
0x7c, 0x65, 0x3e, 0x71, 0xf8, 0xea, 0x20, 0x85,
0x29, 0x6f, 0x3c, 0xf2, 0x19, 0xb5, 0x65, 0xb0,
0xce, 0x06, 0xcc, 0x90, 0x86, 0x20, 0x77, 0xf5,
0xa0, 0xbc, 0x45, 0x9d, 0x4e, 0x92, 0xb4, 0x24,
0xc8, 0x58, 0x4a, 0xc3, 0x4e, 0xb8, 0x95, 0x8d,
0x93, 0x0c, 0xce, 0xe0, 0xf9, 0x7d, 0x7e, 0xd3,
0x46, 0x53, 0x32, 0x95, 0x7d, 0x22, 0x76, 0x0e,
0x95, 0x23, 0x2e, 0xa6, 0x58, 0x1a, 0xb6, 0x74,
0x54, 0x4f, 0x37, 0x5c, 0x60, 0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1c, 0x38, 0x33, 0x10, 0x60, 0x24, 0x48,
0xb2, 0x7a, 0xb9, 0x4e, 0x8d, 0x36, 0xcf, 0xce,
0xf6, 0x31, 0x3b, 0xa3, 0x18, 0x78, 0x49, 0x91,
0xef, 0xed, 0x86, 0x2c, 0x98, 0x00, 0x18, 0x49,
0x73, 0xb8, 0xe5, 0x2f, 0xc1, 0x58, 0xe0, 0x47,
0x2b, 0x16, 0x41, 0xc3, 0x41, 0x05, 0x00, 0x0b,
0x03, 0x10, 0x00, 0x00, 0x00, 0xb0, 0x02, 0x00,
0x00, 0x00, 0x00 };
uint32_t smblen1 = sizeof(smbbuf1);
uint32_t smblen2 = sizeof(smbbuf2);
uint32_t smblen3 = sizeof(smbbuf3);
TcpSession ssn;
int r = 0;
memset(&f, 0, sizeof(f));
memset(&ssn, 0, sizeof(ssn));
StreamL7DataPtrInit(&ssn,StreamL7GetStorageSize());
f.protoctx = (void *)&ssn;
r = AppLayerParse(&f, ALPROTO_SMB, STREAM_TOSERVER|STREAM_START, smbbuf1, smblen1);
if (r != 0) {
printf("smb header check returned %" PRId32 ", expected 0: ", r);
result = 0;
goto end;
}
SMBState *smb_state = ssn.aldata[AlpGetStateIdx(ALPROTO_SMB)];
if (smb_state == NULL) {
printf("no smb state: ");
result = 0;
goto end;
}
if (smb_state->smb.command != SMB_COM_WRITE_ANDX) {
printf("expected SMB command 0x%02x , got 0x%02x : ", SMB_COM_WRITE_ANDX, smb_state->smb.command);
result = 0;
goto end;
}
r = AppLayerParse(&f, ALPROTO_SMB, STREAM_TOSERVER, smbbuf2, smblen2);
if (r != 0) {
printf("smb header check returned %" PRId32 ", expected 0: ", r);
result = 0;
goto end;
}
r = AppLayerParse(&f, ALPROTO_SMB, STREAM_TOSERVER, smbbuf3, smblen3);
if (r != 0) {
printf("smb header check returned %" PRId32 ", expected 0: ", r);
result = 0;
goto end;
}
printUUID("BIND", smb_state->dcerpc.dcerpcbindbindack.uuid_entry);
end:
return result;
}
#endif
void SMBParserRegisterTests(void) {
#ifdef UNITTESTS
printf("SMBParserRegisterTests\n");
UtRegisterTest("SMBParserTest01", SMBParserTest01, 1);
UtRegisterTest("SMBParserTest02", SMBParserTest02, 1);
}
UtRegisterTest("SMBParserTest03", SMBParserTest03, 1);
#endif
}
src/app-layer-smb.h
typedef struct wordcount_ {
uint8_t wordcount;
uint8_t wordcountleft;
uint8_t *words;
}SMBWordCount;
typedef struct bytecount_ {
uint8_t bytecountbytes;
uint16_t bytecount;
uint16_t bytecountleft;
uint8_t *bytes;
}SMBByteCount;
......
uint8_t andxcommand;
uint16_t andxoffset;
uint16_t andxbytesprocessed;
uint32_t datalength;
uint16_t datalength;
uint16_t datalengthhigh;
uint64_t dataoffset;
}SMBAndX;
(1-1/5)