rapid7/metasploit-framework

View on GitHub
modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb

Summary

Maintainability
F
3 days
Test Coverage

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

  def exploit
    # get system architecture
    arch = sysinfo['Architecture']
    if arch != payload_instance.arch.first
      fail_with(Failure::BadConfig, 'Wrong payload architecture!')
Severity: Minor
Found in modules/exploits/windows/local/dnsadmin_serverlevelplugindll.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 check has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

  def check
    version = get_version_info
    if version.windows_server?
      vprint_good('OS seems vulnerable.')
    else
Severity: Minor
Found in modules/exploits/windows/local/dnsadmin_serverlevelplugindll.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

File dnsadmin_serverlevelplugindll.rb has 317 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'metasploit/framework/compiler/windows'

class MetasploitModule < Msf::Exploit::Local
  Rank = NormalRanking

Severity: Minor
Found in modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb - About 3 hrs to fix

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

      def exploit
        # get system architecture
        arch = sysinfo['Architecture']
        if arch != payload_instance.arch.first
          fail_with(Failure::BadConfig, 'Wrong payload architecture!')
    Severity: Major
    Found in modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb - About 2 hrs to fix

      Method check has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def check
          version = get_version_info
          if version.windows_server?
            vprint_good('OS seems vulnerable.')
          else
      Severity: Major
      Found in modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb - About 2 hrs to fix

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

          def initialize(info = {})
            super(
              update_info(
                info,
                'Name' => 'DnsAdmin ServerLevelPluginDll Feature Abuse Privilege Escalation',
        Severity: Major
        Found in modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb - About 2 hrs to fix

          Method restart_service has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

            def restart_service(opts = {})
              # for deleting the DLL
              if opts['session'] && opts['dllpath']
                session = opts['session']
                dllpath = opts['dllpath']
          Severity: Minor
          Found in modules/exploits/windows/local/dnsadmin_serverlevelplugindll.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 make_serverlevelplugindll has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def make_serverlevelplugindll(arch)
              # generate the payload
              payload = generate_payload
              # the C template for the ServerLevelPluginDll DLL
              c_template = %|
          Severity: Minor
          Found in modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb - About 1 hr to fix

            Method restart_service has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def restart_service(opts = {})
                # for deleting the DLL
                if opts['session'] && opts['dllpath']
                  session = opts['session']
                  dllpath = opts['dllpath']
            Severity: Minor
            Found in modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb - About 1 hr to fix

              Avoid too many return statements within this method.
              Open

                    return Exploit::CheckCode::Safe
              Severity: Major
              Found in modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                      return Exploit::CheckCode::Safe
                Severity: Major
                Found in modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                        return Exploit::CheckCode::Unknown
                  Severity: Major
                  Found in modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb - About 30 mins to fix

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

                        loop do
                          svc_state = service_status('DNS')
                          if svc_state[:state] == 1
                            sleep 1
                            break
                    modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb on lines 208..216
                    modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb on lines 328..336

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

                    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

                        loop do
                          svc_state = service_status('DNS')
                          if svc_state[:state] == 4
                            sleep 1
                            break
                    modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb on lines 307..315
                    modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb on lines 328..336

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

                    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

                        loop do
                          svc_state = service_status('DNS')
                          if svc_state[:state] == 4
                            sleep 1
                            break
                    modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb on lines 208..216
                    modules/exploits/windows/local/dnsadmin_serverlevelplugindll.rb on lines 307..315

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

                    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