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

          [ 'Automatic', { } ],

          #
          # Individual targets
          #
modules/exploits/windows/mssql/ms09_004_sp_replwritetovarbin.rb on lines 77..242

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

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

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

          [ 'Automatic', { } ],

          #
          # Individual targets
          #
modules/exploits/windows/mssql/ms09_004_sp_replwritetovarbin_sqli.rb on lines 79..244

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

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 weblogic_deserialize_marshalledobject.rb has 452 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class MetasploitModule < Msf::Exploit::Remote
  Rank = ManualRanking

  include Msf::Exploit::Remote::Tcp
  include Msf::Exploit::JavaDeserialization
Severity: Minor
Found in modules/exploits/multi/misc/weblogic_deserialize_marshalledobject.rb - About 6 hrs to fix

    File xml.rb has 452 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'base64'
    module Msf::DBManager::Import::MetasploitFramework::XML
      #
      # CONSTANTS
      #
    Severity: Minor
    Found in lib/msf/core/db_manager/import/metasploit_framework/xml.rb - About 6 hrs to fix

      Method generate_html has 171 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def generate_html(payload)
          enc_code = Rex::Text.to_unescape(payload.encoded, Rex::Arch.endian(target.arch))
      
          custom_js = %Q|
      function check(){
      Severity: Major
      Found in modules/exploits/windows/browser/mozilla_interleaved_write.rb - About 6 hrs to fix

        Exploit has 49 methods (exceeds 20 allowed). Consider refactoring.
        Open

        public class Exploit extends Applet {
        
            private static final long serialVersionUID = 2205862970052148546L;
        
            @Override
        Severity: Minor
        Found in external/source/exploits/CVE-2010-0094/Exploit.java - About 6 hrs to fix

          Class MetasploitModule has 49 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class MetasploitModule < Msf::Exploit::Remote
            Rank = GoodRanking
          
            include Msf::Exploit::Remote::Tcp
            include Msf::Exploit::EXE
          Severity: Minor
          Found in modules/exploits/multi/misc/java_jdwp_debugger.rb - About 6 hrs to fix

            File krb5_pac.rb has 451 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require 'bindata'
            require 'ruby_smb/dcerpc'
            require 'rex/proto/ms_dtyp'
            
            # full MIDL spec for PAC
            Severity: Minor
            Found in lib/rex/proto/kerberos/pac/krb5_pac.rb - About 6 hrs to fix

              Method dump_ntds_hashes has 170 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def dump_ntds_hashes
                  _machine_name, domain_name, dns_domain_name = get_machine_name_and_domain_info
                  return unless domain_name
              
                  print_status('Dumping Domain Credentials (domain\\uid:rid:lmhash:nthash)')
              Severity: Major
              Found in modules/auxiliary/gather/windows_secrets_dump.rb - About 6 hrs to fix

                Method run has 170 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def run
                    # we have to overload the process_cracker_results from password_cracker.rb since LANMAN
                    # is a special case where we may need to do some combining
                    def process_cracker_results(results, cred)
                      return results if cred['core_id'].nil? # make sure we have good data
                Severity: Major
                Found in modules/auxiliary/analyze/crack_windows.rb - About 6 hrs to fix

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

                    def generate(_opts = {})
                  
                      dnsname        = datastore['DNSZONE']
                      wType        = 0x0010    #DNS_TYPE_TEXT (TEXT)
                      wTypeOffset    = 0x1c
                  Severity: Major
                  Found in modules/payloads/singles/windows/dns_txt_query_exec.rb - About 6 hrs to fix

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

                      def initialize(info = {})
                        super(merge_info(info,
                          'Name'          => 'Reverse TCP Stager',
                          'Description'   => 'Connect back to the attacker',
                          'Author'        => 'toto',
                    Severity: Major
                    Found in modules/payloads/stagers/netware/reverse_tcp.rb - About 6 hrs to fix

                      Method get_filezilla_creds has 170 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def get_filezilla_creds(paths)
                          fs_xml = '' # FileZilla Server.xml           - Settings for the local install
                          fsi_xml = '' # FileZilla Server Interface.xml - Last server used with the interface
                          credentials = Rex::Text::Table.new(
                            'Header' => 'FileZilla FTP Server Credentials',
                      Severity: Major
                      Found in modules/post/windows/gather/credentials/filezilla_server.rb - About 6 hrs to fix

                        File accounts.rb has 450 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        module Msf
                          class Post
                            module Windows
                              module Accounts
                                include Msf::Post::Windows::Error
                        Severity: Minor
                        Found in lib/msf/core/post/windows/accounts.rb - About 6 hrs to fix

                          Method exploit_newuser has 169 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def exploit_newuser
                          
                              # TODO: Check if option admin_role exists via admin/people/permissions/roles
                          
                              # call login page to extract tokens
                          Severity: Major
                          Found in modules/exploits/multi/http/drupal_drupageddon.rb - About 6 hrs to fix

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

                              def exploit
                                marker = rand_text_alpha(6)
                                sqli_rand = rand_text_numeric(4+rand(4))
                                sqli = "' and (select 1 from(select count(*),concat((select (select concat(0x#{marker.unpack('H*')[0]},Hex(cast(id as char)),0x#{marker.unpack('H*')[0]})) "
                                sqli << "from alienvault.sessions where login='admin' limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and '#{sqli_rand}'='#{sqli_rand}"
                            Severity: Major
                            Found in modules/exploits/linux/http/alienvault_sqli_exec.rb - About 6 hrs to fix

                              File driver.rb has 448 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              require 'find'
                              require 'erb'
                              require 'rexml/document'
                              require 'fileutils'
                              require 'digest/md5'
                              Severity: Minor
                              Found in lib/msf/ui/console/driver.rb - About 6 hrs to fix

                                Method record_detection has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def record_detection(cli, request)
                                    os_name = nil
                                    os_flavor = nil
                                    os_sp = nil
                                    os_lang = nil
                                Severity: Minor
                                Found in modules/auxiliary/server/browser_autopwn.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 process_hash has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def process_hash(entry, attr)
                                    service_details = {
                                      workspace_id: myworkspace_id,
                                      module_fullname: fullname,
                                      origin_type: :service,
                                Severity: Minor
                                Found in modules/auxiliary/gather/ldap_hashdump.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 parse_users has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def parse_users(buff)
                                    buff.each_line do |line|
                                      uid = nil
                                      next if line.strip.empty?
                                
                                
                                Severity: Minor
                                Found in modules/auxiliary/scanner/finger/finger_users.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

                                Severity
                                Category
                                Status
                                Source
                                Language