rapid7/metasploit-framework

View on GitHub
modules/exploits/multi/http/eventlog_file_upload.rb

Summary

Maintainability
D
1 day
Test Coverage

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

  def initialize(info = {})
    super(update_info(info,
      'Name'        => 'ManageEngine Eventlog Analyzer Arbitrary File Upload',
      'Description' => %q{
        This module exploits a file upload vulnerability in ManageEngine Eventlog Analyzer.
Severity: Major
Found in modules/exploits/multi/http/eventlog_file_upload.rb - About 2 hrs to fix

    File eventlog_file_upload.rb has 262 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class MetasploitModule < Msf::Exploit::Remote
      Rank = ExcellentRanking
    
      include Msf::Exploit::Remote::HttpClient
      include Msf::Exploit::FileDropper
    Severity: Minor
    Found in modules/exploits/multi/http/eventlog_file_upload.rb - About 2 hrs to fix

      Method generate_jsp_payload has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def generate_jsp_payload
          opts = {:arch => @my_target.arch, :platform => @my_target.platform}
          payload = exploit_regenerate_payload(@my_target.platform, @my_target.arch)
          exe = generate_payload_exe(opts)
          base64_exe = Rex::Text.encode_base64(exe)
      Severity: Minor
      Found in modules/exploits/multi/http/eventlog_file_upload.rb - About 2 hrs to fix

        Method pick_target has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def pick_target
            return target if target.name != 'Automatic'
        
            print_status("Determining target")
        
        
        Severity: Minor
        Found in modules/exploits/multi/http/eventlog_file_upload.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 pick_target has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def pick_target
            return target if target.name != 'Automatic'
        
            print_status("Determining target")
        
        
        Severity: Minor
        Found in modules/exploits/multi/http/eventlog_file_upload.rb - About 1 hr to fix

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

            def check
              version = get_version
              if version >= "7" and version <= "9"
                # version 7 to < 8.1 detection
                res = send_request_cgi({
          Severity: Minor
          Found in modules/exploits/multi/http/eventlog_file_upload.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 create_zip_and_upload has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def create_zip_and_upload(payload, target_path, is_payload = true)
              # Zipping with CM_STORE to avoid errors decompressing the zip
              # in the Java vulnerable application
              zip = Rex::Zip::Archive.new(Rex::Zip::CM_STORE)
              zip.add_file(target_path, payload)
          Severity: Minor
          Found in modules/exploits/multi/http/eventlog_file_upload.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

          Avoid too many return statements within this method.
          Open

                  return targets[2]
          Severity: Major
          Found in modules/exploits/multi/http/eventlog_file_upload.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return targets[3]
            Severity: Major
            Found in modules/exploits/multi/http/eventlog_file_upload.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                  return nil
              Severity: Major
              Found in modules/exploits/multi/http/eventlog_file_upload.rb - About 30 mins to fix

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

                    jsp = %Q|
                    <%@page import="java.io.*"%>
                    <%@page import="sun.misc.BASE64Decoder"%>
                    <%
                    try {
                Severity: Major
                Found in modules/exploits/multi/http/eventlog_file_upload.rb and 4 other locations - About 1 hr to fix
                modules/exploits/multi/http/novell_servicedesk_rce.rb on lines 208..226
                modules/exploits/multi/http/sysaid_auth_file_upload.rb on lines 197..215
                modules/exploits/multi/http/webnms_file_upload.rb on lines 166..184
                modules/exploits/windows/browser/facebook_extractiptc.rb on lines 76..85

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

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

                    if @my_target['Platform'] == 'linux'
                      var_proc1 = Rex::Text.rand_text_alpha(rand(8) + 3)
                      chmod = %Q|
                      Process #{var_proc1} = Runtime.getRuntime().exec("chmod 777 " + #{var_path});
                      Thread.sleep(200);
                Severity: Major
                Found in modules/exploits/multi/http/eventlog_file_upload.rb and 5 other locations - About 55 mins to fix
                modules/exploits/multi/http/manage_engine_dc_pmp_sqli.rb on lines 353..367
                modules/exploits/multi/http/manageengine_search_sqli.rb on lines 114..128
                modules/exploits/multi/http/novell_servicedesk_rce.rb on lines 191..205
                modules/exploits/multi/http/sysaid_auth_file_upload.rb on lines 180..194
                modules/exploits/multi/http/webnms_file_upload.rb on lines 149..163

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

                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