rapid7/metasploit-framework

View on GitHub
modules/exploits/windows/http/trackit_file_upload.rb

Summary

Maintainability
F
4 days
Test Coverage

File trackit_file_upload.rb has 371 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

  include Msf::Exploit::Remote::HttpClient
  include Msf::Exploit::EXE
Severity: Minor
Found in modules/exploits/windows/http/trackit_file_upload.rb - About 4 hrs to fix

    Method get_traversal_path has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

      def get_traversal_path
        #
        # ConfigurationService packet structure:
        #
        # @packet_header_pre_packet_size
    Severity: Minor
    Found in modules/exploits/windows/http/trackit_file_upload.rb - About 4 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 send_file has 103 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def send_file(traversal_path, filename, file_content)
        #
        # FileStorageService packet structure:
        #
        # @packet_header_pre_packet_size
    Severity: Major
    Found in modules/exploits/windows/http/trackit_file_upload.rb - About 4 hrs to fix

      Method get_traversal_path has 90 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def get_traversal_path
          #
          # ConfigurationService packet structure:
          #
          # @packet_header_pre_packet_size
      Severity: Major
      Found in modules/exploits/windows/http/trackit_file_upload.rb - About 3 hrs to fix

        Method exploit has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

          def exploit
            @packet_header_pre_packet_size= [
              0x2e, 0x4e, 0x45, 0x54, 0x01, 0x00, 0x00, 0x00,
              0x00, 0x00
            ]
        Severity: Minor
        Found in modules/exploits/windows/http/trackit_file_upload.rb - About 3 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 77 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def exploit
            @packet_header_pre_packet_size= [
              0x2e, 0x4e, 0x45, 0x54, 0x01, 0x00, 0x00, 0x00,
              0x00, 0x00
            ]
        Severity: Major
        Found in modules/exploits/windows/http/trackit_file_upload.rb - About 3 hrs to fix

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

            def check
              version = get_version
              if version != nil
                if (version[0].to_i < 11) or
                (version[0].to_i == 11 and version[1].to_i <= 3) or
          Severity: Minor
          Found in modules/exploits/windows/http/trackit_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 initialize has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def initialize(info = {})
              super(update_info(info,
                'Name'           => 'Numara / BMC Track-It! FileStorageService Arbitrary File Upload',
                'Description'    => %q{
                  This module exploits an arbitrary file upload vulnerability in Numara / BMC Track-It!
          Severity: Minor
          Found in modules/exploits/windows/http/trackit_file_upload.rb - About 1 hr to fix

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

              def send_file(traversal_path, filename, file_content)
                #
                # FileStorageService packet structure:
                #
                # @packet_header_pre_packet_size
            Severity: Minor
            Found in modules/exploits/windows/http/trackit_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

            Consider simplifying this complex logical expression.
            Open

                  if (version[0].to_i < 11) or
                  (version[0].to_i == 11 and version[1].to_i <= 3) or
                  (version[0].to_i == 11 and version[1].to_i == 3 and version[2].to_i == 0 and version[3].to_i < 999)
                    ctx = { 'Msf' => framework, 'MsfExploit' => self }
                    sock = Rex::Socket.create_tcp({ 'PeerHost' => rhost, 'PeerPort' => datastore['RPORT_REMOTING'], 'Context' => ctx })
            Severity: Major
            Found in modules/exploits/windows/http/trackit_file_upload.rb - About 1 hr to fix

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

                      if (index = (buf_reply.index(web_data_dir_str))) != nil
                        # after web_data_dir_str, discard 5 bytes then get web_data_dir_size
                        size = buf_reply[index + web_data_dir_str.length + 5,1].unpack('C*')[0]
                        web_data_dir = buf_reply[index + web_data_dir_str.length + 6, size]
                        if file_storage_dir != nil and web_data_dir != nil
              Severity: Minor
              Found in modules/exploits/windows/http/trackit_file_upload.rb and 1 other location - About 45 mins to fix
              modules/exploits/windows/http/trackit_file_upload.rb on lines 210..216

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

              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

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

                      if (index = (buf_reply.index(file_storage_dir_str))) != nil
                        # after file_storage_dir_str, discard 5 bytes then get file_storage_dir_size
                        size = buf_reply[index + file_storage_dir_str.length + 5,1].unpack('C*')[0]
                        file_storage_dir = buf_reply[index + file_storage_dir_str.length + 6, size]
                        if file_storage_dir != nil and web_data_dir != nil
              Severity: Minor
              Found in modules/exploits/windows/http/trackit_file_upload.rb and 1 other location - About 45 mins to fix
              modules/exploits/windows/http/trackit_file_upload.rb on lines 218..224

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

              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

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

                    0x06, 0x00, 0x01, 0x01, 0x18, 0x00, 0x00, 0x00,
                    0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74,
                    0x69, 0x6f, 0x6e, 0x2f, 0x6f, 0x63, 0x74, 0x65,
                    0x74, 0x2d, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d,
                    0x00, 0x00
              Severity: Minor
              Found in modules/exploits/windows/http/trackit_file_upload.rb and 2 other locations - About 35 mins to fix
              modules/auxiliary/gather/trackit_sql_domain_creds.rb on lines 89..93
              modules/exploits/windows/lotus/domino_icalendar_organizer.rb on lines 127..166

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

              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

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

                  if @version == 9
                    file_content = Msf::Util::EXE.to_exe_asp(exe)
                    filename = rand_text_alpha_lower(rand(6) + 6) + ".asp"
                  else
                    file_content = Msf::Util::EXE.to_exe_aspx(exe)
              Severity: Minor
              Found in modules/exploits/windows/http/trackit_file_upload.rb and 1 other location - About 35 mins to fix
              modules/exploits/windows/http/trackit_file_upload.rb on lines 510..515

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

              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

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

                      if @version == 9
                        file_content = Msf::Util::EXE.to_exe_aspx(exe)
                        filename = rand_text_alpha_lower(rand(6) + 6) + ".aspx"
                      else
                        file_content = Msf::Util::EXE.to_exe_asp(exe)
              Severity: Minor
              Found in modules/exploits/windows/http/trackit_file_upload.rb and 1 other location - About 35 mins to fix
              modules/exploits/windows/http/trackit_file_upload.rb on lines 487..492

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

              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

                    @packet_header_pre_uri_size.length +
                    2 + # uri_size
                    @packet_header_pre_uri.length +
                    uri.length +
                    @packet_header_post_uri.length +
              Severity: Minor
              Found in modules/exploits/windows/http/trackit_file_upload.rb and 1 other location - About 30 mins to fix
              modules/exploits/windows/http/trackit_file_upload.rb on lines 149..160

              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

                    @packet_header_pre_uri_size.length +
                    2 + # uri_size
                    @packet_header_pre_uri.length +
                    uri.length +
                    @packet_header_post_uri.length +
              Severity: Minor
              Found in modules/exploits/windows/http/trackit_file_upload.rb and 1 other location - About 30 mins to fix
              modules/exploits/windows/http/trackit_file_upload.rb on lines 336..347

              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

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

                  packet_body_pre_file_size = [
                    0x01, 0x00, 0x00, 0x00, 0x09, 0x5f, 0x72, 0x61,
                    0x77, 0x42, 0x79, 0x74, 0x65, 0x73, 0x07, 0x02,
                    0x05, 0x00, 0x00, 0x00, 0x09, 0x06, 0x00, 0x00,
                    0x00, 0x0f, 0x06, 0x00, 0x00, 0x00
              Severity: Minor
              Found in modules/exploits/windows/http/trackit_file_upload.rb and 1 other location - About 30 mins to fix
              modules/exploits/windows/browser/ms12_004_midi.rb on lines 554..586

              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

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

                    (version[0].to_i == 11 and version[1].to_i <= 3) or
                    (version[0].to_i == 11 and version[1].to_i == 3 and version[2].to_i == 0 and version[3].to_i < 999)
                      ctx = { 'Msf' => framework, 'MsfExploit' => self }
                      sock = Rex::Socket.create_tcp({ 'PeerHost' => rhost, 'PeerPort' => datastore['RPORT_REMOTING'], 'Context' => ctx })
                      if not sock.nil?
              Severity: Minor
              Found in modules/exploits/windows/http/trackit_file_upload.rb and 1 other location - About 20 mins to fix
              modules/exploits/windows/scada/rockwell_factorytalk_rce.rb on lines 104..107

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

              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

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

                  packet_body_start_pre_method_size = [
                    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                    0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                    0x00, 0x15, 0x11, 0x00, 0x00, 0x00, 0x12
                  ]
              Severity: Minor
              Found in modules/exploits/windows/http/trackit_file_upload.rb and 2 other locations - About 15 mins to fix
              modules/auxiliary/gather/trackit_sql_domain_creds.rb on lines 96..100
              modules/exploits/windows/http/trackit_file_upload.rb on lines 291..295

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

              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

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

                  packet_body_start_pre_method_size = [
                    0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
                    0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                    0x00, 0x15, 0x14, 0x00, 0x00, 0x00, 0x12
                  ]
              Severity: Minor
              Found in modules/exploits/windows/http/trackit_file_upload.rb and 2 other locations - About 15 mins to fix
              modules/auxiliary/gather/trackit_sql_domain_creds.rb on lines 96..100
              modules/exploits/windows/http/trackit_file_upload.rb on lines 133..137

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

              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