-
Notifications
You must be signed in to change notification settings - Fork 0
/
comm_structs.h
289 lines (226 loc) · 5.22 KB
/
comm_structs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
// Copyright (C) 2022 ESET spol. s r.o.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// SPDX-License-Identifier: GPL-2.0
#define MAXARGSIZE 128
#define MAXPATH 128
#define MAXARG 32
#define MAX_SOCKADDR 28 // sockaddr_in6
enum EVENT_TYPE {
//***********************************
// PROCESS EVENTS
//***********************************
FORK_EVENT = 0,
EXEC_TRACE_EVENT,
EXIT_EVENT,
EXECVE_ARG,
EXECVE_PATH,
EXECVE_RET,
CLONE_ENTER,
CLONE_RET,
CLONE3_ENTER,
CLONE3_RET,
FORK_ENTER,
FORK_RET,
VFORK_ENTER,
VFORK_RET,
UNSHARE_ENTER,
UNSHARE_RET,
//***********************************
// FILE EVENTS
//***********************************
OPEN_ENTER,
OPEN_RET,
OPENAT_ENTER,
OPENAT_RET,
CREAT_ENTER,
CREAT_RET,
CHMOD_ENTER,
CHMOD_RET,
FCHMOD_ENTER,
FCHMOD_RET,
FCHMODAT_ENTER,
FCHMODAT_RET,
UNLINK_ENTER,
UNLINK_RET,
UNLINKAT_ENTER,
UNLINKAT_RET,
RENAME_ENTER,
RENAME_RET,
RENAMEAT_ENTER,
RENAMEAT_RET,
RENAMEAT2_ENTER,
RENAMEAT2_RET,
IOCTL_ENTER,
IOCTL_RET,
//***********************************
// CWD EVENTS
//***********************************
CHDIR_ENTER,
CHDIR_RET,
FCHDIR_ENTER,
FCHDIR_RET,
CHROOT_ENTER,
CHROOT_RET,
//***********************************
// DESCRIPTOR EVENTS
//***********************************
FCNTL_ENTER,
FCNTL_RET,
DUP_ENTER,
DUP_RET,
DUP2_ENTER,
DUP2_RET,
DUP3_ENTER,
DUP3_RET,
MEMFD_CREATE_ENTER,
MEMFD_CREATE_RET,
CLOSE_ENTER,
CLOSE_RET,
//***********************************
// NETWORK EVENTS
//***********************************
CONNECT_ENTER,
CONNECT_RET,
ACCEPT_ENTER,
ACCEPT_RET,
KILL_ENTER,
KILL_RET,
};
typedef uint64_t event_type_t;
struct event_header {
event_type_t event_type;
uint64_t timestamp;
uint64_t pid_tgid;
uint32_t uid;
uint32_t gid;
} __attribute__((packed));
struct fork_event {
struct event_header header;
int32_t child_pid;
} __attribute__((packed));
struct execve_path {
struct event_header header;
char path[MAXPATH];
int32_t fd;
} __attribute__((packed));
struct execve_arg {
struct event_header header;
char arg[MAXARGSIZE];
} __attribute__((packed));
struct execve_ret {
struct event_header header;
int retval;
} __attribute__((packed));
struct exec_trace {
struct event_header header;
char path[MAXPATH];
} __attribute__((packed));
struct exit_event {
struct event_header header;
} __attribute__((packed));
struct exit_code {
struct event_header header;
int32_t ret;
} __attribute__((packed));
struct exit_codepath {
struct event_header header;
int32_t ret;
char path[MAXPATH];
} __attribute__((packed));
struct exit_codepath2 {
struct event_header header;
int32_t ret;
char source[MAXPATH];
char target[MAXPATH];
} __attribute__((packed));
struct path_event {
struct event_header header;
char path[MAXPATH];
} __attribute__((packed));
struct descriptor_event {
struct event_header header;
int32_t fd;
} __attribute__((packed));
struct openat_enter {
struct event_header header;
int32_t dirfd;
int32_t flags;
int32_t mode;
} __attribute__((packed));
struct renameat_enter {
struct event_header header;
int32_t olddirfd;
int32_t newdirfd;
int32_t flags;
} __attribute__((packed));
struct unlinkat_enter {
struct event_header header;
int32_t dirfd;
int32_t flags;
} __attribute__((packed));
struct clone_enter {
struct event_header header;
uint64_t clone_flags;
uint64_t newsp;
} __attribute__((packed));
struct unshare_enter {
struct event_header header;
uint64_t flags;
} __attribute__((packed));
struct fcntl_enter {
struct event_header header;
int32_t fd;
int32_t cmd;
int64_t arg;
} __attribute__((packed));
struct dup3_enter {
struct event_header header;
uint32_t oldfd;
uint32_t newfd;
int32_t flags;
} __attribute__((packed));
struct fchmod_enter {
struct event_header header;
int32_t fd;
uint32_t mode;
} __attribute__((packed));
struct fchmodat_enter {
struct event_header header;
int32_t dfd;
char filename[MAXPATH];
uint32_t mode;
} __attribute__((packed));
struct memfd_create_enter {
struct event_header header;
char name[MAXPATH];
int32_t flags;
} __attribute__((packed));
struct chroot_enter {
struct event_header header;
char name[MAXPATH];
} __attribute__((packed));
struct tcp_event {
struct event_header header;
uint8_t sockaddr[MAX_SOCKADDR];
int32_t addrlen;
int32_t fd;
int32_t ret;
} __attribute__((packed));
struct kill_enter {
struct event_header header;
pid_t target;
int32_t signal;
} __attribute__((packed));