rapid7/metasploit-framework

View on GitHub
modules/post/windows/manage/execute_dotnet_assembly.rb

Summary

Maintainability
D
2 days
Test Coverage

File execute_dotnet_assembly.rb has 330 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class MetasploitModule < Msf::Post

  include Msf::Post::File
  include Msf::Exploit::Retry
  include Msf::Post::Windows::Priv
Severity: Minor
Found in modules/post/windows/manage/execute_dotnet_assembly.rb - About 3 hrs to fix

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

      def execute_assembly(exe_path, clr_version)
        if datastore['TECHNIQUE'] == 'SPAWN_AND_INJECT'
          self.hprocess = launch_process
          self.terminate_process = datastore['KILL']
          check_process_suitability(hprocess.pid)
    Severity: Minor
    Found in modules/post/windows/manage/execute_dotnet_assembly.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 execute_assembly has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def execute_assembly(exe_path, clr_version)
        if datastore['TECHNIQUE'] == 'SPAWN_AND_INJECT'
          self.hprocess = launch_process
          self.terminate_process = datastore['KILL']
          check_process_suitability(hprocess.pid)
    Severity: Major
    Found in modules/post/windows/manage/execute_dotnet_assembly.rb - About 2 hrs to fix

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

        def initialize(info = {})
          super(
            update_info(
              info,
              'Name' => 'Execute .net Assembly (x64 only)',
      Severity: Major
      Found in modules/post/windows/manage/execute_dotnet_assembly.rb - About 2 hrs to fix

        Method copy_assembly has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def copy_assembly(pipe_name, appdomain_name, clr_version, exe_path, process)
            print_status("Host injected. Copy assembly into #{process.pid}...")
            # Structure:
            # - Packed metadata (string/data lengths, flags)
            # - Pipe Name
        Severity: Minor
        Found in modules/post/windows/manage/execute_dotnet_assembly.rb - About 1 hr to fix

          Method check_requirements has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def check_requirements(clr_req, installed_dotnet_versions)
              installed_dotnet_versions.each do |fi|
                if clr_req == 'v4.0.30319'
                  if fi[0] == '4'
                    vprint_status('Requirements ok')
          Severity: Minor
          Found in modules/post/windows/manage/execute_dotnet_assembly.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 read_output has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def read_output(pipe, logfilename)
              print_status('Start reading output')
          
              print_status("Writing output to #{logfilename}")
              logfile = File.open(logfilename, 'wb')
          Severity: Minor
          Found in modules/post/windows/manage/execute_dotnet_assembly.rb - About 45 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 copy_assembly has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def copy_assembly(pipe_name, appdomain_name, clr_version, exe_path, process)
          Severity: Minor
          Found in modules/post/windows/manage/execute_dotnet_assembly.rb - About 35 mins to fix

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

              def find_required_clr(exe_path)
                filecontent = File.read(exe_path).bytes
                sign = 'v4.0.30319'.bytes
                filecontent.each_with_index do |_item, index|
                  sign.each_with_index do |subitem, indexsub|
            Severity: Minor
            Found in modules/post/windows/manage/execute_dotnet_assembly.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 copy_assembly has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def copy_assembly(pipe_name, appdomain_name, clr_version, exe_path, process)
                print_status("Host injected. Copy assembly into #{process.pid}...")
                # Structure:
                # - Packed metadata (string/data lengths, flags)
                # - Pipe Name
            Severity: Minor
            Found in modules/post/windows/manage/execute_dotnet_assembly.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 open_process has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def open_process(pid)
                if (pid == 0) || pid.nil?
                  fail_with(Failure::BadConfig, 'Inject technique selected, but no PID set')
                end
            
            
            Severity: Minor
            Found in modules/post/windows/manage/execute_dotnet_assembly.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 run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def run
                exe_path = datastore['DOTNET_EXE']
            
                unless File.file?(exe_path)
                  fail_with(Failure::BadConfig, 'Assembly not found')
            Severity: Minor
            Found in modules/post/windows/manage/execute_dotnet_assembly.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