-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathanalyzerDiff.cpp
More file actions
42 lines (37 loc) · 796 Bytes
/
analyzerDiff.cpp
File metadata and controls
42 lines (37 loc) · 796 Bytes
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
#include "analyzerDiff.h"
#include "compareUtils.h"
#include <iostream>
using namespace std;
#define THRESHOLD 0.5
AnalyzerDiff::AnalyzerDiff()
{
_className = "AnalyzerDiff";
}
AnalyzerDiff::AnalyzerDiff(const unsigned char* data, uint size)
: Analyzer(data, size)
{
_className = "AnalyzerDiff";
}
string AnalyzerDiff::analyze()
{
double max_coef = 0.0;
int max_ans = 0;
int ind_max = 0;
for (int i = 0; i < _amountShellcodes; i++)
{
int ans = CompareUtils::compare_diff(_shellcodes[i], _shellcodeSizes[i], _data, _data_size);
double coef = ans * 1.0 / _shellcodeSizes[i];
if (coef > THRESHOLD)
{
max_coef = coef;
if (ans > max_ans)
{
max_ans = ans;
ind_max = i;
}
}
}
if (max_coef > THRESHOLD)
return _shellcodeNames[ind_max];
return string();
}