rapid7/metasploit-framework

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

Summary

Maintainability
D
2 days
Test Coverage

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

  def exploit
    jsp_name = datastore['JSP'] || rand_text_alpha(8+rand(8))
    app_base = datastore['APPBASE'] || rand_text_alpha(8+rand(8))

    mytarget = target
Severity: Major
Found in modules/exploits/multi/http/jboss_maindeployer.rb - About 5 hrs to fix

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

      def exploit
        jsp_name = datastore['JSP'] || rand_text_alpha(8+rand(8))
        app_base = datastore['APPBASE'] || rand_text_alpha(8+rand(8))
    
        mytarget = target
    Severity: Minor
    Found in modules/exploits/multi/http/jboss_maindeployer.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 initialize has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def initialize(info = {})
        super(update_info(info,
          'Name'        => 'JBoss JMX Console Deployer Upload and Execute',
          'Description' => %q{
              This module can be used to execute a payload on JBoss servers that have
    Severity: Major
    Found in modules/exploits/multi/http/jboss_maindeployer.rb - About 2 hrs to fix

      File jboss_maindeployer.rb has 271 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      class MetasploitModule < Msf::Exploit::Remote
        Rank = ExcellentRanking
      
        HttpFingerprint = { :pattern => [ /(Jetty|JBoss)/ ] }
      
      
      Severity: Minor
      Found in modules/exploits/multi/http/jboss_maindeployer.rb - About 2 hrs to fix

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

          def auto_target
            if datastore['VERB'] == 'HEAD' then
              print_status("Sorry, automatic target detection doesn't work with HEAD requests")
            else
              print_status("Attempting to automatically select a target...")
        Severity: Minor
        Found in modules/exploits/multi/http/jboss_maindeployer.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

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

                  [ 'Automatic (Java based)',
                    {
                      'Arch' => ARCH_JAVA,
                      'Platform' => 'java'
                    }
        Severity: Minor
        Found in modules/exploits/multi/http/jboss_maindeployer.rb and 2 other locations - About 25 mins to fix
        modules/exploits/multi/http/jboss_bshdeployer.rb on lines 45..75
        modules/exploits/multi/http/jboss_deploymentfilerepository.rb on lines 38..68

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

        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 (target.name =~ /Automatic/)
              mytarget = auto_target()
              if (not mytarget)
                fail_with(Failure::NoTarget, "Unable to automatically select a target")
              end
        Severity: Minor
        Found in modules/exploits/multi/http/jboss_maindeployer.rb and 1 other location - About 20 mins to fix
        modules/exploits/multi/http/tomcat_mgr_deploy.rb on lines 157..164

        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

              res = send_request_cgi({
                  'method'    => datastore['VERB'],
                  'uri'       => normalize_uri(datastore['PATH'], '/HtmlAdaptor'),
                  'vars_post' =>
                    {
        Severity: Minor
        Found in modules/exploits/multi/http/jboss_maindeployer.rb and 2 other locations - About 15 mins to fix
        modules/exploits/multi/http/jboss_maindeployer.rb on lines 183..194
        modules/exploits/multi/http/jboss_maindeployer.rb on lines 269..280

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

        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

              res = send_request_cgi({
                  'method'    => datastore['VERB'],
                  'uri'       => normalize_uri(datastore['PATH'], '/HtmlAdaptor'),
                  'vars_get' =>
                    {
        Severity: Minor
        Found in modules/exploits/multi/http/jboss_maindeployer.rb and 2 other locations - About 15 mins to fix
        modules/exploits/multi/http/jboss_maindeployer.rb on lines 170..181
        modules/exploits/multi/http/jboss_maindeployer.rb on lines 269..280

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

        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

            res = send_request_cgi({
              'method'    => datastore['VERB'],
              'uri'       => normalize_uri(datastore['PATH'], '/HtmlAdaptor'),
              'vars_post' =>
                {
        Severity: Minor
        Found in modules/exploits/multi/http/jboss_maindeployer.rb and 2 other locations - About 15 mins to fix
        modules/exploits/multi/http/jboss_maindeployer.rb on lines 170..181
        modules/exploits/multi/http/jboss_maindeployer.rb on lines 183..194

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

        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 (res.body =~ /<td.*?OSName.*?(Linux|FreeBSD|Windows).*?<\/td>/m)
              os = $1
              if (os =~ /Linux/i)
                return 'linux'
              elsif (os =~ /FreeBSD/i)
        Severity: Minor
        Found in modules/exploits/multi/http/jboss_maindeployer.rb and 1 other location - About 15 mins to fix
        modules/exploits/multi/http/jboss_invoke_deploy.rb on lines 338..346

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

        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