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
|
idmef_path_destroy(path);
|
20
|
return -1;
|
21
|
}
|
22
|
|
23
|
ret = idmef_path_set(path, message, val);
|
24
|
|
25
|
idmef_value_destroy(val);
|
26
|
idmef_path_destroy(path);
|
27
|
|
28
|
return ret;
|
29
|
}
|
30
|
|
31
|
|
32
|
int main(int argc, char **argv)
|
33
|
{
|
34
|
int ret;
|
35
|
|
36
|
prelude_client_t *client;
|
37
|
idmef_message_t *idmef;
|
38
|
|
39
|
|
40
|
ret = prelude_init(&argc, argv);
|
41
|
if ( ret < 0 ) {
|
42
|
prelude_perror(ret, "unable to initialize the prelude library");
|
43
|
return -1;
|
44
|
}
|
45
|
|
46
|
ret = prelude_client_new(&client, ANALYZER_NAME);
|
47
|
if ( ! client ) {
|
48
|
prelude_perror(ret, "Unable to create a prelude client object");
|
49
|
return -1;
|
50
|
}
|
51
|
|
52
|
ret = prelude_client_start(client);
|
53
|
if ( ret < 0 ) {
|
54
|
prelude_perror(ret, "Unable to start prelude client");
|
55
|
return -1;
|
56
|
}
|
57
|
|
58
|
|
59
|
ret = idmef_message_new(&idmef);
|
60
|
if ( ret < 0 )
|
61
|
return -1;
|
62
|
|
63
|
|
64
|
add_idmef_object(idmef, "alert.classification.reference(0).name", "PRELID-1234");
|
65
|
add_idmef_object(idmef, "alert.classification.reference(0).origin", "PRELID");
|
66
|
add_idmef_object(idmef, "alert.classification.reference(0).url", "http://www.prelude-ids.org/");
|
67
|
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!");
|
68
|
add_idmef_object(idmef, "alert.assessment.impact.severity", "info");
|
69
|
add_idmef_object(idmef, "alert.assessment.impact.completion", "succeeded");
|
70
|
add_idmef_object(idmef, "alert.classification.text", "This alert was sent from the simplest analyzer ever");
|
71
|
|
72
|
add_idmef_object(idmef, "alert.additional_data(0).type", "string");
|
73
|
add_idmef_object(idmef, "alert.additional_data(0).meaning", "Signature ID");
|
74
|
add_idmef_object(idmef, "alert.additional_data(0).data", "1");
|
75
|
|
76
|
prelude_client_send_idmef(client, idmef);
|
77
|
idmef_message_destroy(idmef);
|
78
|
|
79
|
prelude_client_destroy(client, PRELUDE_CLIENT_EXIT_STATUS_SUCCESS);
|
80
|
|
81
|
return 0;
|
82
|
}
|