-
Notifications
You must be signed in to change notification settings - Fork 20
/
cobject.h
209 lines (170 loc) · 4.46 KB
/
cobject.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
/*
* File: cobject.h
* Author: Oleg Zharkov
*
*/
#ifndef COBJECT_H
#define COBJECT_H
#include "main.h"
#include "config.h"
using namespace std;
class CollectorObject {
public:
//
static string node_id;
static string sensor_id;
static char active_response[OS_HEADER_SIZE];
static char remote_upload[OS_HEADER_SIZE];
static bool arStatus;
static bool uploadStatus;
static int timezone;
static int log_size;
static long startup_timer;
static long gosleep_timer;
static long update_timer;
// Wazuh config parameters
static char wazuh_host[OS_HEADER_SIZE];
static int wazuh_port;
static char wazuh_user[OS_HEADER_SIZE];
static char wazuh_pwd[OS_HEADER_SIZE];
static bool wazuhServerStatus;
static char suri_log[OS_BUFFER_SIZE];
static bool surilog_status;
static char wazuh_log[OS_BUFFER_SIZE];
static bool wazuhlog_status;
static char modsec_log[OS_BUFFER_SIZE];
static bool modseclog_status;
static char suri_path[OS_BUFFER_SIZE];
static char suri_rules[OS_BUFFER_SIZE];
static char suri_iprep[OS_BUFFER_SIZE];
static char wazuh_path[OS_BUFFER_SIZE];
static char wazuh_rules[OS_BUFFER_SIZE];
static char wazuh_iprep[OS_BUFFER_SIZE];
static char modsec_path[OS_BUFFER_SIZE];
static char modsec_rules[OS_BUFFER_SIZE];
static char modsec_iprep[OS_BUFFER_SIZE];
char collector_time[OS_DATETIME_SIZE];
//Syslog info string
static char SysLogInfo[OS_LONG_HEADER_SIZE];
CollectorObject () {
node_id.clear();
sensor_id.clear();
wazuhServerStatus = true;
arStatus = true;
uploadStatus = true;
surilog_status = true;
wazuhlog_status = true;
modseclog_status = true;
timezone = 0;
log_size = 0;
startup_timer = 0;
gosleep_timer = 0;
update_timer = 0;
wazuh_port = 0;
}
string GetNodeId() { return node_id; }
virtual int GetConfig();
string GetNodeTime();
string GetGraylogFormat();
void ReplaceAll(string& input, const string& from, const string& to);
long GetStartupTimer() { return startup_timer; }
long GetGosleepTimer() { return gosleep_timer; }
long GetUpdateTimer() { return update_timer; }
static void SysLog(char* info);
static int ValidDigit(char* ip_str);
static int IsValidIp(string ip);
static uint32_t IPToUInt(string ip);
static bool IsIPInRange(string ip, string network, string mask);
static unsigned int GetBufferSize(char* source);
};
class Event {
public:
int event_type;
string ref_id;
void Reset() {
ref_id.clear();
event_type = 0;
}
};
class BinData : public Event {
public:
string data;
void Reset() {
Event::Reset();
data.clear();
}
BinData () {
data.clear();
event_type = 2;
}
};
class Rule : public BinData {
public:
string name_rule;
void Reset() {
BinData::Reset();
name_rule.clear();
}
Rule () {
data.clear();
name_rule.clear();
event_type = 6;
}
};
class Alert : public Event {
public:
// Record
string alert_uuid;
string source;
string type;
int event;
int severity;
int score;
string description;
string srcip;
string dstip;
string srcagent;
string dstagent;
unsigned int srcport;
unsigned int dstport;
string user;
string sensor;
string location;
string action;
string filter;
string status;
string info;
string event_json;
string event_time;
std::vector<string> list_cats;
void Reset() {
Event::Reset();
event_type = 0;
alert_uuid.clear();
source.clear();
type.clear();
event = 0;
severity = 0;
description.clear();
srcip.clear();
dstip.clear();
action.clear();
location.clear();
user.clear();
status.clear();
info.clear();
event_json.clear();
// new
score = 0;
srcagent.clear();
dstagent.clear();
srcport = 0;
dstport = 0;
sensor.clear();
filter.clear();
event_time.clear();
list_cats.clear();
}
void CreateAlertUUID(void);
};
#endif /* COBJECT_H */