-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.cpp
More file actions
85 lines (77 loc) · 2 KB
/
main.cpp
File metadata and controls
85 lines (77 loc) · 2 KB
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
#include <finddecryptor/reader.h>
#include "detectSimilar.h"
#include "timer.h"
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <algorithm>
#define BLOCK_SIZE 40000u
#define OVERLAP 20000u
//#define BLOCK_SIZE 1500u
//#define OVERLAP 100u
using namespace std;
using namespace find_decryptor;
using namespace detect_similar;
int main(int argc, char** argv)
{
TimerAnalyzer::start(TimeTotal);
uint bl_size = BLOCK_SIZE;
int type = 1;
if (argc >= 4)
type = atoi(argv[3]);
if (argc >= 6)
bl_size = atoi(argv[5]);
uint overlap = min(bl_size / 2, OVERLAP);
DetectSimilar ds((DetectSimilar::AnalyzerType)(type), DetectSimilar::AnalyzerFlagBrute, (argc >= 5) ? atoi(argv[4]) : 0);
if (argv[2][strlen(argv[2])-1] == '/')
{
ds.loadShellcodes(argv[2]);
}
else
{
if (!ds.loadModel(argv[2]))
{
cerr << "Error: could not load model." << endl;
return 0;
}
}
Reader reader;
reader.load(argv[1]);
/*
ds.link(reader.pointer(), reader.size());
string ans = ds.analyze();
*/
string ans;
uint processed = 0;
TimerAnalyzer::start(TimeProcess);
for (uint data_start = 0, i = 0; data_start < reader.size(); data_start += bl_size - overlap, i++)
{
if (i > 0)
cerr << 100 * (float) data_start / reader.size() << "% processed" << endl;
ds.link(reader.pointer() + data_start, min(reader.size() - data_start, bl_size));
string my_ans = ds.analyze();
processed += bl_size;
if (!my_ans.empty()) {
ans = my_ans;
break;
}
}
TimerAnalyzer::stop(TimeProcess);
processed = max(processed, (uint) reader.size());
if (!ans.empty())
{
cout << ans << endl;
}
else
{
cout << "Not an attack" << endl;
}
TimerAnalyzer::stop(TimeTotal);
cerr << "Total time: " << TimerAnalyzer::secs(TimeTotal) << endl;
cerr << "Processing time: " << TimerAnalyzer::secs(TimeProcess) << endl;
float speed = processed * 8 / 1024.0 / TimerAnalyzer::secs(TimeProcess);
cerr << "Speed: " << speed << " kbit/s = " << speed / 8 << " KiB/sec" << endl;
return 0;
}