52 _ctx_details(
bool _is64b =
false, ULONGLONG _rip = 0, ULONGLONG _rsp = 0, ULONGLONG _rbp = 0, ULONGLONG _ret_addr = 0)
54 init(_is64b, _rip, _rsp, _rbp, _ret_addr);
57 void init(
bool _is64b =
false, ULONGLONG _rip = 0, ULONGLONG _rsp = 0, ULONGLONG _rbp = 0, ULONGLONG _ret_addr = 0)
63 this->last_ret = _ret_addr;
64 this->ret_on_stack = 0;
65 this->is_ret_as_syscall =
true;
66 this->is_ret_in_frame =
true;
67 this->is_managed =
false;
68 this->callStack.clear();
75 SuspAddrReport(ULONGLONG _module = 0 ,
size_t _moduleSize = 0, DWORD _allocProtection = 0)
84 std::cout << __FUNCTION__ <<
" : " << std::hex <<
module <<
" : " <<
moduleSize
88 <<
" entropy: " <<
stats.entropy
91 ULONGLONG susp_addr = *itr;
92 std::cout <<
" " << susp_addr;
94 std::cout <<
" ]" << std::endl;
117 std::string addrTypeStr =
"susp_return_addr";
119 addrTypeStr =
"susp_addr";
122 OUT_PADDED(outs, level,
"\"" << addrTypeStr <<
"\" : [");
126 const ULONGLONG susp_addr = *itr;
133 outs <<
"\"" << std::hex << susp_addr <<
"\"";
146 outs <<
"\"" << std::hex << (ULONGLONG)
module <<
"\"";
149 OUT_PADDED(outs, level,
"\"module_size\" : ");
150 outs <<
"\"" << std::hex << (ULONGLONG)
moduleSize <<
"\"";
154 OUT_PADDED(outs, level,
"\"alloc_protection\" : ");
157 OUT_PADDED(outs, level,
"\"curr_protection\" : ");
166 outs <<
"\"" << std::dec <<
is_code <<
"\"";
167 if (
stats.isFilled()) {
169 stats.toJSON(outs, level);
207 for (
auto itr = this->
suspAreaReports.begin(); itr != this->suspAreaReports.end(); ++itr) {
218 return found->second;
220 for (
auto itr = this->
suspAreaReports.begin(); itr != this->suspAreaReports.end(); ++itr) {
232 bool printCallstack = (jdetails >=
JSON_DETAILS) ?
true :
false;
234 printCallstack =
true;
237 printCallstack =
true;
240 outs <<
"\"" << std::hex << details.
rsp <<
"\"";
243 OUT_PADDED(outs, level,
"\"frames_count\" : ");
244 outs << std::dec << details.
callStack.size();
245 if (printCallstack) {
252 const ULONGLONG addr = *itr;
253 outs <<
"\"" << std::hex << addr;
256 const std::string &sym = sItr->second;
272 outs <<
"\"" <<
"UNKNOWN" <<
"\"";
279 OUT_PADDED(outs, level,
"\"wait_reason\" : ");
284 OUT_PADDED(outs, level,
"\"callstack\" : {\n");
291 OUT_PADDED(outs, level,
"\"native_callstack\" : {\n");
296 bool showLastCall = (jdetails >=
JSON_DETAILS) ?
true :
false;
308 if (!this->
lastFunction.empty() && (this->lastFunction != this->lastSyscall)) {
320 OUT_PADDED(outs, level,
"\"indicators\" : [");
336 outs << std::dec <<
tid;
338 OUT_PADDED(outs, level,
"\"thread_info\" : {\n");
346 OUT_PADDED(outs, level,
"\"susp_areas\" : [\n");
358 suspr->
toJSON(outs, level + 2, jdetails);
369 OUT_PADDED(outs, level,
"\"thread_scan\" : {\n");
428 bool fetchWow64ThreadCtxDetails(IN HANDLE hProcess, IN HANDLE hThread, IN OUT
ctx_details& cDetails);
virtual const bool _toJSON(std::stringstream &outs, size_t level=JSON_LEVEL, const pesieve::t_json_level &jdetails=JSON_BASIC)
ModuleScanReport(HMODULE _module, size_t _moduleSize, t_scan_status _status=SCAN_NOT_SUSPICIOUS)
A container of all the process modules that were scanned.
ProcessFeatureScanner(HANDLE _processHandle)
void addSuspAddr(ULONGLONG addr)
SuspAddrReport(ULONGLONG _module=0, size_t _moduleSize=0, DWORD _allocProtection=0)
const bool toJSON(std::stringstream &outs, size_t level, const pesieve::t_json_level &jdetails) const
std::set< ULONGLONG > suspAddresses
bool addressesToJSON(std::stringstream &outs, size_t level, const pesieve::t_json_level &jdetails) const
bool moduleInfoToJSON(std::stringstream &outs, size_t level, const pesieve::t_json_level &jdetails) const
A report from the thread scan, generated by ThreadScanner.
virtual const void callstackToJSON(std::stringstream &outs, size_t level, const pesieve::t_json_level &jdetails, const ctx_details &details)
ctx_details nativeWow64Details
std::map< ULONGLONG, SuspAddrReport * > suspAreaReports
std::set< ThSusIndicator > indicators
std::map< ULONGLONG, std::string > addrToSymbol
bool has_native_wow64_context
virtual const void fieldsToJSON(std::stringstream &outs, size_t level, const pesieve::t_json_level &jdetails)
ThreadScanReport(DWORD _tid)
static std::string translate_wait_reason(DWORD thread_wait_reason)
const bool threadInfoToJSON(std::stringstream &outs, size_t level, const pesieve::t_json_level &jdetails)
static const DWORD THREAD_STATE_UNKNOWN
const bool indicatorsToJSON(std::stringstream &outs, size_t level, const pesieve::t_json_level &jdetails)
static const DWORD THREAD_STATE_WAITING
SuspAddrReport * findAreaForAddress(const ULONGLONG &susp_addr)
std::set< ULONGLONG > shcCandidates
virtual const bool toJSON(std::stringstream &outs, size_t level, const pesieve::t_json_level &jdetails)
static std::string translate_thread_state(DWORD thread_state)
virtual ThreadScanReport * scanRemote()
size_t analyzeCallStackInfo(IN OUT ThreadScanReport &my_report)
bool reportSuspiciousAddr(ThreadScanReport *my_report, ULONGLONG susp_addr)
std::string resolveAddrToString(IN ULONGLONG addr)
std::string resolveLowLevelFuncName(IN const ULONGLONG addr, OUT OPTIONAL size_t *disp=nullptr)
size_t _analyzeCallStack(IN OUT ctx_details &cDetails, OUT IN std::set< ULONGLONG > &shcCandidates)
bool checkReturnAddrIntegrity(IN const std::vector< ULONGLONG > &callStack, IN OUT ThreadScanReport &my_report)
void printThreadInfo(const util::thread_info &threadi)
void reportResolvedCallstack(ThreadScanReport &my_report)
ThreadScanner(HANDLE hProc, bool _isReflection, bool _isManaged, const util::thread_info &_info, ModulesInfo &_modulesInfo, peconv::ExportsMapper *_exportsMap, ProcessSymbolsManager *_symbols)
bool printResolvedAddr(const ULONGLONG addr)
bool assessIndicators(ThreadScanReport &my_report)
bool fillAreaStats(SuspAddrReport *my_report)
bool filterDotNet(ThreadScanReport &my_report)
bool fetchNativeThreadCtxDetails(IN HANDLE hProcess, IN HANDLE hThread, IN OUT ctx_details &cDetails)
void initReport(ThreadScanReport &my_report)
peconv::ExportsMapper * exportsMap
const util::thread_info & info
bool isAddrInNamedModule(ULONGLONG addr)
static std::string choosePreferredFunctionName(const std::string &dbgSymbol, const std::string &manualSymbol)
size_t fillCallStackInfo(IN HANDLE hThread, const IN LPVOID ctx, IN OUT ctx_details &cDetails)
ProcessSymbolsManager * symbols
bool scanRemoteThreadCtx(HANDLE hThread, ThreadScanReport &my_report)
ModulesInfo & modulesInfo
bool fetchThreadCtxDetails(IN HANDLE hProcess, IN HANDLE hThread, OUT ThreadScanReport &my_report)
struct pesieve::util::_thread_info thread_info
struct pesieve::_ctx_details ctx_details
A custom structure keeping a fragment of a thread context.
std::string indicator_to_str(const ThSusIndicator &indicator)
enum pesieve::ThSusIndicator _ThSusIndicator
@ THI_SUS_CALLSTACK_CORRUPT
@ THI_SUS_CALLS_INTEGRITY
@ JSON_DETAILS
include the basic list patches in the main JSON report
void init(bool _is64b=false, ULONGLONG _rip=0, ULONGLONG _rsp=0, ULONGLONG _rbp=0, ULONGLONG _ret_addr=0)
std::vector< ULONGLONG > callStack
_ctx_details(bool _is64b=false, ULONGLONG _rip=0, ULONGLONG _rsp=0, ULONGLONG _rbp=0, ULONGLONG _ret_addr=0)