PE-sieve
Scans all running processes. Recognizes and dumps a variety of potentially malicious implants (replaced/implanted PEs, shellcodes, hooks, in-memory patches).
|
Classes | |
struct | _mem_region_info |
struct | _thread_info |
struct | _thread_info_ext |
struct | _THREAD_LAST_SYSCALL_INFORMATION |
struct | AutoBuffer |
struct | BasicBuffer |
struct | ByteBuffer |
struct | Mutex |
struct | MutexLocker |
struct | PSS_VA_CLONE_INFORMATION |
struct | T_CLIENT_ID |
struct | t_refl_args |
struct | T_RTLP_PROCESS_REFLECTION_REFLECTION_INFORMATION |
Typedefs | |
typedef struct pesieve::util::_THREAD_LAST_SYSCALL_INFORMATION | THREAD_LAST_SYSCALL_INFORMATION |
typedef struct pesieve::util::_THREAD_LAST_SYSCALL_INFORMATION * | PTHREAD_LAST_SYSCALL_INFORMATION |
typedef struct pesieve::util::_thread_info_ext | thread_info_ext |
typedef struct pesieve::util::_thread_info | thread_info |
typedef struct pesieve::util::_mem_region_info | mem_region_info |
Functions | |
size_t | calc_offset (MemPageData &memPage, LPVOID field) |
size_t | calc_sec_hdrs_offset (MemPageData &memPage, IMAGE_FILE_HEADER *nt_file_hdr) |
size_t | calc_nt_hdr_offset (MemPageData &memPage, IMAGE_SECTION_HEADER *first_sec, bool is64bit=true) |
bool | validate_hdrs_alignment (MemPageData &memPage, IMAGE_FILE_HEADER *nt_file_hdr, IMAGE_SECTION_HEADER *_sec_hdr) |
size_t | count_section_hdrs (BYTE *loadedData, size_t loadedSize, IMAGE_SECTION_HEADER *hdr_ptr) |
IMAGE_SECTION_HEADER * | get_first_section (BYTE *loadedData, size_t loadedSize, IMAGE_SECTION_HEADER *hdr_ptr) |
void | print_scantime (std::stringstream &stream, size_t timeInMs) |
BYTE * | find_pattern (BYTE *buffer, size_t buf_size, BYTE *pattern_buf, size_t pattern_size, size_t max_iter=0) |
size_t | is_32bit_code (BYTE *loadedData, size_t loadedSize) |
size_t | is_64bit_code (BYTE *loadedData, size_t loadedSize) |
bool | is_code (BYTE *loadedData, size_t loadedSize) |
bool | is_executable (DWORD mapping_type, DWORD protection) |
bool | is_readable (DWORD mapping_type, DWORD protection) |
bool | is_normal_inaccessible (DWORD state, DWORD mapping_type, DWORD protection) |
bool | get_current_color (int descriptor, WORD &color) |
void | print_in_color (int color, const std::string &text, bool is_error=false) |
bool | is_hex (const char *buf, size_t len) |
bool | is_dec (const char *buf, size_t len) |
std::string & | ltrim (std::string &str, const std::string &chars="\t\n\v\f\r ") |
std::string & | rtrim (std::string &str, const std::string &chars="\t\n\v\f\r ") |
std::string & | trim (std::string &str, const std::string &chars="\t\n\v\f\r ") |
long | get_number (const char *buf) |
bool | is_number (const char *buf) |
bool | is_in_list (std::string searched_string, std::set< std::string > &string_list, bool to_lower=true) |
size_t | string_to_list (IN::std::string s, IN char _delim, OUT std::set< std::string > &elements_list, bool to_lower=true) |
size_t | enum_modules (IN HANDLE hProcess, IN OUT HMODULE hMods[], IN const DWORD hModsMax, IN DWORD filters) |
void | init_syspaths () |
HANDLE | nt_create_file (PCWSTR filePath) |
std::string | nt_retrieve_file_path (HANDLE hFile) |
bool | is_relative (const char *path, size_t path_len) |
bool | is_disk_relative (const char *path, size_t path_len) |
std::string | remap_to_drive_letter (const std::string &full_path) |
std::string | relative_to_absolute_path (std::string path) |
std::string | replace_char (std::string &str, char ch1, char ch2) |
bool | convert_to_wow64_path (char *szModName) |
std::string | convert_to_win32_path (const std::string &path) |
std::string | device_path_to_win32_path (const std::string &full_path) |
std::string | expand_path (const std::string &path) |
char * | get_subpath_ptr (char *modulePath, char *searchedPath) |
std::string | escape_path_separators (std::string path) |
std::string | get_system_drive () |
bool | dir_exists (const char *path) |
bool | create_dir_recursively (const std::string &path) |
std::string | strip_prefix (std::string path, std::string prefix) |
BOOL (CALLBACK *_MiniDumpWriteDump)(HANDLE hProcess | |
bool | load_MiniDumpWriteDump () |
bool | make_minidump (DWORD pid, const std::string &out_file) |
HMODULE | get_or_load_module (const char *name) |
BOOL | set_privilege (HANDLE hToken, LPCTSTR Privilege, BOOL bEnablePrivilege) |
BOOL | _get_process_DEP_policy (HANDLE processHandle, DWORD &flags, BOOL &is_permanent) |
DEP_SYSTEM_POLICY_TYPE | _get_system_DEP_policy () |
bool | set_debug_privilege () |
process_integrity_t | get_integrity_level (HANDLE hProcess) |
bool | is_DEP_enabled (HANDLE hProcess) |
NTSTATUS (NTAPI *_RtlCreateProcessReflection)(HANDLE ProcessHandle | |
DWORD (__stdcall *_PssCaptureSnapshot)(HANDLE ProcessHandle | |
bool | load_PssCaptureFreeSnapshot () |
bool | load_RtlCreateProcessReflection () |
DWORD WINAPI | refl_creator (LPVOID lpParam) |
HANDLE | make_process_reflection1 (HANDLE orig_hndl) |
HPSS | make_process_snapshot (HANDLE orig_hndl) |
bool | release_process_snapshot (HANDLE procHndl, HPSS snapshot) |
HANDLE | make_process_reflection2 (HPSS snapshot) |
bool | can_make_process_reflection () |
HANDLE | make_process_reflection (HANDLE orig_hndl) |
bool | release_process_reflection (HANDLE *reflection_hndl) |
BOOL (WINAPI *g_IsWow64Process)(IN HANDLE = nullptr | |
HMODULE | get_kernel32_hndl () |
BOOL | is_process_wow64 (IN HANDLE processHandle, OUT BOOL *isProcWow64) |
bool | is_process_64bit (IN HANDLE process) |
bool | is_current_wow64 () |
BOOL | wow64_disable_fs_redirection (OUT PVOID *OldValue) |
BOOL | wow64_revert_fs_redirection (IN PVOID OldValue) |
BOOL | wow64_get_thread_context (IN HANDLE hThread, IN OUT PWOW64_CONTEXT lpContext) |
std::string | to_lowercase (std::string) |
bool | is_cstr_equal (char const *a, char const *b, const size_t max_len) |
bool | isSyscallFunc (const std::string &funcName) |
size_t | extract_syscalls (BYTE *pe_buf, size_t pe_size, std::map< DWORD, std::string > &syscallToName, size_t startID=0) |
size_t | extract_from_dll (IN const std::string &path, size_t startSyscallID, OUT std::map< DWORD, std::string > &syscallToName) |
size_t | extract_syscall_table (OUT std::map< DWORD, std::string > &syscallToName) |
bool | query_thread_details (IN DWORD tid, OUT pesieve::util::thread_info &info) |
bool | query_threads_details (IN OUT std::map< DWORD, thread_info > &threads_info) |
bool | fetch_threads_info (IN DWORD pid, OUT std::map< DWORD, thread_info > &threads_info) |
bool | fetch_threads_by_snapshot (IN DWORD pid, OUT std::map< DWORD, thread_info > &threads_info) |
bool | get_next_commited_region (HANDLE processHandle, ULONGLONG start_va, MEMORY_BASIC_INFORMATION &page_info) |
size_t | enum_workingset (HANDLE processHandle, std::set< mem_region_info > ®ions) |
DWORD | count_workingset_entries (HANDLE processHandle) |
Variables | |
DWORD | ProcessId |
DWORD HANDLE | hFile |
DWORD HANDLE MINIDUMP_TYPE | DumpType |
DWORD HANDLE MINIDUMP_TYPE PMINIDUMP_EXCEPTION_INFORMATION | ExceptionParam |
DWORD HANDLE MINIDUMP_TYPE PMINIDUMP_EXCEPTION_INFORMATION PMINIDUMP_USER_STREAM_INFORMATION | UserStreamParam |
DWORD HANDLE MINIDUMP_TYPE PMINIDUMP_EXCEPTION_INFORMATION PMINIDUMP_USER_STREAM_INFORMATION PMINIDUMP_CALLBACK_INFORMATION | CallbackParam = NULL |
ULONG | Flags |
ULONG PVOID | StartRoutine |
ULONG PVOID PVOID | StartContext |
ULONG PVOID PVOID HANDLE | EventHandle |
ULONG PVOID PVOID HANDLE T_RTLP_PROCESS_REFLECTION_REFLECTION_INFORMATION * | ReflectionInformation = NULL |
PSS_CAPTURE_FLAGS | CaptureFlags |
PSS_CAPTURE_FLAGS DWORD | ThreadContextFlags |
PSS_CAPTURE_FLAGS DWORD HPSS * | SnapshotHandle = NULL |
PSS_QUERY_INFORMATION_CLASS | InformationClass |
PSS_QUERY_INFORMATION_CLASS void * | Buffer |
PSS_QUERY_INFORMATION_CLASS void DWORD | BufferLength = NULL |
const DWORD | reflection_access1 = PROCESS_CREATE_THREAD | PROCESS_VM_OPERATION | PROCESS_DUP_HANDLE |
const DWORD | reflection_access2 = PROCESS_CREATE_THREAD | PROCESS_VM_OPERATION | PROCESS_DUP_HANDLE | PROCESS_CREATE_PROCESS |
const DWORD | reflection_access = reflection_access2 |
HMODULE | g_kernel32Hndl = nullptr |
OUT | PBOOL = nullptr |
IN OUT PWOW64_CONTEXT | lpContext = nullptr |
typedef struct pesieve::util::_mem_region_info pesieve::util::mem_region_info |
typedef struct pesieve::util::_THREAD_LAST_SYSCALL_INFORMATION * pesieve::util::PTHREAD_LAST_SYSCALL_INFORMATION |
typedef struct pesieve::util::_thread_info pesieve::util::thread_info |
typedef struct pesieve::util::_thread_info_ext pesieve::util::thread_info_ext |
typedef struct pesieve::util::_THREAD_LAST_SYSCALL_INFORMATION pesieve::util::THREAD_LAST_SYSCALL_INFORMATION |
Enumerator | |
---|---|
INTEGRITY_UNKNOWN | |
INTEGRITY_LOW | |
INTEGRITY_MEDIUM | |
INTEGRITY_HIGH | |
INTEGRITY_SYSTEM |
Definition at line 8 of file process_privilege.h.
Definition at line 51 of file process_reflection.cpp.
Definition at line 77 of file process_reflection.cpp.
DEP_SYSTEM_POLICY_TYPE pesieve::util::_get_system_DEP_policy | ( | ) |
pesieve::util::BOOL | ( | CALLBACK * | _MiniDumpWriteDump | ) |
pesieve::util::BOOL | ( | WINAPI * | g_IsWow64Process | ) | = nullptr |
size_t pesieve::util::calc_nt_hdr_offset | ( | MemPageData & | memPage, |
IMAGE_SECTION_HEADER * | first_sec, | ||
bool | is64bit = true ) |
size_t pesieve::util::calc_offset | ( | MemPageData & | memPage, |
LPVOID | field ) |
size_t pesieve::util::calc_sec_hdrs_offset | ( | MemPageData & | memPage, |
IMAGE_FILE_HEADER * | nt_file_hdr ) |
bool pesieve::util::can_make_process_reflection | ( | ) |
std::string pesieve::util::convert_to_win32_path | ( | const std::string & | path | ) |
bool pesieve::util::convert_to_wow64_path | ( | char * | szModName | ) |
size_t pesieve::util::count_section_hdrs | ( | BYTE * | loadedData, |
size_t | loadedSize, | ||
IMAGE_SECTION_HEADER * | hdr_ptr ) |
DWORD pesieve::util::count_workingset_entries | ( | HANDLE | processHandle | ) |
bool pesieve::util::create_dir_recursively | ( | const std::string & | path | ) |
std::string pesieve::util::device_path_to_win32_path | ( | const std::string & | full_path | ) |
bool pesieve::util::dir_exists | ( | const char * | path | ) |
pesieve::util::DWORD | ( | __stdcall * | _PssCaptureSnapshot | ) |
size_t pesieve::util::enum_workingset | ( | HANDLE | processHandle, |
std::set< mem_region_info > & | regions ) |
std::string pesieve::util::escape_path_separators | ( | std::string | path | ) |
Definition at line 27 of file path_util.cpp.
std::string pesieve::util::expand_path | ( | const std::string & | path | ) |
size_t pesieve::util::extract_from_dll | ( | IN const std::string & | path, |
size_t | startSyscallID, | ||
OUT std::map< DWORD, std::string > & | syscallToName ) |
size_t pesieve::util::extract_syscall_table | ( | OUT std::map< DWORD, std::string > & | syscallToName | ) |
size_t pesieve::util::extract_syscalls | ( | BYTE * | pe_buf, |
size_t | pe_size, | ||
std::map< DWORD, std::string > & | syscallToName, | ||
size_t | startID = 0 ) |
bool pesieve::util::fetch_threads_by_snapshot | ( | IN DWORD | pid, |
OUT std::map< DWORD, thread_info > & | threads_info ) |
bool pesieve::util::fetch_threads_info | ( | IN DWORD | pid, |
OUT std::map< DWORD, thread_info > & | threads_info ) |
BYTE * pesieve::util::find_pattern | ( | BYTE * | buffer, |
size_t | buf_size, | ||
BYTE * | pattern_buf, | ||
size_t | pattern_size, | ||
size_t | max_iter = 0 ) |
Definition at line 10 of file artefacts_util.cpp.
bool pesieve::util::get_current_color | ( | int | descriptor, |
WORD & | color ) |
IMAGE_SECTION_HEADER * pesieve::util::get_first_section | ( | BYTE * | loadedData, |
size_t | loadedSize, | ||
IMAGE_SECTION_HEADER * | hdr_ptr ) |
pesieve::util::process_integrity_t pesieve::util::get_integrity_level | ( | HANDLE | hProcess | ) |
HMODULE pesieve::util::get_kernel32_hndl | ( | ) |
Definition at line 13 of file process_util.cpp.
bool pesieve::util::get_next_commited_region | ( | HANDLE | processHandle, |
ULONGLONG | start_va, | ||
MEMORY_BASIC_INFORMATION & | page_info ) |
long pesieve::util::get_number | ( | const char * | buf | ) |
|
inline |
Definition at line 9 of file process_privilege.cpp.
char * pesieve::util::get_subpath_ptr | ( | char * | modulePath, |
char * | searchedPath ) |
Definition at line 5 of file path_util.cpp.
std::string pesieve::util::get_system_drive | ( | ) |
Definition at line 46 of file path_util.cpp.
void pesieve::util::init_syspaths | ( | ) |
Definition at line 27 of file path_converter.cpp.
size_t pesieve::util::is_32bit_code | ( | BYTE * | loadedData, |
size_t | loadedSize ) |
size_t pesieve::util::is_64bit_code | ( | BYTE * | loadedData, |
size_t | loadedSize ) |
bool pesieve::util::is_code | ( | BYTE * | loadedData, |
size_t | loadedSize ) |
bool pesieve::util::is_cstr_equal | ( | char const * | a, |
char const * | b, | ||
const size_t | max_len ) |
Definition at line 12 of file strings_util.cpp.
bool pesieve::util::is_current_wow64 | ( | ) |
bool pesieve::util::is_dec | ( | const char * | buf, |
size_t | len ) |
Definition at line 22 of file format_util.cpp.
bool pesieve::util::is_DEP_enabled | ( | HANDLE | hProcess | ) |
bool pesieve::util::is_disk_relative | ( | const char * | path, |
size_t | path_len ) |
Definition at line 111 of file path_converter.cpp.
Definition at line 109 of file artefacts_util.cpp.
bool pesieve::util::is_hex | ( | const char * | buf, |
size_t | len ) |
Definition at line 11 of file format_util.cpp.
bool pesieve::util::is_in_list | ( | std::string | searched_string, |
std::set< std::string > & | string_list, | ||
bool | to_lower = true ) |
Definition at line 81 of file format_util.cpp.
Definition at line 125 of file artefacts_util.cpp.
bool pesieve::util::is_number | ( | const char * | buf | ) |
bool pesieve::util::is_process_64bit | ( | IN HANDLE | process | ) |
Definition at line 118 of file artefacts_util.cpp.
bool pesieve::util::is_relative | ( | const char * | path, |
size_t | path_len ) |
Definition at line 95 of file path_converter.cpp.
bool pesieve::util::isSyscallFunc | ( | const std::string & | funcName | ) |
Definition at line 11 of file syscall_extractor.cpp.
bool pesieve::util::load_MiniDumpWriteDump | ( | ) |
bool pesieve::util::load_PssCaptureFreeSnapshot | ( | ) |
bool pesieve::util::load_RtlCreateProcessReflection | ( | ) |
std::string & pesieve::util::ltrim | ( | std::string & | str, |
const std::string & | chars = "\t\n\v\f\r " ) |
Definition at line 97 of file format_util.cpp.
HANDLE pesieve::util::make_process_reflection | ( | HANDLE | orig_hndl | ) |
HANDLE pesieve::util::make_process_reflection1 | ( | HANDLE | orig_hndl | ) |
HANDLE pesieve::util::make_process_reflection2 | ( | HPSS | snapshot | ) |
HPSS pesieve::util::make_process_snapshot | ( | HANDLE | orig_hndl | ) |
HANDLE pesieve::util::nt_create_file | ( | PCWSTR | filePath | ) |
std::string pesieve::util::nt_retrieve_file_path | ( | HANDLE | hFile | ) |
pesieve::util::NTSTATUS | ( | NTAPI * | _RtlCreateProcessReflection | ) |
void pesieve::util::print_in_color | ( | int | color, |
const std::string & | text, | ||
bool | is_error = false ) |
void pesieve::util::print_scantime | ( | std::stringstream & | stream, |
size_t | timeInMs ) |
Definition at line 44 of file scanner.cpp.
bool pesieve::util::query_thread_details | ( | IN DWORD | tid, |
OUT pesieve::util::thread_info & | info ) |
bool pesieve::util::query_threads_details | ( | IN OUT std::map< DWORD, thread_info > & | threads_info | ) |
DWORD WINAPI pesieve::util::refl_creator | ( | LPVOID | lpParam | ) |
std::string pesieve::util::relative_to_absolute_path | ( | std::string | path | ) |
bool pesieve::util::release_process_reflection | ( | HANDLE * | reflection_hndl | ) |
std::string pesieve::util::remap_to_drive_letter | ( | const std::string & | full_path | ) |
std::string pesieve::util::replace_char | ( | std::string & | str, |
char | ch1, | ||
char | ch2 ) |
Definition at line 185 of file path_converter.cpp.
std::string & pesieve::util::rtrim | ( | std::string & | str, |
const std::string & | chars = "\t\n\v\f\r " ) |
Definition at line 103 of file format_util.cpp.
bool pesieve::util::set_debug_privilege | ( | ) |
size_t pesieve::util::string_to_list | ( | IN::std::string | s, |
IN char | _delim, | ||
OUT std::set< std::string > & | elements_list, | ||
bool | to_lower = true ) |
std::string pesieve::util::strip_prefix | ( | std::string | path, |
std::string | prefix ) |
std::string pesieve::util::to_lowercase | ( | std::string | str | ) |
Definition at line 6 of file strings_util.cpp.
std::string & pesieve::util::trim | ( | std::string & | str, |
const std::string & | chars = "\t\n\v\f\r " ) |
bool pesieve::util::validate_hdrs_alignment | ( | MemPageData & | memPage, |
IMAGE_FILE_HEADER * | nt_file_hdr, | ||
IMAGE_SECTION_HEADER * | _sec_hdr ) |
BOOL pesieve::util::wow64_disable_fs_redirection | ( | OUT PVOID * | OldValue | ) |
BOOL pesieve::util::wow64_get_thread_context | ( | IN HANDLE | hThread, |
IN OUT PWOW64_CONTEXT | lpContext ) |
BOOL pesieve::util::wow64_revert_fs_redirection | ( | IN PVOID | OldValue | ) |
PSS_QUERY_INFORMATION_CLASS void* pesieve::util::Buffer |
Definition at line 104 of file process_reflection.cpp.
PSS_QUERY_INFORMATION_CLASS void DWORD pesieve::util::BufferLength = NULL |
Definition at line 105 of file process_reflection.cpp.
DWORD HANDLE MINIDUMP_TYPE PMINIDUMP_EXCEPTION_INFORMATION PMINIDUMP_USER_STREAM_INFORMATION PMINIDUMP_CALLBACK_INFORMATION pesieve::util::CallbackParam = NULL |
Definition at line 15 of file process_minidump.cpp.
PSS_CAPTURE_FLAGS pesieve::util::CaptureFlags |
Definition at line 91 of file process_reflection.cpp.
DWORD HANDLE MINIDUMP_TYPE pesieve::util::DumpType |
Definition at line 12 of file process_minidump.cpp.
ULONG PVOID PVOID HANDLE pesieve::util::EventHandle |
Definition at line 45 of file process_reflection.cpp.
DWORD HANDLE MINIDUMP_TYPE PMINIDUMP_EXCEPTION_INFORMATION pesieve::util::ExceptionParam |
Definition at line 13 of file process_minidump.cpp.
ULONG pesieve::util::Flags |
Definition at line 42 of file process_reflection.cpp.
HMODULE pesieve::util::g_kernel32Hndl = nullptr |
Definition at line 6 of file process_util.cpp.
DWORD HANDLE pesieve::util::hFile |
Definition at line 11 of file process_minidump.cpp.
PSS_QUERY_INFORMATION_CLASS pesieve::util::InformationClass |
Definition at line 103 of file process_reflection.cpp.
IN OUT PWOW64_CONTEXT pesieve::util::lpContext = nullptr |
Definition at line 11 of file process_util.cpp.
OUT pesieve::util::PBOOL = nullptr |
Definition at line 8 of file process_util.cpp.
DWORD pesieve::util::ProcessId |
Definition at line 10 of file process_minidump.cpp.
const DWORD pesieve::util::reflection_access = reflection_access2 |
Definition at line 18 of file process_reflection.h.
const DWORD pesieve::util::reflection_access1 = PROCESS_CREATE_THREAD | PROCESS_VM_OPERATION | PROCESS_DUP_HANDLE |
Definition at line 12 of file process_reflection.h.
const DWORD pesieve::util::reflection_access2 = PROCESS_CREATE_THREAD | PROCESS_VM_OPERATION | PROCESS_DUP_HANDLE | PROCESS_CREATE_PROCESS |
Definition at line 15 of file process_reflection.h.
ULONG PVOID PVOID HANDLE T_RTLP_PROCESS_REFLECTION_REFLECTION_INFORMATION* pesieve::util::ReflectionInformation = NULL |
Definition at line 46 of file process_reflection.cpp.
HPSS pesieve::util::SnapshotHandle = NULL |
Definition at line 93 of file process_reflection.cpp.
ULONG PVOID PVOID pesieve::util::StartContext |
Definition at line 44 of file process_reflection.cpp.
ULONG PVOID pesieve::util::StartRoutine |
Definition at line 43 of file process_reflection.cpp.
PSS_CAPTURE_FLAGS DWORD pesieve::util::ThreadContextFlags |
Definition at line 92 of file process_reflection.cpp.
DWORD HANDLE MINIDUMP_TYPE PMINIDUMP_EXCEPTION_INFORMATION PMINIDUMP_USER_STREAM_INFORMATION pesieve::util::UserStreamParam |
Definition at line 14 of file process_minidump.cpp.