suricata
detect-krb5-ticket-encryption.c
Go to the documentation of this file.
1/* Copyright (C) 2022 Open Information Security Foundation
2 *
3 * You can copy, redistribute or modify this Program under the terms of
4 * the GNU General Public License version 2 as published by the Free
5 * Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * version 2 along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17
18#include "suricata-common.h"
19#include "rust.h"
20
22
23#include "detect-engine.h"
24#include "detect-parse.h"
25
26static int g_krb5_ticket_encryption_list_id = 0;
27
28static void DetectKrb5TicketEncryptionFree(DetectEngineCtx *de_ctx, void *ptr)
29{
30 SCKrb5DetectEncryptionFree(ptr);
31}
32
33static int DetectKrb5TicketEncryptionMatch(DetectEngineThreadCtx *det_ctx, Flow *f, uint8_t flags,
34 void *state, void *txv, const Signature *s, const SigMatchCtx *ctx)
35{
36 const DetectKrb5TicketEncryptionData *dd = (const DetectKrb5TicketEncryptionData *)ctx;
37
38 SCEnter();
39
40 SCReturnInt(SCKrb5DetectEncryptionMatch(txv, dd));
41}
42
43static int DetectKrb5TicketEncryptionSetup(
44 DetectEngineCtx *de_ctx, Signature *s, const char *krb5str)
45{
46 DetectKrb5TicketEncryptionData *krb5d = NULL;
47
49 return -1;
50
51 krb5d = SCKrb5DetectEncryptionParse(krb5str);
52 if (krb5d == NULL)
53 goto error;
54
56 g_krb5_ticket_encryption_list_id) == NULL) {
57 goto error;
58 }
59
60 return 0;
61
62error:
63 if (krb5d != NULL)
64 DetectKrb5TicketEncryptionFree(de_ctx, krb5d);
65 return -1;
66}
67
69{
70 sigmatch_table[DETECT_KRB5_TICKET_ENCRYPTION].name = "krb5.ticket_encryption";
71 sigmatch_table[DETECT_KRB5_TICKET_ENCRYPTION].desc = "match Kerberos 5 ticket encryption";
73 "/rules/kerberos-keywords.html#krb5-ticket-encryption";
75 sigmatch_table[DETECT_KRB5_TICKET_ENCRYPTION].AppLayerTxMatch = DetectKrb5TicketEncryptionMatch;
76 sigmatch_table[DETECT_KRB5_TICKET_ENCRYPTION].Setup = DetectKrb5TicketEncryptionSetup;
77 sigmatch_table[DETECT_KRB5_TICKET_ENCRYPTION].Free = DetectKrb5TicketEncryptionFree;
78
79 // Tickets are only from server to client
82
83 g_krb5_ticket_encryption_list_id = DetectBufferTypeRegister("krb5_ticket_encryption");
84 SCLogDebug("g_krb5_ticket_encryption_list_id %d", g_krb5_ticket_encryption_list_id);
85}
@ ALPROTO_KRB5
uint8_t flags
Definition decode-gre.h:0
@ DETECT_KRB5_TICKET_ENCRYPTION
int DetectBufferTypeRegister(const char *name)
void DetectAppLayerInspectEngineRegister(const char *name, AppProto alproto, uint32_t dir, int progress, InspectEngineFuncPtr Callback, InspectionBufferGetDataPtr GetData)
Registers an app inspection engine.
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.
void DetectKrb5TicketEncryptionRegister(void)
int SCDetectSignatureSetAppProto(Signature *s, AppProto alproto)
SigMatch * SCSigMatchAppendSMToList(DetectEngineCtx *de_ctx, Signature *s, uint16_t type, SigMatchCtx *ctx, const int list)
Append a SigMatch to the list type.
SigTableElmt * sigmatch_table
#define SIG_FLAG_TOCLIENT
Definition detect.h:272
DetectEngineCtx * de_ctx
struct Thresholds ctx
main detection engine ctx
Definition detect.h:932
Flow data structure.
Definition flow.h:356
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
Definition detect.h:351
const char * url
Definition detect.h:1462
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
Definition detect.h:1441
void(* Free)(DetectEngineCtx *, void *)
Definition detect.h:1446
const char * desc
Definition detect.h:1461
int(* AppLayerTxMatch)(DetectEngineThreadCtx *, Flow *, uint8_t flags, void *alstate, void *txv, const Signature *, const SigMatchCtx *)
Definition detect.h:1424
int(* Match)(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
Definition detect.h:1421
const char * name
Definition detect.h:1459
Signature container.
Definition detect.h:668
#define SCEnter(...)
Definition util-debug.h:277
#define SCLogDebug(...)
Definition util-debug.h:275
#define SCReturnInt(x)
Definition util-debug.h:281