2014-04-06 18:31:53 +00:00
|
|
|
/* Benjamin DELPY `gentilkiwi`
|
2020-09-17 01:17:11 +00:00
|
|
|
https://blog.gentilkiwi.com
|
2014-04-06 18:31:53 +00:00
|
|
|
benjamin@gentilkiwi.com
|
2015-08-25 09:19:01 +00:00
|
|
|
Licence : https://creativecommons.org/licenses/by/4.0/
|
2014-04-06 18:31:53 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <ntstatus.h>
|
|
|
|
#define WIN32_NO_STATUS
|
|
|
|
#define SECURITY_WIN32
|
2016-07-10 22:32:51 +00:00
|
|
|
#define CINTERFACE
|
|
|
|
#define COBJMACROS
|
2014-04-06 18:31:53 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#include <sspi.h>
|
|
|
|
#include <sddl.h>
|
|
|
|
#include <wincred.h>
|
|
|
|
#include <ntsecapi.h>
|
|
|
|
#include <ntsecpkg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <wchar.h>
|
|
|
|
#include "../modules/kull_m_output.h"
|
|
|
|
//#define KERBEROS_TOOLS
|
2017-03-26 00:35:32 +00:00
|
|
|
//#define SERVICE_INCONTROL
|
2014-04-25 00:03:55 +00:00
|
|
|
#define NET_MODULE
|
2019-03-25 00:57:56 +00:00
|
|
|
#if defined(_M_ARM64)
|
|
|
|
#define MIMIKATZ_ARCH L"arm64"
|
|
|
|
#elif defined(_M_X64)
|
2014-04-06 18:31:53 +00:00
|
|
|
#define MIMIKATZ_ARCH L"x64"
|
2019-03-25 00:57:56 +00:00
|
|
|
#elif defined(_M_IX86)
|
2014-04-06 18:31:53 +00:00
|
|
|
#define MIMIKATZ_ARCH L"x86"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define MIMIKATZ L"mimikatz"
|
2019-03-25 00:57:56 +00:00
|
|
|
#define MIMIKATZ_VERSION L"2.2.0"
|
2016-01-06 01:46:28 +00:00
|
|
|
#define MIMIKATZ_CODENAME L"A La Vie, A L\'Amour"
|
2020-05-18 22:56:24 +00:00
|
|
|
#define MIMIKATZ_MAX_WINBUILD L"19041"
|
2018-12-09 23:03:02 +00:00
|
|
|
#define MIMIKATZ_FULL MIMIKATZ L" " MIMIKATZ_VERSION L" (" MIMIKATZ_ARCH L") #" MIMIKATZ_MAX_WINBUILD L" " TEXT(__DATE__) L" " TEXT(__TIME__)
|
2016-10-05 18:37:29 +00:00
|
|
|
#define MIMIKATZ_SECOND L"\"" MIMIKATZ_CODENAME L"\""
|
2014-04-23 20:00:29 +00:00
|
|
|
#define MIMIKATZ_DEFAULT_LOG MIMIKATZ L".log"
|
2014-04-06 18:31:53 +00:00
|
|
|
#define MIMIKATZ_DRIVER L"mimidrv"
|
|
|
|
#define MIMIKATZ_KERBEROS_EXT L"kirbi"
|
2017-03-19 15:03:54 +00:00
|
|
|
#define MIMIKATZ_SERVICE MIMIKATZ L"svc"
|
2014-04-06 18:31:53 +00:00
|
|
|
|
2019-03-25 00:57:56 +00:00
|
|
|
#if defined(_WINDLL)
|
2014-05-04 23:24:54 +00:00
|
|
|
#define MIMIKATZ_AUTO_COMMAND_START 0
|
|
|
|
#else
|
|
|
|
#define MIMIKATZ_AUTO_COMMAND_START 1
|
2017-07-19 23:33:50 +00:00
|
|
|
#endif
|
|
|
|
|
2019-03-25 00:57:56 +00:00
|
|
|
#if defined(_POWERKATZ)
|
2017-07-19 23:33:50 +00:00
|
|
|
#define MIMIKATZ_AUTO_COMMAND_STRING L"powershell"
|
|
|
|
#else
|
2014-05-04 23:24:54 +00:00
|
|
|
#define MIMIKATZ_AUTO_COMMAND_STRING L"commandline"
|
|
|
|
#endif
|
|
|
|
|
2019-03-25 00:57:56 +00:00
|
|
|
#if !defined(NT_SUCCESS)
|
2014-04-06 18:31:53 +00:00
|
|
|
#define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0)
|
|
|
|
#endif
|
|
|
|
|
2019-03-25 00:57:56 +00:00
|
|
|
#if !defined(PRINT_ERROR)
|
2014-04-06 18:31:53 +00:00
|
|
|
#define PRINT_ERROR(...) (kprintf(L"ERROR " TEXT(__FUNCTION__) L" ; " __VA_ARGS__))
|
|
|
|
#endif
|
|
|
|
|
2019-03-25 00:57:56 +00:00
|
|
|
#if !defined(PRINT_ERROR_AUTO)
|
2014-04-06 18:31:53 +00:00
|
|
|
#define PRINT_ERROR_AUTO(func) (kprintf(L"ERROR " TEXT(__FUNCTION__) L" ; " func L" (0x%08x)\n", GetLastError()))
|
|
|
|
#endif
|
|
|
|
|
2019-03-25 00:57:56 +00:00
|
|
|
#if !defined(W00T)
|
2014-04-06 18:31:53 +00:00
|
|
|
#define W00T(...) (kprintf(TEXT(__FUNCTION__) L" w00t! ; " __VA_ARGS__))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
DWORD MIMIKATZ_NT_MAJOR_VERSION, MIMIKATZ_NT_MINOR_VERSION, MIMIKATZ_NT_BUILD_NUMBER;
|
|
|
|
|
2019-03-25 00:57:56 +00:00
|
|
|
#if !defined(MS_ENH_RSA_AES_PROV_XP)
|
2014-04-06 18:31:53 +00:00
|
|
|
#define MS_ENH_RSA_AES_PROV_XP L"Microsoft Enhanced RSA and AES Cryptographic Provider (Prototype)"
|
|
|
|
#endif
|
|
|
|
|
2020-05-18 22:56:24 +00:00
|
|
|
#if !defined(MS_PLATFORM_CRYPTO_PROVIDER)
|
|
|
|
#define MS_PLATFORM_CRYPTO_PROVIDER L"Microsoft Platform Crypto Provider"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(NCRYPT_PCP_PLATFORM_TYPE_PROPERTY)
|
|
|
|
#define NCRYPT_PCP_PLATFORM_TYPE_PROPERTY L"PCP_PLATFORM_TYPE"
|
|
|
|
#endif
|
|
|
|
|
2020-08-04 12:06:21 +00:00
|
|
|
#if !defined(TPM_RSA_SRK_SEAL_KEY)
|
|
|
|
#define TPM_RSA_SRK_SEAL_KEY L"MICROSOFT_PCP_KSP_RSA_SEAL_KEY_3BD1C4BF-004E-4E2F-8A4D-0BF633DCB074"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(NCRYPT_SEALING_FLAG)
|
|
|
|
#define NCRYPT_SEALING_FLAG 0x00000100
|
|
|
|
#endif
|
|
|
|
|
2019-03-25 00:57:56 +00:00
|
|
|
#if !defined(SCARD_PROVIDER_CARD_MODULE)
|
2017-05-08 20:12:31 +00:00
|
|
|
#define SCARD_PROVIDER_CARD_MODULE 0x80000001
|
|
|
|
#endif
|
|
|
|
|
2014-04-06 18:31:53 +00:00
|
|
|
#define RtlEqualGuid(L1, L2) (RtlEqualMemory(L1, L2, sizeof(GUID)))
|
2015-06-03 00:13:43 +00:00
|
|
|
|
2016-07-19 15:48:55 +00:00
|
|
|
#define SIZE_ALIGN(size, alignment) (size + ((size % alignment) ? (alignment - (size % alignment)) : 0))
|
2017-02-26 01:10:41 +00:00
|
|
|
#define KIWI_NEVERTIME(filetime) (*(PLONGLONG) filetime = MAXLONGLONG)
|
2016-07-19 15:48:55 +00:00
|
|
|
|
2014-04-06 18:31:53 +00:00
|
|
|
#define LM_NTLM_HASH_LENGTH 16
|
|
|
|
|
|
|
|
#define KULL_M_WIN_BUILD_XP 2600
|
|
|
|
#define KULL_M_WIN_BUILD_2K3 3790
|
|
|
|
#define KULL_M_WIN_BUILD_VISTA 6000
|
|
|
|
#define KULL_M_WIN_BUILD_7 7600
|
|
|
|
#define KULL_M_WIN_BUILD_8 9200
|
|
|
|
#define KULL_M_WIN_BUILD_BLUE 9600
|
2018-12-03 01:06:10 +00:00
|
|
|
#define KULL_M_WIN_BUILD_10_1507 10240
|
|
|
|
#define KULL_M_WIN_BUILD_10_1511 10586
|
|
|
|
#define KULL_M_WIN_BUILD_10_1607 14393
|
|
|
|
#define KULL_M_WIN_BUILD_10_1703 15063
|
|
|
|
#define KULL_M_WIN_BUILD_10_1709 16299
|
|
|
|
#define KULL_M_WIN_BUILD_10_1803 17134
|
|
|
|
#define KULL_M_WIN_BUILD_10_1809 17763
|
2019-05-12 23:17:31 +00:00
|
|
|
#define KULL_M_WIN_BUILD_10_1903 18362
|
2020-05-18 22:56:24 +00:00
|
|
|
#define KULL_M_WIN_BUILD_10_1909 18363
|
|
|
|
#define KULL_M_WIN_BUILD_10_2004 19041
|
2021-05-11 18:34:56 +00:00
|
|
|
#define KULL_M_WIN_BUILD_10_20H2 19042
|
2022-07-26 07:38:10 +00:00
|
|
|
#define KULL_M_WIN_BUILD_10_21H2 19044
|
2021-09-06 22:19:15 +00:00
|
|
|
#define KULL_M_WIN_BUILD_2022 20348
|
2023-08-03 08:55:55 +00:00
|
|
|
#define KULL_M_WIN_BUILD_11_22H2 22621
|
2014-04-06 18:31:53 +00:00
|
|
|
|
|
|
|
#define KULL_M_WIN_MIN_BUILD_XP 2500
|
|
|
|
#define KULL_M_WIN_MIN_BUILD_2K3 3000
|
2015-01-13 21:08:23 +00:00
|
|
|
#define KULL_M_WIN_MIN_BUILD_VISTA 5000
|
2014-04-06 18:31:53 +00:00
|
|
|
#define KULL_M_WIN_MIN_BUILD_7 7000
|
|
|
|
#define KULL_M_WIN_MIN_BUILD_8 8000
|
2014-10-10 08:53:03 +00:00
|
|
|
#define KULL_M_WIN_MIN_BUILD_BLUE 9400
|
2021-08-09 23:59:35 +00:00
|
|
|
#define KULL_M_WIN_MIN_BUILD_10 9800
|
2022-07-26 07:38:10 +00:00
|
|
|
#define KULL_M_WIN_MIN_BUILD_11 22000
|
2022-09-19 12:57:55 +00:00
|
|
|
|
|
|
|
/* mimikatz 3 transition */
|
2022-09-19 20:50:46 +00:00
|
|
|
#define PRINT_ERROR_NUMBER(func, error) PRINT_ERROR(func L": 0x%08x\n", error)
|
|
|
|
|
2022-09-19 12:57:55 +00:00
|
|
|
#define GET_CLI_ARG(name, var) (kull_m_string_args_byName(argc, argv, name, var, NULL))
|
|
|
|
#define GET_CLI_ARG_DEF(name, var, def) (kull_m_string_args_byName(argc, argv, name, var, def))
|
|
|
|
#define GET_CLI_ARG_PRESENT(name) (kull_m_string_args_byName(argc, argv, name, NULL, NULL))
|
|
|
|
|
|
|
|
#define kprintf_level(subject, ...) kprintf(L"%*s" subject, level << 1, L"", __VA_ARGS__)
|
|
|
|
|
|
|
|
#define kprinthex(lpData, cbData) kull_m_string_wprintf_hex(lpData, (DWORD) cbData, 0); kprintf(L"\n")
|
|
|
|
#define kprinthex16(lpData, cbData) kull_m_string_wprintf_hex(lpData, (DWORD) cbData, 1 | (16 << 16)); kprintf(L"\n")
|
|
|
|
|
|
|
|
#define kull_m_cli_guid(pGuid, bNewLine) kull_m_string_displayGUID(pGuid); if(bNewLine) kprintf(L"\n")
|
|
|
|
#define kull_m_cli_sid(pSid, bNewLine) kull_m_string_displaySID(pSid); if(bNewLine) kprintf(L"\n")
|
|
|
|
|
|
|
|
#define kull_m_crypto_Base64StringToBinary kull_m_string_quick_base64_to_Binary
|