90 if (type >= REPORT_TYPES_COUNT) {
94 std::set<ModuleScanReport*>::iterator itr;
95 for (itr = this->reportsByType[type].begin(); itr != this->reportsByType[type].end(); ++itr) {
106 if (
report ==
nullptr)
return;
109 if (type >= REPORT_TYPES_COUNT) {
112 this->reportsByType[type].insert(
report);
117 if (!hasModule((ULONGLONG)module_base)) {
120 std::set<ModuleScanReport*>::const_iterator itr;
121 for (itr = reportsByType[REPORT_HEADERS_SCAN].begin(); itr != reportsByType[REPORT_HEADERS_SCAN].end(); ++itr) {
124 if (
report->isHdrReplaced()) {
137 std::set<ModuleScanReport*>::iterator itr;
138 for (itr = this->reportsByType[type].begin(); itr != this->reportsByType[type].end(); ++itr) {
142 if (!hdrRep)
continue;
155 summary.pid = this->pid;
156 summary.is_64bit = this->is64bit;
157 summary.is_managed = this->isManaged;
158 summary.is_reflection = this->isReflection;
159 summary.errors =
static_cast<DWORD>(this->errorsCount);
160 summary.skipped =
static_cast<DWORD>(this->reportsByType[REPORT_SKIPPED_SCAN].size());
161 summary.scanned =
static_cast<DWORD>(this->reportsByType[REPORT_HEADERS_SCAN].size());
163 std::vector<ModuleScanReport*>::const_iterator itr = moduleReports.begin();
164 for (; itr != moduleReports.end(); ++itr) {
167 summary.suspicious++;
174 summary.patched =
MASK_TO_DWORD(countSuspiciousPerType(REPORT_CODE_SCAN));
175 summary.iat_hooked =
MASK_TO_DWORD(countSuspiciousPerType(REPORT_IAT_SCAN));
176 summary.implanted_shc =
MASK_TO_DWORD(countSuspiciousPerType(REPORT_MEMPAGE_SCAN) + countSuspiciousPerType(REPORT_THREADS_SCAN));
177 summary.implanted_pe =
MASK_TO_DWORD(countSuspiciousPerType(REPORT_ARTEFACT_SCAN));
178 summary.implanted =
MASK_TO_DWORD(summary.implanted_shc + summary.implanted_pe);
179 summary.hdr_mod =
MASK_TO_DWORD(countSuspiciousPerType(REPORT_HEADERS_SCAN) - summary.replaced);
180 summary.unreachable_file =
MASK_TO_DWORD(countSuspiciousPerType(REPORT_UNREACHABLE_SCAN) + countResultsPerType(REPORT_UNREACHABLE_SCAN,
pesieve::SCAN_ERROR));
181 summary.other =
MASK_TO_DWORD(summary.suspicious - (summary.patched + summary.replaced + summary.implanted + summary.hdr_mod + summary.iat_hooked));
187 std::stringstream stream;
190 bool is_first =
true;
191 std::vector<ModuleScanReport*>::const_iterator itr;
192 for (itr = this->moduleReports.begin(); itr != this->moduleReports.end(); ++itr) {
199 mod->
toJSON(stream, level + 2, jdetails);
205 if (moduleReports.size()) {
213 std::stringstream &stream,
size_t start_level,
214 const pesieve::t_results_filter &filter,
220 size_t level = start_level + 1;
224 stream << std::dec <<
report.
pid <<
",\n";
225 OUT_PADDED(stream, level,
"\"is_64_bit\" : ");
227 OUT_PADDED(stream, level,
"\"is_managed\" : ");
229 OUT_PADDED(stream, level,
"\"main_image_path\" : \"");
231 OUT_PADDED(stream, level,
"\"used_reflection\" : ");
233 OUT_PADDED(stream, level,
"\"scanner_version\" : ");
235 OUT_PADDED(stream, level,
"\"scanned\" : \n");
238 OUT_PADDED(stream, level + 1,
"\"total\" : ");
240 OUT_PADDED(stream, level + 1,
"\"skipped\" : ");
242 OUT_PADDED(stream, level + 1,
"\"modified\" : \n");
245 OUT_PADDED(stream, level + 2,
"\"total\" : ");
247 OUT_PADDED(stream, level + 2,
"\"patched\" : ");
249 OUT_PADDED(stream, level + 2,
"\"iat_hooked\" : ");
251 OUT_PADDED(stream, level + 2,
"\"replaced\" : ");
253 OUT_PADDED(stream, level + 2,
"\"hdr_modified\" : ");
255 OUT_PADDED(stream, level + 2,
"\"implanted_pe\" : ");
257 OUT_PADDED(stream, level + 2,
"\"implanted_shc\" : ");
259 OUT_PADDED(stream, level + 2,
"\"unreachable_file\" : ");
261 OUT_PADDED(stream, level + 2,
"\"other\" : ");
262 stream << std::dec << other <<
"\n";
264 OUT_PADDED(stream, level + 1,
"\"errors\" : ");
267 stream << listModules(level, filter, jdetails);
A report from the artefacts scan, generated by ArtefactScanner.
A report from the code scan, generated by CodeScanner.
A report from an IAT scan, generated by IATScanner.
A base class of all the reports detailing on the output of the performed module's scan.
virtual const bool toJSON(std::stringstream &outs, size_t level=JSON_LEVEL, const pesieve::t_json_level &jdetails=JSON_BASIC)=0
static t_scan_status get_scan_status(const ModuleScanReport *report)
size_t countResultsPerType(const t_report_type type, const t_scan_status result) const
virtual const bool toJSON(std::stringstream &stream, size_t level, const t_results_filter &filter, const pesieve::t_json_level &jdetails) const
bool isModuleReplaced(HMODULE module_base)
pesieve::t_report generateSummary() const
std::string listModules(size_t level, const t_results_filter &filter, const t_json_level &jdetails) const
@ REPORT_UNREACHABLE_SCAN
static t_report_type getReportType(ModuleScanReport *report)
size_t countHdrsReplaced() const
bool hasAnyShownType(const t_results_filter &filter)
void appendToType(ModuleScanReport *report)
A report from the thread scan, generated by ThreadScanner.
A report from the working set scan, generated by WorkingSetScanner.
#define MASK_TO_DWORD(val)
DWORD(__stdcall *_PssCaptureSnapshot)(HANDLE ProcessHandle
std::string escape_path_separators(std::string path)
enum pesieve::module_scan_status t_scan_status
bool is_shown_type(t_scan_status status, t_results_filter filter)
#define PESIEVE_VERSION_STR
Final summary about the scanned process.
DWORD errors
the number of elements that could not be scanned because of errors. If errors == ERROR_SCAN_FAILURE,...
DWORD implanted_shc
implanted shellcodes
bool is_reflection
was the scan performed on process reflection
DWORD scanned
number of all scanned modules
DWORD patched
detected modifications in the code
DWORD suspicious
general summary of suspicious
bool is_64bit
is process 64 bit
DWORD iat_hooked
detected IAT hooks
DWORD hdr_mod
PE header is modified (but not replaced)
DWORD unreachable_file
cannot read the file corresponding to the module in memory
DWORD implanted_pe
the full PE was probably loaded manually
DWORD skipped
some of the modules must be skipped (i.e. dotNET managed code have different characteristics and this...
DWORD replaced
PE file replaced in memory (probably hollowed)
bool is_managed
is process managed (.NET)
DWORD other
other indicators
DWORD pid
pid of the process that was scanned