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
patch_analyzer.h
Go to the documentation of this file.
1#pragma once
2
3#include "module_data.h"
4#include "patch_list.h"
5
6namespace pesieve {
7
10 {
11 public:
12 typedef enum {
14 OP_JMP = 0xE9,
20
21 PatchAnalyzer(ModuleData &_moduleData, DWORD _sectionRVA, PBYTE patched_code, size_t code_size)
22 : moduleData(_moduleData), sectionRVA(_sectionRVA), patchedCode(patched_code), codeSize(code_size)
23 {
26 }
27
28 size_t analyzeHook(PatchList::Patch &patch);
29
30 size_t analyzeOther(PatchList::Patch& patch);
31
32 protected:
33 size_t _analyzeHook(PatchList::Patch &patch, PBYTE patch_ptr, ULONGLONG patch_va);
34 size_t _analyzeRelocated(PatchList::Patch &patch, BYTE* patch_ptr);
35
36 size_t parseJmpViaAddr(PatchList::Patch &patch, PBYTE patch_ptr, ULONGLONG patch_va);
37 size_t parseShortJmp(PatchList::Patch &patch, PBYTE patch_ptr, ULONGLONG patch_va);
38 size_t parseJmp(PatchList::Patch &patch, PBYTE patch_ptr, ULONGLONG patch_va);
39 size_t parseMovJmp(PatchList::Patch &patch, PBYTE patch_ptr, bool is_long);
40 size_t parsePushRet(PatchList::Patch &patch, PBYTE patch_ptr);
41
42 template <typename DELTA_T>
43 ULONGLONG getJmpDestAddr(ULONGLONG currVA, int instrLen, DELTA_T lVal);
44
45 bool is64Modifier(BYTE op);
46 bool isLongModifier(BYTE op);
47
49
53 size_t codeSize;
54
55 std::set<DWORD> relocs;
56 };
57
58}; //namespace pesieve
59
Loads a module from the disk, corresponding to the module in the scanned process' memory.
Definition module_data.h:15
bool loadRelocatedFields(std::set< DWORD > &fields_rvas)
A postprocessor of the detected code patches. Detects if the patch is a hook, and if so,...
size_t _analyzeHook(PatchList::Patch &patch, PBYTE patch_ptr, ULONGLONG patch_va)
size_t parseShortJmp(PatchList::Patch &patch, PBYTE patch_ptr, ULONGLONG patch_va)
size_t _analyzeRelocated(PatchList::Patch &patch, BYTE *patch_ptr)
PatchAnalyzer(ModuleData &_moduleData, DWORD _sectionRVA, PBYTE patched_code, size_t code_size)
std::set< DWORD > relocs
size_t analyzeOther(PatchList::Patch &patch)
size_t parseJmpViaAddr(PatchList::Patch &patch, PBYTE patch_ptr, ULONGLONG patch_va)
size_t parseJmp(PatchList::Patch &patch, PBYTE patch_ptr, ULONGLONG patch_va)
ULONGLONG getJmpDestAddr(ULONGLONG currVA, int instrLen, DELTA_T lVal)
size_t parseMovJmp(PatchList::Patch &patch, PBYTE patch_ptr, bool is_long)
size_t parsePushRet(PatchList::Patch &patch, PBYTE patch_ptr)
size_t analyzeHook(PatchList::Patch &patch)