2015-04-25 11:11:29 +10:00
|
|
|
/*!
|
|
|
|
* @file config.h
|
|
|
|
* @brief Declarations of functions and types that define endpoint and transport configurations.
|
|
|
|
*/
|
2020-04-17 17:46:27 +10:00
|
|
|
#ifndef _METERPRETER_COMMON_CONFIG_H
|
|
|
|
#define _METERPRETER_COMMON_CONFIG_H
|
2015-04-25 11:11:29 +10:00
|
|
|
|
|
|
|
/*! @brief This is the size of the certificate hash that is validated (sha1) */
|
|
|
|
#define CERT_HASH_SIZE 20
|
|
|
|
#define URL_SIZE 512
|
|
|
|
#define UA_SIZE 256
|
2020-04-17 17:46:27 +10:00
|
|
|
#define UUID_SIZE 16
|
2015-04-25 11:11:29 +10:00
|
|
|
#define PROXY_HOST_SIZE 128
|
|
|
|
#define PROXY_USER_SIZE 64
|
|
|
|
#define PROXY_PASS_SIZE 64
|
2022-04-06 14:21:08 +01:00
|
|
|
#define LOG_PATH_SIZE 260 // https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd
|
2015-04-25 11:11:29 +10:00
|
|
|
|
|
|
|
typedef wchar_t CHARTYPE;
|
2016-10-02 06:23:58 -05:00
|
|
|
|
2015-05-13 15:46:33 +10:00
|
|
|
typedef CHARTYPE* STRTYPE;
|
|
|
|
typedef CHARTYPE const * CSTRTYPE;
|
2015-04-25 11:11:29 +10:00
|
|
|
|
2017-08-18 16:36:33 +10:00
|
|
|
// Make sure we byte-align based on what we're given in the structure definitions
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
|
2015-04-25 11:11:29 +10:00
|
|
|
typedef struct _MetsrvSession
|
|
|
|
{
|
2020-04-17 17:46:27 +10:00
|
|
|
union
|
|
|
|
{
|
|
|
|
UINT_PTR handle;
|
|
|
|
BYTE padding[8];
|
2017-07-05 16:15:06 +10:00
|
|
|
} comms_handle; ///! Socket/handle for communications (if there is one).
|
2015-04-28 11:23:37 +10:00
|
|
|
DWORD exit_func; ///! Exit func identifier for when the session ends.
|
2015-04-25 11:11:29 +10:00
|
|
|
int expiry; ///! The total number of seconds to wait before killing off the session.
|
2020-04-17 17:46:27 +10:00
|
|
|
BYTE uuid[UUID_SIZE]; ///! UUID
|
2017-06-05 21:15:27 +10:00
|
|
|
BYTE session_guid[sizeof(GUID)]; ///! Current session GUID
|
2022-04-21 00:53:34 +01:00
|
|
|
#ifdef DEBUGTRACE
|
2022-04-26 23:49:04 +01:00
|
|
|
CHARTYPE log_path[LOG_PATH_SIZE]; ///! Location to place the log file. Only set when msfconsole specifies MeterpreterDebugLogging
|
2022-04-21 00:53:34 +01:00
|
|
|
#endif
|
2015-04-25 11:11:29 +10:00
|
|
|
} MetsrvSession;
|
|
|
|
|
|
|
|
typedef struct _MetsrvTransportCommon
|
|
|
|
{
|
2015-04-28 13:50:13 +10:00
|
|
|
CHARTYPE url[URL_SIZE]; ///! Transport url: scheme://host:port/URI
|
2015-04-25 11:11:29 +10:00
|
|
|
int comms_timeout; ///! Number of sessions to wait for a new packet.
|
|
|
|
int retry_total; ///! Total seconds to retry comms for.
|
|
|
|
int retry_wait; ///! Seconds to wait between reconnects.
|
|
|
|
} MetsrvTransportCommon;
|
|
|
|
|
|
|
|
typedef struct _MetsrvTransportProxy
|
|
|
|
{
|
|
|
|
CHARTYPE hostname[PROXY_HOST_SIZE]; ///! Proxy hostname.
|
|
|
|
CHARTYPE username[PROXY_USER_SIZE]; ///! Proxy username.
|
|
|
|
CHARTYPE password[PROXY_PASS_SIZE]; ///! Proxy password.
|
|
|
|
} MetsrvTransportProxy;
|
|
|
|
|
|
|
|
typedef struct _MetsrvTransportHttp
|
|
|
|
{
|
|
|
|
MetsrvTransportCommon common;
|
|
|
|
MetsrvTransportProxy proxy;
|
|
|
|
CHARTYPE ua[256]; ///! User agent string.
|
|
|
|
BYTE ssl_cert_hash[CERT_HASH_SIZE]; ///! Expected SSL certificate hash.
|
2017-08-18 16:36:33 +10:00
|
|
|
CHARTYPE custom_headers[1]; ///! Custom headers to add to outbound requests (arb length, NULL terminated).
|
2015-04-25 11:11:29 +10:00
|
|
|
} MetsrvTransportHttp;
|
|
|
|
|
2020-04-17 17:46:27 +10:00
|
|
|
typedef struct _MetsrvTransportTcp
|
|
|
|
{
|
|
|
|
MetsrvTransportCommon common;
|
|
|
|
} MetsrvTransportTcp;
|
|
|
|
|
2017-07-05 16:15:06 +10:00
|
|
|
typedef struct _MetsrvTransportNamedPipe
|
2015-04-25 11:11:29 +10:00
|
|
|
{
|
|
|
|
MetsrvTransportCommon common;
|
2017-07-05 16:15:06 +10:00
|
|
|
} MetsrvTransportNamedPipe;
|
2015-04-25 11:11:29 +10:00
|
|
|
|
|
|
|
typedef struct _MetsrvExtension
|
|
|
|
{
|
|
|
|
DWORD size; ///! Size of the extension.
|
|
|
|
BYTE dll[1]; ///! Array of extension bytes (will be more than 1).
|
|
|
|
} MetsrvExtension;
|
|
|
|
|
|
|
|
typedef struct _MetsrvConfig
|
|
|
|
{
|
|
|
|
MetsrvSession session;
|
|
|
|
MetsrvTransportCommon transports[1]; ///! Placeholder for 0 or more transports
|
2015-04-28 17:39:55 +10:00
|
|
|
// Extensions will appear after this
|
2015-11-10 15:43:59 +10:00
|
|
|
// After extensions, we get a list of extension initialisers
|
2020-04-17 17:46:27 +10:00
|
|
|
// <name of extension>\x00<datasize><data>
|
2015-11-10 15:43:59 +10:00
|
|
|
// <name of extension>\x00<datasize><data>
|
|
|
|
// \x00
|
2015-04-25 11:11:29 +10:00
|
|
|
} MetsrvConfig;
|
|
|
|
|
2016-12-08 16:00:04 +10:00
|
|
|
// We force 64bit alignment for HANDLES and POINTERS in order
|
|
|
|
// to be cross compatible between x86 and x64 migration.
|
|
|
|
typedef struct _COMMONMIGRATECONTEXT
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
HANDLE hEvent;
|
|
|
|
BYTE bPadding1[8];
|
|
|
|
} e;
|
|
|
|
|
|
|
|
union
|
|
|
|
{
|
|
|
|
LPBYTE lpPayload;
|
|
|
|
BYTE bPadding2[8];
|
|
|
|
} p;
|
2017-07-05 16:15:06 +10:00
|
|
|
} COMMONMIGRATECONTEXT, * LPCOMMONMIGRATECONTEXT;
|
2016-12-08 16:00:04 +10:00
|
|
|
|
2017-08-18 16:36:33 +10:00
|
|
|
#pragma pack(pop)
|
|
|
|
|
2015-04-25 11:11:29 +10:00
|
|
|
#endif
|