Skip to content

Commit

Permalink
Compatible with Visual Studio 2015
Browse files Browse the repository at this point in the history
  • Loading branch information
gentilkiwi committed Jul 23, 2015
1 parent c00b9cf commit e6924b7
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 36 deletions.
4 changes: 2 additions & 2 deletions inc/DbgHelp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,7 @@ typedef enum {
hdSym, // where symbols are stored
hdSrc, // where source is stored
hdMax // end marker
};
} DBG_HD_ENUM;

typedef struct _OMAP {
ULONG rva;
Expand Down Expand Up @@ -3053,7 +3053,7 @@ typedef enum {
sfPdb,
sfMpd,
sfMax
};
} DBG_SF_ENUM;

BOOL
IMAGEAPI
Expand Down
2 changes: 1 addition & 1 deletion mimikatz/mimikatz.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int wmain(int argc, wchar_t * argv[])
while (status != STATUS_FATAL_APP_EXIT)
{
kprintf(L"\n" MIMIKATZ L" # "); fflush(stdin);
if(wscanf_s(L"%[^\n]s", input, ARRAYSIZE(input)) == 1)
if(fgetws(input, ARRAYSIZE(input), stdin) && (input[0] != L'\n'))
{
kprintf_inputline(L"%s\n", input);
status = mimikatz_dispatchCommand(input);
Expand Down
1 change: 1 addition & 0 deletions mimikatz/mimikatz.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<PlatformToolset>v100</PlatformToolset>
<PlatformToolset Condition="'$(VCTargetsPath11)' != ''">v110_xp</PlatformToolset>
<PlatformToolset Condition="'$(VCTargetsPath12)' != ''">v120_xp</PlatformToolset>
<PlatformToolset Condition="'$(VCTargetsPath14)' != ''">v140_xp</PlatformToolset>
<UseOfMfc>static</UseOfMfc>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="Exists('$(VCTargetsPath)\Platforms\$(Platform)\PlatformToolsets\ddk2003') Or Exists('$(VCTargetsPath)\..\Platforms\$(Platform)\PlatformToolsets\ddk2003')">
Expand Down
2 changes: 1 addition & 1 deletion mimikatz/modules/kuhl_m_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ BOOL CALLBACK kuhl_m_misc_detours_callback_process(PSYSTEM_PROCESS_INFORMATION p
{
HANDLE hProcess;
PKULL_M_MEMORY_HANDLE hMemoryProcess;
DWORD pid = (DWORD) pSystemProcessInformation->UniqueProcessId;
DWORD pid = PtrToUlong(pSystemProcessInformation->UniqueProcessId);

if(pid > 4)
{
Expand Down
18 changes: 9 additions & 9 deletions mimikatz/modules/sekurlsa/kuhl_m_sekurlsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,12 +477,12 @@ void kuhl_m_sekurlsa_krbtgt_keys(PVOID addr, PCWSTR prefix)
kprintf(L"%u credentials\n", creds5->cbCred);
for(i = 0; i < creds5->cbCred; i++)
{
kprintf(L"\t * %s : ", kuhl_m_kerberos_ticket_etype((LONG) creds5->credentials[i].type));
kprintf(L"\t * %s : ", kuhl_m_kerberos_ticket_etype(PtrToLong(creds5->credentials[i].type)));
aLsass.address = creds5->credentials[i].key;
if(aLocal.address = LocalAlloc(LPTR, (DWORD) creds5->credentials[i].size))
if(aLocal.address = LocalAlloc(LPTR, PtrToUlong(creds5->credentials[i].size)))
{
if(kull_m_memory_copy(&aLocal, &aLsass, (DWORD) creds5->credentials[i].size))
kull_m_string_wprintf_hex(aLocal.address, (DWORD) creds5->credentials[i].size, 0);
if(kull_m_memory_copy(&aLocal, &aLsass, PtrToUlong(creds5->credentials[i].size)))
kull_m_string_wprintf_hex(aLocal.address, PtrToUlong(creds5->credentials[i].size), 0);
LocalFree(aLocal.address);
}
kprintf(L"\n");
Expand All @@ -506,12 +506,12 @@ void kuhl_m_sekurlsa_krbtgt_keys(PVOID addr, PCWSTR prefix)
kprintf(L"%u credentials\n", creds6->cbCred);
for(i = 0; i < creds6->cbCred; i++)
{
kprintf(L"\t * %s : ", kuhl_m_kerberos_ticket_etype((LONG) creds6->credentials[i].type));
kprintf(L"\t * %s : ", kuhl_m_kerberos_ticket_etype(PtrToLong(creds6->credentials[i].type)));
aLsass.address = creds6->credentials[i].key;
if(aLocal.address = LocalAlloc(LPTR, (DWORD) creds6->credentials[i].size))
if(aLocal.address = LocalAlloc(LPTR, PtrToUlong(creds6->credentials[i].size)))
{
if(kull_m_memory_copy(&aLocal, &aLsass, (DWORD) creds6->credentials[i].size))
kull_m_string_wprintf_hex(aLocal.address, (DWORD) creds6->credentials[i].size, 0);
if(kull_m_memory_copy(&aLocal, &aLsass, PtrToUlong(creds6->credentials[i].size)))
kull_m_string_wprintf_hex(aLocal.address, PtrToUlong(creds6->credentials[i].size), 0);
LocalFree(aLocal.address);
}
kprintf(L"\n");
Expand Down Expand Up @@ -1020,7 +1020,7 @@ VOID kuhl_m_sekurlsa_genericCredsOutput(PKIWI_GENERIC_PRIMARY_CREDENTIAL mesCred
buffer.Buffer = (PWSTR) pHashPassword->Checksump;
if(kull_m_string_getUnicodeString(&buffer, cLsass.hLsassMem))
{
if((flags & KUHL_SEKURLSA_CREDS_DISPLAY_KERBEROS_10) && (pHashPassword->Size > FIELD_OFFSET(LSAISO_DATA_BLOB, data)))
if((flags & KUHL_SEKURLSA_CREDS_DISPLAY_KERBEROS_10) && (pHashPassword->Size > (ULONG) FIELD_OFFSET(LSAISO_DATA_BLOB, data)))
{
kuhl_m_sekurlsa_genericLsaIsoOutput((PLSAISO_DATA_BLOB) buffer.Buffer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ void kuhl_m_sekurlsa_kerberos_enum_tickets(IN PKIWI_BASIC_SECURITY_LOGON_SESSION
kprintf(L"\n\t [%08x]", nbTickets);
if(pKiwiTicket = kuhl_m_sekurlsa_kerberos_createTicket((LPBYTE) aTicket.address, pData->cLsass->hLsassMem))
{
isNormalSessionKey = (pData->cLsass->osContext.BuildNumber < KULL_M_WIN_BUILD_10) || (pKiwiTicket->Key.Length < FIELD_OFFSET(LSAISO_DATA_BLOB, data));
isNormalSessionKey = (pData->cLsass->osContext.BuildNumber < KULL_M_WIN_BUILD_10) || (pKiwiTicket->Key.Length < (ULONG) FIELD_OFFSET(LSAISO_DATA_BLOB, data));
kuhl_m_kerberos_ticket_display(pKiwiTicket, isNormalSessionKey, FALSE);
if(isFile)
if(filename = kuhl_m_sekurlsa_kerberos_generateFileName(pData->LogonId, grp, nbTickets, pKiwiTicket, MIMIKATZ_KERBEROS_EXT))
Expand Down
1 change: 1 addition & 0 deletions mimilib/mimilib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<PlatformToolset>v100</PlatformToolset>
<PlatformToolset Condition="'$(VCTargetsPath11)' != ''">v110_xp</PlatformToolset>
<PlatformToolset Condition="'$(VCTargetsPath12)' != ''">v120_xp</PlatformToolset>
<PlatformToolset Condition="'$(VCTargetsPath14)' != ''">v140_xp</PlatformToolset>
<UseOfMfc>static</UseOfMfc>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="Exists('$(VCTargetsPath)\Platforms\$(Platform)\PlatformToolsets\ddk2003') Or Exists('$(VCTargetsPath)\..\Platforms\$(Platform)\PlatformToolsets\ddk2003')">
Expand Down
10 changes: 5 additions & 5 deletions mimilib/sekurlsadbg/kwindbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ VOID kuhl_m_sekurlsa_genericCredsOutput(PKIWI_GENERIC_PRIMARY_CREDENTIAL mesCred
buffer.Buffer = (PWSTR) pHashPassword->Checksump;
if(kull_m_string_getDbgUnicodeString(&buffer))
{
if((flags & KUHL_SEKURLSA_CREDS_DISPLAY_KERBEROS_10) && (pHashPassword->Size > FIELD_OFFSET(LSAISO_DATA_BLOB, data)))
if((flags & KUHL_SEKURLSA_CREDS_DISPLAY_KERBEROS_10) && (pHashPassword->Size > (DWORD) FIELD_OFFSET(LSAISO_DATA_BLOB, data)))
{
kuhl_m_sekurlsa_genericLsaIsoOutput((PLSAISO_DATA_BLOB) buffer.Buffer);
}
Expand Down Expand Up @@ -477,11 +477,11 @@ void kuhl_m_sekurlsa_krbtgt_keys(PVOID addr, LPCSTR prefix)
dprintf("%u credentials\n", creds6->cbCred);
for(i = 0; i < creds6->cbCred; i++)
{
dprintf("\t * %s : ", kuhl_m_kerberos_ticket_etype((LONG) creds6->credentials[i].type));
if(buffer = LocalAlloc(LPTR, (DWORD) creds6->credentials[i].size))
dprintf("\t * %s : ", kuhl_m_kerberos_ticket_etype(PtrToLong(creds6->credentials[i].type)));
if(buffer = LocalAlloc(LPTR, PtrToUlong(creds6->credentials[i].size)))
{
if(ReadMemory((ULONG_PTR) creds6->credentials[i].key, buffer, (DWORD) creds6->credentials[i].size, NULL))
kull_m_string_dprintf_hex(buffer, (DWORD) creds6->credentials[i].size, 0);
if(ReadMemory((ULONG_PTR) creds6->credentials[i].key, buffer, PtrToUlong(creds6->credentials[i].size), NULL))
kull_m_string_dprintf_hex(buffer, PtrToUlong(creds6->credentials[i].size), 0);
LocalFree(buffer);
}
dprintf("\n");
Expand Down
1 change: 1 addition & 0 deletions mimilove/mimilove.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<PlatformToolset>v100</PlatformToolset>
<PlatformToolset Condition="'$(VCTargetsPath11)' != ''">v110_xp</PlatformToolset>
<PlatformToolset Condition="'$(VCTargetsPath12)' != ''">v120_xp</PlatformToolset>
<PlatformToolset Condition="'$(VCTargetsPath14)' != ''">v140_xp</PlatformToolset>
<UseOfMfc>static</UseOfMfc>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="Exists('$(VCTargetsPath)\Platforms\$(Platform)\PlatformToolsets\ddk2003') Or Exists('$(VCTargetsPath)\..\Platforms\$(Platform)\PlatformToolsets\ddk2003')">
Expand Down
4 changes: 2 additions & 2 deletions modules/kull_m_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ BOOL kull_m_memory_copy(OUT PKULL_M_MEMORY_ADDRESS Destination, IN PKULL_M_MEMOR
status = kull_m_minidump_copy(Source->hMemory->pHandleProcessDmp->hMinidump, Destination->address, Source->address, Length);
break;
case KULL_M_MEMORY_TYPE_FILE:
if(SetFilePointer(Source->hMemory->pHandleFile->hFile, (LONG) Source->address, NULL, FILE_BEGIN) != INVALID_SET_FILE_POINTER)
if(SetFilePointer(Source->hMemory->pHandleFile->hFile, PtrToLong(Source->address), NULL, FILE_BEGIN) != INVALID_SET_FILE_POINTER)
status = ReadFile(Source->hMemory->pHandleFile->hFile, Destination->address, (DWORD) Length, &nbReadWrite, NULL);
break;
case KULL_M_MEMORY_TYPE_KERNEL:
Expand All @@ -131,7 +131,7 @@ BOOL kull_m_memory_copy(OUT PKULL_M_MEMORY_ADDRESS Destination, IN PKULL_M_MEMOR
switch(Source->hMemory->type)
{
case KULL_M_MEMORY_TYPE_OWN:
if(!Destination->address || SetFilePointer(Destination->hMemory->pHandleFile->hFile, (LONG) Destination->address, NULL, FILE_BEGIN))
if(!Destination->address || SetFilePointer(Destination->hMemory->pHandleFile->hFile, PtrToLong(Destination->address), NULL, FILE_BEGIN))
status = WriteFile(Destination->hMemory->pHandleFile->hFile, Source->address, (DWORD) Length, &nbReadWrite, NULL);
break;
default:
Expand Down
26 changes: 13 additions & 13 deletions modules/kull_m_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ NTSTATUS kull_m_process_getProcessInformation(PKULL_M_PROCESS_ENUM_CALLBACK call
BOOL CALLBACK kull_m_process_callback_pidForName(PSYSTEM_PROCESS_INFORMATION pSystemProcessInformation, PVOID pvArg)
{
if(((PKULL_M_PROCESS_PID_FOR_NAME) pvArg)->isFound = RtlEqualUnicodeString(&pSystemProcessInformation->ImageName, ((PKULL_M_PROCESS_PID_FOR_NAME) pvArg)->name, TRUE))
*((PKULL_M_PROCESS_PID_FOR_NAME) pvArg)->processId = (DWORD) pSystemProcessInformation->UniqueProcessId;
*((PKULL_M_PROCESS_PID_FOR_NAME) pvArg)->processId = PtrToUlong(pSystemProcessInformation->UniqueProcessId);
return !((PKULL_M_PROCESS_PID_FOR_NAME) pvArg)->isFound;
}

Expand Down Expand Up @@ -105,17 +105,17 @@ NTSTATUS kull_m_process_getVeryBasicModuleInformations(PKULL_M_MEMORY_HANDLE mem
if(continueCallback && NT_SUCCESS(status) && kull_m_process_peb(memory, (PPEB) &Peb32, TRUE))
{
status = STATUS_PARTIAL_COPY;

for(pLdrEntry32 = (PLDR_DATA_TABLE_ENTRY_F32) ((PBYTE) (((PEB_LDR_DATA_F32 *) Peb32.Ldr)->InMemoryOrderModulevector.Flink) - FIELD_OFFSET(LDR_DATA_TABLE_ENTRY_F32, InMemoryOrderLinks));
(pLdrEntry32 != (PLDR_DATA_TABLE_ENTRY_F32) ((PBYTE) (Peb32.Ldr) + FIELD_OFFSET(PEB_LDR_DATA, InLoadOrderModulevector))) && continueCallback;
pLdrEntry32 = (PLDR_DATA_TABLE_ENTRY_F32) ((PBYTE) (pLdrEntry32->InMemoryOrderLinks.Flink ) - FIELD_OFFSET(LDR_DATA_TABLE_ENTRY_F32, InMemoryOrderLinks))
for(pLdrEntry32 = (PLDR_DATA_TABLE_ENTRY_F32) ((PBYTE) ULongToPtr(((PEB_LDR_DATA_F32 *) ULongToPtr(Peb32.Ldr))->InMemoryOrderModulevector.Flink) - FIELD_OFFSET(LDR_DATA_TABLE_ENTRY_F32, InMemoryOrderLinks));
(pLdrEntry32 != (PLDR_DATA_TABLE_ENTRY_F32) ((PBYTE) ULongToPtr(Peb32.Ldr) + FIELD_OFFSET(PEB_LDR_DATA, InLoadOrderModulevector))) && continueCallback;
pLdrEntry32 = (PLDR_DATA_TABLE_ENTRY_F32) ((PBYTE) ULongToPtr(pLdrEntry32->InMemoryOrderLinks.Flink) - FIELD_OFFSET(LDR_DATA_TABLE_ENTRY_F32, InMemoryOrderLinks))
)
{
moduleInformation.DllBase.address = (PVOID) pLdrEntry32->DllBase;
moduleInformation.DllBase.address = ULongToPtr(pLdrEntry32->DllBase);
moduleInformation.SizeOfImage = pLdrEntry32->SizeOfImage;
moduleName.Length = pLdrEntry32->BaseDllName.Length;
moduleName.MaximumLength = pLdrEntry32->BaseDllName.MaximumLength;
moduleName.Buffer = (PWSTR) pLdrEntry32->BaseDllName.Buffer;
moduleName.Buffer = (PWSTR) ULongToPtr(pLdrEntry32->BaseDllName.Buffer);
kull_m_process_adjustTimeDateStamp(&moduleInformation);
continueCallback = callBack(&moduleInformation, pvArg);
}
Expand Down Expand Up @@ -163,27 +163,27 @@ NTSTATUS kull_m_process_getVeryBasicModuleInformations(PKULL_M_MEMORY_HANDLE mem
if(continueCallback && NT_SUCCESS(status) && kull_m_process_peb(memory, (PPEB) &Peb32, TRUE))
{
status = STATUS_PARTIAL_COPY;
aBuffer.address = &LdrData32; aProcess.address = (PVOID) Peb32.Ldr;
aBuffer.address = &LdrData32; aProcess.address = ULongToPtr(Peb32.Ldr);
if(kull_m_memory_copy(&aBuffer, &aProcess, sizeof(LdrData32)))
{
for(
aLire = (PBYTE) (LdrData32.InMemoryOrderModulevector.Flink) - FIELD_OFFSET(LDR_DATA_TABLE_ENTRY_F32, InMemoryOrderLinks),
fin = (PBYTE) (Peb32.Ldr) + FIELD_OFFSET(PEB_LDR_DATA_F32, InLoadOrderModulevector);
aLire = (PBYTE) ULongToPtr(LdrData32.InMemoryOrderModulevector.Flink) - FIELD_OFFSET(LDR_DATA_TABLE_ENTRY_F32, InMemoryOrderLinks),
fin = (PBYTE) ULongToPtr(Peb32.Ldr) + FIELD_OFFSET(PEB_LDR_DATA_F32, InLoadOrderModulevector);
(aLire != fin) && continueCallback;
aLire = (PBYTE) LdrEntry32.InMemoryOrderLinks.Flink - FIELD_OFFSET(LDR_DATA_TABLE_ENTRY_F32, InMemoryOrderLinks)
aLire = (PBYTE) ULongToPtr(LdrEntry32.InMemoryOrderLinks.Flink) - FIELD_OFFSET(LDR_DATA_TABLE_ENTRY_F32, InMemoryOrderLinks)
)
{
aBuffer.address = &LdrEntry32; aProcess.address = aLire;
if(kull_m_memory_copy(&aBuffer, &aProcess, sizeof(LdrEntry32)))
{
moduleInformation.DllBase.address = (PVOID) LdrEntry32.DllBase;
moduleInformation.DllBase.address = ULongToPtr(LdrEntry32.DllBase);
moduleInformation.SizeOfImage = LdrEntry32.SizeOfImage;

moduleName.Length = LdrEntry32.BaseDllName.Length;
moduleName.MaximumLength = LdrEntry32.BaseDllName.MaximumLength;
if(moduleName.Buffer = (PWSTR) LocalAlloc(LPTR, moduleName.MaximumLength))
{
aBuffer.address = moduleName.Buffer; aProcess.address = (PVOID) LdrEntry32.BaseDllName.Buffer;
aBuffer.address = moduleName.Buffer; aProcess.address = ULongToPtr(LdrEntry32.BaseDllName.Buffer);
if(kull_m_memory_copy(&aBuffer, &aProcess, moduleName.MaximumLength))
{
kull_m_process_adjustTimeDateStamp(&moduleInformation);
Expand Down
4 changes: 2 additions & 2 deletions modules/kull_m_token.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ BOOL CALLBACK kull_m_token_getTokens_process_callback(PSYSTEM_PROCESS_INFORMATIO
BOOL status = TRUE;
HANDLE hProcess, hToken;

if(hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, (ULONG) pSystemProcessInformation->UniqueProcessId))
if(hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, PtrToUlong(pSystemProcessInformation->UniqueProcessId)))
{
if(OpenProcessToken(hProcess, TOKEN_QUERY | TOKEN_DUPLICATE, &hToken))
{
status = ((PKULL_M_TOKEN_ENUM_DATA) pvArg)->callback(hToken, (ULONG) pSystemProcessInformation->UniqueProcessId, ((PKULL_M_TOKEN_ENUM_DATA) pvArg)->pvArg);
status = ((PKULL_M_TOKEN_ENUM_DATA) pvArg)->callback(hToken, PtrToUlong(pSystemProcessInformation->UniqueProcessId), ((PKULL_M_TOKEN_ENUM_DATA) pvArg)->pvArg);
CloseHandle(hToken);
}
CloseHandle(hProcess);
Expand Down

0 comments on commit e6924b7

Please sign in to comment.