rapid7/metasploit-framework

View on GitHub
modules/auxiliary/server/capture/mssql.rb

Summary

Maintainability
F
1 wk
Test Coverage

Method mssql_get_hash has a Cognitive Complexity of 135 (exceeds 5 allowed). Consider refactoring.
Open

  def mssql_get_hash(arg = {})
    ntlm_ver = arg[:ntlm_ver]
    if ntlm_ver == NTLM_CONST::NTLM_V1_RESPONSE or ntlm_ver == NTLM_CONST::NTLM_2_SESSION_RESPONSE
      lm_hash = arg[:lm_hash]
      nt_hash = arg[:nt_hash]
Severity: Minor
Found in modules/auxiliary/server/capture/mssql.rb - About 2 days 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

File mssql.rb has 470 lines of code (exceeds 250 allowed). Consider refactoring.
Open

NTLM_CONST = Rex::Proto::NTLM::Constants
NTLM_CRYPT = Rex::Proto::NTLM::Crypt
NTLM_UTILS = Rex::Proto::NTLM::Utils
MESSAGE = Rex::Proto::NTLM::Message

Severity: Minor
Found in modules/auxiliary/server/capture/mssql.rb - About 7 hrs to fix

    Method mssql_get_hash has 167 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def mssql_get_hash(arg = {})
        ntlm_ver = arg[:ntlm_ver]
        if ntlm_ver == NTLM_CONST::NTLM_V1_RESPONSE or ntlm_ver == NTLM_CONST::NTLM_2_SESSION_RESPONSE
          lm_hash = arg[:lm_hash]
          nt_hash = arg[:nt_hash]
    Severity: Major
    Found in modules/auxiliary/server/capture/mssql.rb - About 6 hrs to fix

      Method mssql_parse_ntlmsspi has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def mssql_parse_ntlmsspi(data, info)
          start = data.index('NTLMSSP')
          if start
            data.slice!(0,start)
          else
      Severity: Minor
      Found in modules/auxiliary/server/capture/mssql.rb - About 1 hr to fix

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

          def mssql_parse_ntlmsspi(data, info)
            start = data.index('NTLMSSP')
            if start
              data.slice!(0,start)
            else
        Severity: Minor
        Found in modules/auxiliary/server/capture/mssql.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 mssql_parse_login has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def mssql_parse_login(data, info)
            status = data.slice!(0,1).unpack('C')[0]
            len = data.slice!(0,2).unpack('n')[0]
        
            if len > data.length + 4
        Severity: Minor
        Found in modules/auxiliary/server/capture/mssql.rb - About 1 hr to fix

          Method on_client_data has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def on_client_data(c)
              info = {:errors => [], :ip => @state[c][:ip]}
              data = c.get_once
              return if not data
          
          
          Severity: Minor
          Found in modules/auxiliary/server/capture/mssql.rb - About 1 hr to fix

            Method mssql_send_ntlm_challenge has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def mssql_send_ntlm_challenge(c, info)
                win_domain = Rex::Text.to_unicode(@domain_name.upcase)
                win_name = Rex::Text.to_unicode(@domain_name.upcase)
                dns_domain = Rex::Text.to_unicode(@domain_name.downcase)
                dns_name = Rex::Text.to_unicode(@domain_name.downcase)
            Severity: Minor
            Found in modules/auxiliary/server/capture/mssql.rb - About 1 hr to fix

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

                def initialize
                  super(
                    'Name'           => 'Authentication Capture: MSSQL',
                    'Description'    => %q{
                      This module provides a fake MSSQL service that
              Severity: Minor
              Found in modules/auxiliary/server/capture/mssql.rb - About 1 hr to fix

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

                  def on_client_data(c)
                    info = {:errors => [], :ip => @state[c][:ip]}
                    data = c.get_once
                    return if not data
                
                
                Severity: Minor
                Found in modules/auxiliary/server/capture/mssql.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

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

                  def mssql_parse_login(data, info)
                    status = data.slice!(0,1).unpack('C')[0]
                    len = data.slice!(0,2).unpack('n')[0]
                
                    if len > data.length + 4
                Severity: Minor
                Found in modules/auxiliary/server/capture/mssql.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

                Method mssql_parse_reply has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def mssql_parse_reply(data, info)
                    info[:errors] = []
                    return if not data
                    until data.empty? or ( info[:errors] and not info[:errors].empty? )
                      token = data.slice!(0,1).unpack('C')[0]
                Severity: Minor
                Found in modules/auxiliary/server/capture/mssql.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

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

                      case ntlm_ver
                      when NTLM_CONST::NTLM_V1_RESPONSE
                        if NTLM_CRYPT::is_hash_from_empty_pwd?({:hash => [nt_hash].pack("H*"),:srv_challenge => @challenge,
                          :ntlm_ver => NTLM_CONST::NTLM_V1_RESPONSE, :type => 'ntlm' })
                          print_status("NLMv1 Hash correspond to an empty password, ignoring ... ")
                Severity: Major
                Found in modules/auxiliary/server/capture/mssql.rb and 1 other location - About 5 hrs to fix
                modules/auxiliary/server/capture/http_ntlm.rb on lines 232..280

                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 196.

                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

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

                      if(datastore['JOHNPWFILE'] and user)
                        case ntlm_ver
                        when NTLM_CONST::NTLM_V1_RESPONSE, NTLM_CONST::NTLM_2_SESSION_RESPONSE
                          fd = File.open(datastore['JOHNPWFILE'] + '_netntlm', "ab")
                          fd.puts(
                Severity: Major
                Found in modules/auxiliary/server/capture/mssql.rb and 1 other location - About 4 hrs to fix
                modules/auxiliary/server/capture/http_ntlm.rb on lines 353..395

                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 144.

                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

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

                      if(datastore['CAINPWFILE'] and user)
                        if ntlm_ver == NTLM_CONST::NTLM_V1_RESPONSE or ntlm_ver == NTLM_CONST::NTLM_2_SESSION_RESPONSE
                          fd = File.open(datastore['CAINPWFILE'], "ab")
                          fd.puts(
                          [
                Severity: Major
                Found in modules/auxiliary/server/capture/mssql.rb and 1 other location - About 1 hr to fix
                modules/auxiliary/server/capture/http_ntlm.rb on lines 337..351

                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 56.

                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

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

                        capturelogmessage =
                        "#{capturedtime}\nNTLMv2 Response Captured from #{host} \n" +
                        "DOMAIN: #{domain} USER: #{user} \n" +
                        "LMHASH:#{lm_hash_message ? lm_hash_message : "<NULL>"} " +
                        "LM_CLIENT_CHALLENGE:#{lm_chall_message ? lm_chall_message : "<NULL>"}\n" +
                Severity: Major
                Found in modules/auxiliary/server/capture/mssql.rb and 1 other location - About 1 hr to fix
                modules/auxiliary/server/capture/http_ntlm.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 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

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

                    if ntlm_ver == NTLM_CONST::NTLM_V1_RESPONSE or ntlm_ver == NTLM_CONST::NTLM_2_SESSION_RESPONSE
                      lm_hash = arg[:lm_hash]
                      nt_hash = arg[:nt_hash]
                    else
                      lm_hash = arg[:lm_hash]
                Severity: Minor
                Found in modules/auxiliary/server/capture/mssql.rb and 1 other location - About 35 mins to fix
                modules/auxiliary/server/capture/http_ntlm.rb on lines 212..220

                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 36.

                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

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

                        capturelogmessage =
                        "#{capturedtime}\nNTLM2_SESSION Response Captured from #{host} \n" +
                        "DOMAIN: #{domain} USER: #{user} \n" +
                        "NTHASH:#{nt_hash ? nt_hash : "<NULL>"}\n" +
                        "NT_CLIENT_CHALLENGE:#{lm_hash_message ? lm_hash_message[0,16] : "<NULL>"} \n"
                Severity: Minor
                Found in modules/auxiliary/server/capture/mssql.rb and 1 other location - About 35 mins to fix
                modules/auxiliary/server/capture/http_ntlm.rb on lines 305..309

                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 35.

                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

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

                        capturelogmessage =
                        "#{capturedtime}\nNTLMv1 Response Captured from #{host} \n" +
                        "DOMAIN: #{domain} USER: #{user} \n" +
                        "LMHASH:#{lm_hash_message ? lm_hash_message : "<NULL>"} \nNTHASH:#{nt_hash ? nt_hash : "<NULL>"}\n"
                Severity: Minor
                Found in modules/auxiliary/server/capture/mssql.rb and 1 other location - About 25 mins to fix
                modules/auxiliary/server/capture/http_ntlm.rb on lines 290..293

                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 30.

                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