diff --git a/data/meterpreter/ext_server_networkpug.lso b/data/meterpreter/ext_server_networkpug.lso index 11bee1c9fd..24fe4031ea 100755 Binary files a/data/meterpreter/ext_server_networkpug.lso and b/data/meterpreter/ext_server_networkpug.lso differ diff --git a/data/meterpreter/ext_server_sniffer.lso b/data/meterpreter/ext_server_sniffer.lso index 35b67b5837..385bb8cc42 100755 Binary files a/data/meterpreter/ext_server_sniffer.lso and b/data/meterpreter/ext_server_sniffer.lso differ diff --git a/data/meterpreter/ext_server_stdapi.lso b/data/meterpreter/ext_server_stdapi.lso index 03d49b8d0e..12451db144 100755 Binary files a/data/meterpreter/ext_server_stdapi.lso and b/data/meterpreter/ext_server_stdapi.lso differ diff --git a/data/meterpreter/msflinker_linux_x86.bin b/data/meterpreter/msflinker_linux_x86.bin old mode 100755 new mode 100644 index 38ddd7586d..f52f546cce Binary files a/data/meterpreter/msflinker_linux_x86.bin and b/data/meterpreter/msflinker_linux_x86.bin differ diff --git a/external/source/meterpreter/source/common/base.c b/external/source/meterpreter/source/common/base.c index a7aeaad4a9..6e133fc1ad 100644 --- a/external/source/meterpreter/source/common/base.c +++ b/external/source/meterpreter/source/common/base.c @@ -125,7 +125,7 @@ DWORD command_register(Command *command) { Command *newCommand; - dprintf("Registering a new command..."); + dprintf("Registering a new command (%s)...", command->method); if (!(newCommand = (Command *)malloc(sizeof(Command)))) return ERROR_NOT_ENOUGH_MEMORY; @@ -212,6 +212,23 @@ VOID command_throtle( int maxthreads ) } */ +#ifndef _WIN32 +/* + * Reap child zombie threads on linux 2.4 (before NPTL) + * each thread appears as a process and pthread_join don't necessarily reap it + * threads are created using the clone syscall, so use special __WCLONE flag in waitpid + */ + +VOID reap_zombie_thread(void * param) +{ + while(1) { + waitpid(-1, NULL, __WCLONE); + // on 2.6 kernels, don't chew 100% CPU + usleep(500000); + } +} +#endif + /* * Process a single command in a seperate thread of execution. */ @@ -243,6 +260,11 @@ DWORD THREADCALL command_process_thread( THREAD * thread ) commandThreadList = list_create(); if( commandThreadList == NULL ) return ERROR_INVALID_HANDLE; +#ifndef _WIN32 + pthread_t tid; + pthread_create(&tid, NULL, reap_zombie_thread, NULL); + dprintf("reap_zombie_thread created, thread_id : 0x%x",tid); +#endif } list_add( commandThreadList, thread ); diff --git a/external/source/meterpreter/source/common/common.h b/external/source/meterpreter/source/common/common.h index 85a3d4adf8..43aedb9bbb 100644 --- a/external/source/meterpreter/source/common/common.h +++ b/external/source/meterpreter/source/common/common.h @@ -15,6 +15,8 @@ #include +#include +#include #include #include #include diff --git a/external/source/meterpreter/source/extensions/sniffer/sniffer.c b/external/source/meterpreter/source/extensions/sniffer/sniffer.c index c2e06260cb..9a60c959d2 100644 --- a/external/source/meterpreter/source/extensions/sniffer/sniffer.c +++ b/external/source/meterpreter/source/extensions/sniffer/sniffer.c @@ -1098,8 +1098,6 @@ DWORD __declspec(dllexport) InitServerExtension(Remote *remote) { DWORD index; - hMetSrv = remote->hMetSrv; - dprintf("[SERVER] Registering command handlers..."); for (index = 0; customCommands[index].method; index++) { dprintf("Registering command index %d", index); @@ -1112,6 +1110,7 @@ DWORD __declspec(dllexport) InitServerExtension(Remote *remote) memset(open_captures, 0, sizeof(open_captures)); #ifdef _WIN32 + hMetSrv = remote->hMetSrv; // initialize structures for the packet sniffer sdk hMgr = NULL; hErr = 0; diff --git a/external/source/meterpreter/source/extensions/stdapi/server/fs/file.c b/external/source/meterpreter/source/extensions/stdapi/server/fs/file.c index 461368208b..9fb843b2dc 100644 --- a/external/source/meterpreter/source/extensions/stdapi/server/fs/file.c +++ b/external/source/meterpreter/source/extensions/stdapi/server/fs/file.c @@ -85,8 +85,8 @@ static DWORD file_channel_eof(Channel *channel, Packet *request, LPVOID context, LPBOOL isEof) { FileContext *ctx = (FileContext *)context; - - return feof(ctx->fd) ? TRUE : FALSE; + *isEof = feof(ctx->fd) ? TRUE : FALSE; + return ERROR_SUCCESS; } /* diff --git a/external/source/meterpreter/source/extensions/stdapi/server/stdapi.c b/external/source/meterpreter/source/extensions/stdapi/server/stdapi.c index 17e1c68f3f..7e6780e459 100644 --- a/external/source/meterpreter/source/extensions/stdapi/server/stdapi.c +++ b/external/source/meterpreter/source/extensions/stdapi/server/stdapi.c @@ -326,13 +326,13 @@ Command customCommands[] = { EMPTY_DISPATCH_HANDLER }, }, -#ifdef _WIN32 // Socket { "stdapi_net_socket_tcp_shutdown", { request_net_socket_tcp_shutdown, { 0 }, 0 }, { EMPTY_DISPATCH_HANDLER }, }, +#ifdef _WIN32 // UI { "stdapi_ui_enable_mouse", { request_ui_enable_mouse, { 0 }, 0 }, diff --git a/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb b/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb index e209150b4c..ceb7fc8f45 100644 --- a/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb +++ b/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb @@ -161,11 +161,13 @@ class Console::CommandDispatcher::Stdapi::Fs print_error("#{args[0]} is a directory") else fd = client.fs.file.new(args[0], "rb") - - until fd.eof? - print(fd.read) + begin + until fd.eof? + print(fd.read) + end + # EOFError is raised if file is empty, do nothing, just catch + rescue EOFError end - fd.close end