rapid7/metasploit-framework

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

Summary

Maintainability
D
2 days
Test Coverage

File cve_2022_21999_spoolfool_privesc.rb has 339 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

  prepend Msf::Exploit::Remote::AutoCheck
  include Msf::Post::File
Severity: Minor
Found in modules/exploits/windows/local/cve_2022_21999_spoolfool_privesc.rb - About 4 hrs to fix

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

      def exploit
        fail_with(Failure::None, 'Already running as SYSTEM') if is_system?
    
        unless session.arch == ARCH_X64
          fail_with(Failure::BadConfig, 'This exploit only supports x64 sessions')
    Severity: Minor
    Found in modules/exploits/windows/local/cve_2022_21999_spoolfool_privesc.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 68 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def initialize(info = {})
        super(
          update_info(
            info,
            'Name' => 'CVE-2022-21999 SpoolFool Privesc',
    Severity: Major
    Found in modules/exploits/windows/local/cve_2022_21999_spoolfool_privesc.rb - About 2 hrs to fix

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

        def exploit
          fail_with(Failure::None, 'Already running as SYSTEM') if is_system?
      
          unless session.arch == ARCH_X64
            fail_with(Failure::BadConfig, 'This exploit only supports x64 sessions')
      Severity: Major
      Found in modules/exploits/windows/local/cve_2022_21999_spoolfool_privesc.rb - About 2 hrs to fix

        Class MetasploitModule has 21 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class MetasploitModule < Msf::Exploit::Local
          Rank = NormalRanking
        
          prepend Msf::Exploit::Remote::AutoCheck
          include Msf::Post::File
        Severity: Minor
        Found in modules/exploits/windows/local/cve_2022_21999_spoolfool_privesc.rb - About 2 hrs to fix

          Method set_perms_on_payload has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def set_perms_on_payload
              obj_type = session.railgun.const('SE_FILE_OBJECT')
              sec_info = session.railgun.const('DACL_SECURITY_INFORMATION')
              ret = advapi32.GetNamedSecurityInfoA(
                @payload_path,
          Severity: Minor
          Found in modules/exploits/windows/local/cve_2022_21999_spoolfool_privesc.rb - About 1 hr to fix

            Method get_default_printer has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def get_default_printer
                xps = 'Microsoft XPS Document Writer'
                pdf = 'Microsoft Print to PDF'
            
                local_const = session.railgun.const('PRINTER_ENUM_LOCAL')
            Severity: Minor
            Found in modules/exploits/windows/local/cve_2022_21999_spoolfool_privesc.rb - About 1 hr to fix

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

                def set_perms_on_payload
                  obj_type = session.railgun.const('SE_FILE_OBJECT')
                  sec_info = session.railgun.const('DACL_SECURITY_INFORMATION')
                  ret = advapi32.GetNamedSecurityInfoA(
                    @payload_path,
              Severity: Minor
              Found in modules/exploits/windows/local/cve_2022_21999_spoolfool_privesc.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

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

                def get_default_printer
                  xps = 'Microsoft XPS Document Writer'
                  pdf = 'Microsoft Print to PDF'
              
                  local_const = session.railgun.const('PRINTER_ENUM_LOCAL')
              Severity: Minor
              Found in modules/exploits/windows/local/cve_2022_21999_spoolfool_privesc.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

              There are no issues that match your filters.

              Category
              Status