using namespace snort;
#ifdef DEBUG_MSGS
-static inline void rna_logger_message(const RnaLoggerEvent& rle)
+static inline void rna_logger_message(const RnaLoggerEvent& rle, const Packet* p)
{
char macbuf[19] = { '\0' };
if ( rle.mac )
SfIpString ipbuf;
ip.set(rle.ip); // using this instead of packet's ip to support ARP
if ( rle.mac )
- debug_logf(rna_trace, nullptr, "RNA log: type %u, subtype %u, mac %s, ip %s\n",
+ debug_logf(rna_trace, p, "RNA log: type %u, subtype %u, mac %s, ip %s\n",
rle.type, rle.subtype, macbuf, ip.ntop(ipbuf));
else
- debug_logf(rna_trace, nullptr, "RNA log: type %u, subtype %u, ip %s\n",
+ debug_logf(rna_trace, p, "RNA log: type %u, subtype %u, ip %s\n",
rle.type, rle.subtype, ip.ntop(ipbuf));
if ( rle.hc )
{
if ( rle.hc->version[0] != '\0' )
- debug_logf(rna_trace, nullptr,
+ debug_logf(rna_trace, p,
"RNA client log: client %u, service %u, version %s\n",
rle.hc->id, rle.hc->service, rle.hc->version);
else
- debug_logf(rna_trace, nullptr, "RNA client log: client %u, service %u\n",
+ debug_logf(rna_trace, p, "RNA client log: client %u, service %u\n",
rle.hc->id, rle.hc->service);
}
if ( rle.ha )
{
- debug_logf(rna_trace, nullptr,
+ debug_logf(rna_trace, p,
"RNA Service Info log: appid: %d proto %u, port: %u\n",
rle.ha->appid, (uint32_t)rle.ha->proto, rle.ha->port);
for ( auto& s: rle.ha->info )
{
if ( s.vendor[0] != '\0' )
- debug_logf(rna_trace, nullptr, "RNA Service Info log: vendor: %s\n",
+ debug_logf(rna_trace, p, "RNA Service Info log: vendor: %s\n",
s.vendor);
if ( s.version[0] != '\0' )
- debug_logf(rna_trace, nullptr, "RNA Service Info log: version: %s\n",
+ debug_logf(rna_trace, p, "RNA Service Info log: version: %s\n",
s.version);
}
if ( rle.type == RNA_EVENT_CHANGE and rle.subtype == CHANGE_BANNER_UPDATE )
- debug_logf(rna_trace, nullptr, "RNA Banner log: true\n");
+ debug_logf(rna_trace, p, "RNA Banner log: true\n");
}
if ( rle.user )
{
if ( rle.user and *rle.user )
- debug_logf(rna_trace, nullptr,
+ debug_logf(rna_trace, p,
"RNA user login: service %u, user name %s\n", rle.appid, rle.user);
}
}
else
- debug_logf(rna_trace, nullptr, "RNA log: type %u, subtype %u, mac %s\n",
+ debug_logf(rna_trace, p, "RNA log: type %u, subtype %u, mac %s\n",
rle.type, rle.subtype, macbuf);
}
#endif
EventManager::call_loggers(nullptr, const_cast<Packet*>(p), "RNA", &rle);
#ifdef DEBUG_MSGS
- rna_logger_message(rle);
+ rna_logger_message(rle, p);
#endif
return true;
}
{ \
if ((smb_data + (strcuture_size)) > end) \
{ \
- debug_logf(dce_smb_trace, nullptr, "%s : smb data beyond end detected\n",\
- smb2_command_string[cmd]); \
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(), \
+ "%s : smb data beyond end detected\n", smb2_command_string[cmd]); \
counter ++; \
return; \
} \
static void DCE2_Smb2CleanFtrackerTcpRef(DCE2_Smb2SessionTracker* str, uint64_t file_id)
{
- debug_logf(dce_smb_trace, nullptr, "updating conn for fid %" PRIu64 "\n", file_id);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "updating conn for fid %" PRIu64 "\n", file_id);
auto all_conn_trackers = str->conn_trackers.get_all_entry();
for ( auto& h : all_conn_trackers )
{
ssd->ftracker_tcp->bytes_processed += detection_size;
FileDirection dir = ssd->ftracker_tcp->upload ? FILE_UPLOAD : FILE_DOWNLOAD;
- debug_logf(dce_smb_trace, nullptr, "file_process fid %" PRIu64 " data_size %" PRIu32 ""
+ debug_logf(dce_smb_trace, p, "file_process fid %" PRIu64 " data_size %" PRIu32 ""
" offset %" PRIu64 " bytes processed %" PRIu64 "\n", ssd->ftracker_tcp->file_id,
data_size, ssd->ftracker_tcp->file_offset, ssd->ftracker_tcp->bytes_processed);
ssd->ftracker_tcp->bytes_processed > ssd->ftracker_tcp->file_size) )
{
dce2_smb_stats.v2_extra_file_data_err++;
- debug_logf(dce_smb_trace, nullptr, "extra file data\n");
+ debug_logf(dce_smb_trace, p, "extra file data\n");
DCE2_Smb2TreeTracker* ttr = ssd->ftracker_tcp->ttr;
uint64_t file_id = ssd->ftracker_tcp->file_id;
if (!file_flows->file_process(p, ssd->ftracker_tcp->file_name_hash, file_data, data_size,
ssd->ftracker_tcp->file_offset, dir, ssd->ftracker_tcp->file_id))
{
- debug_logf(dce_smb_trace, nullptr, "file_process completed\n");
+ debug_logf(dce_smb_trace, p, "file_process completed\n");
DCE2_Smb2TreeTracker* ttr = ssd->ftracker_tcp->ttr;
uint64_t file_id = ssd->ftracker_tcp->file_id;
if (structure_size == SMB2_ERROR_RESPONSE_STRUC_SIZE and Smb2Error(smb_hdr))
{
- debug_logf(dce_smb_trace, nullptr, "%s_RESP: error\n",
- smb2_command_string[SMB2_COM_SESSION_SETUP]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_RESP: error\n", smb2_command_string[SMB2_COM_SESSION_SETUP]);
dce2_smb_stats.v2_setup_err_resp++;
}
else if (structure_size == SMB2_SETUP_RESPONSE_STRUC_SIZE)
}
else if (structure_size != SMB2_SETUP_REQUEST_STRUC_SIZE)
{
- debug_logf(dce_smb_trace, nullptr, "%s: invalid struct size\n",
- smb2_command_string[SMB2_COM_SESSION_SETUP]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s: invalid struct size\n", smb2_command_string[SMB2_COM_SESSION_SETUP]);
dce2_smb_stats.v2_setup_inv_str_sz++;
}
}
if (!DCE2_Smb2InsertTid(ssd, tid,
((const Smb2TreeConnectResponseHdr*)smb_data)->share_type, str))
{
- debug_logf(dce_smb_trace, nullptr, "%s: ignored %d\n",
- smb2_command_string[SMB2_COM_TREE_CONNECT], tid);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s: ignored %d\n", smb2_command_string[SMB2_COM_TREE_CONNECT], tid);
dce2_smb_stats.v2_tree_cnct_ignored++;
}
}
else if (structure_size != SMB2_TREE_CONNECT_REQUEST_STRUC_SIZE)
{
- debug_logf(dce_smb_trace, nullptr, "%s: invalid struct size\n",
- smb2_command_string[SMB2_COM_TREE_CONNECT]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s: invalid struct size\n", smb2_command_string[SMB2_COM_TREE_CONNECT]);
dce2_smb_stats.v2_tree_cnct_inv_str_sz++;
}
}
}
else
{
- debug_logf(dce_smb_trace, nullptr, "%s: invalid struct size\n",
- smb2_command_string[SMB2_COM_TREE_DISCONNECT]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s: invalid struct size\n", smb2_command_string[SMB2_COM_TREE_DISCONNECT]);
dce2_smb_stats.v2_tree_discn_inv_str_sz++;
}
}
if (file_data >= end)
{
dce2_smb_stats.v2_crt_inv_file_data++;
- debug_logf(dce_smb_trace, nullptr, "%s_REQ: invalid file data seen\n",
- smb2_command_string[SMB2_COM_CREATE]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_REQ: invalid file data seen\n", smb2_command_string[SMB2_COM_CREATE]);
return;
}
if (!size or (file_data + size > end))
{
dce2_smb_stats.v2_crt_inv_file_data++;
- debug_logf(dce_smb_trace, nullptr, "%s_REQ: invalid file data seen with size %" PRIu16 "\n",
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_REQ: invalid file data seen with size %" PRIu16 "\n",
smb2_command_string[SMB2_COM_CREATE], size);
return;
}
else
{
- debug_logf(dce_smb_trace, nullptr, "%s_REQ: max req exceeded\n",
- smb2_command_string[SMB2_COM_CREATE]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_REQ: max req exceeded\n", smb2_command_string[SMB2_COM_CREATE]);
dce_alert(GID_DCE2, DCE2_SMB_MAX_REQS_EXCEEDED, (dce2CommonStats*)&dce2_smb_stats,
ssd->sd);
}
}
else
{
- debug_logf(dce_smb_trace, nullptr, "%s_REQ: name_offset %" PRIu16 "\n",
- smb2_command_string[SMB2_COM_CREATE], name_offset);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_REQ: name_offset %" PRIu16 "\n", smb2_command_string[SMB2_COM_CREATE], name_offset);
dce2_smb_stats.v2_crt_req_hdr_err++;
}
}
FileContext* file = get_smb_file_context(ftracker->file_name_hash, fileId_persistent,
true);
- debug_logf(dce_smb_trace, nullptr, "%s_RESP: file size %" PRIu64 " fid %" PRIu64 ""
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_RESP: file size %" PRIu64 " fid %" PRIu64 ""
"file_name_hash %" PRIu64 " file context %s\n", smb2_command_string[SMB2_COM_CREATE],
file_size, fileId_persistent, ftracker->file_name_hash, (file ? "found" : "not found"));
ttr->removeRtracker(mid);
dce2_smb_stats.v2_crt_err_resp++;
- debug_logf(dce_smb_trace, nullptr, "%s_RESP: error\n",
- smb2_command_string[SMB2_COM_CREATE]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_RESP: error\n", smb2_command_string[SMB2_COM_CREATE]);
}
// Using structure size to decide whether it is response or request
else if (structure_size == SMB2_CREATE_REQUEST_STRUC_SIZE)
if (!ttr)
{
- debug_logf(dce_smb_trace, nullptr, "%s_REQ: mid stream session detected\n",
- smb2_command_string[SMB2_COM_CREATE]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_REQ: mid stream session detected\n", smb2_command_string[SMB2_COM_CREATE]);
ttr = DCE2_Smb2InsertTid(ssd, tid, SMB2_SHARE_TYPE_DISK, str);
if (!ttr)
{
- debug_logf(dce_smb_trace, nullptr, "%s_REQ: insert tree tracker failed\n",
- smb2_command_string[SMB2_COM_CREATE]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_REQ: insert tree tracker failed\n", smb2_command_string[SMB2_COM_CREATE]);
return;
}
}
else if (SMB2_SHARE_TYPE_DISK != ttr->get_share_type())
{
dce2_smb_stats.v2_crt_req_ipc++;
- debug_logf(dce_smb_trace, nullptr, "%s_REQ: ignored for ipc share\n",
- smb2_command_string[SMB2_COM_CREATE]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_REQ: ignored for ipc share\n", smb2_command_string[SMB2_COM_CREATE]);
return;
}
DCE2_Smb2CreateRequest(ssd, (const Smb2CreateRequestHdr*)smb_data, end, str, ttr, mid);
if (!ttr)
{
- debug_logf(dce_smb_trace, nullptr, "%s_RESP: tree tracker missing\n",
- smb2_command_string[SMB2_COM_CREATE]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_RESP: tree tracker missing\n", smb2_command_string[SMB2_COM_CREATE]);
dce2_smb_stats.v2_crt_tree_trkr_misng++;
return;
}
DCE2_Smb2RequestTracker* rtr = ttr->findRtracker(mid);
if (!rtr)
{
- debug_logf(dce_smb_trace, nullptr, "%s_RESP: req tracker missing\n",
- smb2_command_string[SMB2_COM_CREATE]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_RESP: req tracker missing\n", smb2_command_string[SMB2_COM_CREATE]);
dce2_smb_stats.v2_crt_rtrkr_misng++;
return;
}
if (((const Smb2CreateResponseHdr*)smb_data)->file_attributes &
SMB2_CREATE_RESPONSE_DIRECTORY)
{
- debug_logf(dce_smb_trace, nullptr, "%s_RESP: not processing for directory\n",
- smb2_command_string[SMB2_COM_CREATE]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_RESP: not processing for directory\n", smb2_command_string[SMB2_COM_CREATE]);
ttr->removeRtracker(mid);
DCE2_Smb2CleanFtrackerTcpRef(str, fileId_persistent);
ttr->removeFtracker(fileId_persistent);
}
else
{
- debug_logf(dce_smb_trace, nullptr, "%s: invalid struct size\n",
- smb2_command_string[SMB2_COM_CREATE]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s: invalid struct size\n", smb2_command_string[SMB2_COM_CREATE]);
dce2_smb_stats.v2_crt_inv_str_sz++;
}
}
if (structure_size == SMB2_ERROR_RESPONSE_STRUC_SIZE and Smb2Error(smb_hdr))
{
- debug_logf(dce_smb_trace, nullptr, "%s_RESP: error\n",
- smb2_command_string[SMB2_COM_CLOSE]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_RESP: error\n", smb2_command_string[SMB2_COM_CLOSE]);
dce2_smb_stats.v2_cls_err_resp++;
}
// Using structure size to decide whether it is response or request
if (!ftracker)
{
dce2_smb_stats.v2_cls_req_ftrkr_misng++;
- debug_logf(dce_smb_trace, nullptr, "%s_REQ: ftracker missing %" PRIu64 "\n",
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_REQ: ftracker missing %" PRIu64 "\n",
smb2_command_string[SMB2_COM_CLOSE], fileId_persistent);
return;
}
}
else if (structure_size != SMB2_CLOSE_RESPONSE_STRUC_SIZE)
{
- debug_logf(dce_smb_trace, nullptr, "%s: invalid struct size\n",
- smb2_command_string[SMB2_COM_CLOSE]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s: invalid struct size\n", smb2_command_string[SMB2_COM_CLOSE]);
dce2_smb_stats.v2_cls_inv_str_sz++;
}
}
// Using structure size to decide whether it is response or request
if (structure_size == SMB2_ERROR_RESPONSE_STRUC_SIZE and Smb2Error(smb_hdr))
{
- debug_logf(dce_smb_trace, nullptr, "%s: error resp\n",
- smb2_command_string[SMB2_COM_SET_INFO]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s: error resp\n", smb2_command_string[SMB2_COM_SET_INFO]);
dce2_smb_stats.v2_stinf_err_resp++;
}
else if (structure_size == SMB2_SET_INFO_REQUEST_STRUC_SIZE)
ftracker->file_size = file_size;
FileContext* file = get_smb_file_context(ftracker->file_name_hash,
fileId_persistent);
- debug_logf(dce_smb_trace, nullptr,
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
"%s_REQ: set file size %" PRIu64 " fid %" PRIu64 " file context %s\n",
smb2_command_string[SMB2_COM_SET_INFO], file_size, fileId_persistent,
file ? "found" : "not found");
else
{
dce2_smb_stats.v2_stinf_req_ftrkr_misng++;
- debug_logf(dce_smb_trace, nullptr,"%s_REQ: ftracker missing\n",
- smb2_command_string[SMB2_COM_SET_INFO]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_REQ: ftracker missing\n", smb2_command_string[SMB2_COM_SET_INFO]);
}
}
else
{
- debug_logf(dce_smb_trace, nullptr,"%s_REQ: header error\n",
- smb2_command_string[SMB2_COM_SET_INFO]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_REQ: header error\n", smb2_command_string[SMB2_COM_SET_INFO]);
dce2_smb_stats.v2_stinf_req_hdr_err++;
}
}
else if (structure_size != SMB2_SET_INFO_RESPONSE_STRUC_SIZE)
{
- debug_logf(dce_smb_trace, nullptr, "%s: invalid struct size\n",
- smb2_command_string[SMB2_COM_SET_INFO]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s: invalid struct size\n", smb2_command_string[SMB2_COM_SET_INFO]);
dce2_smb_stats.v2_stinf_inv_str_sz++;
}
}
}
else
{
- debug_logf(dce_smb_trace, nullptr, "%s_REQ: max req exceeded\n",
- smb2_command_string[SMB2_COM_READ]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_REQ: max req exceeded\n", smb2_command_string[SMB2_COM_READ]);
dce_alert(GID_DCE2, DCE2_SMB_MAX_REQS_EXCEEDED, (dce2CommonStats*)&dce2_smb_stats,
ssd->sd);
return;
if (ftracker->file_size and (offset > ftracker->file_size))
{
- debug_logf(dce_smb_trace, nullptr, "%s_REQ: invalid file offset\n",
- smb2_command_string[SMB2_COM_READ]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_REQ: invalid file offset\n", smb2_command_string[SMB2_COM_READ]);
dce_alert(GID_DCE2, DCE2_SMB_INVALID_FILE_OFFSET, (dce2CommonStats*)&dce2_smb_stats,
ssd->sd);
}
request = ttr->findRtracker(message_id);
if (!request)
{
- debug_logf(dce_smb_trace, nullptr, "%s_RESP: request tracker missing\n",
- smb2_command_string[SMB2_COM_READ]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_RESP: request tracker missing\n", smb2_command_string[SMB2_COM_READ]);
dce2_smb_stats.v2_read_rtrkr_misng++;
return;
}
data_offset = alignedNtohs((const uint16_t*)(&(smb_read_hdr->data_offset)));
if (data_offset + (const uint8_t*)smb_hdr > end)
{
- debug_logf(dce_smb_trace, nullptr, "%s_RESP: bad offset\n",
- smb2_command_string[SMB2_COM_READ]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_RESP: bad offset\n", smb2_command_string[SMB2_COM_READ]);
dce_alert(GID_DCE2, DCE2_SMB_BAD_OFF, (dce2CommonStats*)&dce2_smb_stats, ssd->sd);
}
}
ttr->removeRtracker(mid);
dce2_smb_stats.v2_read_err_resp++;
- debug_logf(dce_smb_trace, nullptr, "%s_RESP: error\n",
- smb2_command_string[SMB2_COM_WRITE]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_RESP: error\n", smb2_command_string[SMB2_COM_WRITE]);
}
// Using structure size to decide whether it is response or request
else if (structure_size == SMB2_READ_REQUEST_STRUC_SIZE)
else
{
dce2_smb_stats.v2_read_inv_str_sz++;
- debug_logf(dce_smb_trace, nullptr, "%s: invalid struct size\n",
- smb2_command_string[SMB2_COM_WRITE]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s: invalid struct size\n", smb2_command_string[SMB2_COM_WRITE]);
}
}
}
else
{
- debug_logf(dce_smb_trace, nullptr, "%s_REQ: max req exceeded\n",
- smb2_command_string[SMB2_COM_WRITE]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_REQ: max req exceeded\n", smb2_command_string[SMB2_COM_WRITE]);
dce_alert(GID_DCE2, DCE2_SMB_MAX_REQS_EXCEEDED, (dce2CommonStats*)&dce2_smb_stats,
ssd->sd);
return;
data_offset = alignedNtohs((const uint16_t*)(&(smb_write_hdr->data_offset)));
if (data_offset + (const uint8_t*)smb_hdr > end)
{
- debug_logf(dce_smb_trace, nullptr, "%s_REQ: bad offset\n",
- smb2_command_string[SMB2_COM_WRITE]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_REQ: bad offset\n", smb2_command_string[SMB2_COM_WRITE]);
dce_alert(GID_DCE2, DCE2_SMB_BAD_OFF, (dce2CommonStats*)&dce2_smb_stats, ssd->sd);
}
}
ttr->removeRtracker(mid);
dce2_smb_stats.v2_wrt_err_resp++;
- debug_logf(dce_smb_trace, nullptr, "%s_RESP: error\n",
- smb2_command_string[SMB2_COM_WRITE]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s_RESP: error\n", smb2_command_string[SMB2_COM_WRITE]);
}
// Using structure size to decide whether it is response or request
else if (structure_size == SMB2_WRITE_REQUEST_STRUC_SIZE)
}
else
{
- debug_logf(dce_smb_trace, nullptr, "%s: invalid struct size\n",
- smb2_command_string[SMB2_COM_WRITE]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s: invalid struct size\n", smb2_command_string[SMB2_COM_WRITE]);
dce2_smb_stats.v2_wrt_inv_str_sz++;
}
}
}
else
{
- debug_logf(dce_smb_trace, nullptr, "%s: invalid struct size\n",
- smb2_command_string[SMB2_COM_LOGOFF]);
+ debug_logf(dce_smb_trace, DetectionEngine::get_current_packet(),
+ "%s: invalid struct size\n", smb2_command_string[SMB2_COM_LOGOFF]);
dce2_smb_stats.v2_logoff_inv_str_sz++;
}
}