rapid7/metasploit-framework

View on GitHub
lib/metasploit/framework/password_crackers/hashcat/formatter.rb

Summary

Maintainability
C
1 day
Test Coverage

Method hash_to_hashcat has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

          def self.hash_to_hashcat(cred)
            case cred.private.type
            when 'Metasploit::Credential::NTLMHash'
              both = cred.private.data.split(':')
              if both[0].upcase == 'AAD3B435B51404EEAAD3B435B51404EE' # lanman empty, return ntlm
Severity: Minor
Found in lib/metasploit/framework/password_crackers/hashcat/formatter.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 hash_to_hashcat has 76 lines of code (exceeds 25 allowed). Consider refactoring.
Open

          def self.hash_to_hashcat(cred)
            case cred.private.type
            when 'Metasploit::Credential::NTLMHash'
              both = cred.private.data.split(':')
              if both[0].upcase == 'AAD3B435B51404EEAAD3B435B51404EE' # lanman empty, return ntlm
Severity: Major
Found in lib/metasploit/framework/password_crackers/hashcat/formatter.rb - About 3 hrs to fix

    Avoid too many return statements within this method.
    Open

                      return "#{cred.id}:#{Regexp.last_match(1).scan(/.{1,40}/m).join(':').downcase}"
    Severity: Major
    Found in lib/metasploit/framework/password_crackers/hashcat/formatter.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                        return "#{cred.id}:#{cred.private.data}"
      Severity: Major
      Found in lib/metasploit/framework/password_crackers/hashcat/formatter.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                          return "#{cred.id}:#{Regexp.last_match(1).upcase}"
        Severity: Major
        Found in lib/metasploit/framework/password_crackers/hashcat/formatter.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return "#{cred.id}:#{cred.private.data}"
          Severity: Major
          Found in lib/metasploit/framework/password_crackers/hashcat/formatter.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return "#{cred.id}:$cram_md5$#{Rex::Text.encode_base64(data[0])}$#{password}"
            Severity: Major
            Found in lib/metasploit/framework/password_crackers/hashcat/formatter.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return "#{cred.id}:#{cred.private.data.split(':').first}"
              Severity: Major
              Found in lib/metasploit/framework/password_crackers/hashcat/formatter.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return "#{cred.id}:#{cred.private.data}"
                Severity: Major
                Found in lib/metasploit/framework/password_crackers/hashcat/formatter.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return "#{cred.id}:#{cred.private.data}"
                  Severity: Major
                  Found in lib/metasploit/framework/password_crackers/hashcat/formatter.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return "#{cred.id}:#{cred.private.data.sub('$HEX$', ':').sub('$dynamic_82$', '')}"
                    Severity: Major
                    Found in lib/metasploit/framework/password_crackers/hashcat/formatter.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return "#{cred.id}:#{cred.private.data.downcase.sub('*', '')}"
                      Severity: Major
                      Found in lib/metasploit/framework/password_crackers/hashcat/formatter.rb - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                          return "#{cred.id}:#{hash}:#{salt}"
                        Severity: Major
                        Found in lib/metasploit/framework/password_crackers/hashcat/formatter.rb - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                            return "#{cred.id}:#{Regexp.last_match(1)}:#{cred.public.username}"
                          Severity: Major
                          Found in lib/metasploit/framework/password_crackers/hashcat/formatter.rb - About 30 mins to fix

                            There are no issues that match your filters.

                            Category
                            Status