rapid7/metasploit-framework

View on GitHub
scripts/meterpreter/netenum.rb

Summary

Maintainability
D
2 days
Test Coverage

File netenum.rb has 308 lines of code (exceeds 250 allowed). Consider refactoring.
Open

@@exec_opts = Rex::Parser::Arguments.new(
  "-h"  => [ false, "Help menu." ],
  "-r"  => [ true,  "The target address range or CIDR identifier" ],
  "-p" => [ false, "To Perform Ping Sweep on IP Range" ],
  "-l" => [ false, "To Perform DNS Reverse Lookup on IP Range" ],
Severity: Minor
Found in scripts/meterpreter/netenum.rb - About 3 hrs to fix

    Method pingsweep has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def pingsweep(session, iprange, dest)
      dest = dest + "-pingsweep.txt"
      print_status("Performing ping sweep for IP range #{iprange}")
      filewrt(dest,"Ping sweep for IP range #{iprange}")
      iplst = []
    Severity: Minor
    Found in scripts/meterpreter/netenum.rb - About 3 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 reverselookup has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def reverselookup(session, iprange, dest)
      dest = dest + "-DNS-reverse-lookup.txt"
      print_status("Performing DNS reverse lookup for IP range #{iprange}")
      filewrt(dest,"DNS reverse lookup for IP range #{iprange}")
      iplst =[]
    Severity: Minor
    Found in scripts/meterpreter/netenum.rb - About 3 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 pingsweep has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def pingsweep(session, iprange, dest)
      dest = dest + "-pingsweep.txt"
      print_status("Performing ping sweep for IP range #{iprange}")
      filewrt(dest,"Ping sweep for IP range #{iprange}")
      iplst = []
    Severity: Minor
    Found in scripts/meterpreter/netenum.rb - About 1 hr to fix

      Method reverselookup has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def reverselookup(session, iprange, dest)
        dest = dest + "-DNS-reverse-lookup.txt"
        print_status("Performing DNS reverse lookup for IP range #{iprange}")
        filewrt(dest,"DNS reverse lookup for IP range #{iprange}")
        iplst =[]
      Severity: Minor
      Found in scripts/meterpreter/netenum.rb - About 1 hr to fix

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

        def frwdlp(session, hostlst, domain, dest)
          dest = dest + "-DNS-forward-lookup.txt"
          print_status("Performing DNS forward lookup for hosts in #{hostlst} for domain #{domain}")
          filewrt(dest,"DNS forward lookup for hosts in #{hostlst} for domain #{domain}")
          result = []
        Severity: Minor
        Found in scripts/meterpreter/netenum.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 frwdlp has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def frwdlp(session, hostlst, domain, dest)
          dest = dest + "-DNS-forward-lookup.txt"
          print_status("Performing DNS forward lookup for hosts in #{hostlst} for domain #{domain}")
          filewrt(dest,"DNS forward lookup for hosts in #{hostlst} for domain #{domain}")
          result = []
        Severity: Minor
        Found in scripts/meterpreter/netenum.rb - About 1 hr to fix

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

          def stdlookup(session, domain, dest)
            dest = dest + "-general-record-lookup.txt"
            print_status("Getting MX and NS Records for domain #{domain}")
            filewrt(dest,"SOA, NS and MX Records for domain #{domain}")
            types = ["SOA","NS","MX"]
          Severity: Minor
          Found in scripts/meterpreter/netenum.rb - About 1 hr to fix

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

            def srvreclkp(session, domain, dest)
              dest = dest + "-srvenum.txt"
              srout = []
              garbage = []
              srvrcd = [
            Severity: Minor
            Found in scripts/meterpreter/netenum.rb - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                  if dom != nil && hostlist!= nil &&
                    message(logs)
                    frwdlp(session, hostlist, dom, dest)
                  elsif dom == nil
                    print_error("Please add a domain name for DNS forward lookup: -d <value>")
              Severity: Major
              Found in scripts/meterpreter/netenum.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                  elsif stdlkp == 1
                    if dom != nil
                      message(logs)
                      stdlookup(session, dom, dest)
                    else
                Severity: Major
                Found in scripts/meterpreter/netenum.rb - About 45 mins to fix

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

                  def stdlookup(session, domain, dest)
                    dest = dest + "-general-record-lookup.txt"
                    print_status("Getting MX and NS Records for domain #{domain}")
                    filewrt(dest,"SOA, NS and MX Records for domain #{domain}")
                    types = ["SOA","NS","MX"]
                  Severity: Minor
                  Found in scripts/meterpreter/netenum.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

                  There are no issues that match your filters.

                  Category
                  Status