rapid7/metasploit-framework

View on GitHub
lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb

Summary

Maintainability
F
4 days
Test Coverage

File kiwi.rb has 378 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rex/post/meterpreter/extensions/kiwi/tlv'
require 'rex/post/meterpreter/extensions/kiwi/command_ids'
require 'rexml/document'
require 'set'

Severity: Minor
Found in lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb - About 5 hrs to fix

    Class Kiwi has 30 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Kiwi < Extension
    
      def self.extension_id
        EXTENSION_ID_KIWI
      end
    Severity: Minor
    Found in lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb - About 3 hrs to fix

      Method parse_msv has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

        def parse_msv(output)
          results = {}
          lines = output.lines
      
          while lines.length > 0 do
      Severity: Minor
      Found in lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb - About 2 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 golden_ticket_create has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def golden_ticket_create(opts={})
          cmd = [
            "\"kerberos::golden /user:",
            opts[:user],
            " /domain:",
      Severity: Minor
      Found in lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb - About 2 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 password_change has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        def password_change(opts)
          cmd = "lsadump::changentlm /user:#{opts[:user]}"
          cmd << " /server:#{opts[:server]}" if opts[:server]
          cmd << " /oldpassword:#{opts[:old_pass]}" if opts[:old_pass]
          cmd << " /oldntlm:#{opts[:old_hash]}" if opts[:old_hash]
      Severity: Minor
      Found in lib/rex/post/meterpreter/extensions/kiwi/kiwi.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 parse_kerberos has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def parse_kerberos(output)
          results = {}
          lines = output.lines
      
          while lines.length > 0 do
      Severity: Minor
      Found in lib/rex/post/meterpreter/extensions/kiwi/kiwi.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 parse_wdigest has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def parse_wdigest(output)
          results = {}
          lines = output.lines
      
          while lines.length > 0 do
      Severity: Minor
      Found in lib/rex/post/meterpreter/extensions/kiwi/kiwi.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 parse_tspkg has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def parse_tspkg(output)
          results = {}
          lines = output.lines
      
          while lines.length > 0 do
      Severity: Minor
      Found in lib/rex/post/meterpreter/extensions/kiwi/kiwi.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 parse_livessp has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def parse_livessp(output)
          results = {}
          lines = output.lines
      
          while lines.length > 0 do
      Severity: Minor
      Found in lib/rex/post/meterpreter/extensions/kiwi/kiwi.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 parse_ssp has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def parse_ssp(output)
          results = {}
          lines = output.lines
      
          while lines.length > 0 do
      Severity: Minor
      Found in lib/rex/post/meterpreter/extensions/kiwi/kiwi.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 golden_ticket_create has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def golden_ticket_create(opts={})
          cmd = [
            "\"kerberos::golden /user:",
            opts[:user],
            " /domain:",
      Severity: Minor
      Found in lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb - About 1 hr to fix

        Method wifi_parse_shared has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def wifi_parse_shared(wifi_interfaces)
            results = []
        
            exec_cmd('"base64 /in:off /out:on"')
            wifi_interfaces.keys.each do |key|
        Severity: Minor
        Found in lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb - About 1 hr to fix

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

            def password_change(opts)
              cmd = "lsadump::changentlm /user:#{opts[:user]}"
              cmd << " /server:#{opts[:server]}" if opts[:server]
              cmd << " /oldpassword:#{opts[:old_pass]}" if opts[:old_pass]
              cmd << " /oldntlm:#{opts[:old_hash]}" if opts[:old_hash]
          Severity: Minor
          Found in lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb - About 1 hr to fix

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

              def parse_msv(output)
                results = {}
                lines = output.lines
            
                while lines.length > 0 do
            Severity: Minor
            Found in lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb - About 1 hr to fix

              Method wifi_parse_shared has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                def wifi_parse_shared(wifi_interfaces)
                  results = []
              
                  exec_cmd('"base64 /in:off /out:on"')
                  wifi_interfaces.keys.each do |key|
              Severity: Minor
              Found in lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb - About 55 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 dcsync_ntlm has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def dcsync_ntlm(domain_user)
                  result = {
                    ntlm: '<NOT FOUND>',
                    lm: '<NOT FOUND>',
                    sid: '<NOT FOUND>',
              Severity: Minor
              Found in lib/rex/post/meterpreter/extensions/kiwi/kiwi.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

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

                def parse_kerberos(output)
                  results = {}
                  lines = output.lines
              
                  while lines.length > 0 do
              Severity: Major
              Found in lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb and 2 other locations - About 1 hr to fix
              lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb on lines 244..272
              lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb on lines 275..303

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

              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 3 locations. Consider refactoring.
              Open

                def parse_tspkg(output)
                  results = {}
                  lines = output.lines
              
                  while lines.length > 0 do
              Severity: Major
              Found in lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb and 2 other locations - About 1 hr to fix
              lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb on lines 244..272
              lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb on lines 306..334

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

              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 3 locations. Consider refactoring.
              Open

                def parse_wdigest(output)
                  results = {}
                  lines = output.lines
              
                  while lines.length > 0 do
              Severity: Major
              Found in lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb and 2 other locations - About 1 hr to fix
              lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb on lines 275..303
              lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb on lines 306..334

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

              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

                def parse_ssp(output)
                  results = {}
                  lines = output.lines
              
                  while lines.length > 0 do
              Severity: Major
              Found in lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb and 1 other location - About 1 hr to fix
              lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb on lines 180..209

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

              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

                def parse_livessp(output)
                  results = {}
                  lines = output.lines
              
                  while lines.length > 0 do
              Severity: Major
              Found in lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb and 1 other location - About 1 hr to fix
              lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb on lines 212..241

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

              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