rapid7/metasploit-framework

View on GitHub
modules/exploits/linux/samba/is_known_pipename.rb

Summary

Maintainability
D
2 days
Test Coverage

File is_known_pipename.rb has 360 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

  include Msf::Exploit::Remote::DCERPC
  include Msf::Exploit::Remote::SMB::Client
Severity: Minor
Found in modules/exploits/linux/samba/is_known_pipename.rb - About 4 hrs to fix

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

      def initialize(info = {})
        super(update_info(info,
          'Name'           => 'Samba is_known_pipename() Arbitrary Module Load',
          'Description'    => %q{
              This module triggers an arbitrary shared library load vulnerability
    Severity: Major
    Found in modules/exploits/linux/samba/is_known_pipename.rb - About 2 hrs to fix

      Method cycle_possible_payloads has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def cycle_possible_payloads
          template_base = ::File.join(Msf::Config.data_directory, "exploits", "CVE-2017-7494")
          template_list = []
          template_type = nil
          template_arch = nil
      Severity: Minor
      Found in modules/exploits/linux/samba/is_known_pipename.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 cycle_possible_payloads has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def cycle_possible_payloads
          template_base = ::File.join(Msf::Config.data_directory, "exploits", "CVE-2017-7494")
          template_list = []
          template_type = nil
          template_arch = nil
      Severity: Minor
      Found in modules/exploits/linux/samba/is_known_pipename.rb - About 1 hr to fix

        Method check has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def check
            res = smb_fingerprint
        
            unless res['native_lm'] =~ /Samba ([\d\.]+)/
              print_error("does not appear to be Samba: #{res['os']} / #{res['native_lm']}")
        Severity: Minor
        Found in modules/exploits/linux/samba/is_known_pipename.rb - About 1 hr to fix

          Method trigger_payload has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def trigger_payload
          
              target = [@share_path, @path, @payload_name].join("/").gsub(/\/+/, '/')
              [
                "\\\\PIPE\\" + target,
          Severity: Minor
          Found in modules/exploits/linux/samba/is_known_pipename.rb - About 1 hr to fix

            Method trigger_payload has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def trigger_payload
            
                target = [@share_path, @path, @payload_name].join("/").gsub(/\/+/, '/')
                [
                  "\\\\PIPE\\" + target,
            Severity: Minor
            Found in modules/exploits/linux/samba/is_known_pipename.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 find_writeable_share_path has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def find_writeable_share_path
                @path = nil
                share_info = smb_netshareenumall
                if datastore['SMB_SHARE_NAME'].to_s.length > 0
                  share_info.unshift [datastore['SMB_SHARE_NAME'], 'DISK', '']
            Severity: Minor
            Found in modules/exploits/linux/samba/is_known_pipename.rb - About 55 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

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

              def check
                res = smb_fingerprint
            
                unless res['native_lm'] =~ /Samba ([\d\.]+)/
                  print_error("does not appear to be Samba: #{res['os']} / #{res['native_lm']}")
            Severity: Minor
            Found in modules/exploits/linux/samba/is_known_pipename.rb - About 45 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

            Method enumerate_directories has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def enumerate_directories(share)
                begin
                  vprint_status('Use Rex client (SMB1 only) to enumerate directories, since it is not compatible with RubySMB client')
                  connect(versions: [1])
                  smb_login
            Severity: Minor
            Found in modules/exploits/linux/samba/is_known_pipename.rb - About 45 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

            Method find_writeable_path has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def find_writeable_path(share)
                subdirs = enumerate_directories(share)
                return unless subdirs
            
                if datastore['SMB_FOLDER'].to_s.length > 0
            Severity: Minor
            Found in modules/exploits/linux/samba/is_known_pipename.rb - About 35 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

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

              def exploit
                # Validate settings
                sanity_check
            
                # Setup SMB
            Severity: Minor
            Found in modules/exploits/linux/samba/is_known_pipename.rb - About 35 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

            Avoid too many return statements within this method.
            Open

                return CheckCode::Appears
            Severity: Major
            Found in modules/exploits/linux/samba/is_known_pipename.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                    return CheckCode::Detected
              Severity: Major
              Found in modules/exploits/linux/samba/is_known_pipename.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                      return CheckCode::Safe
                Severity: Major
                Found in modules/exploits/linux/samba/is_known_pipename.rb - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status