rapid7/metasploit-framework

View on GitHub

Showing 22,177 of 22,177 total issues

Method generate has 185 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.generate(cmd)
      mscorlib = Assemblies::VERSIONS['4.0.0.0'].fetch('mscorlib')
      system = Assemblies::VERSIONS['4.0.0.0'].fetch('System')

      library = Types::RecordValues::BinaryLibrary.new(

    File rpc_module.rb has 475 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'json'
    
    module Msf
    module RPC
    class RPC_Module < RPC_Base
    Severity: Minor
    Found in lib/msf/core/rpc/v10/rpc_module.rb - About 7 hrs to fix

      File openvas.rb has 474 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'openvas-omp'
      
      module Msf
        class Plugin::OpenVAS < Msf::Plugin
          class OpenVASCommandDispatcher
      Severity: Minor
      Found in plugins/openvas.rb - About 7 hrs to fix

        File manageengine_adaudit_plus_authenticated_rce.rb has 474 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        class MetasploitModule < Msf::Exploit::Remote
        
          Rank = ExcellentRanking
          prepend Msf::Exploit::Remote::AutoCheck
          include Msf::Exploit::Remote::HttpClient

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

          NTLM_CONST = Rex::Proto::NTLM::Constants
          NTLM_CRYPT = Rex::Proto::NTLM::Crypt
          NTLM_UTILS = Rex::Proto::NTLM::Utils
          MESSAGE = Rex::Proto::NTLM::Message
          
          
          Severity: Minor
          Found in modules/auxiliary/server/capture/mssql.rb - About 7 hrs to fix

            Method abuse has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
            Open

            def abuse(session,targets,commands,username,password,delay)
              #for each target
              targets.each do |t|
                next if t.strip.length < 1
                next if t[0,1] == "#"
            Severity: Minor
            Found in scripts/meterpreter/schtasksabuse.rb - About 7 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 build_script_response has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
            Open

              def build_script_response(cli, request)
                response = create_response()
                response['Expires'] = '0'
                response['Cache-Control'] = 'must-revalidate'
            
            
            Severity: Minor
            Found in modules/auxiliary/server/browser_autopwn.rb - About 7 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 run_host has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
            Open

              def run_host(ip)
                if datastore['RPORT'].blank? || datastore['RPORT'] == 0
                  smb_services = [
                    { port: 445, direct: true },
                    { port: 139, direct: false }
            Severity: Minor
            Found in modules/auxiliary/scanner/smb/smb_version.rb - About 7 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 exploit has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
            Open

              def exploit
                unless datastore['AutoCheck']
                  cookie_jar.clear
                  res = authenticate
                  fail_with(Failure::NoAccess, 'Authentication failed') if res&.body =~ %r{<title>ZM - Login</title>}
            Severity: Minor
            Found in modules/exploits/unix/webapp/zoneminder_lang_exec.rb - About 7 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 parse_sudo has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
            Open

              def parse_sudo(sudo_data)
                cmd_data = sudo_data.scan(/may run the following commands.*?$(.*)\z/m).flatten.first
            
                # remove leading whitespace from each line and remove linewraps
                formatted_data = ''
            Severity: Minor
            Found in modules/post/multi/recon/sudo_commands.rb - About 7 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 initialize has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
            Open

              def initialize(ssh, cmd = nil, pty: false, cleanup: false)
                self.lsock, self.rsock = Rex::Socket.tcp_socket_pair()
                self.lsock.extend(Rex::IO::Stream)
                self.lsock.extend(PeerInfo)
                self.rsock.extend(Rex::IO::Stream)
            Severity: Minor
            Found in lib/net/ssh/command_stream.rb - About 7 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 end_element has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
            Open

              def end_element(name)
                case name
                when "description", "information"
                  return unless in_tag("detaillist")
                  return unless in_tag("detail")
            Severity: Minor
            Found in lib/rex/parser/outpost24_document.rb - About 7 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 run has 181 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def run
                print_status('Starting SQL injection workflow...')
            
                res = send_request_cgi(
                  'method' => 'GET',
            Severity: Major
            Found in modules/auxiliary/admin/http/fortra_filecatalyst_workflow_sqli.rb - About 7 hrs to fix

              File version.rb has 468 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              module Msf::Exploit::Remote::HTTP::Gitlab::Version
                # Used to check if the version is correct: must contain at least one dot
                GITLAB_VERSION_PATTERN = '(\d+\.\d+(?:\.\d+)*)'.freeze
                # CSS-based filename fingerprinting
                GITLAB_CSS_PATTERN = '<link rel="stylesheet"(?: media="[a-z]+")? href="/assets/application-([a-z0-9]+)[.]css"'.freeze
              Severity: Minor
              Found in lib/msf/core/exploit/remote/http/gitlab/version.rb - About 7 hrs to fix

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

                  def exploit
                    # Encode the shellcode.
                    shellcode = Rex::Text.to_unescape(payload.encoded, Rex::Arch.endian(target.arch))
                
                    # Create some nops.
                Severity: Major
                Found in modules/exploits/windows/fileformat/etrust_pestscan.rb and 2 other locations - About 7 hrs to fix
                modules/exploits/windows/fileformat/activepdf_webgrabber.rb on lines 52..102
                modules/exploits/windows/fileformat/mcafee_hercules_deletesnapshot.rb on lines 51..101

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

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                  def exploit
                    # Encode the shellcode.
                    shellcode = Rex::Text.to_unescape(payload.encoded, Rex::Arch.endian(target.arch))
                
                    # Create some nops.
                modules/exploits/windows/fileformat/activepdf_webgrabber.rb on lines 52..102
                modules/exploits/windows/fileformat/etrust_pestscan.rb on lines 49..95

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

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                  def exploit
                    # Encode the shellcode.
                    shellcode = Rex::Text.to_unescape(payload.encoded, Rex::Arch.endian(target.arch))
                
                    # Create some nops.
                Severity: Major
                Found in modules/exploits/windows/fileformat/activepdf_webgrabber.rb and 2 other locations - About 7 hrs to fix
                modules/exploits/windows/fileformat/etrust_pestscan.rb on lines 49..95
                modules/exploits/windows/fileformat/mcafee_hercules_deletesnapshot.rb on lines 51..101

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

                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

                Class RbMysql has 51 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class RbMysql
                
                  require "rbmysql/constants"
                  require "rbmysql/error"
                  require "rbmysql/charset"
                Severity: Major
                Found in lib/rbmysql.rb - About 7 hrs to fix

                  Class RPC_Db has 51 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  class RPC_Db < RPC_Base
                  
                  private
                  
                    include Metasploit::Credential::Creation
                  Severity: Major
                  Found in lib/msf/core/rpc/v10/rpc_db.rb - About 7 hrs to fix

                    File beagent_sha_auth_rce.rb has 465 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    class MetasploitModule < Msf::Exploit::Remote
                      Rank = ExcellentRanking
                    
                      include Msf::Exploit::Remote::Tcp
                      include Msf::Exploit::Remote::NDMPSocket
                    Severity: Minor
                    Found in modules/exploits/multi/veritas/beagent_sha_auth_rce.rb - About 7 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language