rapid7/metasploit-framework

View on GitHub
modules/post/windows/manage/kerberos_tickets.rb

Summary

Maintainability
D
2 days
Test Coverage

File kerberos_tickets.rb has 299 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rex/proto/kerberos/model/kerberos_flags'
require 'rex/proto/kerberos/model/ticket_flags'
require 'rex/proto/ms_dtyp'

class MetasploitModule < Msf::Post
Severity: Minor
Found in modules/post/windows/manage/kerberos_tickets.rb - About 3 hrs to fix

    Method dump_session_tickets has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

      def dump_session_tickets(handle, auth_package, logon_session_data_ptr, query_tkt_cache_res_ptr)
        case session.native_arch
        when ARCH_X64
          query_tkt_cache_response_klass = KERB_QUERY_TKT_CACHE_RESPONSE_x64
          retrieve_tkt_request_klass = KERB_RETRIEVE_TKT_REQUEST_x64
    Severity: Minor
    Found in modules/post/windows/manage/kerberos_tickets.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 initialize has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def initialize(info = {})
        super(
          update_info(
            info,
            'Name' => 'Kerberos Ticket Management',
    Severity: Major
    Found in modules/post/windows/manage/kerberos_tickets.rb - About 2 hrs to fix

      Method dump_session_tickets has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def dump_session_tickets(handle, auth_package, logon_session_data_ptr, query_tkt_cache_res_ptr)
          case session.native_arch
          when ARCH_X64
            query_tkt_cache_response_klass = KERB_QUERY_TKT_CACHE_RESPONSE_x64
            retrieve_tkt_request_klass = KERB_RETRIEVE_TKT_REQUEST_x64
      Severity: Minor
      Found in modules/post/windows/manage/kerberos_tickets.rb - About 1 hr to fix

        Method get_token_statistics has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

          def get_token_statistics(token: nil)
            if token.nil?
              result = session.railgun.advapi32.OpenThreadToken(CURRENT_THREAD, session.railgun.const('TOKEN_QUERY'), false, @ptr_size)
              unless result['return']
                error = ::WindowsError::Win32.find_by_retval(result['GetLastError']).first
        Severity: Minor
        Found in modules/post/windows/manage/kerberos_tickets.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 print_logon_session_summary has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def print_logon_session_summary(logon_session_data_ptr, annotation: nil)
            sid = '???'
            if datastore['VERBOSE'] && logon_session_data_ptr.contents.psid != 0
              # reading the SID requires 3 railgun calls so only do it in verbose mode to speed things up
              # reading the data directly wouldn't be much faster because SIDs are of a variable length
        Severity: Minor
        Found in modules/post/windows/manage/kerberos_tickets.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 action_dump_tickets has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def action_dump_tickets
            handle = lsa_register_logon_process
            luids = nil
            if handle
              if target_luid
        Severity: Minor
        Found in modules/post/windows/manage/kerberos_tickets.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 action_dump_tickets has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def action_dump_tickets
            handle = lsa_register_logon_process
            luids = nil
            if handle
              if target_luid
        Severity: Minor
        Found in modules/post/windows/manage/kerberos_tickets.rb - About 1 hr to fix

          Method action_enum_luids has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def action_enum_luids
              current_luid = get_current_luid
              luids = lsa_enumerate_logon_sessions
              fail_with(Failure::Unknown, 'Failed to enumerate logon sessions.') if luids.nil?
          
          
          Severity: Minor
          Found in modules/post/windows/manage/kerberos_tickets.rb - About 45 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