rapid7/metasploit-framework

View on GitHub
modules/auxiliary/spoof/arp/arp_poisoning.rb

Summary

Maintainability
F
6 days
Test Coverage

Method arp_poisoning has a Cognitive Complexity of 97 (exceeds 5 allowed). Consider refactoring.
Open

  def arp_poisoning
    lsmac = datastore['LOCALSMAC'] || @smac
    raise 'Local Source Mac is not in correct format' unless is_mac?(lsmac)

    dhosts_range = Rex::Socket::RangeWalker.new(datastore['DHOSTS'])
Severity: Minor
Found in modules/auxiliary/spoof/arp/arp_poisoning.rb - About 1 day 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 run has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    open_pcap({'SNAPLEN' => 68, 'FILTER' => "arp[6:2] == 0x0002"})
    @netifaces = true
    if not netifaces_implemented?
      print_error("WARNING : Pcaprub is not uptodate, some functionality will not be available")
Severity: Minor
Found in modules/auxiliary/spoof/arp/arp_poisoning.rb - About 1 day 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 start_listener has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

  def start_listener(dsthosts_cache, srchosts_cache)

    if datastore['BIDIRECTIONAL']
      args = {:BIDIRECTIONAL => true,  :dhosts => dsthosts_cache.dup, :shosts => srchosts_cache.dup}
    else
Severity: Minor
Found in modules/auxiliary/spoof/arp/arp_poisoning.rb - About 5 hrs 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 arp_poisoning has 127 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def arp_poisoning
    lsmac = datastore['LOCALSMAC'] || @smac
    raise 'Local Source Mac is not in correct format' unless is_mac?(lsmac)

    dhosts_range = Rex::Socket::RangeWalker.new(datastore['DHOSTS'])
Severity: Major
Found in modules/auxiliary/spoof/arp/arp_poisoning.rb - About 5 hrs to fix

    File arp_poisoning.rb has 362 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class MetasploitModule < Msf::Auxiliary
      include Msf::Exploit::Remote::Capture
      include Msf::Auxiliary::Report
    
      def initialize
    Severity: Minor
    Found in modules/auxiliary/spoof/arp/arp_poisoning.rb - About 4 hrs to fix

      Method run has 88 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def run
          open_pcap({'SNAPLEN' => 68, 'FILTER' => "arp[6:2] == 0x0002"})
          @netifaces = true
          if not netifaces_implemented?
            print_error("WARNING : Pcaprub is not uptodate, some functionality will not be available")
      Severity: Major
      Found in modules/auxiliary/spoof/arp/arp_poisoning.rb - About 3 hrs to fix

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

          def start_listener(dsthosts_cache, srchosts_cache)
        
            if datastore['BIDIRECTIONAL']
              args = {:BIDIRECTIONAL => true,  :dhosts => dsthosts_cache.dup, :shosts => srchosts_cache.dup}
            else
        Severity: Major
        Found in modules/auxiliary/spoof/arp/arp_poisoning.rb - About 2 hrs to fix

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

            def initialize
              super(
                'Name'        => 'ARP Spoof',
                'Description' => %q{
                  Spoof ARP replies and poison remote ARP caches to conduct IP address spoofing or a denial of service.
          Severity: Minor
          Found in modules/auxiliary/spoof/arp/arp_poisoning.rb - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                            if (liste_dst_ips.include? pkt.arp_saddr_ip and liste_src_ips.include? pkt.arp_daddr_ip) or
                              (args[:BIDIRECTIONAL] and liste_dst_ips.include? pkt.arp_daddr_ip and liste_src_ips.include? pkt.arp_saddr_ip)
                              vprint_status("Listener : Request from #{pkt.arp_saddr_ip} for #{pkt.arp_daddr_ip}")
                              reply = buildreply(pkt.arp_daddr_ip, @smac, pkt.arp_saddr_ip, pkt.eth_saddr)
                              3.times{listener_capture.inject(reply.to_s)}
            Severity: Major
            Found in modules/auxiliary/spoof/arp/arp_poisoning.rb - About 45 mins to fix

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  while (Time.now.to_f < etime)
                    while(reply = getreply())
                      next if not reply.is_arp?
                      if @dhosts.include? reply.arp_saddr_ip
                        print_good("#{reply.arp_saddr_ip} appears to be up.")
              Severity: Major
              Found in modules/auxiliary/spoof/arp/arp_poisoning.rb and 1 other location - About 1 hr to fix
              modules/auxiliary/spoof/arp/arp_poisoning.rb on lines 228..237

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 48.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                    while (Time.now.to_f < etime)
                      while(reply = getreply())
                        next if not reply.is_arp?
                        if @shosts.include? reply.arp_saddr_ip
                          print_good("#{reply.arp_saddr_ip} appears to be up.")
              Severity: Major
              Found in modules/auxiliary/spoof/arp/arp_poisoning.rb and 1 other location - About 1 hr to fix
              modules/auxiliary/spoof/arp/arp_poisoning.rb on lines 191..200

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 48.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                            @srchosts_cache.keys.sort.each do |shost|
                              smac = @srchosts_cache[shost]
                              if shost != dhost
                                vprint_status("Sending arp packet for #{shost} to #{dhost}")
                                reply = buildreply(shost, smac, dhost, dmac)
              Severity: Minor
              Found in modules/auxiliary/spoof/arp/arp_poisoning.rb and 1 other location - About 50 mins to fix
              modules/auxiliary/spoof/arp/arp_poisoning.rb on lines 134..140

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 43.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                        @dsthosts_cache.keys.sort.each do |dhost|
                          dmac = @dsthosts_cache[dhost]
                          if shost != dhost
                            vprint_status("Sending arp packet for #{dhost} to #{shost}")
                            reply = buildreply(dhost, @smac, shost, smac)
              Severity: Minor
              Found in modules/auxiliary/spoof/arp/arp_poisoning.rb and 1 other location - About 50 mins to fix
              modules/auxiliary/spoof/arp/arp_poisoning.rb on lines 271..277

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 43.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                            @dsthosts_cache.keys.sort.each do |dhost|
                              dmac = @dsthosts_cache[dhost]
                              if shost != dhost
                                vprint_status("Sending arp packet for #{dhost} to #{shost}")
                                reply = buildreply(dhost, dmac, shost, smac)
              Severity: Minor
              Found in modules/auxiliary/spoof/arp/arp_poisoning.rb and 1 other location - About 50 mins to fix
              modules/auxiliary/spoof/arp/arp_poisoning.rb on lines 111..117

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 43.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                        @srchosts_cache.keys.sort.each do |shost|
                          smac = @srchosts_cache[shost]
                          if shost != dhost
                            vprint_status("Sending arp packet for #{shost} to #{dhost}")
                            reply = buildreply(shost, @smac, dhost, dmac)
              Severity: Minor
              Found in modules/auxiliary/spoof/arp/arp_poisoning.rb and 1 other location - About 50 mins to fix
              modules/auxiliary/spoof/arp/arp_poisoning.rb on lines 295..301

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 43.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              There are no issues that match your filters.

              Category
              Status