+92
+-- fixed fast_pattern only auto configuration
+-- more detection buffer cleanup
+
91
-- eliminated more RULE_OPTION_TYPE_*
-- converted remaining rule options over to use cursor
-- finally eliminated doe_ptr and friends ... yay!
-- merged ips_option_base64_{data,decode}.cc
-- fast_pattern_only (previously fast_pattern:only) is gone
- (delete the option, Snort will figure it out)
90
-- added InspectApi.buffers and Inspector::getbuf()
/*
** Reset the appropriate application-layer protocol fields
*/
- ClearHttpBuffers();
p->alt_dsize = 0;
DetectReset();
THREAD_LOCAL uint32_t http_mask;
THREAD_LOCAL HttpBuffer http_buffer[HTTP_BUFFER_MAX];
-THREAD_LOCAL DataPointer file_data_ptr;
-THREAD_LOCAL DataBuffer DecodeBuffer;
+THREAD_LOCAL DataPointer g_alt_data;
+THREAD_LOCAL DataPointer g_file_data;
const char* http_buffer_name[HTTP_BUFFER_MAX] =
{
#include "detect.h"
#include "snort.h"
#include "snort_debug.h"
-#include "treenodes.h"
-#ifndef DECODE_BLEN
#define DECODE_BLEN 65535
-#define MAX_URI 8192
-
enum HTTP_BUFFER
{
HTTP_BUFFER_NONE,
HTTP_BUFFER_URI,
HTTP_BUFFER_MAX
};
-#endif
-
-enum DetectFlagType
-{
- FLAG_ALT_DECODE = 0x0001,
- FLAG_DETECT_ALL = 0xffff
-};
struct HttpBuffer
{
const uint8_t* buf;
- uint16_t length;
+ unsigned length;
uint32_t encode_type;
};
struct DataPointer
{
uint8_t *data;
- uint16_t len;
+ unsigned len;
};
struct DataBuffer
{
uint8_t data[DECODE_BLEN];
- uint16_t len;
+ unsigned len;
};
extern THREAD_LOCAL uint32_t http_mask;
extern THREAD_LOCAL HttpBuffer http_buffer[HTTP_BUFFER_MAX];
extern const char* http_buffer_name[HTTP_BUFFER_MAX];
-extern THREAD_LOCAL DataPointer file_data_ptr;
-extern THREAD_LOCAL DataBuffer DecodeBuffer;
+extern THREAD_LOCAL DataPointer g_alt_data;
+extern THREAD_LOCAL DataPointer g_file_data;
static inline void ClearHttpBuffers (void)
{
#define IsLimitedDetect(pktPtr) (pktPtr->packet_flags & PKT_HTTP_DECODE)
-static inline void setFileDataPtr(uint8_t *ptr, uint16_t decode_size)
+static inline void set_alt_data(uint8_t* p, unsigned n)
{
- file_data_ptr.data = ptr;
- file_data_ptr.len = decode_size;
+ g_alt_data.data = p;
+ g_alt_data.len = n;
+}
+
+static inline void set_file_data(uint8_t* p, unsigned n)
+{
+ g_file_data.data = p;
+ g_file_data.len = n;
}
void EventTrace_Init(void);
return ( snort_conf->event_trace_max > 0 );
}
-static inline void SetAltDecode(uint16_t altLen)
-{
- DecodeBuffer.len = altLen;
-}
-
static inline void DetectReset()
{
- file_data_ptr.data = NULL;
- file_data_ptr.len = 0;
- DecodeBuffer.len = 0;
+ g_alt_data.len = 0;
+ g_file_data.len = 0;
+ ClearHttpBuffers();
}
int IsGzipData(Flow*); // FIXIT these from HI
if ( so && so->get_pattern_count() > 0 )
{
- if ( DecodeBuffer.len )
+ if(g_alt_data.len)
{
start_state = 0;
- so->search(DecodeBuffer.data, DecodeBuffer.len,
- rule_tree_match, omd, &start_state);
+ so->search(g_alt_data.data, g_alt_data.len,
+ rule_tree_match, omd, &start_state);
#ifdef PPM_MGR
/* Bail if we spent too much time already */
if (PPM_PACKET_ABORT_FLAG())
#endif
}
- /* Adding this extra search on file data since we no more use DecodeBuffer to decode now*/
- if(file_data_ptr.len)
+ if(g_file_data.len)
{
start_state = 0;
- so->search(file_data_ptr.data, file_data_ptr.len,
+ so->search(g_file_data.data, g_file_data.len,
rule_tree_match, omd, &start_state);
#ifdef PPM_MGR
/* Bail if we spent too much time already */
}
*/
- setFileDataPtr((uint8_t*)start, (uint16_t)(data_end - start));
+ set_file_data((uint8_t*)start, (data_end - start));
if ((mime_ssn->data_state == STATE_DATA_HEADER) ||
(mime_ssn->data_state == STATE_DATA_UNKNOWN))
int detection_size = getDetectionSize(conf->b64_depth, conf->qp_depth,
conf->uu_depth, conf->bitenc_depth, (Email_DecodeState *)(mime_ssn->decode_state) );
- setFileDataPtr(((Email_DecodeState *)(mime_ssn->decode_state))->decodePtr, (uint16_t)detection_size);
+ set_file_data(((Email_DecodeState *)(mime_ssn->decode_state))->decodePtr, detection_size);
/*Process file type/file signature*/
if (file_api->file_process(p,(uint8_t *)((Email_DecodeState *)(mime_ssn->decode_state))->decodePtr,
(uint16_t)((Email_DecodeState *)(mime_ssn->decode_state))->decoded_bytes, position, upload, false)
DecodeConfig *conf= mime_ssn->decode_conf;
int detection_size = getDetectionSize(conf->b64_depth, conf->qp_depth,
conf->uu_depth, conf->bitenc_depth, (Email_DecodeState *)(mime_ssn->decode_state) );
- setFileDataPtr(((Email_DecodeState *)(mime_ssn->decode_state))->decodePtr, (uint16_t)detection_size);
+ set_file_data(((Email_DecodeState *)(mime_ssn->decode_state))->decodePtr, detection_size);
}
else
{
- setFileDataPtr(((Email_DecodeState *)(mime_ssn->decode_state))->decodePtr, 0);
+ set_file_data(((Email_DecodeState *)(mime_ssn->decode_state))->decodePtr, 0);
}
if ((data_end_marker != end)||(mime_ssn->state_flags & MIME_FLAG_MIME_END))
{
void Cursor::reset(Packet* p)
{
- if ( DecodeBuffer.len )
+ if ( g_alt_data.len )
{
- set("pkt_data", (uint8_t *)DecodeBuffer.data, DecodeBuffer.len);
+ set("pkt_data", g_alt_data.data, g_alt_data.len);
}
else if( IsLimitedDetect(p) )
{
PROFILE_VARS;
PREPROC_PROFILE_START(fileDataPerfStats);
- data = file_data_ptr.data;
- len = file_data_ptr.len;
+ data = g_file_data.data;
+ len = g_file_data.len;
if ( (data == NULL)|| (len == 0) )
{
if(!IsJSNormData(p->flow))
{
TextLog_Print(log, "%s\n", "Normalized JavaScript for this packet");
- LogCharData(log, (char *)file_data_ptr.data, file_data_ptr.len);
+ LogCharData(log, (char *)g_file_data.data, g_file_data.len);
}
else if(!IsGzipData(p->flow))
{
TextLog_Print(log, "%s\n", "Decompressed Data for this packet");
- LogCharData(log, (char *)file_data_ptr.data, file_data_ptr.len);
+ LogCharData(log, (char *)g_file_data.data, g_file_data.len);
}
}
else
if(!IsJSNormData(p->flow))
{
TextLog_Print(log, "%s\n", "Normalized JavaScript for this packet");
- LogNetData(log, file_data_ptr.data, file_data_ptr.len, NULL);
+ LogNetData(log, g_file_data.data, g_file_data.len, NULL);
}
else if(!IsGzipData(p->flow))
{
TextLog_Print(log, "%s\n", "Decompressed Data for this packet");
- LogNetData(log, file_data_ptr.data, file_data_ptr.len, NULL);
+ LogNetData(log, g_file_data.data, g_file_data.len, NULL);
}
}
}
{
int status;
- setFileDataPtr((uint8_t *)p->data, (uint16_t)p->dsize);
+ set_file_data((uint8_t *)p->data, p->dsize);
status = file_api->file_process(p, (uint8_t *)p->data,
(uint16_t)p->dsize, data_ssn->position, data_ssn->direction, false);
#include "ipv6_port.h"
+static THREAD_LOCAL DataBuffer DecodeBuffer;
+
/*
* Used to keep track of pipelined commands and the last one
* that resulted in a
*/
#define CONSECUTIVE_8BIT_THRESHOLD 3
+static THREAD_LOCAL DataBuffer DecodeBuffer;
+
/*
* Function: normalize_telnet(Packet *)
*
}
}
- SetAltDecode((uint16_t)(write_ptr - start));
+ set_alt_data(DecodeBuffer.data, (uint16_t)(write_ptr - start));
- /* DEBUG_WRAP(DebugMessage(DEBUG_FTPTELNET,
- "Converted buffer after telnet normalization:\n");
- LogNetData(DecodeBuffer.data, DecodeBuffer.len, NULL););
- */
return ret;
}
detect_data_size = 0;
}
- setFileDataPtr((uint8_t *)session->server.response.body, (uint16_t)detect_data_size);
+ set_file_data((uint8_t *)session->server.response.body, detect_data_size);
if (PacketHasPAFPayload(p)
&& file_api->file_process(p,(uint8_t *)session->server.response.body, (uint16_t)session->server.response.body_size,
if(hsd == NULL)
return -1;
- if((hsd->log_flags & HTTP_LOG_GZIP_DATA) && (file_data_ptr.len > 0 ))
+ if((hsd->log_flags & HTTP_LOG_GZIP_DATA) && (g_file_data.len > 0 ))
return 0;
else
return -1;
{
if(!IsGzipData(flow))
{
- *buf = file_data_ptr.data;
- *len = file_data_ptr.len;
+ *buf = g_file_data.data;
+ *len = g_file_data.len;
*type = EVENT_INFO_GZIP_DATA;
return 1;
}
if(hsd == NULL)
return -1;
- if((hsd->log_flags & HTTP_LOG_JSNORM_DATA) && (file_data_ptr.len > 0 ))
+ if((hsd->log_flags & HTTP_LOG_JSNORM_DATA) && (g_file_data.len > 0 ))
return 0;
else
return -1;
{
if(!IsJSNormData(flow))
{
- *buf = file_data_ptr.data;
- *len = file_data_ptr.len;
+ *buf = g_file_data.data;
+ *len = g_file_data.len;
*type = EVENT_INFO_JSNORM_DATA;
return 1;
}
#include "hi_ui_config.h"
#include "hi_si.h"
+#define MAX_URI 8192
+
int hi_normalization(HI_SESSION *session, int iInspectMode, HttpsessionData *hsd);
int hi_norm_uri(HI_SESSION *session, u_char *uribuf,int *uribuf_size,
const u_char *uri, int uri_size, uint16_t *encodeType);
#define RPC_FRAG_HDR_SIZE sizeof(uint32_t)
#define RPC_FRAG_LEN(ptr) (ntohl(*((uint32_t *)ptr)) & 0x7FFFFFFF)
+static THREAD_LOCAL DataBuffer DecodeBuffer;
+
using namespace std;
struct RpcDecodeConfig
return RPC_STATUS__ERROR;
}
- SetAltDecode((uint16_t)(RPC_FRAG_HDR_SIZE + fraglen));
+ set_alt_data(DecodeBuffer.data, (RPC_FRAG_HDR_SIZE + fraglen));
return RPC_STATUS__SUCCESS;
}
return RPC_STATUS__ERROR;
}
- SetAltDecode((uint16_t)RpcBufLen(&rsdata->frag));
+ set_alt_data(DecodeBuffer.data, RpcBufLen(&rsdata->frag));
if (RpcBufLen(&rsdata->frag) > RPC_MAX_BUF_SIZE)
RpcBufClean(&rsdata->frag);
return RPC_STATUS__ERROR;
}
- SetAltDecode((uint16_t)RpcBufLen(&rsdata->seg));
+ set_alt_data(DecodeBuffer.data, RpcBufLen(&rsdata->seg));
if (RpcBufLen(&rsdata->seg) > RPC_MAX_BUF_SIZE)
{
//LogNetData(data, decoded_len, NULL);
);
- SetAltDecode((uint16_t)decoded_len);
+ set_alt_data(DecodeBuffer.data, decoded_len);
return 0;
}