From 49b712c2c8fbe9b9ffc1a06d4641dab910bcff9a Mon Sep 17 00:00:00 2001 From: HD Moore Date: Thu, 10 Dec 2009 05:42:47 +0000 Subject: [PATCH] Updated meterpreter binaries with a slight change to the thread schedule (solves a looping problem when the socket is dead). git-svn-id: file:///home/svn/framework3/trunk@7793 4d416f70-5f16-0410-b530-b9f4589650da --- c/meterpreter/source/common/arch/win/scheduler.c | 15 +++++++-------- c/meterpreter/source/common/common.h | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/c/meterpreter/source/common/arch/win/scheduler.c b/c/meterpreter/source/common/arch/win/scheduler.c index 88b3d74b..39b4d3ff 100644 --- a/c/meterpreter/source/common/arch/win/scheduler.c +++ b/c/meterpreter/source/common/arch/win/scheduler.c @@ -210,26 +210,25 @@ DWORD THREADCALL scheduler_waitable_thread( THREAD * thread ) list_add( schedulerThreadList, thread ); - waitableHandles[0] = entry->waitable; - - waitableHandles[1] = thread->sigterm->handle; + waitableHandles[0] = thread->sigterm->handle; + waitableHandles[1] = entry->waitable; dprintf( "[SCHEDULER] entering scheduler_waitable_thread( 0x%08X )", thread ); while( !terminate ) { - dprintf( "[SCHEDULER] scheduler_waitable_thread( 0x%08X ) waiting on 0x%08X and 0x%08X", thread, waitableHandles[0], waitableHandles[1]); + result = WaitForMultipleObjects( 2, (HANDLE *)&waitableHandles, FALSE, INFINITE ); - dprintf( "[SCHEDULER] scheduler_waitable_thread( 0x%08X ) waiting on 0x%08X and 0x%08X returned %d", thread, waitableHandles[0], waitableHandles[1], result - WAIT_OBJECT_0); switch( result - WAIT_OBJECT_0 ) { case 0: - entry->routine( entry->remote, entry->context ); - break; - case 1: dprintf( "[SCHEDULER] scheduler_waitable_thread( 0x%08X ), signaled to terminate...", thread ); terminate = TRUE; break; + case 1: + dprintf( "[SCHEDULER] scheduler_waitable_thread( 0x%08X ), signaled on waitable...", thread ); + entry->routine( entry->remote, entry->context ); + break; default: break; } diff --git a/c/meterpreter/source/common/common.h b/c/meterpreter/source/common/common.h index 2ba9a435..6e2aab05 100644 --- a/c/meterpreter/source/common/common.h +++ b/c/meterpreter/source/common/common.h @@ -32,7 +32,7 @@ #include "list.h" -// #define DEBUGTRACE +//#define DEBUGTRACE #ifdef DEBUGTRACE #define dprintf(...) real_dprintf(__VA_ARGS__)