rapid7/metasploit-framework

View on GitHub
modules/exploits/windows/http/exchange_proxynotshell_rce.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method initialize has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name' => 'Microsoft Exchange ProxyNotShell RCE',
Severity: Major
Found in modules/exploits/windows/http/exchange_proxynotshell_rce.rb - About 2 hrs to fix

    Method execute_command has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def execute_command(cmd, _opts = {})
        xaml = Nokogiri::XML(<<-XAML, nil, nil, Nokogiri::XML::ParseOptions::NOBLANKS).root
          <ResourceDictionary
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Severity: Minor
    Found in modules/exploits/windows/http/exchange_proxynotshell_rce.rb - About 1 hr to fix

      Method check has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def check
          @ssrf_email ||= Faker::Internet.email
          res = send_http('GET', '/mapi/nspi/')
          return CheckCode::Unknown if res.nil?
          return CheckCode::Unknown('Server responded with 401 Unauthorized.') if res.code == 401
      Severity: Minor
      Found in modules/exploits/windows/http/exchange_proxynotshell_rce.rb - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method generate has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.generate
          from_values([
            Types::RecordValues::SerializationHeaderRecord.new(root_id: 1, header_id: -1),
            Types::RecordValues::SystemClassWithMembersAndTypes.from_member_values(
              class_info: Types::General::ClassInfo.new(
      Severity: Minor
      Found in modules/exploits/windows/http/exchange_proxynotshell_rce.rb - About 1 hr to fix

        Method exploit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def exploit
            # if we're doing pre-exploit checks, make sure the target is Exchange Server 2019 because the XamlGadget does not
            # work on Exchange Server 2016
            if datastore['AutoCheck'] && !datastore['ForceExploit'] && (version = exchange_get_version)
              vprint_status("Detected Exchange version: #{version}")
        Severity: Minor
        Found in modules/exploits/windows/http/exchange_proxynotshell_rce.rb - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        There are no issues that match your filters.

        Category
        Status