rapid7/metasploit-framework

View on GitHub

Showing 7,361 of 22,177 total issues

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

      if aa
        new_page = page.gsub(%r{(AA<</O )\d+ \d(.*)}m, '\1' + "#{trailers[0].fetch('Size').to_i + 5} 0" + '\2')
      else
        new_page = page.gsub(/(>> *\r?\n? *endobj)/m, "/AA<<\/O #{trailers[0].fetch('Size').to_i + 5} 0 R>>" + '\1')
Severity: Major
Found in modules/exploits/windows/fileformat/adobe_pdf_embedded_exe.rb and 2 other locations - About 40 mins to fix
modules/exploits/windows/fileformat/adobe_pdf_embedded_exe.rb on lines 277..280
modules/exploits/windows/fileformat/adobe_pdf_embedded_exe.rb on lines 311..314

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

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

Consider simplifying this complex logical expression.
Open

        if
        (
            (start.hi() < off.hi() || (start.hi() == off.hi() && start.lo() <= off.lo())) &&
            (end.hi() > off.hi() || (end.hi() == off.hi() && end.lo() > off.lo()))
        )
Severity: Major
Found in data/exploits/javascript_utils/utils.js - About 40 mins to fix

    Consider simplifying this complex logical expression.
    Open

                next unless (using_p && eprofile.include?(xref[0].split('/').last)) || (using_m && xref[0].to_s.match(mname)) || (!using_m && !using_p)
    Severity: Major
    Found in plugins/wmap.rb - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

                  next unless !(using_p && eprofile.include?(xref[0].split('/').last)) || (using_m && xref[0].to_s.match(mname)) || (!using_m && !using_p)
      Severity: Major
      Found in plugins/wmap.rb - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

                    next unless (using_p && eprofile.include?(xref[0].split('/').last)) || (using_m && xref[0].to_s.match(mname)) || (!using_m && !using_p)
        Severity: Major
        Found in plugins/wmap.rb - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

                      next unless (using_p && eprofile.include?(xref[0].split('/').last)) || (using_m && xref[0].to_s.match(mname)) || (!using_m && !using_p)
          Severity: Major
          Found in plugins/wmap.rb - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                        next unless !(using_p && eprofile.include?(xref[0].split('/').last)) || (using_m && xref[0].to_s.match(mname)) || (!using_m && !using_p)
            Severity: Major
            Found in plugins/wmap.rb - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

                          next unless (using_p && eprofile.include?(xref[0].split('/').last)) || (using_m && xref[0].to_s.match(mname)) || (!using_m && !using_p)
              Severity: Major
              Found in plugins/wmap.rb - About 40 mins to fix

                Consider simplifying this complex logical expression.
                Open

                        if !(target.to_s =~ get_link_filter)
                          form = {}.merge!(form_template)
                          form[:method] = (f['method'] || 'GET').upcase
                          form[:query]  = target.query.to_s if form[:method] != "GET"
                          form[:path]   = target.path
                Severity: Major
                Found in modules/auxiliary/scanner/http/crawler.rb - About 40 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                      if (res && res.code == 200 && res.headers['Server'] && (res.headers['Server'].include?('Team-R Web') || res.body.include?('binom_ico') || res.body.include?('team-r')))
                  
                        print_good("#{rhost}:#{rport} - Binom3 confirmed...")
                  
                        return true
                  Severity: Major
                  Found in modules/auxiliary/scanner/http/binom3_login_config_pass_dump.rb - About 40 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                        if res.code == 200 &&
                            res.body.length > 0 &&
                            res.headers['Content-Disposition'] &&
                            res.headers['Content-Disposition'].include?('attachment; filename') &&
                            res.headers['Content-Length'] &&
                    Severity: Major
                    Found in modules/auxiliary/scanner/http/wp_simple_backup_file_read.rb - About 40 mins to fix

                      Consider simplifying this complex logical expression.
                      Open

                          if res && res.code == 200 &&
                              res.body.to_s =~ /ManageEngine Password Manager Pro/ &&
                              (
                                res.body.to_s =~ /login\.css\?([0-9]+)/ ||                            # PMP v6
                                res.body.to_s =~ /login\.css\?version=([0-9]+)/ ||                    # PMP v6
                      Severity: Major
                      Found in modules/exploits/multi/http/manage_engine_dc_pmp_sqli.rb - About 40 mins to fix

                        Consider simplifying this complex logical expression.
                        Open

                            return CheckCode::Safe("Detected Splunk version #{version} which is not vulnerable") unless
                              (Rex::Version.new('9.0.0') <= version && version < Rex::Version.new('9.0.5')) ||
                              (Rex::Version.new('8.2.0') <= version && version < Rex::Version.new('8.2.11')) ||
                              (Rex::Version.new('8.1.0') <= version && version < Rex::Version.new('8.1.14'))

                          Consider simplifying this complex logical expression.
                          Open

                              if (version[2] > 9030 && version[3] == 'sd') ||
                                  (version[2] > 99999 && version[3] == 'ae') ||
                                  (version[2] > 99999 && version[3] == 'sc')
                                return Exploit::CheckCode::Safe
                              else
                          Severity: Major
                          Found in modules/exploits/multi/http/manageengine_auth_upload.rb - About 40 mins to fix

                            Consider simplifying this complex logical expression.
                            Open

                                unless res && ((res.code == 200 && res.body.include?('<title>Error</title>')) || ((res.code == 404 || res.code == 500) && res.body.include?('<title>Error Occurred While Processing Request</title>')))
                                  fail_with(Failure::UnexpectedReply, 'Failed to plant the payload in the ColdFusion output log file')
                                end
                            Severity: Major
                            Found in modules/exploits/multi/http/adobe_coldfusion_rce_cve_2023_26360.rb - About 40 mins to fix

                              Consider simplifying this complex logical expression.
                              Open

                                  unless res && ((res.code == 200 && res.body.include?('<title>Error</title>')) || ((res.code == 404 || res.code == 500) && res.body.include?('<title>Error Occurred While Processing Request</title>')))
                                    fail_with(Failure::UnexpectedReply, 'Failed to execute the payload in the ColdFusion output log file')
                                  end
                              Severity: Major
                              Found in modules/exploits/multi/http/adobe_coldfusion_rce_cve_2023_26360.rb - About 40 mins to fix

                                Consider simplifying this complex logical expression.
                                Open

                                    if (version[0] <= 7 && version[2] < 7016 && version[3] == 'sd') ||
                                    (version[0] == 4 && version[3] == 'ae') ||
                                    (version[3] == 'sc')
                                      # These are all "old style" versions (sc is always old style)
                                      return targets[1]
                                Severity: Major
                                Found in modules/exploits/multi/http/manageengine_auth_upload.rb - About 40 mins to fix

                                  Consider simplifying this complex logical expression.
                                  Open

                                      if res and res.code == 200 and res.body =~ /Weblogic Bridge Message/
                                        # BEA WebLogic 8.1 SP6 - mod_wl_20.so
                                        case res.body
                                        when (/Build date\/time:<\/B> <I>Jun 16 2006 15:14:11/ and /Change Number:<\/B> <I>779586/)
                                          return "Version found: BEA WebLogic 8.1 SP6 - mod_wl_20.so"
                                  Severity: Major
                                  Found in modules/exploits/windows/http/bea_weblogic_post_bof.rb - About 40 mins to fix

                                    Consider simplifying this complex logical expression.
                                    Open

                                        if (package.to_s.start_with?('8') && package < Rex::Version.new('8.0.32-1ubuntu1.2')) ||
                                           (package.to_s.start_with?('7') && package < Rex::Version.new('7.0.52-1ubuntu0.7')) ||
                                           (package.to_s.start_with?('6') && package < Rex::Version.new('6.0.35-1ubuntu3.8'))
                                          return CheckCode::Appears("Vulnerable app version detected: #{package}")
                                        end
                                    Severity: Major
                                    Found in modules/exploits/linux/local/tomcat_ubuntu_log_init_priv_esc.rb - About 40 mins to fix

                                      Consider simplifying this complex logical expression.
                                      Open

                                          if kernel_version < Rex::Version.new('5.8') ||
                                             kernel_version >= Rex::Version.new('5.16.11') ||
                                             (kernel_version >= Rex::Version.new('5.15.25') && kernel_version < Rex::Version.new('5.16')) ||
                                             (kernel_version >= Rex::Version.new('5.10.102') && kernel_version < Rex::Version.new('5.11'))
                                            return CheckCode::Safe("Linux kernel version #{kernel_version} is not vulnerable")
                                      Severity: Major
                                      Found in modules/exploits/linux/local/cve_2022_0847_dirtypipe.rb - About 40 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language