rapid7/metasploit-framework

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

Summary

Maintainability
C
1 day
Test Coverage

File sharepoint_dynamic_proxy_generator_auth_bypass_rce.rb has 313 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'securerandom'

class MetasploitModule < Msf::Exploit::Remote
  Rank = ExcellentRanking

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

      def drop_and_execute_payload
        bdcm_data = "<?xml version=\"1.0\" encoding=\"utf-8\"?>
    <Model
      xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
      xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" Name=\"BDCMetadata\"

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

        def initialize(info = {})
          super(
            update_info(
              info,
              'Name' => 'Sharepoint Dynamic Proxy Generator Unauth RCE',

        Method ensure_target_dir_present has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def ensure_target_dir_present
            res = send_get_request('/_api/web/GetFolderByServerRelativeUrl(\'/\')/Folders')
            @backup_bdc_metadata = ''
            if res&.code == 200 && res&.body&.include?('BusinessDataMetadataCatalog')
              print_status('BDCMetadata file already present on the remote host, backing it up.')

        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 do_auth_bypass has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def do_auth_bypass
            hostname = resolve_target_hostname
            hostname = hostname.split('.')[0] if hostname.include?('.')
        
            print_status("Discovered hostname is: #{hostname}")

        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 get_oauth_info has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def get_oauth_info(hostname)
            vprint_status('getting oauth info')
            res = send_request_cgi({
              'uri' => normalize_uri(target_uri.path, '_api', 'web'),
              'method' => 'GET',

        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