PE-sieve
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
dump_report.h
Go to the documentation of this file.
1#pragma once
2
3#include <windows.h>
4
5#include <iostream>
6#include <sstream>
7#include <string>
8#include <vector>
9
10#include <peconv.h>
11#include "../utils/path_util.h"
13
14namespace pesieve {
15
17 {
18 public:
19
20 ModuleDumpReport(ULONGLONG module_start, size_t module_size)
21 : moduleStart(module_start), moduleSize(module_size), rebasedTo(module_start),
22 isDumped(false), isReportDumped(false),
23 is_corrupt_pe(false),
24 is_shellcode(false)
25 {
26 }
27
28 const virtual bool toJSON(std::stringstream &outs, size_t level);
29
30 ULONGLONG moduleStart;
31 size_t moduleSize;
32 ULONGLONG rebasedTo;
35 std::string impRecMode;
38 std::string mode_info;
39 std::string dumpFileName;
40 std::string hooksTagFileName;
42 std::string impListFileName;
44 std::string iatHooksFileName;
45 };
46
49 {
50 public:
52 : pid(_pid)
53 {
54 }
55
60
62 {
63 if (!report) return;
64 moduleReports.push_back(report);
65 }
66
67 size_t countTotal() const
68 {
69 return moduleReports.size();
70 }
71
72 bool isFilled() const
73 {
74 if (countTotal()) return true;
75 if (this->minidumpPath.length()) return true;
76 return false;
77 }
78
79 size_t countDumped() const
80 {
81 size_t dumped = 0;
82 std::vector<ModuleDumpReport*>::const_iterator itr = moduleReports.begin();
83 for (; itr != moduleReports.end(); ++itr) {
84 ModuleDumpReport* module = *itr;
85 if (module->isDumped) {
86 dumped++;
87 }
88 }
89 return dumped;
90 }
91
92 bool hasModule(const ULONGLONG modBase, const size_t modSize) const
93 {
94 if (!modBase) return false;
95
96 for (auto itr = moduleReports.begin(); itr != moduleReports.end(); ++itr) {
97 const ModuleDumpReport* report = *itr;
98 if (!report->isDumped) continue; // dumping failed
99 if (report->moduleStart == modBase && report->moduleSize == modSize) {
100 return true;
101 }
102 }
103 return false;
104 }
105
106 virtual bool toJSON(std::stringstream &stream, size_t level) const;
107
108 DWORD getPid() const { return pid; }
109
110 std::string outputDir;
111 std::string minidumpPath;
112
113 protected:
114
115 std::string list_dumped_modules(size_t level) const;
116
118 {
119 std::vector<ModuleDumpReport*>::iterator itr = moduleReports.begin();
120 for (; itr != moduleReports.end(); ++itr) {
121 ModuleDumpReport* module = *itr;
122 delete module;
123 }
124 moduleReports.clear();
125 }
126
127 DWORD pid;
128 std::vector<ModuleDumpReport*> moduleReports;
129
130 friend class ResultsDumper;
131 };
132
133};
134
std::string notRecoveredFileName
Definition dump_report.h:43
virtual const bool toJSON(std::stringstream &outs, size_t level)
ModuleDumpReport(ULONGLONG module_start, size_t module_size)
Definition dump_report.h:20
std::string patternsTagFileName
Definition dump_report.h:41
The report aggregating the results of the performed dumps.
Definition dump_report.h:49
virtual bool toJSON(std::stringstream &stream, size_t level) const
std::vector< ModuleDumpReport * > moduleReports
bool hasModule(const ULONGLONG modBase, const size_t modSize) const
Definition dump_report.h:92
std::string list_dumped_modules(size_t level) const
size_t countTotal() const
Definition dump_report.h:67
size_t countDumped() const
Definition dump_report.h:79
void appendReport(ModuleDumpReport *report)
Definition dump_report.h:61
Final summary about the scanned process.