rapid7/metasploit-framework

View on GitHub
lib/msf/util/exe.rb

Summary

Maintainability
F
2 wks
Test Coverage

File exe.rb has 1416 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Msf
module Util
#
# The class provides methods for creating and encoding executable file
# formats for various platforms. It is a replacement for the previous
Severity: Major
Found in lib/msf/util/exe.rb - About 3 days to fix

    Class EXE has 74 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class EXE
    
    require 'rex'
    require 'rex/peparsey'
    require 'rex/pescan'
    Severity: Major
    Found in lib/msf/util/exe.rb - About 1 day to fix

      Method to_executable_fmt has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.to_executable_fmt(framework, arch, plat, code, fmt, exeopts)
          # For backwards compatibility with the way this gets called when
          # generating from Msf::Simple::Payload.generate_simple
          if arch.kind_of? Array
            output = nil
      Severity: Minor
      Found in lib/msf/util/exe.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 to_executable_fmt has 175 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.to_executable_fmt(framework, arch, plat, code, fmt, exeopts)
          # For backwards compatibility with the way this gets called when
          # generating from Msf::Simple::Payload.generate_simple
          if arch.kind_of? Array
            output = nil
      Severity: Major
      Found in lib/msf/util/exe.rb - About 7 hrs to fix

        Method to_executable has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.to_executable(framework, arch, plat, code = '', opts = {})
            if elf? code or macho? code
              return code
            end
        
        
        Severity: Minor
        Found in lib/msf/util/exe.rb - About 6 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 win32_rwx_exec_thread has 111 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.win32_rwx_exec_thread(code, block_offset, which_offset='start')
            stub_block = Rex::Payloads::Shuffle.from_graphml_file(
              File.join(Msf::Config.install_root, 'data', 'shellcode', 'block_api.x86.graphml'),
              arch: ARCH_X86,
              name: 'api_call'
        Severity: Major
        Found in lib/msf/util/exe.rb - About 4 hrs to fix

          Method exe_sub_method has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.exe_sub_method(code,opts ={})
              pe = self.get_file_contents(opts[:template])
          
              case opts[:exe_type]
              when :service_exe
          Severity: Minor
          Found in lib/msf/util/exe.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 to_win32pe has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.to_win32pe(framework, code, opts = {})
          
              # For backward compatibility, this is roughly equivalent to 'exe-small' fmt
              if opts[:sub_method]
                if opts[:inject]
          Severity: Minor
          Found in lib/msf/util/exe.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 to_win32pe has 89 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.to_win32pe(framework, code, opts = {})
          
              # For backward compatibility, this is roughly equivalent to 'exe-small' fmt
              if opts[:sub_method]
                if opts[:inject]
          Severity: Major
          Found in lib/msf/util/exe.rb - About 3 hrs to fix

            Method win32_rwx_exec has 84 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.win32_rwx_exec(code)
                stub_block = Rex::Payloads::Shuffle.from_graphml_file(
                  File.join(Msf::Config.install_root, 'data', 'shellcode', 'block_api.x86.graphml'),
                  arch: ARCH_X86,
                  name: 'api_call'
            Severity: Major
            Found in lib/msf/util/exe.rb - About 3 hrs to fix

              Method to_executable has 66 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def self.to_executable(framework, arch, plat, code = '', opts = {})
                  if elf? code or macho? code
                    return code
                  end
              
              
              Severity: Major
              Found in lib/msf/util/exe.rb - About 2 hrs to fix

                Method to_winpe_only has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def self.to_winpe_only(framework, code, opts = {}, arch=ARCH_X86)
                
                    # Allow the user to specify their own EXE template
                    set_template_default(opts, "template_#{arch}_windows.exe")
                
                
                Severity: Minor
                Found in lib/msf/util/exe.rb - About 1 hr to fix

                  Method exe_sub_method has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def self.exe_sub_method(code,opts ={})
                      pe = self.get_file_contents(opts[:template])
                  
                      case opts[:exe_type]
                      when :service_exe
                  Severity: Minor
                  Found in lib/msf/util/exe.rb - About 1 hr to fix

                    Method to_osx_app has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def self.to_osx_app(exe, opts = {})
                        exe_name    = opts.fetch(:exe_name) { Rex::Text.rand_text_alpha(8) }
                        app_name    = opts.fetch(:app_name) { Rex::Text.rand_text_alpha(8) }
                        hidden      = opts.fetch(:hidden, true)
                        plist_extra = opts.fetch(:plist_extra, '')
                    Severity: Minor
                    Found in lib/msf/util/exe.rb - About 1 hr to fix

                      Method to_win32pe_old has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def self.to_win32pe_old(framework, code, opts = {})
                      
                          payload = code.dup
                          # Allow the user to specify their own EXE template
                          set_template_default(opts, "template_x86_windows_old.exe")
                      Severity: Minor
                      Found in lib/msf/util/exe.rb - About 1 hr to fix

                        Method to_exe_vba has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def self.to_exe_vba(exes='')
                            exe = exes.unpack('C*')
                            hash_sub = {}
                            idx = 0
                            maxbytes = 2000
                        Severity: Minor
                        Found in lib/msf/util/exe.rb - About 1 hr to fix

                          Method to_executable_fmt_formats has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def self.to_executable_fmt_formats
                              [
                                "asp",
                                "aspx",
                                "aspx-exe",
                          Severity: Minor
                          Found in lib/msf/util/exe.rb - About 1 hr to fix

                            Method win32_rwx_exec_thread has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def self.win32_rwx_exec_thread(code, block_offset, which_offset='start')
                                stub_block = Rex::Payloads::Shuffle.from_graphml_file(
                                  File.join(Msf::Config.install_root, 'data', 'shellcode', 'block_api.x86.graphml'),
                                  arch: ARCH_X86,
                                  name: 'api_call'
                            Severity: Minor
                            Found in lib/msf/util/exe.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 set_template_default has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def self.set_template_default(opts, exe = nil, path = nil)
                                # If no path specified, use the default one
                                path ||= File.join(Msf::Config.data_directory, "templates")
                            
                                # If there's no default name, we must blow it up.
                            Severity: Minor
                            Found in lib/msf/util/exe.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 to_exe_vbs has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def self.to_exe_vbs(exes = '', opts = {})
                                delay   = opts[:delay]   || 5
                                persist = opts[:persist] || false
                            
                                hash_sub = {}
                            Severity: Minor
                            Found in lib/msf/util/exe.rb - About 1 hr to fix

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

                                def self.replace_msi_buffer(pe, opts)
                                  opts[:msi_template_path] ||= File.join(Msf::Config.data_directory, "templates")
                              
                                  if opts[:msi_template].include?(File::SEPARATOR)
                                    template = opts[:msi_template]
                              Severity: Minor
                              Found in lib/msf/util/exe.rb - About 1 hr to fix

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

                                  def self.to_war(jsp_raw, opts = {})
                                    jsp_name = opts[:jsp_name]
                                    jsp_name ||= Rex::Text.rand_text_alpha_lower(rand(8)+8)
                                    app_name = opts[:app_name]
                                    app_name ||= Rex::Text.rand_text_alpha_lower(rand(8)+8)
                                Severity: Minor
                                Found in lib/msf/util/exe.rb - About 1 hr to fix

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

                                    def self.to_exe_elf(framework, opts, template, code, big_endian=false)
                                      if elf? code
                                        return code
                                      end
                                  
                                  
                                  Severity: Minor
                                  Found in lib/msf/util/exe.rb - About 1 hr to fix

                                    Method to_win32pe_old has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                      def self.to_win32pe_old(framework, code, opts = {})
                                    
                                        payload = code.dup
                                        # Allow the user to specify their own EXE template
                                        set_template_default(opts, "template_x86_windows_old.exe")
                                    Severity: Minor
                                    Found in lib/msf/util/exe.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 to_exe_elf has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                      def self.to_exe_elf(framework, opts, template, code, big_endian=false)
                                        if elf? code
                                          return code
                                        end
                                    
                                    
                                    Severity: Minor
                                    Found in lib/msf/util/exe.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 to_executable_fmt has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                      def self.to_executable_fmt(framework, arch, plat, code, fmt, exeopts)
                                    Severity: Minor
                                    Found in lib/msf/util/exe.rb - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                              case arch
                                              when ARCH_X86,nil
                                                to_solaris_x86_elf(framework, code, exeopts)
                                              end
                                      Severity: Major
                                      Found in lib/msf/util/exe.rb - About 45 mins to fix

                                        Method generate_nops has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                          def self.generate_nops(framework, arch, len, opts = {})
                                            opts['BadChars'] ||= ''
                                            opts['SaveRegisters'] ||= [ 'esp', 'ebp', 'esi', 'edi' ]
                                        
                                            return nil unless framework.nops
                                        Severity: Minor
                                        Found in lib/msf/util/exe.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 to_exe_elf has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                        Open

                                          def self.to_exe_elf(framework, opts, template, code, big_endian=false)
                                        Severity: Minor
                                        Found in lib/msf/util/exe.rb - About 35 mins to fix

                                          Method to_executable has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                          Open

                                            def self.to_executable(framework, arch, plat, code = '', opts = {})
                                          Severity: Minor
                                          Found in lib/msf/util/exe.rb - About 35 mins to fix

                                            Method encode_stub has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                            Open

                                              def self.encode_stub(framework, arch, code, platform = nil, badchars = '')
                                            Severity: Minor
                                            Found in lib/msf/util/exe.rb - About 35 mins to fix

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

                                                def self.to_linux_x86_elf(framework, code, opts = {})
                                                  default = true unless opts[:template]
                                              
                                                  if default
                                                    elf = to_exe_elf(framework, opts, "template_x86_linux.bin", code)
                                              Severity: Minor
                                              Found in lib/msf/util/exe.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 set_template_default_winpe_dll has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                                private_class_method def self.set_template_default_winpe_dll(opts, arch, size, flavor: nil)
                                                  return if opts[:template].present?
                                              
                                                  # dynamic size upgrading is only available when MSF selects the template because there's currently no way to
                                                  # determine the amount of space that is available in the template provided by the user so it's assumed to be 4KiB
                                              Severity: Minor
                                              Found in lib/msf/util/exe.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 win32_rwx_exec has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                                def self.win32_rwx_exec(code)
                                                  stub_block = Rex::Payloads::Shuffle.from_graphml_file(
                                                    File.join(Msf::Config.install_root, 'data', 'shellcode', 'block_api.x86.graphml'),
                                                    arch: ARCH_X86,
                                                    name: 'api_call'
                                              Severity: Minor
                                              Found in lib/msf/util/exe.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 to_bsd_x86_elf(framework, code)
                                              Severity: Major
                                              Found in lib/msf/util/exe.rb - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                        return to_linux_mipsbe_elf(framework, code)
                                                Severity: Major
                                                Found in lib/msf/util/exe.rb - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

                                                          return to_win64pe(framework, code, opts)
                                                  Severity: Major
                                                  Found in lib/msf/util/exe.rb - About 30 mins to fix

                                                    Avoid too many return statements within this method.
                                                    Open

                                                            return to_linux_aarch64_elf(framework, code)
                                                    Severity: Major
                                                    Found in lib/msf/util/exe.rb - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

                                                              return to_linux_mipsle_elf(framework, code)
                                                      Severity: Major
                                                      Found in lib/msf/util/exe.rb - About 30 mins to fix

                                                        Avoid too many return statements within this method.
                                                        Open

                                                                return to_solaris_x86_elf(framework, code)
                                                        Severity: Major
                                                        Found in lib/msf/util/exe.rb - About 30 mins to fix

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                  return to_osx_ppc_macho(framework, code)
                                                          Severity: Major
                                                          Found in lib/msf/util/exe.rb - About 30 mins to fix

                                                            Avoid too many return statements within this method.
                                                            Open

                                                                    return to_bsd_x64_elf(framework, code)
                                                            Severity: Major
                                                            Found in lib/msf/util/exe.rb - About 30 mins to fix

                                                              Avoid too many return statements within this method.
                                                              Open

                                                                      return to_osx_x64_macho(framework, code)
                                                              Severity: Major
                                                              Found in lib/msf/util/exe.rb - About 30 mins to fix

                                                                Avoid too many return statements within this method.
                                                                Open

                                                                        return to_linux_x64_elf(framework, code, opts)
                                                                Severity: Major
                                                                Found in lib/msf/util/exe.rb - About 30 mins to fix

                                                                  Avoid too many return statements within this method.
                                                                  Open

                                                                          return to_linux_armle_elf(framework, code)
                                                                  Severity: Major
                                                                  Found in lib/msf/util/exe.rb - About 30 mins to fix

                                                                    Avoid too many return statements within this method.
                                                                    Open

                                                                            return to_osx_arm_macho(framework, code)
                                                                    Severity: Major
                                                                    Found in lib/msf/util/exe.rb - About 30 mins to fix

                                                                      Avoid too many return statements within this method.
                                                                      Open

                                                                              return to_osx_aarch64_macho(framework, code)
                                                                      Severity: Major
                                                                      Found in lib/msf/util/exe.rb - About 30 mins to fix

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

                                                                          def self.to_exe_vba(exes='')
                                                                            exe = exes.unpack('C*')
                                                                            hash_sub = {}
                                                                            idx = 0
                                                                            maxbytes = 2000
                                                                        Severity: Minor
                                                                        Found in lib/msf/util/exe.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 encode_stub has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                        Open

                                                                          def self.encode_stub(framework, arch, code, platform = nil, badchars = '')
                                                                            return code unless framework.encoders
                                                                            framework.encoders.each_module_ranked('Arch' => arch) do |name, mod|
                                                                              begin
                                                                                enc = framework.encoders.create(name)
                                                                        Severity: Minor
                                                                        Found in lib/msf/util/exe.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

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

                                                                            when 1 # ELFCLASS32 - 32 bit (ruby 1.9+)
                                                                              if big_endian
                                                                                elf[0x44,4] = [elf.length].pack('N') #p_filesz
                                                                                elf[0x48,4] = [elf.length + code.length].pack('N') #p_memsz
                                                                              else # little endian
                                                                        Severity: Major
                                                                        Found in lib/msf/util/exe.rb and 1 other location - About 1 hr to fix
                                                                        lib/msf/util/exe.rb on lines 1046..1052

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

                                                                        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

                                                                            when 2 # ELFCLASS64 - 64 bit (ruby 1.9+)
                                                                              if big_endian
                                                                                elf[0x60,8] = [elf.length].pack('Q>') #p_filesz
                                                                                elf[0x68,8] = [elf.length + code.length].pack('Q>') #p_memsz
                                                                              else # little endian
                                                                        Severity: Major
                                                                        Found in lib/msf/util/exe.rb and 1 other location - About 1 hr to fix
                                                                        lib/msf/util/exe.rb on lines 1038..1044

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

                                                                        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

                                                                            when 'jsp'
                                                                              arch ||= [ ARCH_X86 ]
                                                                              tmp_plat = plat.platforms if plat
                                                                              tmp_plat ||= Msf::Module::PlatformList.transform('win')
                                                                              exe = Msf::Util::EXE.to_executable(framework, arch, tmp_plat, code, exeopts)
                                                                        Severity: Minor
                                                                        Found in lib/msf/util/exe.rb and 1 other location - About 35 mins to fix
                                                                        lib/msf/util/exe.rb on lines 2195..2200

                                                                        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

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

                                                                            when 'war'
                                                                              arch ||= [ ARCH_X86 ]
                                                                              tmp_plat = plat.platforms if plat
                                                                              tmp_plat ||= Msf::Module::PlatformList.transform('win')
                                                                              exe = Msf::Util::EXE.to_executable(framework, arch, tmp_plat, code, exeopts)
                                                                        Severity: Minor
                                                                        Found in lib/msf/util/exe.rb and 1 other location - About 35 mins to fix
                                                                        lib/msf/util/exe.rb on lines 2189..2194

                                                                        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

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

                                                                              "asp",
                                                                              "aspx",
                                                                              "aspx-exe",
                                                                              "axis2",
                                                                              "dll",
                                                                        Severity: Minor
                                                                        Found in lib/msf/util/exe.rb and 1 other location - About 25 mins to fix
                                                                        modules/auxiliary/vsploit/malware/dns/dns_mariposa.rb on lines 31..41

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

                                                                        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

                                                                            if arch.index(ARCH_AARCH64)
                                                                              if plat.index(Msf::Module::Platform::Linux)
                                                                                return to_linux_aarch64_elf(framework, code)
                                                                              end
                                                                        
                                                                        
                                                                        Severity: Minor
                                                                        Found in lib/msf/util/exe.rb and 1 other location - About 20 mins to fix
                                                                        lib/msf/util/exe.rb on lines 153..159

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

                                                                        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

                                                                            if arch.index(ARCH_ARMLE)
                                                                              if plat.index(Msf::Module::Platform::OSX)
                                                                                return to_osx_arm_macho(framework, code)
                                                                              end
                                                                        
                                                                        
                                                                        Severity: Minor
                                                                        Found in lib/msf/util/exe.rb and 1 other location - About 20 mins to fix
                                                                        lib/msf/util/exe.rb on lines 165..171

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

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

                                                                          def self.to_osx_ppc_macho(framework, code, opts = {})
                                                                        
                                                                            # Allow the user to specify their own template
                                                                            set_template_default(opts, "template_ppc_darwin.bin")
                                                                        
                                                                        
                                                                        Severity: Minor
                                                                        Found in lib/msf/util/exe.rb and 3 other locations - About 15 mins to fix
                                                                        lib/msf/util/exe.rb on lines 863..871
                                                                        lib/msf/util/exe.rb on lines 918..926
                                                                        lib/msf/util/exe.rb on lines 936..943

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

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

                                                                          def self.to_osx_x64_macho(framework, code, opts = {})
                                                                            set_template_default(opts, "template_x64_darwin.bin")
                                                                        
                                                                            macho = self.get_file_contents(opts[:template])
                                                                            bin = self.find_payload_tag(macho,
                                                                        Severity: Minor
                                                                        Found in lib/msf/util/exe.rb and 3 other locations - About 15 mins to fix
                                                                        lib/msf/util/exe.rb on lines 863..871
                                                                        lib/msf/util/exe.rb on lines 900..908
                                                                        lib/msf/util/exe.rb on lines 918..926

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

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

                                                                          def self.to_osx_arm_macho(framework, code, opts = {})
                                                                        
                                                                            # Allow the user to specify their own template
                                                                            set_template_default(opts, "template_armle_darwin.bin")
                                                                        
                                                                        
                                                                        Severity: Minor
                                                                        Found in lib/msf/util/exe.rb and 3 other locations - About 15 mins to fix
                                                                        lib/msf/util/exe.rb on lines 900..908
                                                                        lib/msf/util/exe.rb on lines 918..926
                                                                        lib/msf/util/exe.rb on lines 936..943

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

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

                                                                          def self.to_osx_x86_macho(framework, code, opts = {})
                                                                        
                                                                            # Allow the user to specify their own template
                                                                            set_template_default(opts, "template_x86_darwin.bin")
                                                                        
                                                                        
                                                                        Severity: Minor
                                                                        Found in lib/msf/util/exe.rb and 3 other locations - About 15 mins to fix
                                                                        lib/msf/util/exe.rb on lines 863..871
                                                                        lib/msf/util/exe.rb on lines 900..908
                                                                        lib/msf/util/exe.rb on lines 936..943

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

                                                                        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

                                                                            if opts[:inject]
                                                                              injector = Msf::Exe::SegmentInjector.new({
                                                                                  :payload  => code,
                                                                                  :template => opts[:template],
                                                                                  :arch     => :x86,
                                                                        Severity: Minor
                                                                        Found in lib/msf/util/exe.rb and 1 other location - About 15 mins to fix
                                                                        lib/msf/util/exe.rb on lines 609..616

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

                                                                        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

                                                                            if opts[:inject]
                                                                              injector = Msf::Exe::SegmentInjector.new({
                                                                                 :payload  => code,
                                                                                 :template => opts[:template],
                                                                                 :arch     => :x64,
                                                                        Severity: Minor
                                                                        Found in lib/msf/util/exe.rb and 1 other location - About 15 mins to fix
                                                                        lib/msf/util/exe.rb on lines 249..256

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

                                                                        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