rapid7/metasploit-framework

View on GitHub
modules/post/multi/manage/shell_to_meterpreter.rb

Summary

Maintainability
F
4 days
Test Coverage

Method run has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    print_status("Upgrading session ID: #{datastore['SESSION']}")

    # Try hard to find a valid LHOST value in order to
    # make running 'sessions -u' as robust as possible.
Severity: Minor
Found in modules/post/multi/manage/shell_to_meterpreter.rb - About 1 day 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 run has 161 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def run
    print_status("Upgrading session ID: #{datastore['SESSION']}")

    # Try hard to find a valid LHOST value in order to
    # make running 'sessions -u' as robust as possible.
Severity: Major
Found in modules/post/multi/manage/shell_to_meterpreter.rb - About 6 hrs to fix

    File shell_to_meterpreter.rb has 363 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'rex/exploitation/cmdstager'
    
    class MetasploitModule < Msf::Post
      include Exploit::Powershell
      include Post::Architecture
    Severity: Minor
    Found in modules/post/multi/manage/shell_to_meterpreter.rb - About 4 hrs to fix

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

        def transmit_payload(exe, platform)
          #
          # Generate the stager command array
          #
          linemax = 1700
      Severity: Minor
      Found in modules/post/multi/manage/shell_to_meterpreter.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 transmit_payload has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def transmit_payload(exe, platform)
          #
          # Generate the stager command array
          #
          linemax = 1700
      Severity: Major
      Found in modules/post/multi/manage/shell_to_meterpreter.rb - About 2 hrs to fix

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

          def initialize(info = {})
            super(
              update_info(
                info,
                'Name' => 'Shell to Meterpreter Upgrade',
        Severity: Minor
        Found in modules/post/multi/manage/shell_to_meterpreter.rb - About 1 hr to fix

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

            def cleanup_handler(listener_job_id, aborted)
              # Return if the job has already finished
              return nil if framework.jobs[listener_job_id].nil?
          
              framework.threads.spawn('ShellToMeterpreterUpgradeCleanup', false) do
          Severity: Minor
          Found in modules/post/multi/manage/shell_to_meterpreter.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 check_for_listener has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def check_for_listener(lhost, lport)
              client.framework.jobs.each do |_k, j|
                next unless j.name =~ %r{ multi/handler}
          
                current_id = j.jid
          Severity: Minor
          Found in modules/post/multi/manage/shell_to_meterpreter.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

          Avoid too many return statements within this method.
          Open

                return nil
          Severity: Major
          Found in modules/post/multi/manage/shell_to_meterpreter.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                      return nil
            Severity: Major
            Found in modules/post/multi/manage/shell_to_meterpreter.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return nil
              Severity: Major
              Found in modules/post/multi/manage/shell_to_meterpreter.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                          return nil
                Severity: Major
                Found in modules/post/multi/manage/shell_to_meterpreter.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                            return nil
                  Severity: Major
                  Found in modules/post/multi/manage/shell_to_meterpreter.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                          return nil
                    Severity: Major
                    Found in modules/post/multi/manage/shell_to_meterpreter.rb - About 30 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status