Go to the documentation of this file.
53 #define PARSE_REGEX1 "^(!?)([_a-zA-Z0-9]+)(.*)$"
56 #define PARSE_REGEX2 "^(?:\\s*[|,]\\s*(!?)([_a-zA-Z0-9]+))(.*)$"
60 Flow *, uint8_t,
void *,
void *,
64 static void DetectSslStateRegisterTests(
void);
68 static int g_tls_generic_list_id = 0;
90 "generic ssl/tls inspection");
113 Flow *f, uint8_t
flags,
void *alstate,
void *txv,
118 if (ssl_state == NULL) {
125 if ((ssd->
flags & ssl_flags) ^ ssd->
mask) {
147 uint32_t
flags = 0, mask = 0;
149 pcre2_match_data *match = NULL;
153 "ssl_state keyword.",
158 pcre2len =
sizeof(str1);
159 int res = pcre2_substring_copy_bynumber(match, 1, (PCRE2_UCHAR8 *)str1, &pcre2len);
161 SCLogError(
"pcre2_substring_copy_bynumber failed");
164 negate = !strcmp(
"!", str1);
166 pcre2len =
sizeof(str1);
167 res = pcre2_substring_copy_bynumber(match, 2, (PCRE2_UCHAR8 *)str1, &pcre2len);
169 SCLogError(
"pcre2_substring_copy_bynumber failed");
173 if (strcmp(
"client_hello", str1) == 0) {
177 }
else if (strcmp(
"server_hello", str1) == 0) {
181 }
else if (strcmp(
"client_keyx", str1) == 0) {
185 }
else if (strcmp(
"server_keyx", str1) == 0) {
189 }
else if (strcmp(
"unknown", str1) == 0) {
195 "in ssl_state keyword.",
200 pcre2len =
sizeof(str1);
201 res = pcre2_substring_copy_bynumber(match, 3, (PCRE2_UCHAR8 *)str1, &pcre2len);
203 SCLogError(
"pcre2_substring_copy_bynumber failed");
206 while (res >= 0 && strlen(str1) > 0) {
207 pcre2_match_data *match2 = NULL;
211 "ssl_state keyword.",
214 pcre2_match_data_free(match2);
219 pcre2len =
sizeof(str2);
220 res = pcre2_substring_copy_bynumber(match2, 1, (PCRE2_UCHAR8 *)str2, &pcre2len);
222 SCLogError(
"pcre2_substring_copy_bynumber failed");
223 pcre2_match_data_free(match2);
226 negate = !strcmp(
"!", str2);
228 pcre2len =
sizeof(str2);
229 res = pcre2_substring_copy_bynumber(match2, 2, (PCRE2_UCHAR8 *)str2, &pcre2len);
231 SCLogError(
"pcre2_substring_copy_bynumber failed");
232 pcre2_match_data_free(match2);
235 if (strcmp(
"client_hello", str2) == 0) {
239 }
else if (strcmp(
"server_hello", str2) == 0) {
243 }
else if (strcmp(
"client_keyx", str2) == 0) {
247 }
else if (strcmp(
"server_keyx", str2) == 0) {
251 }
else if (strcmp(
"unknown", str2) == 0) {
257 "in ssl_state keyword.",
259 pcre2_match_data_free(match2);
263 pcre2len =
sizeof(str2);
264 res = pcre2_substring_copy_bynumber(match2, 3, (PCRE2_UCHAR8 *)str2, &pcre2len);
266 SCLogError(
"pcre2_substring_copy_bynumber failed");
267 pcre2_match_data_free(match2);
271 memcpy(str1, str2,
sizeof(str1));
272 pcre2_match_data_free(match2);
282 pcre2_match_data_free(match);
287 pcre2_match_data_free(match);
314 DetectSslStateFree(
de_ctx, ssd);
SSLv[2.0|3.[0|1|2|3]] state structure.
SigTableElmt * sigmatch_table
void(* Free)(DetectEngineCtx *, void *)
#define DETECT_SSL_STATE_CLIENT_HELLO
main detection engine ctx
#define DETECT_SSL_STATE_UNKNOWN
int(* AppLayerTxMatch)(DetectEngineThreadCtx *, Flow *, uint8_t flags, void *alstate, void *txv, const Signature *, const SigMatchCtx *)
int DetectParsePcreExec(DetectParseRegex *parse_regex, pcre2_match_data **match, const char *str, int start_offset, int options)
int SCDetectSignatureSetAppProto(Signature *s, AppProto alproto)
#define SIG_FLAG_TOCLIENT
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
#define SIG_FLAG_TOSERVER
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
SigMatch * SCSigMatchAppendSMToList(DetectEngineCtx *de_ctx, Signature *s, uint16_t type, SigMatchCtx *ctx, const int list)
Append a SigMatch to the list type.
void DetectSslStateRegister(void)
Registers the keyword handlers for the "ssl_state" keyword.
Data structures and function prototypes for keeping state for the detection engine.
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
int DetectBufferTypeRegister(const char *name)
uint8_t DetectEngineInspectGenericList(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, const struct DetectEngineAppInspectionEngine_ *engine, const Signature *s, Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
Do the content inspection & validation for a signature.
#define DETECT_SSL_STATE_SERVER_KEYX
#define SCLogError(...)
Macro used to log ERROR messages.
void DetectAppLayerInspectEngineRegister(const char *name, AppProto alproto, uint32_t dir, int progress, InspectEngineFuncPtr Callback, InspectionBufferGetDataPtr GetData)
Registers an app inspection engine.
void DetectBufferTypeSetDescriptionByName(const char *name, const char *desc)
#define DETECT_SSL_STATE_CLIENT_KEYX
void(* RegisterTests)(void)
#define DETECT_SSL_STATE_SERVER_HELLO