PE-sieve
Scans all running processes. Recognizes and dumps a variety of potentially malicious implants (replaced/implanted PEs, shellcodes, hooks, in-memory patches).
Toggle main menu visibility
Loading...
Searching...
No Matches
postprocessors
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
"
12
#include "
../utils/path_converter.h
"
13
14
namespace
pesieve
{
15
16
class
ModuleDumpReport
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
;
33
bool
is_corrupt_pe
;
34
bool
is_shellcode
;
35
std::string
impRecMode
;
36
bool
isReportDumped
;
37
bool
isDumped
;
38
std::string
mode_info
;
39
std::string
dumpFileName
;
40
std::string
hooksTagFileName
;
41
std::string
patternsTagFileName
;
42
std::string
impListFileName
;
43
std::string
notRecoveredFileName
;
44
std::string
iatHooksFileName
;
45
};
46
48
class
ProcessDumpReport
49
{
50
public
:
51
ProcessDumpReport
(DWORD _pid)
52
:
pid
(_pid)
53
{
54
}
55
56
~ProcessDumpReport
()
57
{
58
deleteModuleReports
();
59
}
60
61
void
appendReport
(
ModuleDumpReport
*
report
)
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
117
void
deleteModuleReports
()
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
pesieve::ModuleDumpReport
Definition
dump_report.h:17
pesieve::ModuleDumpReport::moduleSize
size_t moduleSize
Definition
dump_report.h:31
pesieve::ModuleDumpReport::rebasedTo
ULONGLONG rebasedTo
Definition
dump_report.h:32
pesieve::ModuleDumpReport::isDumped
bool isDumped
Definition
dump_report.h:37
pesieve::ModuleDumpReport::moduleStart
ULONGLONG moduleStart
Definition
dump_report.h:30
pesieve::ModuleDumpReport::mode_info
std::string mode_info
Definition
dump_report.h:38
pesieve::ModuleDumpReport::notRecoveredFileName
std::string notRecoveredFileName
Definition
dump_report.h:43
pesieve::ModuleDumpReport::toJSON
virtual const bool toJSON(std::stringstream &outs, size_t level)
Definition
dump_report.cpp:7
pesieve::ModuleDumpReport::hooksTagFileName
std::string hooksTagFileName
Definition
dump_report.h:40
pesieve::ModuleDumpReport::is_shellcode
bool is_shellcode
Definition
dump_report.h:34
pesieve::ModuleDumpReport::is_corrupt_pe
bool is_corrupt_pe
Definition
dump_report.h:33
pesieve::ModuleDumpReport::isReportDumped
bool isReportDumped
Definition
dump_report.h:36
pesieve::ModuleDumpReport::dumpFileName
std::string dumpFileName
Definition
dump_report.h:39
pesieve::ModuleDumpReport::iatHooksFileName
std::string iatHooksFileName
Definition
dump_report.h:44
pesieve::ModuleDumpReport::impListFileName
std::string impListFileName
Definition
dump_report.h:42
pesieve::ModuleDumpReport::ModuleDumpReport
ModuleDumpReport(ULONGLONG module_start, size_t module_size)
Definition
dump_report.h:20
pesieve::ModuleDumpReport::patternsTagFileName
std::string patternsTagFileName
Definition
dump_report.h:41
pesieve::ModuleDumpReport::impRecMode
std::string impRecMode
Definition
dump_report.h:35
pesieve::ProcessDumpReport::toJSON
virtual bool toJSON(std::stringstream &stream, size_t level) const
Definition
dump_report.cpp:63
pesieve::ProcessDumpReport::deleteModuleReports
void deleteModuleReports()
Definition
dump_report.h:117
pesieve::ProcessDumpReport::ResultsDumper
friend class ResultsDumper
Definition
dump_report.h:130
pesieve::ProcessDumpReport::moduleReports
std::vector< ModuleDumpReport * > moduleReports
Definition
dump_report.h:128
pesieve::ProcessDumpReport::pid
DWORD pid
Definition
dump_report.h:127
pesieve::ProcessDumpReport::hasModule
bool hasModule(const ULONGLONG modBase, const size_t modSize) const
Definition
dump_report.h:92
pesieve::ProcessDumpReport::list_dumped_modules
std::string list_dumped_modules(size_t level) const
Definition
dump_report.cpp:93
pesieve::ProcessDumpReport::~ProcessDumpReport
~ProcessDumpReport()
Definition
dump_report.h:56
pesieve::ProcessDumpReport::getPid
DWORD getPid() const
Definition
dump_report.h:108
pesieve::ProcessDumpReport::isFilled
bool isFilled() const
Definition
dump_report.h:72
pesieve::ProcessDumpReport::countTotal
size_t countTotal() const
Definition
dump_report.h:67
pesieve::ProcessDumpReport::outputDir
std::string outputDir
Definition
dump_report.h:110
pesieve::ProcessDumpReport::countDumped
size_t countDumped() const
Definition
dump_report.h:79
pesieve::ProcessDumpReport::ProcessDumpReport
ProcessDumpReport(DWORD _pid)
Definition
dump_report.h:51
pesieve::ProcessDumpReport::appendReport
void appendReport(ModuleDumpReport *report)
Definition
dump_report.h:61
pesieve::ProcessDumpReport::minidumpPath
std::string minidumpPath
Definition
dump_report.h:111
pesieve
Definition
pesieve.py:1
path_converter.h
path_util.h
report
Final summary about the scanned process.
Definition
pe_sieve_types.h:151
Generated by
1.17.0