rapid7/metasploit-framework

View on GitHub
modules/exploits/windows/dcerpc/cve_2021_1675_printnightmare.rb

Summary

Maintainability
C
1 day
Test Coverage

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

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name' => 'Print Spooler Remote DLL Injection',
Severity: Major
Found in modules/exploits/windows/dcerpc/cve_2021_1675_printnightmare.rb - About 2 hrs to fix

    File cve_2021_1675_printnightmare.rb has 259 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'windows_error'
    require 'ruby_smb'
    require 'ruby_smb/error'
    
    class MetasploitModule < Msf::Exploit::Remote
    Severity: Minor
    Found in modules/exploits/windows/dcerpc/cve_2021_1675_printnightmare.rb - About 2 hrs to fix

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

        def check
          begin
            connect(backend: :ruby_smb)
          rescue Rex::ConnectionError
            return Exploit::CheckCode::Unknown('Failed to connect to the remote service.')
      Severity: Minor
      Found in modules/exploits/windows/dcerpc/cve_2021_1675_printnightmare.rb - About 2 hrs to fix

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

          def add_printer_driver_ex(container)
            flags = PrintSystem::APD_INSTALL_WARNED_DRIVER | PrintSystem::APD_COPY_FROM_DIRECTORY | PrintSystem::APD_COPY_ALL_FILES
        
            begin
              response = rprn_call('RpcAddPrinterDriverEx', p_name: "\\\\#{datastore['RHOST']}", p_driver_container: container, dw_file_copy_flags: flags)
        Severity: Minor
        Found in modules/exploits/windows/dcerpc/cve_2021_1675_printnightmare.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 has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def check
            begin
              connect(backend: :ruby_smb)
            rescue Rex::ConnectionError
              return Exploit::CheckCode::Unknown('Failed to connect to the remote service.')
        Severity: Minor
        Found in modules/exploits/windows/dcerpc/cve_2021_1675_printnightmare.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 add_printer_driver_ex has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def add_printer_driver_ex(container)
            flags = PrintSystem::APD_INSTALL_WARNED_DRIVER | PrintSystem::APD_COPY_FROM_DIRECTORY | PrintSystem::APD_COPY_ALL_FILES
        
            begin
              response = rprn_call('RpcAddPrinterDriverEx', p_name: "\\\\#{datastore['RHOST']}", p_driver_container: container, dw_file_copy_flags: flags)
        Severity: Minor
        Found in modules/exploits/windows/dcerpc/cve_2021_1675_printnightmare.rb - About 1 hr to fix

          Avoid too many return statements within this method.
          Open

                return Exploit::CheckCode::Unknown('Received unknown status code, implying the target is not vulnerable.')
          Severity: Major
          Found in modules/exploits/windows/dcerpc/cve_2021_1675_printnightmare.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                  return Exploit::CheckCode::Vulnerable('Received ERROR_BAD_NET_NAME, implying the target is vulnerable.')
            Severity: Major
            Found in modules/exploits/windows/dcerpc/cve_2021_1675_printnightmare.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                    return Exploit::CheckCode::Safe('Received ERROR_ACCESS_DENIED implying the target is patched.')
              Severity: Major
              Found in modules/exploits/windows/dcerpc/cve_2021_1675_printnightmare.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                      return Exploit::CheckCode::Vulnerable('Received ERROR_PATH_NOT_FOUND, implying the target is vulnerable.')
                Severity: Major
                Found in modules/exploits/windows/dcerpc/cve_2021_1675_printnightmare.rb - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status