/src/suricata7/src/output-json-rdp.c
Line | Count | Source |
1 | | /* Copyright (C) 2019-2021 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 | | /** |
19 | | * \file |
20 | | * |
21 | | * \author Zach Kelly <zach.kelly@lmco.com> |
22 | | * |
23 | | * Application layer logger for RDP |
24 | | */ |
25 | | |
26 | | #include "suricata-common.h" |
27 | | #include "detect.h" |
28 | | #include "pkt-var.h" |
29 | | #include "conf.h" |
30 | | #include "threads.h" |
31 | | #include "threadvars.h" |
32 | | #include "tm-threads.h" |
33 | | #include "util-unittest.h" |
34 | | #include "util-buffer.h" |
35 | | #include "util-debug.h" |
36 | | #include "util-byte.h" |
37 | | #include "output.h" |
38 | | #include "output-json.h" |
39 | | #include "app-layer.h" |
40 | | #include "app-layer-parser.h" |
41 | | #include "app-layer-rdp.h" |
42 | | #include "output-json-rdp.h" |
43 | | #include "rust.h" |
44 | | |
45 | | static int JsonRdpLogger(ThreadVars *tv, void *thread_data, |
46 | | const Packet *p, Flow *f, void *state, void *tx, uint64_t tx_id) |
47 | 236 | { |
48 | 236 | OutputJsonThreadCtx *thread = thread_data; |
49 | | |
50 | 236 | JsonBuilder *js = CreateEveHeader(p, LOG_DIR_PACKET, "rdp", NULL, thread->ctx); |
51 | 236 | if (unlikely(js == NULL)) { |
52 | 0 | return TM_ECODE_OK; |
53 | 0 | } |
54 | 236 | if (!rs_rdp_to_json(tx, js)) { |
55 | 0 | jb_free(js); |
56 | 0 | return TM_ECODE_FAILED; |
57 | 0 | } |
58 | 236 | OutputJsonBuilderBuffer(js, thread); |
59 | | |
60 | 236 | jb_free(js); |
61 | 236 | return TM_ECODE_OK; |
62 | 236 | } |
63 | | |
64 | | static OutputInitResult OutputRdpLogInitSub(ConfNode *conf, |
65 | | OutputCtx *parent_ctx) |
66 | 2 | { |
67 | 2 | AppLayerParserRegisterLogger(IPPROTO_TCP, ALPROTO_RDP); |
68 | 2 | return OutputJsonLogInitSub(conf, parent_ctx); |
69 | 2 | } |
70 | | |
71 | | void JsonRdpLogRegister(void) |
72 | 33 | { |
73 | | /* Register as an eve sub-module. */ |
74 | 33 | OutputRegisterTxSubModule(LOGGER_JSON_TX, "eve-log", "JsonRdpLog", "eve-log.rdp", |
75 | 33 | OutputRdpLogInitSub, ALPROTO_RDP, JsonRdpLogger, JsonLogThreadInit, JsonLogThreadDeinit, |
76 | 33 | NULL); |
77 | | |
78 | 33 | SCLogDebug("rdp json logger registered."); |
79 | 33 | } |