HollowsHunter
Scans all running processes. Recognizes and dumps a variety of potentially malicious implants (replaced/implanted PEs, shellcodes, hooks, in-memory patches).
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1
#define WIN32_LEAN_AND_MEAN
2
3
#ifndef _WIN64
4
#undef USE_ETW
//ETW support works only for 64 bit
5
#endif
//_WIN64
6
7
#if (_MSC_VER < 1900)
8
#undef USE_ETW
//ETW not supported
9
#endif
10
11
#include <iostream>
12
#include <string>
13
14
#include "color_scheme.h"
15
#include "
hh_scanner.h
"
16
17
#include <pe_sieve_types.h>
18
#include <pe_sieve_return_codes.h>
19
20
#include "
params_info/params.h
"
21
22
#include "
util/process_privilege.h
"
23
#include "
util/strings_util.h
"
24
#include "
hh_ver_short.h
"
25
26
using namespace
hhunter::util
;
27
28
// Global arguments
29
t_hh_params
g_hh_args
;
30
31
#ifdef USE_ETW
32
#include "
etw_listener.h
"
33
#endif
34
35
void
compatibility_alert
()
36
{
37
print_in_color
(WARNING_COLOR,
"[!] Scanner mismatch! For a 64-bit OS, use the 64-bit version of the scanner!\n"
);
38
}
39
40
t_pesieve_res
deploy_scan
()
41
{
42
t_pesieve_res scan_res = PESIEVE_NOT_DETECTED;
43
hhunter::util::set_debug_privilege
();
44
if
(
g_hh_args
.
pesieve_args
.data >= pesieve::PE_DATA_SCAN_INACCESSIBLE &&
g_hh_args
.
pesieve_args
.make_reflection ==
false
) {
45
print_in_color
(
RED
,
"[WARNING] Scanning of inaccessible pages is enabled only in the reflection mode!\n"
);
46
}
47
if
(
g_hh_args
.
etw_scan
)
48
{
49
#ifdef USE_ETW
50
const
char
profileIni[] =
"HH_ETWProfile.ini"
;
51
ETWProfile
profile;
52
profile.
initProfile
(profileIni);
53
if
(!profile.
isEnabled
()) {
54
std::cerr <<
"Cannot start ETW: the profile (\""
<< profileIni <<
"\") is empty\n"
;
55
return
PESIEVE_ERROR;
56
}
57
std::cout <<
"ETWProfile defined by:\""
<< profileIni <<
"\"\n"
;
58
if
(!ETWstart(profile)) {
59
return
PESIEVE_ERROR;
60
}
61
#else
62
std::cerr <<
"ETW support is disabled\n"
;
63
return
PESIEVE_ERROR;
64
#endif
65
}
66
else
67
{
68
HHScanner
hhunter
(
g_hh_args
);
69
do
{
70
HHScanReport
*report =
hhunter
.scan();
71
if
(report) {
72
hhunter
.summarizeScan(report,
g_hh_args
.
pesieve_args
.results_filter);
73
if
(report->
countReports
(pesieve::SHOW_SUSPICIOUS) > 0) {
74
scan_res = PESIEVE_DETECTED;
75
}
76
delete
report;
77
}
78
if
(!
HHScanner::isScannerCompatibile
()) {
79
compatibility_alert
();
80
}
81
}
while
(
g_hh_args
.
loop_scanning
);
82
}
83
return
scan_res;
84
}
85
86
int
main
(
int
argc,
char
*argv[])
87
{
88
g_hh_args
.
init
();
89
90
bool
info_req =
false
;
91
HHParams
uParams(
HH_VERSION_STR
);
92
if
(!uParams.parse(argc, argv)) {
93
return
PESIEVE_INFO;
94
}
95
uParams.
fillStruct
(
g_hh_args
);
96
97
// if scanning of inaccessible pages was requested, auto-enable reflection mode:
98
if
(
g_hh_args
.
pesieve_args
.data == pesieve::PE_DATA_SCAN_INACCESSIBLE ||
g_hh_args
.
pesieve_args
.data == pesieve::PE_DATA_SCAN_INACCESSIBLE_ONLY) {
99
if
(!
g_hh_args
.
pesieve_args
.make_reflection) {
100
g_hh_args
.
pesieve_args
.make_reflection =
true
;
101
print_in_color
(
RED
,
"[WARNING] Scanning of inaccessible pages requested: auto-enabled reflection mode!\n"
);
102
}
103
}
104
105
print_version
(
HH_VERSION_STR
);
106
std::cout << std::endl;
107
if
(argc < 2) {
108
print_in_color
(
WHITE
,
"Default scan deployed."
);
109
std::cout << std::endl;
110
}
111
const
t_pesieve_res res =
deploy_scan
();
112
uParams.
freeStruct
(
g_hh_args
);
113
return
res;
114
}
HHParams
Definition
params.h:118
HHParams::freeStruct
void freeStruct(t_hh_params &ps)
Definition
params.h:479
HHParams::fillStruct
void fillStruct(t_hh_params &ps)
Definition
params.h:424
HHScanReport
Definition
hh_report.h:13
HHScanReport::countReports
size_t countReports(const pesieve::t_results_filter rfilter) const
Definition
hh_report.h:39
HHScanner
Definition
hh_scanner.h:24
HHScanner::isScannerCompatibile
static bool isScannerCompatibile()
Definition
hh_scanner.cpp:131
etw_listener.h
hh_scanner.h
hh_ver_short.h
HH_VERSION_STR
#define HH_VERSION_STR
Definition
hh_ver_short.h:8
main
int main(int argc, char *argv[])
Definition
main.cpp:86
g_hh_args
t_hh_params g_hh_args
Definition
main.cpp:29
deploy_scan
t_pesieve_res deploy_scan()
Definition
main.cpp:40
compatibility_alert
void compatibility_alert()
Definition
main.cpp:35
hhunter::util
Definition
process_privilege.cpp:6
hhunter::util::set_debug_privilege
bool set_debug_privilege()
Definition
process_privilege.cpp:71
hhunter
Definition
process_privilege.cpp:5
params.h
print_version
void print_version(const std::string &version, WORD info_color=HILIGHTED_COLOR)
Definition
params.h:68
process_privilege.h
strings_util.h
ETWProfile
Definition
etw_settings.h:5
ETWProfile::isEnabled
bool isEnabled()
Definition
etw_settings.h:40
ETWProfile::initProfile
bool initProfile(const std::string &fileName)
Definition
etw_settings.h:18
hh_params
Definition
hh_params.h:20
hh_params::init
void init()
Definition
hh_params.cpp:3
hh_params::pesieve_args
pesieve::t_params pesieve_args
Definition
hh_params.h:36
hh_params::etw_scan
bool etw_scan
Definition
hh_params.h:25
hh_params::loop_scanning
bool loop_scanning
Definition
hh_params.h:24
print_in_color
void print_in_color(WORD color, const std::string &text)
Definition
term_util.cpp:33
WHITE
#define WHITE
Definition
term_util.h:24
RED
#define RED
Definition
term_util.h:21
Generated by
1.12.0