rapid7/metasploit-framework

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

Summary

Maintainability
D
1 day
Test Coverage

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

  def initialize(info = {})
    super(update_info(info,
      'Name'           => 'Samba SetInformationPolicy AuditEventsInfo Heap Overflow',
      'Description'    => %q{
          This module triggers a vulnerability in the LSA RPC service of the Samba daemon
Severity: Major
Found in modules/exploits/linux/samba/setinfopolicy_heap.rb - About 5 hrs to fix

    File setinfopolicy_heap.rb has 305 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class MetasploitModule < Msf::Exploit::Remote
      Rank = NormalRanking
    
      include Msf::Exploit::Remote::DCERPC
      include Msf::Exploit::Remote::SMB::Client
    Severity: Minor
    Found in modules/exploits/linux/samba/setinfopolicy_heap.rb - About 3 hrs to fix

      Method brute_exploit has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def brute_exploit(target_addrs)
          print_status("Trying to exploit Samba with address 0x%.8x..." % target_addrs['libgcrypt_base'])
          datastore['DCERPC::fake_bind_multi'] = false
          datastore['DCERPC::max_frag_size'] = 4248
          datastore['DCERPC::smb_pipeio'] = 'trans'
      Severity: Major
      Found in modules/exploits/linux/samba/setinfopolicy_heap.rb - About 2 hrs to fix

        Method call has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def call(dcerpc, function, data, do_recv = true)
        
            frag_size = data.length
            if dcerpc.options['frag_size']
              frag_size = dcerpc.options['frag_size']
        Severity: Minor
        Found in modules/exploits/linux/samba/setinfopolicy_heap.rb - About 1 hr to fix

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

            def exploit
              if target.bruteforce?
                bf = target.bruteforce
          
                if datastore['StartBrute'] and datastore['StartBrute'] > 0
          Severity: Minor
          Found in modules/exploits/linux/samba/setinfopolicy_heap.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 call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def call(dcerpc, function, data, do_recv = true)
          
              frag_size = data.length
              if dcerpc.options['frag_size']
                frag_size = dcerpc.options['frag_size']
          Severity: Minor
          Found in modules/exploits/linux/samba/setinfopolicy_heap.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 make_request has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def make_request(opnum=0, data="", size=data.length, ctx=0, object_id = '')
          Severity: Minor
          Found in modules/exploits/linux/samba/setinfopolicy_heap.rb - About 35 mins to fix

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

              def brute_exploit(target_addrs)
                print_status("Trying to exploit Samba with address 0x%.8x..." % target_addrs['libgcrypt_base'])
                datastore['DCERPC::fake_bind_multi'] = false
                datastore['DCERPC::max_frag_size'] = 4248
                datastore['DCERPC::smb_pipeio'] = 'trans'
            Severity: Minor
            Found in modules/exploits/linux/samba/setinfopolicy_heap.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::Unknown
            Severity: Major
            Found in modules/exploits/linux/samba/setinfopolicy_heap.rb - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status