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
23#include "util/strings_util.h"
24#include "hh_ver_short.h"
25
26using namespace hhunter::util;
27
28// Global arguments
30
31#ifdef USE_ETW
32#include "etw_listener.h"
33#endif
34
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
40t_pesieve_res deploy_scan()
41{
42 t_pesieve_res scan_res = PESIEVE_NOT_DETECTED;
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 }
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 {
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 }
80 }
81 } while (g_hh_args.loop_scanning);
82 }
83 return scan_res;
84}
85
86int main(int argc, char *argv[])
87{
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
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}
void freeStruct(t_hh_params &ps)
Definition params.h:479
void fillStruct(t_hh_params &ps)
Definition params.h:424
size_t countReports(const pesieve::t_results_filter rfilter) const
Definition hh_report.h:39
static bool isScannerCompatibile()
#define HH_VERSION_STR
Definition hh_ver_short.h:8
int main(int argc, char *argv[])
Definition main.cpp:86
t_hh_params g_hh_args
Definition main.cpp:29
t_pesieve_res deploy_scan()
Definition main.cpp:40
void compatibility_alert()
Definition main.cpp:35
void print_version(const std::string &version, WORD info_color=HILIGHTED_COLOR)
Definition params.h:68
bool isEnabled()
bool initProfile(const std::string &fileName)
void init()
Definition hh_params.cpp:3
pesieve::t_params pesieve_args
Definition hh_params.h:36
bool etw_scan
Definition hh_params.h:25
bool loop_scanning
Definition hh_params.h:24
void print_in_color(WORD color, const std::string &text)
Definition term_util.cpp:33
#define WHITE
Definition term_util.h:24
#define RED
Definition term_util.h:21