-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck.h
93 lines (79 loc) · 2.56 KB
/
check.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
struct sysCPS *inputHEAD = NULL;
/***********************************************************
fuctions - COMPARE and CHECK
* has to add branches to the signature
* identify a metric to identify attack
* currently mean and varience are used to calculate the abnormality in the process behaviour
***********************************************************/
void compare(struct sysCPS *inp, char *name1, char *name2) {
int lS=0, lL=0, lI=0, n=0;
FILE *file=fopen(tmpSigF, "w");
float m=0.0, v=0.0;
struct sStruct *str;
makePoset(name1);
lS = lengthPoset(head);
lI = lengthPoset(inp);
str = string_lcs_v2(inp, head, lI, lS);
fprintf(file, "%s", str->str1);
fclose(file);
makePoset(tmpSigF);
// lL = lengthPoset(head);
lL = lI - str->l + 1 - lS;
file = fopen(name2, "r");
fscanf(file, "%d %f %f", &n, &m, &v);
fclose(file);
printf("\nLS:%d LI:%d LL:%d [%d]\n", lS, lI, lL, str->l);
/*********************************
* condition to check for anomaly
* has to modify it some more
*********************************/
if((lL < (lS - v))) { //&& (lL > (m - v))) {
printf("\t\tNORMAL BEHAVIOUR\n");
}
else {
printf("\t\tABNORMAL BEHAVIOUR\n");
}
}
/**
* void evalScore() {
* userfeed back can be included here
* }
**/
void check(char *input) {
FILE *fileI = fopen(input, "r");
FILE *fileS; // = fopen(siglist, "r");
char name1[100], name2[100], name3[100];
printf("\nProcessing input file: %s\n", input);
/**
* int i=0;
* makePoset(input);
* clean();
* inputHEAD = head;
* head = NULL;
**/
fscanf(fileI, "%s", name3);
while(!feof(fileI)) {
printf("\tFile: %s\n", name3);
fileS = fopen(siglist, "r");
fscanf(fileS, "%s %s", name1, name2);
makePoset(name3);
clean();
inputHEAD = head;
/**
* for sig in list of signature
**/
while(!feof(fileS)) {
printf("\t\tSigFile: %s %d\n", name1, lengthPoset(inputHEAD));
compare(inputHEAD, name1, name2);
fscanf(fileS, "%s %s", name1, name2);
}
fscanf(fileI, "%s", name3);
fclose(fileS);
}
fclose(fileI);
/***********************************************************************************
* evalScore(resut_score, );
* find the number of mismatches usign the same algorithm to find mean and varience
* then compare it with the signature values
***********************************************************************************/
}