13#define OUT_PADDED(stream, field_size, str) \
15if (field_size) stream << std::setw(field_size) << ' '; \
23 if (scan_report.suspicious) {
26 if (scan_report.errors == pesieve::ERROR_SCAN_FAILURE) {
27 this->
failed.push_back(scan_report.pid);
34 if (rfilter == pesieve::SHOW_NONE) {
45 const size_t max_len = size_t(std::floor(std::log10(
double(scannedCount))) + 1) % 100;
47 bool isFailed =
false;
48 DWORD pid = itr->first;
49 pesieve::t_report rep = itr->second;
50 if ((rfilter & pesieve::SHOW_SUSPICIOUS) == 0) {
51 if (rep.suspicious)
continue;
53 if ((rfilter & pesieve::SHOW_NOT_SUSPICIOUS) == 0) {
54 if (!rep.suspicious)
continue;
56 if (rep.errors == pesieve::ERROR_SCAN_FAILURE) {
60 if (isFailed && ((rfilter & pesieve::SHOW_ERRORS) == 0)) {
63 stream << L
"[" << std::setw(max_len) << counter++ << L
"]: PID: " << std::dec << pid << L
", ";
64 stream << L
"Name: " << this->
pidToName[pid];
66 stream << L
" : FAILED";
76 std::vector<DWORD>::const_iterator itr;
77 OUT_PADDED(stream, level, L
"\"suspicious\" : [\n");
86 stream << std::dec << pid << L
",\n";
87 OUT_PADDED(stream, level, L
"\"is_managed\" : ");
88 stream << std::dec <<
pidToReport[pid].is_managed << L
",\n";
90 stream << L
"\"" << this->
pidToName[pid] << L
"\",\n";
92 stream << std::dec <<
pidToReport[pid].replaced << L
",\n";
93 OUT_PADDED(stream, level, L
"\"hdr_modified\" : ");
94 stream << std::dec <<
pidToReport[pid].hdr_mod << L
",\n";
97 stream << std::dec <<
pidToReport[pid].patched << L
",\n";
100 OUT_PADDED(stream, level, L
"\"iat_hooked\" : ");
101 stream << std::dec <<
pidToReport[pid].iat_hooked << L
",\n";
103 OUT_PADDED(stream, level, L
"\"implanted_pe\" : ");
104 stream << std::dec <<
pidToReport[pid].implanted_pe << L
",\n";
105 OUT_PADDED(stream, level, L
"\"implanted_shc\" : ");
106 stream << std::dec <<
pidToReport[pid].implanted_shc << L
",\n";
107 OUT_PADDED(stream, level, L
"\"unreachable_file\" : ");
108 stream << std::dec <<
pidToReport[pid].unreachable_file << L
",\n";
110 stream << std::dec <<
pidToReport[pid].other << L
"\n";
130 const size_t suspicious_count =
countReports(pesieve::SHOW_SUSPICIOUS);
131 size_t all_count = 0;
132 OUT_PADDED(stream, level, L
"\"scan_date_time\" : ");
134 OUT_PADDED(stream, level, L
"\"scan_timestamp\" : ");
135 stream << std::dec <<
startTime << L
",\n";
136 OUT_PADDED(stream, level, L
"\"scan_time_ms\" : ");
138 OUT_PADDED(stream, level, L
"\"scanned_count\" : ");
139 stream << std::dec <<
countTotal(
true) << L
",\n";
140 OUT_PADDED(stream, level, L
"\"failed_count\" : ");
141 stream << std::dec <<
countReports(pesieve::SHOW_ERRORS) << L
",\n";
142 OUT_PADDED(stream, level, L
"\"suspicious_count\" : ");
143 stream << std::dec << suspicious_count;
144 if (suspicious_count > 0) {
156template<
class STR_STREAM>
159 float seconds = ((float)timeInMs / 1000);
160 float minutes = ((float)timeInMs / 60000);
161 stream << std::dec << timeInMs << L
" ms.";
163 stream << L
" = " << seconds << L
" sec.";
166 stream << L
" = " << minutes << L
" min.";
173 stream << L
"--------" << std::endl;
174 stream << L
"SUMMARY:\n";
176 stream << L
"Finished scan in: ";
179 const size_t scannedCount =
countReports(pesieve::SHOW_SUCCESSFUL_ONLY);
180 stream << L
"[*] Total scanned: " << std::dec << scannedCount << L
"\n";
181 if ((rfilter & pesieve::SHOW_NOT_SUSPICIOUS) && scannedCount > 0) {
182 stream << L
"[+] List of scanned: \n";
185 if (rfilter & pesieve::SHOW_SUSPICIOUS) {
186 const size_t count =
countReports(pesieve::SHOW_SUSPICIOUS);
187 stream << L
"[*] Total suspicious: " << std::dec << count << L
"\n";
189 stream << L
"[+] List of suspicious: \n";
193 if (rfilter & pesieve::SHOW_ERRORS) {
194 const size_t count =
countReports(pesieve::SHOW_ERRORS);
195 stream << L
"[*] Total failed: " << std::dec << count << L
"\n";
bool appendReport(pesieve::t_report &scan_report, const std::wstring &img_name)
std::map< DWORD, std::wstring > pidToName
void toString(std::wstringstream &stream, const pesieve::t_results_filter rfilter)
std::map< DWORD, pesieve::t_report > pidToReport
size_t reportsToJSON(std::wstringstream &stream, size_t level, const t_hh_params ¶ms)
std::vector< DWORD > suspicious
size_t countReports(const pesieve::t_results_filter rfilter) const
size_t countTotal(bool successfulOnly=true) const
DWORD getScanTime() const
size_t reportsToString(std::wstringstream &stream, const pesieve::t_results_filter rfilter)
size_t toJSON(std::wstringstream &stream, const t_hh_params ¶ms)
std::vector< DWORD > failed
void print_scantime(STR_STREAM &stream, size_t timeInMs)
#define OUT_PADDED(stream, field_size, str)
std::wstring strtime(const time_t t)
pesieve::t_params pesieve_args