(cot->frag_tracker.opnum != DCE2_SENTINEL) ?
(uint16_t)cot->frag_tracker.opnum : (uint16_t)cot->opnum;
- if ( DetectionEngine::get_current_packet()->is_from_client() )
+ Packet* p = DetectionEngine::get_current_packet();
+ if (p == nullptr)
+ return;
+
+ if ( p->is_from_client() )
{
DceRpcCoRequest* co_req = (DceRpcCoRequest*)((uint8_t*)co_hdr + sizeof(DceRpcCoHdr));
/* Doesn't really matter if this wraps ... it is basically just for presentation */
static inline DCE2_CoSeg* DCE2_CoGetSegPtr(DCE2_CoTracker* cot)
{
- if ( DetectionEngine::get_current_packet()->is_from_server() )
+ Packet* p = DetectionEngine::get_current_packet();
+ if (p == nullptr)
+ return nullptr;
+ if ( p->is_from_server() )
return &cot->srv_seg;
return &cot->cli_seg;
return DCE2_RET__ERROR;
}
- if (DetectionEngine::get_current_packet()->is_from_client() && (cot->max_xmit_frag != DCE2_SENTINEL))
+ Packet* p = DetectionEngine::get_current_packet();
+ if (p == nullptr)
+ return DCE2_RET__ERROR;
+
+ if (p->is_from_client() && (cot->max_xmit_frag != DCE2_SENTINEL))
{
if (frag_len > cot->max_xmit_frag)
{
static DCE2_Buffer* DCE2_CoGetFragBuf(DCE2_CoFragTracker* ft)
{
- if ( DetectionEngine::get_current_packet()->is_from_server() )
+ Packet* p = DetectionEngine::get_current_packet();
+ if (p == nullptr)
+ return nullptr;
+
+ if ( p->is_from_server() )
return ft->srv_stub_buf;
return ft->cli_stub_buf;
uint32_t frag_len = 0, seg_len = 0;
Packet* rpkt = nullptr;
+ if (seg_buf == nullptr)
+ return nullptr;
+
*rtype = DCE2_RPKT_TYPE__NULL;
switch (co_rtype)
DCE2_CoRpktType co_rtype, const DceRpcCoHdr** co_hdr)
{
dce2CommonStats* dce_common_stats = dce_get_proto_stats_ptr(sd);
- bool from_client = DetectionEngine::get_current_packet()->is_from_client();
+ Packet* p = DetectionEngine::get_current_packet();
+ if (p == nullptr)
+ return nullptr;
+ bool from_client = p->is_from_client();
int co_hdr_len = from_client ? DCE2_MOCK_HDR_LEN__CO_CLI : DCE2_MOCK_HDR_LEN__CO_SRV;
int smb_hdr_len = from_client ? DCE2_MOCK_HDR_LEN__SMB_CLI : DCE2_MOCK_HDR_LEN__SMB_SRV;
DCE2_Ret status;
dce2CommonStats* dce_common_stats = dce_get_proto_stats_ptr(sd);
Packet* p = DetectionEngine::get_current_packet();
+ if (p == nullptr)
+ return DCE2_RET__ERROR;
if ( p->is_from_client() )
{
cot->call_id = DceRpcCoCallId(co_hdr);
Packet* p = DetectionEngine::get_current_packet();
+ if (p == nullptr)
+ return;
if (DceRpcCoFirstFrag(co_hdr) && DceRpcCoLastFrag(co_hdr))
{
const DceRpcCoHdr* co_hdr = (const DceRpcCoHdr*)frag_ptr;
int pdu_type = DceRpcCoPduType(co_hdr);
dce2CommonStats* dce_common_stats = dce_get_proto_stats_ptr(sd);
+ Packet* p = DetectionEngine::get_current_packet();
+ if (p == nullptr)
+ return;
/* We've got the main header. Move past it to the
* start of the pdu */
dce2_move(frag_ptr, frag_len, sizeof(DceRpcCoHdr));
/* Client specific pdu types - some overlap with server */
- if ( DetectionEngine::get_current_packet()->is_from_client() )
+ if ( p->is_from_client() )
{
switch (pdu_type)
{
static void DCE2_CoEarlyReassemble(DCE2_SsnData* sd, DCE2_CoTracker* cot)
{
DCE2_Buffer* frag_buf = DCE2_CoGetFragBuf(&cot->frag_tracker);
+ Packet* p = DetectionEngine::get_current_packet();
- if ( DetectionEngine::get_current_packet()->is_from_server() )
+ if ( (p == nullptr) || p->is_from_server() )
return;
if (!DCE2_BufferIsEmpty(frag_buf))
const uint8_t* data_ptr, uint32_t data_len)
{
Packet* p = DetectionEngine::get_current_packet();
+ if (p == nullptr)
+ return nullptr;
Packet* rpkt = nullptr;
- int smb_hdr_len = p->is_from_client() ? DCE2_MOCK_HDR_LEN__SMB_CLI : DCE2_MOCK_HDR_LEN__SMB_SRV;
+ int smb_hdr_len = p->is_from_client() ? DCE2_MOCK_HDR_LEN__SMB_CLI :
+ DCE2_MOCK_HDR_LEN__SMB_SRV;
switch (sd->trans)
{
dce2CommonStats* dce_common_stats = dce_get_proto_stats_ptr(sd);
int smb_hdr_len;
- if ( DetectionEngine::get_current_packet()->is_from_client() )
+ Packet* p = DetectionEngine::get_current_packet();
+ if (p == nullptr)
+ return;
+
+ if ( p->is_from_client() )
{
smb_hdr_len = DCE2_MOCK_HDR_LEN__SMB_CLI;
dce_common_stats->co_cli_seg_reassembled++;
dce2CommonStats* dce_common_stats = dce_get_proto_stats_ptr(sd);
uint32_t num_frags = 0;
+ if (seg == nullptr)
+ return;
+
dce_common_stats->co_pdus++;
co_reassembled = 0;
session_key = key;
reload_prune = false;
do_not_delete = false;
+ file_context_cleaned = false;
command_prev = SMB2_COM_MAX;
encryption_flag = false;
SMB_DEBUG(dce_smb_trace, DEFAULT_TRACE_OPTION_ID, TRACE_DEBUG_LEVEL, GET_CURRENT_PACKET,
uint64_t get_session_id() { return session_id; }
void set_do_not_delete(bool flag) { do_not_delete = flag; }
bool get_do_not_delete() { return do_not_delete; }
+ void set_file_context_cleaned(bool flag) { file_context_cleaned = flag; }
+ bool get_file_context_cleaned() { return file_context_cleaned; }
void set_prev_comand(uint16_t cmd) { command_prev = cmd; }
uint16_t get_prev_command() { return command_prev; }
std::mutex co_tracker_mutex;
// do_not_delete is to make sure when we are in processing we should not delete the context
// which is being processed
bool do_not_delete;
+ bool file_context_cleaned;
Dce2Smb2TreeTracker* find_tree_for_message(const uint64_t, const uint32_t);
uint64_t session_id;
//to keep the tab of previous command