|
|
|
|
@ -36,7 +36,7 @@ use suricata_sys::sys::{
|
|
|
|
|
|
|
|
|
|
pub static mut DCERPC_MAX_STUB_SIZE: u32 = 1048576;
|
|
|
|
|
|
|
|
|
|
// Constant DCERPC UDP Header length
|
|
|
|
|
// Constant DCERPC TCP Header length
|
|
|
|
|
pub const DCERPC_HDR_LEN: u16 = 16;
|
|
|
|
|
// FIRST flag set on the packet
|
|
|
|
|
pub const DCERPC_UUID_ENTRY_FLAG_FF: u16 = 0x0001;
|
|
|
|
|
@ -205,6 +205,8 @@ pub struct DCERPCTransaction {
|
|
|
|
|
pub resp_lost: bool,
|
|
|
|
|
pub req_cmd: u8,
|
|
|
|
|
pub resp_cmd: u8,
|
|
|
|
|
pub req_hdr: Option<Vec<u8>>,
|
|
|
|
|
pub resp_hdr: Option<Vec<u8>>,
|
|
|
|
|
pub activityuuid: Vec<u8>,
|
|
|
|
|
pub seqnum: u32,
|
|
|
|
|
pub tx_data: AppLayerTxData,
|
|
|
|
|
@ -278,18 +280,39 @@ pub struct Uuid {
|
|
|
|
|
pub node: Vec<u8>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
|
pub struct DCERPCHdr {
|
|
|
|
|
pub rpc_vers: u8,
|
|
|
|
|
pub rpc_vers_minor: u8,
|
|
|
|
|
pub hdrtype: u8,
|
|
|
|
|
pub pfc_flags: u8,
|
|
|
|
|
pub packed_drep: Vec<u8>,
|
|
|
|
|
pub packed_drep: [u8; 4],
|
|
|
|
|
pub frag_length: u16,
|
|
|
|
|
pub auth_length: u16,
|
|
|
|
|
pub call_id: u32,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl DCERPCHdr {
|
|
|
|
|
pub fn to_bytes(&self) -> [u8; DCERPC_HDR_LEN as usize] {
|
|
|
|
|
let mut b = [0u8; DCERPC_HDR_LEN as usize];
|
|
|
|
|
b[0] = self.rpc_vers;
|
|
|
|
|
b[1] = self.rpc_vers_minor;
|
|
|
|
|
b[2] = self.hdrtype;
|
|
|
|
|
b[3] = self.pfc_flags;
|
|
|
|
|
b[4..8].copy_from_slice(&self.packed_drep);
|
|
|
|
|
if self.packed_drep[0] & 0x10 != 0 {
|
|
|
|
|
b[8..10].copy_from_slice(&self.frag_length.to_le_bytes());
|
|
|
|
|
b[10..12].copy_from_slice(&self.auth_length.to_le_bytes());
|
|
|
|
|
b[12..16].copy_from_slice(&self.call_id.to_le_bytes());
|
|
|
|
|
} else {
|
|
|
|
|
b[8..10].copy_from_slice(&self.frag_length.to_be_bytes());
|
|
|
|
|
b[10..12].copy_from_slice(&self.auth_length.to_be_bytes());
|
|
|
|
|
b[12..16].copy_from_slice(&self.call_id.to_be_bytes());
|
|
|
|
|
}
|
|
|
|
|
b
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
|
pub struct DCERPCBind {
|
|
|
|
|
pub numctxitems: u8,
|
|
|
|
|
@ -585,6 +608,7 @@ impl DCERPCState {
|
|
|
|
|
}
|
|
|
|
|
let mut tx = self.create_tx(hdr);
|
|
|
|
|
tx.req_cmd = hdr.hdrtype;
|
|
|
|
|
tx.req_hdr = Some(hdr.to_bytes().to_vec());
|
|
|
|
|
tx.req_done = true;
|
|
|
|
|
if let Some(flow) = self.flow {
|
|
|
|
|
sc_app_layer_parser_trigger_raw_stream_inspection(
|
|
|
|
|
@ -762,6 +786,7 @@ impl DCERPCState {
|
|
|
|
|
match transaction {
|
|
|
|
|
Some(ref mut tx) => {
|
|
|
|
|
tx.req_cmd = hdr_type;
|
|
|
|
|
tx.req_hdr = Some(hdr.to_bytes().to_vec());
|
|
|
|
|
tx.ctxid = request.ctxid;
|
|
|
|
|
tx.opnum = request.opnum;
|
|
|
|
|
tx.first_request_seen = request.first_request_seen;
|
|
|
|
|
@ -769,6 +794,7 @@ impl DCERPCState {
|
|
|
|
|
None => {
|
|
|
|
|
let mut tx = self.create_tx(hdr);
|
|
|
|
|
tx.req_cmd = hdr_type;
|
|
|
|
|
tx.req_hdr = Some(hdr.to_bytes().to_vec());
|
|
|
|
|
tx.ctxid = request.ctxid;
|
|
|
|
|
tx.opnum = request.opnum;
|
|
|
|
|
tx.first_request_seen = request.first_request_seen;
|
|
|
|
|
@ -949,10 +975,12 @@ impl DCERPCState {
|
|
|
|
|
self.get_tx_by_call_id(current_call_id, Direction::ToClient, hdrtype)
|
|
|
|
|
{
|
|
|
|
|
tx.resp_cmd = hdrtype;
|
|
|
|
|
tx.resp_hdr = Some(hdr.to_bytes().to_vec());
|
|
|
|
|
tx
|
|
|
|
|
} else {
|
|
|
|
|
let mut tx = self.create_tx(&hdr);
|
|
|
|
|
tx.resp_cmd = hdrtype;
|
|
|
|
|
tx.resp_hdr = Some(hdr.to_bytes().to_vec());
|
|
|
|
|
self.transactions.push_back(tx);
|
|
|
|
|
self.transactions.back_mut().unwrap()
|
|
|
|
|
};
|
|
|
|
|
@ -980,10 +1008,12 @@ impl DCERPCState {
|
|
|
|
|
match transaction {
|
|
|
|
|
Some(tx) => {
|
|
|
|
|
tx.resp_cmd = hdrtype;
|
|
|
|
|
tx.resp_hdr = Some(hdr.to_bytes().to_vec());
|
|
|
|
|
}
|
|
|
|
|
None => {
|
|
|
|
|
let mut tx = self.create_tx(&hdr);
|
|
|
|
|
tx.resp_cmd = hdrtype;
|
|
|
|
|
tx.resp_hdr = Some(hdr.to_bytes().to_vec());
|
|
|
|
|
self.transactions.push_back(tx);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|