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
hook_targets_resolver.cpp
Go to the documentation of this file.
2#include "scanned_modules.h"
3
4#include "scan_report.h"
5#include "code_scanner.h"
6
7using namespace pesieve;
8
10{
11 if (!currPatch) return false;
12
13 const ULONGLONG searchedAddr = currPatch->getHookTargetVA();
14 const ScannedModule* foundMod = processReport.getModuleContaining(searchedAddr);
15 if (!foundMod) return false;
16
18 const peconv::ExportedFunc* expFunc = processReport.exportsMap->find_export_by_va(searchedAddr);
19 if (expFunc) {
20 const std::string targetName = foundMod->getModName() + "." + expFunc->nameToString();
21 currPatch->setHookTargetInfo(foundMod->getStart(), foundMod->isSuspicious(), targetName);
22 return true;
23 }
24 }
25 currPatch->setHookTargetInfo(foundMod->getStart(), foundMod->isSuspicious(), foundMod->getModName());
26 return true;
27}
28
29size_t pesieve::HookTargetResolver::resolveAllHooks(IN OUT std::set<ModuleScanReport*> &code_reports)
30{
31 size_t resolved = 0;
32 std::set<ModuleScanReport*>::iterator cItr;
33 for (cItr = code_reports.begin(); cItr != code_reports.end(); ++cItr) {
34 ModuleScanReport* modrep = *cItr;
35 CodeScanReport *coderep = dynamic_cast<CodeScanReport*>(modrep);
36 if (!coderep) continue;
37
38 std::vector<PatchList::Patch*>::iterator patchItr;
39 for (patchItr = coderep->patchesList.patches.begin();
40 patchItr != coderep->patchesList.patches.end();
41 ++patchItr)
42 {
43 PatchList::Patch* currPatch = *patchItr;
44 if (resolveTarget(currPatch)) {
45 resolved++;
46 }
47 }
48 }
49 return resolved;
50}
A report from the code scan, generated by CodeScanner.
size_t resolveAllHooks(IN OUT std::set< ModuleScanReport * > &code_reports)
Resolves all the hooks collected within the given set of reports.
bool resolveTarget(IN OUT PatchList::Patch *currPatch)
Resolves the information about the target of the provided hook, and fills it back into the object.
A base class of all the reports detailing on the output of the performed module's scan.
bool setHookTargetInfo(ULONGLONG targetModuleBase, bool isSuspiocious, std::string targetModuleName)
Definition patch_list.h:69
ULONGLONG getHookTargetVA()
Definition patch_list.h:64
std::vector< Patch * > patches
Definition patch_list.h:147
peconv::ExportsMapper * exportsMap
Definition scan_report.h:98
ScannedModule * getModuleContaining(ULONGLONG field_addr, size_t field_size=0) const
Definition scan_report.h:85
Represents a basic info about the scanned module, such as its base offset, size, and the status.
std::string getModName() const
ULONGLONG getStart() const