|
|
|
@ -44,6 +44,7 @@ use smb::smb2_records::*;
|
|
|
|
|
|
|
|
|
|
|
|
use smb::smb1::*;
|
|
|
|
use smb::smb1::*;
|
|
|
|
use smb::smb2::*;
|
|
|
|
use smb::smb2::*;
|
|
|
|
|
|
|
|
use smb::smb3::*;
|
|
|
|
use smb::dcerpc::*;
|
|
|
|
use smb::dcerpc::*;
|
|
|
|
use smb::session::*;
|
|
|
|
use smb::session::*;
|
|
|
|
use smb::events::*;
|
|
|
|
use smb::events::*;
|
|
|
|
@ -1053,7 +1054,7 @@ impl SMBState {
|
|
|
|
match parse_smb_version(&nbss_part_hdr.data) {
|
|
|
|
match parse_smb_version(&nbss_part_hdr.data) {
|
|
|
|
IResult::Done(_, ref smb) => {
|
|
|
|
IResult::Done(_, ref smb) => {
|
|
|
|
SCLogDebug!("SMB {:?}", smb);
|
|
|
|
SCLogDebug!("SMB {:?}", smb);
|
|
|
|
if smb.version == 255u8 { // SMB1
|
|
|
|
if smb.version == 0xff_u8 { // SMB1
|
|
|
|
SCLogDebug!("SMBv1 record");
|
|
|
|
SCLogDebug!("SMBv1 record");
|
|
|
|
match parse_smb_record(&nbss_part_hdr.data) {
|
|
|
|
match parse_smb_record(&nbss_part_hdr.data) {
|
|
|
|
IResult::Done(_, ref r) => {
|
|
|
|
IResult::Done(_, ref r) => {
|
|
|
|
@ -1077,7 +1078,7 @@ impl SMBState {
|
|
|
|
_ => { },
|
|
|
|
_ => { },
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if smb.version == 254u8 { // SMB2
|
|
|
|
} else if smb.version == 0xfe_u8 { // SMB2
|
|
|
|
SCLogDebug!("SMBv2 record");
|
|
|
|
SCLogDebug!("SMBv2 record");
|
|
|
|
match parse_smb2_request_record(&nbss_part_hdr.data) {
|
|
|
|
match parse_smb2_request_record(&nbss_part_hdr.data) {
|
|
|
|
IResult::Done(_, ref smb_record) => {
|
|
|
|
IResult::Done(_, ref smb_record) => {
|
|
|
|
@ -1092,6 +1093,7 @@ impl SMBState {
|
|
|
|
_ => { },
|
|
|
|
_ => { },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// no SMB3 here yet, will buffer full records
|
|
|
|
},
|
|
|
|
},
|
|
|
|
_ => { },
|
|
|
|
_ => { },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1151,7 +1153,7 @@ impl SMBState {
|
|
|
|
// gap
|
|
|
|
// gap
|
|
|
|
if self.ts_gap {
|
|
|
|
if self.ts_gap {
|
|
|
|
SCLogDebug!("TODO TS trying to catch up after GAP (input {})", cur_i.len());
|
|
|
|
SCLogDebug!("TODO TS trying to catch up after GAP (input {})", cur_i.len());
|
|
|
|
match search_smb2_record(cur_i) {
|
|
|
|
match search_smb_record(cur_i) {
|
|
|
|
IResult::Done(_, pg) => {
|
|
|
|
IResult::Done(_, pg) => {
|
|
|
|
SCLogDebug!("smb record found");
|
|
|
|
SCLogDebug!("smb record found");
|
|
|
|
let smb2_offset = cur_i.len() - pg.data.len();
|
|
|
|
let smb2_offset = cur_i.len() - pg.data.len();
|
|
|
|
@ -1179,7 +1181,7 @@ impl SMBState {
|
|
|
|
match parse_smb_version(&nbss_hdr.data) {
|
|
|
|
match parse_smb_version(&nbss_hdr.data) {
|
|
|
|
IResult::Done(_, ref smb) => {
|
|
|
|
IResult::Done(_, ref smb) => {
|
|
|
|
SCLogDebug!("SMB {:?}", smb);
|
|
|
|
SCLogDebug!("SMB {:?}", smb);
|
|
|
|
if smb.version == 255u8 { // SMB1
|
|
|
|
if smb.version == 0xff_u8 { // SMB1
|
|
|
|
SCLogDebug!("SMBv1 record");
|
|
|
|
SCLogDebug!("SMBv1 record");
|
|
|
|
match parse_smb_record(&nbss_hdr.data) {
|
|
|
|
match parse_smb_record(&nbss_hdr.data) {
|
|
|
|
IResult::Done(_, ref smb_record) => {
|
|
|
|
IResult::Done(_, ref smb_record) => {
|
|
|
|
@ -1190,7 +1192,7 @@ impl SMBState {
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if smb.version == 254u8 { // SMB2
|
|
|
|
} else if smb.version == 0xfe_u8 { // SMB2
|
|
|
|
let mut nbss_data = nbss_hdr.data;
|
|
|
|
let mut nbss_data = nbss_hdr.data;
|
|
|
|
while nbss_data.len() > 0 {
|
|
|
|
while nbss_data.len() > 0 {
|
|
|
|
SCLogDebug!("SMBv2 record");
|
|
|
|
SCLogDebug!("SMBv2 record");
|
|
|
|
@ -1207,6 +1209,20 @@ impl SMBState {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if smb.version == 0xfd_u8 { // SMB3 transform
|
|
|
|
|
|
|
|
let mut nbss_data = nbss_hdr.data;
|
|
|
|
|
|
|
|
while nbss_data.len() > 0 {
|
|
|
|
|
|
|
|
SCLogDebug!("SMBv3 transform record");
|
|
|
|
|
|
|
|
match parse_smb3_transform_record(&nbss_data) {
|
|
|
|
|
|
|
|
IResult::Done(nbss_data_rem, ref _smb3_record) => {
|
|
|
|
|
|
|
|
nbss_data = nbss_data_rem;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
_ => {
|
|
|
|
|
|
|
|
self.set_event(SMBEvent::MalformedData);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
_ => {
|
|
|
|
_ => {
|
|
|
|
@ -1305,6 +1321,7 @@ impl SMBState {
|
|
|
|
_ => { },
|
|
|
|
_ => { },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// no SMB3 here yet, will buffer full records
|
|
|
|
},
|
|
|
|
},
|
|
|
|
_ => { },
|
|
|
|
_ => { },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1361,8 +1378,8 @@ impl SMBState {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// gap
|
|
|
|
// gap
|
|
|
|
if self.tc_gap {
|
|
|
|
if self.tc_gap {
|
|
|
|
SCLogDebug!("TODO TC trying to catch up after GAP (input {})", cur_i.len());
|
|
|
|
SCLogDebug!("TC trying to catch up after GAP (input {})", cur_i.len());
|
|
|
|
match search_smb2_record(cur_i) {
|
|
|
|
match search_smb_record(cur_i) {
|
|
|
|
IResult::Done(_, pg) => {
|
|
|
|
IResult::Done(_, pg) => {
|
|
|
|
SCLogDebug!("smb record found");
|
|
|
|
SCLogDebug!("smb record found");
|
|
|
|
let smb2_offset = cur_i.len() - pg.data.len();
|
|
|
|
let smb2_offset = cur_i.len() - pg.data.len();
|
|
|
|
@ -1390,7 +1407,7 @@ impl SMBState {
|
|
|
|
match parse_smb_version(&nbss_hdr.data) {
|
|
|
|
match parse_smb_version(&nbss_hdr.data) {
|
|
|
|
IResult::Done(_, ref smb) => {
|
|
|
|
IResult::Done(_, ref smb) => {
|
|
|
|
SCLogDebug!("SMB {:?}", smb);
|
|
|
|
SCLogDebug!("SMB {:?}", smb);
|
|
|
|
if smb.version == 255u8 { // SMB1
|
|
|
|
if smb.version == 0xff_u8 { // SMB1
|
|
|
|
SCLogDebug!("SMBv1 record");
|
|
|
|
SCLogDebug!("SMBv1 record");
|
|
|
|
match parse_smb_record(&nbss_hdr.data) {
|
|
|
|
match parse_smb_record(&nbss_hdr.data) {
|
|
|
|
IResult::Done(_, ref smb_record) => {
|
|
|
|
IResult::Done(_, ref smb_record) => {
|
|
|
|
@ -1401,7 +1418,7 @@ impl SMBState {
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if smb.version == 254u8 { // SMB2
|
|
|
|
} else if smb.version == 0xfe_u8 { // SMB2
|
|
|
|
let mut nbss_data = nbss_hdr.data;
|
|
|
|
let mut nbss_data = nbss_hdr.data;
|
|
|
|
while nbss_data.len() > 0 {
|
|
|
|
while nbss_data.len() > 0 {
|
|
|
|
SCLogDebug!("SMBv2 record");
|
|
|
|
SCLogDebug!("SMBv2 record");
|
|
|
|
@ -1416,6 +1433,20 @@ impl SMBState {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if smb.version == 0xfd_u8 { // SMB3 transform
|
|
|
|
|
|
|
|
let mut nbss_data = nbss_hdr.data;
|
|
|
|
|
|
|
|
while nbss_data.len() > 0 {
|
|
|
|
|
|
|
|
SCLogDebug!("SMBv3 transform record");
|
|
|
|
|
|
|
|
match parse_smb3_transform_record(&nbss_data) {
|
|
|
|
|
|
|
|
IResult::Done(nbss_data_rem, ref _smb3_record) => {
|
|
|
|
|
|
|
|
nbss_data = nbss_data_rem;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
_ => {
|
|
|
|
|
|
|
|
self.set_event(SMBEvent::MalformedData);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
IResult::Incomplete(_) => {
|
|
|
|
IResult::Incomplete(_) => {
|
|
|
|
|