1
|
#include <libprelude/prelude.h>
|
2
|
|
3
|
|
4
|
#define ANALYZER_NAME "simple-analyzer"
|
5
|
|
6
|
static int
|
7
|
add_idmef_object(idmef_message_t *message, const char *object, const char *value)
|
8
|
{
|
9
|
int ret;
|
10
|
idmef_value_t *val;
|
11
|
idmef_path_t *path;
|
12
|
|
13
|
ret = idmef_path_new_fast(&path, object);
|
14
|
if ( ret < 0 )
|
15
|
return -1;
|
16
|
|
17
|
ret = idmef_value_new_from_path(&val, path, value);
|
18
|
if ( ret < 0 ) {
|
19
|
printf("path = %s", object);
|
20
|
prelude_perror(ret, "Unable to create the IDMEF value from path");
|
21
|
idmef_path_destroy(path);
|
22
|
return -1;
|
23
|
}
|
24
|
|
25
|
ret = idmef_path_set(path, message, val);
|
26
|
if ( ret < 0 ) {
|
27
|
prelude_perror(ret, "Unable to create to set the IDMEF path");
|
28
|
idmef_value_destroy(val);
|
29
|
idmef_path_destroy(path);
|
30
|
return -1;
|
31
|
}
|
32
|
|
33
|
idmef_value_destroy(val);
|
34
|
idmef_path_destroy(path);
|
35
|
|
36
|
return ret;
|
37
|
}
|
38
|
|
39
|
|
40
|
int main(int argc, char **argv)
|
41
|
{
|
42
|
int ret;
|
43
|
|
44
|
prelude_client_t *client;
|
45
|
idmef_message_t *idmef;
|
46
|
|
47
|
|
48
|
ret = prelude_init(&argc, argv);
|
49
|
if ( ret < 0 ) {
|
50
|
prelude_perror(ret, "unable to initialize the prelude library");
|
51
|
return -1;
|
52
|
}
|
53
|
|
54
|
ret = prelude_client_new(&client, ANALYZER_NAME);
|
55
|
if ( ! client ) {
|
56
|
prelude_perror(ret, "Unable to create a prelude client object");
|
57
|
return -1;
|
58
|
}
|
59
|
|
60
|
ret = prelude_client_start(client);
|
61
|
if ( ret < 0 ) {
|
62
|
prelude_perror(ret, "Unable to start prelude client");
|
63
|
prelude_client_destroy(client, PRELUDE_CLIENT_EXIT_STATUS_FAILURE);
|
64
|
return -1;
|
65
|
}
|
66
|
|
67
|
|
68
|
ret = idmef_message_new(&idmef);
|
69
|
if ( ret < 0 ) {
|
70
|
prelude_perror(ret, "Unable to create the IDMEF message");
|
71
|
prelude_client_destroy(client, PRELUDE_CLIENT_EXIT_STATUS_FAILURE);
|
72
|
return -1;
|
73
|
}
|
74
|
|
75
|
|
76
|
|
77
|
|
78
|
add_idmef_object(idmef, "alert.assessment.impact.description", "As you can see, this description is useless, because it is describing an event that isn't one!");
|
79
|
add_idmef_object(idmef, "alert.assessment.impact.severity", "info");
|
80
|
add_idmef_object(idmef, "alert.assessment.impact.completion", "succeeded");
|
81
|
add_idmef_object(idmef, "alert.classification.text", "This alert was sent from the simplest analyzer ever");
|
82
|
|
83
|
add_idmef_object(idmef, "alert.source(0).user(0)", "L'homme araignee");
|
84
|
|
85
|
add_idmef_object(idmef, "alert.additional_data(0).type", "string");
|
86
|
add_idmef_object(idmef, "alert.additional_data(0).meaning", "Signature ID");
|
87
|
add_idmef_object(idmef, "alert.additional_data(0).data", "1");
|
88
|
|
89
|
prelude_client_send_idmef(client, idmef);
|
90
|
idmef_message_destroy(idmef);
|
91
|
|
92
|
prelude_client_destroy(client, PRELUDE_CLIENT_EXIT_STATUS_SUCCESS);
|
93
|
|
94
|
return 0;
|
95
|
}
|