forked from ooooooooooossssps/ShellEmuX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
74 lines (67 loc) · 1.73 KB
/
main.cpp
File metadata and controls
74 lines (67 loc) · 1.73 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
#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 1500u
#define OVERLAP 100u
using namespace std;
int main(int argc, char** argv)
{
TimerAnalyzer::start(TimeTotal);
int type = 1;
if (argc >= 4)
type = atoi(argv[3]);
DetectSimilar ds((DetectSimilar::AnalyzerType)(type), DetectSimilar::AnalyzerFlagBrute, (argc >= 5) ? atoi(argv[4]) : 0);
TimerAnalyzer::start(TimeLoadShellcodes);
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;
}
}
TimerAnalyzer::stop(TimeLoadShellcodes);
TimerAnalyzer::start(TimeLoad);
Reader reader;
reader.load(argv[1]);
TimerAnalyzer::stop(TimeLoad);
/*
ds.link(reader.pointer(), reader.size());
string ans = ds.analyze();
*/
string ans;
for (int data_start = 0, i = 0; data_start < reader.size(); data_start += BLOCK_SIZE - OVERLAP, i++)
{
if (i % 10)
cout << 100 * (float) data_start / reader.size() << "% processed" << endl;
ds.link(reader.pointer() + data_start, min(reader.size() - data_start, BLOCK_SIZE));
string my_ans = ds.analyze();
if (!my_ans.empty()) {
ans = my_ans;
break;
}
}
if (!ans.empty())
{
cout << ans << endl;
}
else
{
cout << "Not an attack" << endl;
}
TimerAnalyzer::stop(TimeTotal);
cerr << "Total time: " << TimerAnalyzer::secs(TimeTotal) << endl;
cerr << "Time spent on loading shellcodes: " << TimerAnalyzer::secs(TimeLoadShellcodes) << endl;
cerr << "Time spent on loading data to analyze: " << TimerAnalyzer::secs(TimeLoad) << endl;
return 0;
}