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
report_formatter.cpp
Go to the documentation of this file.
1#include "report_formatter.h"
2#include <string>
3#include <sstream>
4
5using namespace pesieve;
6
8{
9 const t_report report = process_report.generateSummary();
10 std::stringstream stream;
11 //summary:
12 size_t other = report.other;
13 stream << "---" << std::endl;
14 stream << "PID: " << std::dec << report.pid << "\n";
15 stream << "---" << std::endl;
16 stream << "SUMMARY: \n" << std::endl;
17 stream << "Total scanned: " << std::dec << report.scanned << "\n";
18 stream << "Skipped: " << std::dec << report.skipped << "\n";
19 stream << "-\n";
20 stream << "Hooked: " << std::dec << report.patched << "\n";
21 stream << "Replaced: " << std::dec << report.replaced << "\n";
22 stream << "Hdrs Modified: " << std::dec << report.hdr_mod << "\n";
23 stream << "IAT Hooks: " << std::dec << report.iat_hooked << "\n";
24 stream << "Implanted: " << std::dec << report.implanted << "\n";
25 if (report.implanted) {
26 stream << "Implanted PE: " << std::dec << report.implanted_pe << "\n";
27 stream << "Implanted shc: " << std::dec << report.implanted_shc << "\n";
28 }
29 stream << "Unreachable files: " << std::dec << report.unreachable_file << "\n";
30 stream << "Other: " << std::dec << other << "\n";
31 stream << "-\n";
32 stream << "Total suspicious: " << std::dec << report.suspicious << "\n";
33 if (report.errors) {
34 stream << "[!] Errors: " << std::dec << report.errors << "\n";
35 }
36 return stream.str();
37}
38
43 size_t start_level
44)
45{
46 //summary:
47 std::stringstream stream;
48
50 return "";
51 }
52 std::string report_all = stream.str();
53 if (report_all.length() == 0) {
54 return "";
55 }
56 return report_all;
57}
58
62 size_t start_level
63)
64{
65 //summary:
66 std::stringstream stream;
67
68 if (!process_report.toJSON(stream, start_level)) {
69 return "";
70 }
71 std::string report_all = stream.str();
72 if (report_all.length() == 0) {
73 return "";
74 }
75 return report_all;
76}
77
79{
80 if (!report.scan_report || rtype == REPORT_NONE) return 0;
81
82 size_t level = 1;
83 std::stringstream stream;
84 const bool has_dumps = (report.dump_report && report.dump_report->countDumped() > 0) ? true : false;
85 stream << "{\n";
86 if (rtype == REPORT_ALL || rtype == REPORT_SCANNED) {
87 OUT_PADDED(stream, level, "\"scan_report\" :\n");
89 if (rtype == REPORT_ALL && has_dumps) {
90 stream << ",";
91 }
92 stream << "\n";
93 }
94 if (rtype == REPORT_ALL || rtype == REPORT_DUMPED) {
95 if (has_dumps || rtype == REPORT_DUMPED) { // do not output an empty report, unless requested specifically
96 OUT_PADDED(stream, level, "\"dump_report\" :\n");
98 stream << "\n";
99 }
100 }
101 stream << "}\n";
102 return stream.str();
103}
The report aggregating the results of the performed dumps.
Definition dump_report.h:48
The report aggregating the results of the performed scan.
Definition scan_report.h:19
The final report about the actions performed on the process: scanning and dumping.
#define OUT_PADDED(stream, field_size, str)
Definition format_util.h:12
std::string scan_report_to_string(const ProcessScanReport &report)
std::string dump_report_to_json(const ProcessDumpReport &process_report, const pesieve::t_json_level &jdetails, size_t start_level=0)
size_t fill_iat(BYTE *vBuf, size_t vBufSize, IN const peconv::ExportsMapper *exportsMap, IN OUT IATBlock &iat, IN ThunkFoundCallback *callback)
Definition iat_finder.h:31
std::string scan_report_to_json(const ProcessScanReport &process_report, ProcessScanReport::t_report_filter filter, const pesieve::t_json_level &jdetails, size_t start_level=0)
std::string report_to_json(const pesieve::ReportEx &report, const t_report_type rtype, ProcessScanReport::t_report_filter filter, const pesieve::t_json_level &jdetails, size_t start_level=0)
@ REPORT_ALL
output all available reports
@ REPORT_DUMPED
output the dumps report
@ REPORT_NONE
do not output a report
@ REPORT_SCANNED
output the scan report
Final summary about the scanned process.
DWORD implanted
all implants: shellcodes + PEs
DWORD errors
the number of elements that could not be scanned because of errors. If errors == ERROR_SCAN_FAILURE,...
DWORD implanted_shc
implanted shellcodes
DWORD scanned
number of all scanned modules
DWORD patched
detected modifications in the code
DWORD suspicious
general summary of suspicious
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)
DWORD other
other indicators
DWORD pid
pid of the process that was scanned