rapid7/metasploit-framework

View on GitHub
lib/metasploit/framework/password_crackers/cracker.rb

Summary

Maintainability
D
2 days
Test Coverage

File cracker.rb has 357 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Metasploit
  module Framework
    module PasswordCracker
      class PasswordCrackerNotFoundError < StandardError
      end
Severity: Minor
Found in lib/metasploit/framework/password_crackers/cracker.rb - About 4 hrs to fix

    Method jtr_format_to_hashcat_format has 84 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def jtr_format_to_hashcat_format(format)
              case format
              # nix
              when 'md5crypt'
                '500'
    Severity: Major
    Found in lib/metasploit/framework/password_crackers/cracker.rb - About 3 hrs to fix

      Method cracker_version has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

              def cracker_version
                if cracker == 'john'
                  cmd = binary_path
                elsif cracker == 'hashcat'
                  cmd = binary_path
      Severity: Minor
      Found in lib/metasploit/framework/password_crackers/cracker.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 hashcat_crack_command has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

              def hashcat_crack_command
                cmd_string = binary_path
                cmd = [cmd_string, '--session=' + cracker_session_id, '--logfile-disable', '--quiet', '--username']
      
                if pot.present?
      Severity: Minor
      Found in lib/metasploit/framework/password_crackers/cracker.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 hashcat_crack_command has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def hashcat_crack_command
                cmd_string = binary_path
                cmd = [cmd_string, '--session=' + cracker_session_id, '--logfile-disable', '--quiet', '--username']
      
                if pot.present?
      Severity: Minor
      Found in lib/metasploit/framework/password_crackers/cracker.rb - About 1 hr to fix

        Method john_crack_command has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

                def john_crack_command
                  cmd_string = binary_path
        
                  cmd = [cmd_string, '--session=' + cracker_session_id, john_nolog_format]
        
        
        Severity: Minor
        Found in lib/metasploit/framework/password_crackers/cracker.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 john_crack_command has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def john_crack_command
                  cmd_string = binary_path
        
                  cmd = [cmd_string, '--session=' + cracker_session_id, john_nolog_format]
        
        
        Severity: Minor
        Found in lib/metasploit/framework/password_crackers/cracker.rb - About 1 hr to fix

          Method binary_path has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                  def binary_path
                    # Always prefer a manually entered path
                    if cracker_path && ::File.file?(cracker_path)
                      return cracker_path
                    else
          Severity: Minor
          Found in lib/metasploit/framework/password_crackers/cracker.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 john_nolog_format has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                  def john_nolog_format
                    if /(\d{4}-\d{2}-\d{2})/ =~ cracker_version
                      # we lucked out and theres a date, we'll check its older than the commit that changed the nolog
                      if Date.parse(Regexp.last_match(1)) < Date.parse('2020-11-27')
                        return '--nolog'
          Severity: Minor
          Found in lib/metasploit/framework/password_crackers/cracker.rb - About 25 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 show_command has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                  def show_command
                    cmd_string = binary_path
          
                    pot_file = pot || john_pot_file
                    if cracker == 'hashcat'
          Severity: Minor
          Found in lib/metasploit/framework/password_crackers/cracker.rb - About 25 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