+
+
+
420 const DWORD tid = GetThreadId(hThread);
+
+
422 const bool is_ok = fetchThreadCtxDetails(processHandle, hThread, cDetails);
-
424 if (exit_code != STILL_ACTIVE) {
-
-
426 std::cout <<
" ExitCode: " << std::dec << exit_code <<
"\n";
-
-
-
-
-
-
-
-
-
-
-
-
438 bool is_shc = isAddrInShellcode(cDetails.
rip);
-
-
440 if (reportSuspiciousAddr(my_report, cDetails.
rip)) {
-
-
-
-
-
-
-
-
448 const ULONGLONG addr = *itr;
-
449#ifdef _SHOW_THREAD_INFO
-
450 std::cout <<
"Checking shc candidate: " << std::hex << addr <<
"\n";
-
-
-
453 if (reportSuspiciousAddr(my_report, addr)) {
-
-
455#ifdef _SHOW_THREAD_INFO
-
456 std::cout <<
"Found! " << std::hex << addr <<
"\n";
-
-
-
-
-
-
-
463 if (this->
info.is_extended &&
info.ext.state == Waiting
-
-
-
-
467 is_shc = isAddrInShellcode(ret_addr);
-
468#ifdef _SHOW_THREAD_INFO
-
469 std::cout <<
"Return addr: " << std::hex << ret_addr <<
"\n";
-
470 printResolvedAddr(ret_addr);
-
-
472 if (is_shc && reportSuspiciousAddr(my_report, (ULONGLONG)ret_addr)) {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
489 && this->info.is_extended &&
info.ext.state == Waiting &&
info.ext.wait_reason == UserRequest)
-
-
-
-
-
-
-
-
-
+
+
425 GetExitCodeThread(hThread, &exit_code);
+
+
427 if (exit_code != STILL_ACTIVE) {
+
+
429 std::cout <<
" ExitCode: " << std::dec << exit_code <<
"\n";
+
+
+
+
+
+
+
+
+
+
+
+
441 bool is_shc = isAddrInShellcode(cDetails.
rip);
+
+
443 if (reportSuspiciousAddr(my_report, cDetails.
rip)) {
+
+
+
+
+
+
+
+
451 const ULONGLONG addr = *itr;
+
452#ifdef _SHOW_THREAD_INFO
+
453 std::cout <<
"Checking shc candidate: " << std::hex << addr <<
"\n";
+
+
+
456 if (reportSuspiciousAddr(my_report, addr)) {
+
+
458#ifdef _SHOW_THREAD_INFO
+
459 std::cout <<
"Found! " << std::hex << addr <<
"\n";
+
+
+
+
+
+
+
466 if (this->
info.is_extended &&
info.ext.state == Waiting
+
+
+
+
470 is_shc = isAddrInShellcode(ret_addr);
+
471#ifdef _SHOW_THREAD_INFO
+
472 std::cout <<
"Return addr: " << std::hex << ret_addr <<
"\n";
+
473 printResolvedAddr(ret_addr);
+
+
475 if (is_shc && reportSuspiciousAddr(my_report, (ULONGLONG)ret_addr)) {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
492 && this->info.is_extended &&
info.ext.state == Waiting &&
info.ext.wait_reason == UserRequest)
+
+
+
+
+
+
+
+
+
-
-
-
-
504 if (!my_report)
return nullptr;
-
-
506#ifdef _SHOW_THREAD_INFO
-
507 printThreadInfo(
info);
-
-
-
510 bool is_shc = isAddrInShellcode(
info.start_addr);
-
-
512 if (reportSuspiciousAddr(my_report,
info.start_addr)) {
-
-
-
-
-
-
-
-
-
-
-
523 HANDLE hThread = OpenThread(
-
524 THREAD_GET_CONTEXT | THREAD_QUERY_INFORMATION | SYNCHRONIZE,
-
-
-
-
-
-
530 std::cerr <<
"[-] Could not OpenThread. Error: " << GetLastError() << std::endl;
-
-
-
-
-
535 scanRemoteThreadCtx(hThread, my_report);
-
536 CloseHandle(hThread);
-
-
+
+
+
+
+
+
+
507 if (!my_report)
return nullptr;
+
+
509#ifdef _SHOW_THREAD_INFO
+
510 printThreadInfo(
info);
+
+
+
513 bool is_shc = isAddrInShellcode(
info.start_addr);
+
+
515 if (reportSuspiciousAddr(my_report,
info.start_addr)) {
+
+
+
+
+
+
+
+
+
+
+
526 HANDLE hThread = OpenThread(
+
527 THREAD_GET_CONTEXT | THREAD_QUERY_INFORMATION | SYNCHRONIZE,
+
+
+
+
+
+
533 std::cerr <<
"[-] Could not OpenThread. Error: " << GetLastError() << std::endl;
+
+
+
+
+
538 scanRemoteThreadCtx(hThread, my_report);
+
539 CloseHandle(hThread);
+
+
A class responsible for filling in the statistics with the data from the particular buffer.
@@ -691,7 +694,7 @@
static std::string translate_thread_state(DWORD thread_state)
-
virtual ThreadScanReport * scanRemote()
+
virtual ThreadScanReport * scanRemote()
bool reportSuspiciousAddr(ThreadScanReport *my_report, ULONGLONG susp_addr)
size_t fillCallStackInfo(IN HANDLE hProcess, IN HANDLE hThread, IN LPVOID ctx, IN OUT ctx_details &cDetails)
void printThreadInfo(const util::thread_info &threadi)
@@ -700,7 +703,7 @@
size_t analyzeCallStack(IN const std::vector< ULONGLONG > stack_frame, IN OUT ctx_details &cDetails)
bool fetchThreadCtxDetails(IN HANDLE hProcess, IN HANDLE hThread, OUT ctx_details &c)
bool printResolvedAddr(ULONGLONG addr)
-
bool scanRemoteThreadCtx(HANDLE hThread, ThreadScanReport *my_report)
+
bool scanRemoteThreadCtx(HANDLE hThread, ThreadScanReport *my_report)
BOOL is_process_wow64(IN HANDLE processHandle, OUT BOOL *isProcWow64)
BOOL wow64_get_thread_context(IN HANDLE hThread, IN OUT PWOW64_CONTEXT lpContext)
diff --git a/thread__scanner_8h_source.html b/thread__scanner_8h_source.html
index af547eae2..41d8a629c 100644
--- a/thread__scanner_8h_source.html
+++ b/thread__scanner_8h_source.html
@@ -295,7 +295,7 @@
ThreadScanner(HANDLE hProc, bool _isReflection, const util::thread_info &_info, ModulesInfo &_modulesInfo, peconv::ExportsMapper *_exportsMap, ProcessSymbolsManager *_symbols)
-
virtual ThreadScanReport * scanRemote()
+
virtual ThreadScanReport * scanRemote()
bool reportSuspiciousAddr(ThreadScanReport *my_report, ULONGLONG susp_addr)
size_t fillCallStackInfo(IN HANDLE hProcess, IN HANDLE hThread, IN LPVOID ctx, IN OUT ctx_details &cDetails)
void printThreadInfo(const util::thread_info &threadi)
@@ -307,7 +307,7 @@
bool fetchThreadCtxDetails(IN HANDLE hProcess, IN HANDLE hThread, OUT ctx_details &c)
bool printResolvedAddr(ULONGLONG addr)
ProcessSymbolsManager * symbols
-
bool scanRemoteThreadCtx(HANDLE hThread, ThreadScanReport *my_report)
+
bool scanRemoteThreadCtx(HANDLE hThread, ThreadScanReport *my_report)
ModulesInfo & modulesInfo