Skip to content

Commit

Permalink
fix line endings
Browse files Browse the repository at this point in the history
  • Loading branch information
dwelch-r7 committed Apr 26, 2022
1 parent 181d318 commit d17e7d3
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 139 deletions.
160 changes: 80 additions & 80 deletions c/meterpreter/source/extensions/kiwi/main.c
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
/*!
* @file main.c
* @brief Entry point for the kiwi extension.
*/

#include "common.h"
#include "common_metapi.h"

// Required so that use of the API works.
MetApi* met_api = NULL;

#define RDIDLL_NOEXPORT
#include "../../ReflectiveDLLInjection/dll/src/ReflectiveLoader.c"

#include "main.h"

extern wchar_t * powershell_reflective_mimikatz(LPWSTR input);
extern DWORD kuhl_m_kerberos_ptt_data(PVOID data, DWORD dataSize);
/*!
* @file main.c
* @brief Entry point for the kiwi extension.
*/

#include "common.h"
#include "common_metapi.h"

// Required so that use of the API works.
MetApi* met_api = NULL;

#define RDIDLL_NOEXPORT
#include "../../ReflectiveDLLInjection/dll/src/ReflectiveLoader.c"

#include "main.h"

extern wchar_t * powershell_reflective_mimikatz(LPWSTR input);
extern DWORD kuhl_m_kerberos_ptt_data(PVOID data, DWORD dataSize);
extern LONG mimikatz_initOrClean(BOOL Init);


DWORD request_exec_cmd(Remote *remote, Packet *packet);
//DWORD request_kerberos_ticket_use(Remote *remote, Packet *packet);

/*! @brief The enabled commands for this extension. */
Command customCommands[] =
{
//DWORD request_kerberos_ticket_use(Remote *remote, Packet *packet);

/*! @brief The enabled commands for this extension. */
Command customCommands[] =
{
COMMAND_REQ(COMMAND_ID_KIWI_EXEC_CMD, request_exec_cmd),
COMMAND_TERMINATOR
};

COMMAND_TERMINATOR
};

/*!
* @brief Handler for the generic command execution function.
* @param remote Pointer to the \c Remote instance.
Expand Down Expand Up @@ -70,57 +70,57 @@ DWORD request_exec_cmd(Remote *remote, Packet *packet)
return ERROR_SUCCESS;
}

/*!
* @brief Initialize the server extension.
* @param api Pointer to the Meterpreter API structure.
* @param remote Pointer to the remote instance.
* @return Indication of success or failure.
*/
DWORD InitServerExtension(MetApi* api, Remote* remote)
{
met_api = api;
SET_LOGGING_CONTEXT(api)

dprintf("[KIWI] Init server extension - initorclean");
/*!
* @brief Initialize the server extension.
* @param api Pointer to the Meterpreter API structure.
* @param remote Pointer to the remote instance.
* @return Indication of success or failure.
*/
DWORD InitServerExtension(MetApi* api, Remote* remote)
{
met_api = api;
SET_LOGGING_CONTEXT(api)

dprintf("[KIWI] Init server extension - initorclean");
mimikatz_initOrClean(TRUE);

dprintf("[KIWI] Init server extension - register");
met_api->command.register_all(customCommands);

dprintf("[KIWI] Init server extension - done");

return ERROR_SUCCESS;
}

/*!
* @brief Deinitialize the server extension.
* @param remote Pointer to the remote instance.
* @return Indication of success or failure.
*/
DWORD DeinitServerExtension(Remote *remote)
{
mimikatz_initOrClean(FALSE);
met_api->command.deregister_all(customCommands);

return ERROR_SUCCESS;
}

/*!
* @brief Do a stageless initialisation of the extension.
* @param ID of the extension that the init was intended for.
* @param buffer Pointer to the buffer that contains the init data.
* @param bufferSize Size of the \c buffer parameter.
* @return Indication of success or failure.
*/
DWORD StagelessInit(UINT extensionId, const LPBYTE buffer, DWORD bufferSize)
{
return ERROR_SUCCESS;
}

/*!
* @brief Callback for when a command has been added to the meterpreter instance.
* @param commandId The ID of the command that has been added.
*/
VOID CommandAdded(UINT commandId)
{
}

dprintf("[KIWI] Init server extension - register");
met_api->command.register_all(customCommands);

dprintf("[KIWI] Init server extension - done");

return ERROR_SUCCESS;
}

/*!
* @brief Deinitialize the server extension.
* @param remote Pointer to the remote instance.
* @return Indication of success or failure.
*/
DWORD DeinitServerExtension(Remote *remote)
{
mimikatz_initOrClean(FALSE);
met_api->command.deregister_all(customCommands);

return ERROR_SUCCESS;
}

/*!
* @brief Do a stageless initialisation of the extension.
* @param ID of the extension that the init was intended for.
* @param buffer Pointer to the buffer that contains the init data.
* @param bufferSize Size of the \c buffer parameter.
* @return Indication of success or failure.
*/
DWORD StagelessInit(UINT extensionId, const LPBYTE buffer, DWORD bufferSize)
{
return ERROR_SUCCESS;
}

/*!
* @brief Callback for when a command has been added to the meterpreter instance.
* @param commandId The ID of the command that has been added.
*/
VOID CommandAdded(UINT commandId)
{
}
119 changes: 60 additions & 59 deletions c/meterpreter/source/extensions/python/python_main.c
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
/*!
* @file python_main.c
* @brief Entry point and intialisation definitions for the python extension.
*/
#include "common.h"
#include "common_metapi.h"

// Required so that use of the API works.
MetApi* met_api = NULL;

#define REFLECTIVEDLLINJECTION_CUSTOM_DLLMAIN
#define RDIDLL_NOEXPORT
#include "../../ReflectiveDLLInjection/dll/src/ReflectiveLoader.c"

#include "python_commands.h"
#include "python_meterpreter_binding.h"
/*!
* @file python_main.c
* @brief Entry point and intialisation definitions for the python extension.
*/
#include "common.h"
#include "common_metapi.h"

// Required so that use of the API works.
MetApi* met_api = NULL;

#define REFLECTIVEDLLINJECTION_CUSTOM_DLLMAIN
#define RDIDLL_NOEXPORT
#include "../../ReflectiveDLLInjection/dll/src/ReflectiveLoader.c"

#include "python_commands.h"
#include "python_meterpreter_binding.h"

// This is the entry point to the python DLL, we proxy to this from our own init
extern BOOL WINAPI PythonDllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved);
extern BOOL WINAPI CtypesDllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvRes);

Remote* gRemote = NULL;

/*! @brief List of commands that the extended API extension providers. */
Command customCommands[] =
{

/*! @brief List of commands that the extended API extension providers. */
Command customCommands[] =
{
COMMAND_REQ(COMMAND_ID_PYTHON_RESET, request_python_reset),
COMMAND_REQ(COMMAND_ID_PYTHON_EXECUTE, request_python_execute),
COMMAND_TERMINATOR
};

COMMAND_TERMINATOR
};

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpReserved)
{
switch (dwReason)
Expand All @@ -53,44 +53,44 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpReserved)
return TRUE;
}

/*!
* @brief Initialize the server extension.
* @param api Pointer to the Meterpreter API structure.
* @param remote Pointer to the remote instance.
* @return Indication of success or failure.
*/
DWORD InitServerExtension(MetApi* api, Remote* remote)
{
met_api = api;
SET_LOGGING_CONTEXT(api)

met_api->command.register_all(customCommands);
gRemote = remote;

dprintf("[PYTHON] Initialising");
binding_startup();

python_prepare_session();
dprintf("[PYTHON] Registering commands");
met_api->command.register_all(customCommands);

return ERROR_SUCCESS;
}

/*!
* @brief Deinitialize the server extension.
* @param remote Pointer to the remote instance.
* @return Indication of success or failure.
*/
DWORD DeinitServerExtension(Remote *remote)
{
/*!
* @brief Initialize the server extension.
* @param api Pointer to the Meterpreter API structure.
* @param remote Pointer to the remote instance.
* @return Indication of success or failure.
*/
DWORD InitServerExtension(MetApi* api, Remote* remote)
{
met_api = api;
SET_LOGGING_CONTEXT(api)

met_api->command.register_all(customCommands);
gRemote = remote;

dprintf("[PYTHON] Initialising");
binding_startup();

python_prepare_session();
dprintf("[PYTHON] Registering commands");
met_api->command.register_all(customCommands);

return ERROR_SUCCESS;
}

/*!
* @brief Deinitialize the server extension.
* @param remote Pointer to the remote instance.
* @return Indication of success or failure.
*/
DWORD DeinitServerExtension(Remote *remote)
{
met_api->command.deregister_all(customCommands);

python_destroy_session();

return ERROR_SUCCESS;
}


return ERROR_SUCCESS;
}

/*!
* @brief Do a stageless initialisation of the extension.
* @param ID of the extension that the init was intended for.
Expand All @@ -115,4 +115,5 @@ DWORD StagelessInit(UINT extensionId, const LPBYTE buffer, DWORD bufferSize)
VOID CommandAdded(UINT commandId)
{
binding_add_command(commandId);
}
}

0 comments on commit d17e7d3

Please sign in to comment.