|
|
|
@ -76,7 +76,12 @@ static InspectionBuffer *GetResponseData(DetectEngineThreadCtx *det_ctx,
|
|
|
|
const DetectEngineTransforms *transforms,
|
|
|
|
const DetectEngineTransforms *transforms,
|
|
|
|
Flow *_f, const uint8_t _flow_flags,
|
|
|
|
Flow *_f, const uint8_t _flow_flags,
|
|
|
|
void *txv, const int list_id);
|
|
|
|
void *txv, const int list_id);
|
|
|
|
|
|
|
|
static InspectionBuffer *GetRequestData2(DetectEngineThreadCtx *det_ctx,
|
|
|
|
|
|
|
|
const DetectEngineTransforms *transforms, Flow *_f, const uint8_t _flow_flags, void *txv,
|
|
|
|
|
|
|
|
const int list_id);
|
|
|
|
|
|
|
|
static InspectionBuffer *GetResponseData2(DetectEngineThreadCtx *det_ctx,
|
|
|
|
|
|
|
|
const DetectEngineTransforms *transforms, Flow *_f, const uint8_t _flow_flags, void *txv,
|
|
|
|
|
|
|
|
const int list_id);
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* \brief Registration function for keyword: http_cookie
|
|
|
|
* \brief Registration function for keyword: http_cookie
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ -112,6 +117,16 @@ void DetectHttpCookieRegister(void)
|
|
|
|
DetectAppLayerMpmRegister2("http_cookie", SIG_FLAG_TOCLIENT, 2, PrefilterGenericMpmRegister,
|
|
|
|
DetectAppLayerMpmRegister2("http_cookie", SIG_FLAG_TOCLIENT, 2, PrefilterGenericMpmRegister,
|
|
|
|
GetResponseData, ALPROTO_HTTP1, HTP_REQUEST_HEADERS);
|
|
|
|
GetResponseData, ALPROTO_HTTP1, HTP_REQUEST_HEADERS);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DetectAppLayerInspectEngineRegister2("http_cookie", ALPROTO_HTTP2, SIG_FLAG_TOSERVER,
|
|
|
|
|
|
|
|
HTTP2StateDataClient, DetectEngineInspectBufferGeneric, GetRequestData2);
|
|
|
|
|
|
|
|
DetectAppLayerInspectEngineRegister2("http_cookie", ALPROTO_HTTP2, SIG_FLAG_TOCLIENT,
|
|
|
|
|
|
|
|
HTTP2StateDataServer, DetectEngineInspectBufferGeneric, GetResponseData2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DetectAppLayerMpmRegister2("http_cookie", SIG_FLAG_TOSERVER, 2, PrefilterGenericMpmRegister,
|
|
|
|
|
|
|
|
GetRequestData2, ALPROTO_HTTP2, HTTP2StateDataClient);
|
|
|
|
|
|
|
|
DetectAppLayerMpmRegister2("http_cookie", SIG_FLAG_TOCLIENT, 2, PrefilterGenericMpmRegister,
|
|
|
|
|
|
|
|
GetResponseData2, ALPROTO_HTTP2, HTTP2StateDataServer);
|
|
|
|
|
|
|
|
|
|
|
|
DetectBufferTypeSetDescriptionByName("http_cookie",
|
|
|
|
DetectBufferTypeSetDescriptionByName("http_cookie",
|
|
|
|
"http cookie header");
|
|
|
|
"http cookie header");
|
|
|
|
|
|
|
|
|
|
|
|
@ -149,7 +164,7 @@ static int DetectHttpCookieSetupSticky(DetectEngineCtx *de_ctx, Signature *s, co
|
|
|
|
if (DetectBufferSetActiveList(s, g_http_cookie_buffer_id) < 0)
|
|
|
|
if (DetectBufferSetActiveList(s, g_http_cookie_buffer_id) < 0)
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
|
|
if (DetectSignatureSetAppProto(s, ALPROTO_HTTP1) < 0)
|
|
|
|
if (DetectSignatureSetAppProto(s, ALPROTO_HTTP) < 0)
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
@ -211,6 +226,48 @@ static InspectionBuffer *GetResponseData(DetectEngineThreadCtx *det_ctx,
|
|
|
|
return buffer;
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static InspectionBuffer *GetRequestData2(DetectEngineThreadCtx *det_ctx,
|
|
|
|
|
|
|
|
const DetectEngineTransforms *transforms, Flow *_f, const uint8_t _flow_flags, void *txv,
|
|
|
|
|
|
|
|
const int list_id)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
InspectionBuffer *buffer = InspectionBufferGet(det_ctx, list_id);
|
|
|
|
|
|
|
|
if (buffer->inspect == NULL) {
|
|
|
|
|
|
|
|
uint32_t b_len = 0;
|
|
|
|
|
|
|
|
const uint8_t *b = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rs_http2_tx_get_cookie(txv, STREAM_TOSERVER, &b, &b_len) != 1)
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (b == NULL || b_len == 0)
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InspectionBufferSetup(det_ctx, list_id, buffer, b, b_len);
|
|
|
|
|
|
|
|
InspectionBufferApplyTransforms(buffer, transforms);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static InspectionBuffer *GetResponseData2(DetectEngineThreadCtx *det_ctx,
|
|
|
|
|
|
|
|
const DetectEngineTransforms *transforms, Flow *_f, const uint8_t _flow_flags, void *txv,
|
|
|
|
|
|
|
|
const int list_id)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
InspectionBuffer *buffer = InspectionBufferGet(det_ctx, list_id);
|
|
|
|
|
|
|
|
if (buffer->inspect == NULL) {
|
|
|
|
|
|
|
|
uint32_t b_len = 0;
|
|
|
|
|
|
|
|
const uint8_t *b = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rs_http2_tx_get_cookie(txv, STREAM_TOCLIENT, &b, &b_len) != 1)
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (b == NULL || b_len == 0)
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InspectionBufferSetup(det_ctx, list_id, buffer, b, b_len);
|
|
|
|
|
|
|
|
InspectionBufferApplyTransforms(buffer, transforms);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************** UNITESTS **********************************/
|
|
|
|
/******************************** UNITESTS **********************************/
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef UNITTESTS
|
|
|
|
#ifdef UNITTESTS
|
|
|
|
|