|
|
|
@ -16,7 +16,7 @@
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
use std::mem::transmute;
|
|
|
|
use std::mem::transmute;
|
|
|
|
use crate::applayer::{AppLayerResult, AppLayerTxData};
|
|
|
|
use crate::applayer::*;
|
|
|
|
use crate::core::{self, sc_detect_engine_state_free};
|
|
|
|
use crate::core::{self, sc_detect_engine_state_free};
|
|
|
|
use crate::dcerpc::parser;
|
|
|
|
use crate::dcerpc::parser;
|
|
|
|
use nom::error::ErrorKind;
|
|
|
|
use nom::error::ErrorKind;
|
|
|
|
@ -1318,6 +1318,46 @@ pub unsafe extern "C" fn rs_dcerpc_get_stub_data(
|
|
|
|
*endianness = tx.get_endianness();
|
|
|
|
*endianness = tx.get_endianness();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Probe input to see if it looks like DCERPC.
|
|
|
|
|
|
|
|
fn probe(input: &[u8]) -> (bool, bool) {
|
|
|
|
|
|
|
|
match parser::parse_dcerpc_header(input) {
|
|
|
|
|
|
|
|
Ok((_, hdr)) => {
|
|
|
|
|
|
|
|
let is_request = hdr.hdrtype == 0x00;
|
|
|
|
|
|
|
|
let is_dcerpc = hdr.rpc_vers == 0x05 && hdr.rpc_vers_minor == 0x00;
|
|
|
|
|
|
|
|
return (is_dcerpc, is_request);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
Err(_) => (false, false),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
|
|
|
|
pub extern "C" fn rs_dcerpc_probe_tcp(direction: u8, input: *const u8,
|
|
|
|
|
|
|
|
len: u32, rdir: *mut u8) -> i32
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
SCLogDebug!("Probing packet for DCERPC");
|
|
|
|
|
|
|
|
if len == 0 {
|
|
|
|
|
|
|
|
return core::ALPROTO_UNKNOWN;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
let slice: &[u8] = unsafe {
|
|
|
|
|
|
|
|
std::slice::from_raw_parts(input as *mut u8, len as usize)
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
//is_incomplete is checked by caller
|
|
|
|
|
|
|
|
let (is_dcerpc, is_request, ) = probe(slice);
|
|
|
|
|
|
|
|
if is_dcerpc {
|
|
|
|
|
|
|
|
let dir = if is_request {
|
|
|
|
|
|
|
|
core::STREAM_TOSERVER
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
core::STREAM_TOCLIENT
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
if direction & (core::STREAM_TOSERVER|core::STREAM_TOCLIENT) != dir {
|
|
|
|
|
|
|
|
unsafe { *rdir = dir };
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
mod tests {
|
|
|
|
use crate::applayer::AppLayerResult;
|
|
|
|
use crate::applayer::AppLayerResult;
|
|
|
|
|