-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathanalyzerDiff.cpp
More file actions
48 lines (39 loc) · 816 Bytes
/
Copy pathanalyzerDiff.cpp
File metadata and controls
48 lines (39 loc) · 816 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
43
44
45
46
47
48
#include "analyzerDiff.h"
namespace detect_similar
{
using namespace std;
#define THRESHOLD 0.5
AnalyzerDiff::AnalyzerDiff()
: Analyzer()
{
_className = "AnalyzerDiff";
}
AnalyzerDiff::AnalyzerDiff(const unsigned char* data, uint size)
: Analyzer(data, size)
{
_className = "AnalyzerDiff";
}
string AnalyzerDiff::analyze()
{
float max_coef = 0;
int max_ans = 0, ind_max = 0;
for (unsigned int i = 0; i < _shellcodes.size(); i++)
{
int ans = _data.compareDiff(_shellcodes[i], THRESHOLD);
float coef = ans * 1.0 / _shellcodes[i].size;
if (coef > THRESHOLD)
{
if (coef > max_coef)
{
max_coef = coef;
}
if (ans > max_ans)
{
max_ans = ans;
ind_max = i;
}
}
}
return (max_coef <= THRESHOLD) ? string() : _shellcodes[ind_max].name;
}
} //namespace detect_similar