rapid7/metasploit-framework

View on GitHub

Showing 22,177 of 22,177 total issues

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

        def recv_telnet(fd, timeout)

          data = ''

          begin
Severity: Major
Found in lib/metasploit/framework/telnet/client.rb and 1 other location - About 7 hrs to fix
lib/msf/core/exploit/remote/telnet.rb on lines 155..217

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

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

File filezilla_server.rb has 488 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rexml/document'

class MetasploitModule < Msf::Post
  include Msf::Post::File

Severity: Minor
Found in modules/post/windows/gather/credentials/filezilla_server.rb - About 7 hrs to fix

    File shares.rb has 488 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'pathname'
    require 'rex/post/file'
    require 'filesize'
    
    module Rex
    Severity: Minor
    Found in lib/rex/post/smb/ui/console/command_dispatcher/shares.rb - About 7 hrs to fix

      Method parse_server has 192 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def parse_server(data)
          creds = []
          perms = []
          groups = []
          settings = {}
      Severity: Major
      Found in modules/post/windows/gather/credentials/filezilla_server.rb - About 7 hrs to fix

        Method build_t3_request_object has 191 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def build_t3_request_object
            # T3 request serialized data
            # retrieved by watching network traffic
            # This is a proprietary, undocumented protocol
            # TODO: WHAT DOES THIS DO?  CAN WE RANDOMIZE ANY OF IT?
        Severity: Major
        Found in modules/exploits/multi/misc/weblogic_deserialize_marshalledobject.rb - About 7 hrs to fix

          Method exploit has 191 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def exploit
              # Hijacking Administrator session by exploiting objection injection vuln that end up with sqli
              print_status("Hijacking administrator session")
          
              sql = "SELECT id FROM sessions LIMIT 1"
          Severity: Major
          Found in modules/exploits/linux/http/alienvault_exec.rb - About 7 hrs to fix

            Method listeners_start has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
            Open

                  def listeners_start(args)
                    config = parse_start_args(args)
                    if config[:show_help]
                      help('start')
                      return
            Severity: Minor
            Found in plugins/capture.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 a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
            Open

              def run
                # If the action can be detected automatically. (Action: Automatic)
                @my_action = pick_action
                if @my_action.nil?
                  # If the automatic search fails, bye bye.
            Severity: Minor
            Found in modules/auxiliary/gather/cloud_lookup.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 getprocparam has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
            Open

              def getprocparam(rhost)
                print_status("[SAP] Connecting to SAP Management Console SOAP Interface on #{rhost}:#{rport}")
                success = false
                soapenv = 'http://schemas.xmlsoap.org/soap/envelope/'
                xsi = 'http://www.w3.org/2001/XMLSchema-instance'
            Severity: Minor
            Found in modules/auxiliary/scanner/sap/sap_mgmt_con_getprocessparameter.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 49 (exceeds 5 allowed). Consider refactoring.
            Open

              def run_host(target_host)
                begin
                  iplist = Rex::Socket::RangeWalker.new(datastore['RANGE'])
                  portlist = Rex::Socket.portspec_crack(datastore['PORTS'])
                  dead = false
            Severity: Minor
            Found in modules/auxiliary/scanner/http/squid_pivot_scanning.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 enable_xp_cmdshell has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
            Open

              def enable_xp_cmdshell(path,name,shelled)
                # Enables "show advanced options" and xp_cmdshell if needed and possible
                # They cannot be enabled in user transactions (i.e. via openquery)
                # Only enabled if RPC_Out is enabled for linked server
                # All changes are reverted after payload delivery and execution
            Severity: Minor
            Found in modules/exploits/windows/mssql/mssql_linkcrawler.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 49 (exceeds 5 allowed). Consider refactoring.
            Open

              def exploit
                print_status('Obtaining credentails...')
            
                resp = send_request_cgi({
                  'uri'      => '/cslog_export.php',
            Severity: Minor
            Found in modules/exploits/linux/http/samsung_srv_1670d_upload_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 run has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
            Open

              def run
                case session.platform
                when 'windows'
                  listing = cmd_exec('netsh wlan show networks mode=bssid')
                  if listing.nil?
            Severity: Minor
            Found in modules/post/multi/gather/wlan_geolocate.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 dump_jobs has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.dump_jobs(framework, verbose = false, indent = DefaultIndent, col = DefaultColumnWrap)
                columns = [ 'Id', 'Name', "Payload", "Payload opts"]
            
                if (verbose)
                  columns += [ "URIPATH", "Start Time", "Handler opts", "Persist" ]
            Severity: Minor
            Found in lib/msf/base/serializer/readable_text.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 devices_list has 189 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def devices_list
                known_devices = {
                  :'AZ-D140W' =>
                      {
                        name: 'Azmoon', model: 'AZ-D140W', values: [
            Severity: Major
            Found in modules/auxiliary/admin/http/allegro_rompager_auth_bypass.rb - About 7 hrs to fix

              Method run_host has 189 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def run_host(ip)
              
                  http_method = datastore['METHOD'].upcase
              
                  qvars = nil
              Severity: Major
              Found in modules/auxiliary/scanner/http/error_sql_injection.rb - About 7 hrs to fix

                Method exploit has 189 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def exploit
                    # Sanity check the USERNAME and PASSWORD will meet the servers password requirements.
                    fail_with(Failure::BadConfig, 'USERNAME must not be empty.') if datastore['USERNAME'].empty?
                    fail_with(Failure::BadConfig, 'PASSWORD must be 8 characters of more.') if datastore['PASSWORD'].length < 8
                
                

                  Method on_request_uri has 188 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def on_request_uri(cli, request)
                      print_status("Sending #{request.uri} to #{request['User-Agent']}")
                      escaped_payload = Rex::Text.to_unescape(payload.encoded)
                      jscript = %^
                  // HELPER FUNCTIONS
                  Severity: Major
                  Found in modules/exploits/multi/browser/chrome_array_map.rb - About 7 hrs to fix

                    Method import_nmap_xml has 188 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def import_nmap_xml(args={}, &block)
                        return nil if args[:data].nil? or args[:data].empty?
                        wspace = Msf::Util::DBManager.process_opts_workspace(args, framework)
                        bl = validate_ips(args[:blacklist]) ? args[:blacklist].split : []
                    
                    
                    Severity: Major
                    Found in lib/msf/core/db_manager/import/nmap.rb - About 7 hrs to fix

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

                      module Payload::Windows::MeterpreterLoader_x64
                      
                        include Msf::ReflectiveDLLLoader
                        include Msf::Payload::Windows
                      
                      
                      Severity: Major
                      Found in lib/msf/core/payload/windows/x64/meterpreter_loader_x64.rb and 1 other location - About 7 hrs to fix
                      lib/msf/core/payload/windows/meterpreter_loader.rb on lines 12..118

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

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language