File base.rb
has 788 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Msf::Exploit::Remote::Kerberos::ServiceAuthenticator::Base
extend Forwardable
include Msf::Exploit::Remote::Kerberos::Client
include Msf::Auxiliary::Report
include Rex::Proto::Gss::Asn1
Method load_credential_from_file
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def load_credential_from_file(file_path, options = {})
unless File.readable?(file_path.to_s)
wlog("Failed to load ticket file '#{file_path}' (file not readable)")
return nil
end
- Read upRead up
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 authenticate_via_krb5_ccache_credential_tgt
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
def authenticate_via_krb5_ccache_credential_tgt(credential, options = {})
realm = self.realm.upcase
sname = options.fetch(:sname)
client_name = username
Method request_service_ticket
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
def request_service_ticket(session_key, tgt_ticket, realm, client_name, etypes, expiry_time, now, sname, options = {})
etypes = etypes.is_a?(::Enumerable) ? etypes : [etypes]
flags = Set.new([
Rex::Proto::Kerberos::Model::KdcOptionFlags::FORWARDABLE,
Method authenticate
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def authenticate(options = {})
options[:sname] = options.fetch(:sname) { build_spn(options) }
unless options[:credential]
if @credential
- Read upRead up
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
Class Base
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class Msf::Exploit::Remote::Kerberos::ServiceAuthenticator::Base
extend Forwardable
include Msf::Exploit::Remote::Kerberos::Client
include Msf::Auxiliary::Report
include Rex::Proto::Gss::Asn1
Method request_service_ticket
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def request_service_ticket(session_key, tgt_ticket, realm, client_name, etypes, expiry_time, now, sname, options = {})
etypes = etypes.is_a?(::Enumerable) ? etypes : [etypes]
flags = Set.new([
Rex::Proto::Kerberos::Model::KdcOptionFlags::FORWARDABLE,
- Read upRead up
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 authenticate_via_kdc
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
def authenticate_via_kdc(options = {})
realm = self.realm.upcase
client_name = username
server_name = "krbtgt/#{realm}"
Method request_delegation_ticket
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def request_delegation_ticket(session_key, tgt_ticket, realm, client_name, tgt_etype, expiry_time, now)
ticket_options = Rex::Proto::Kerberos::Model::KdcOptionFlags.from_flags(
[
Rex::Proto::Kerberos::Model::KdcOptionFlags::FORWARDABLE,
Rex::Proto::Kerberos::Model::KdcOptionFlags::FORWARDED,
Method authenticate
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def authenticate(options = {})
options[:sname] = options.fetch(:sname) { build_spn(options) }
unless options[:credential]
if @credential
Method u2uself
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def u2uself(credential, options = {})
realm = self.realm.upcase
client_name = options.fetch(:username) { self.username }
sname = options.fetch(:sname) {
Rex::Proto::Kerberos::Model::PrincipalName.new(
Method load_credential_from_file
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def load_credential_from_file(file_path, options = {})
unless File.readable?(file_path.to_s)
wlog("Failed to load ticket file '#{file_path}' (file not readable)")
return nil
end
Method s4u2proxy
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def s4u2proxy(credential, options = {})
realm = self.realm.upcase
sname = options.fetch(:sname)
client_name = username
Method initialize
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(
realm: nil,
hostname: nil,
username: nil,
password: nil,
Method authenticate_via_krb5_ccache_credential_tgs
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def authenticate_via_krb5_ccache_credential_tgs(credential, _options = {})
unless credential.is_a?(Rex::Proto::Kerberos::CredentialCache::Krb5CcacheCredential)
raise TypeError, 'credential must be a Krb5CcacheCredential instance'
end
Method build_gss_ap_req_checksum_value
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_gss_ap_req_checksum_value(mutual_auth, dce_style, ticket, decrypted_part, session_key, realm, client_name)
# @see https://datatracker.ietf.org/doc/html/rfc4121#section-4.1.1
# No channel binding
channel_binding_info = "\x00" * 16
channel_binding_info_len = [channel_binding_info.length].pack('V')
Method s4u2self
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def s4u2self(credential, options = {})
realm = self.realm.upcase
sname = options.fetch(:sname)
client_name = username
Method request_service_ticket
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def request_service_ticket(session_key, tgt_ticket, realm, client_name, etypes, expiry_time, now, sname, options = {})
Method build_gss_ap_req_checksum_value
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def build_gss_ap_req_checksum_value(mutual_auth, dce_style, ticket, decrypted_part, session_key, realm, client_name)
Method request_delegation_ticket
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def request_delegation_ticket(session_key, tgt_ticket, realm, client_name, tgt_etype, expiry_time, now)
Method connect
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def connect(options = {})
unless options[:rhost]
unless (host = @host)
vprint_status("Using DNS to lookup the KDC for #{realm}...")
host = ::Rex::Socket.getresources("_kerberos._tcp.#{realm}", :SRV)&.sample
- Read upRead up
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 a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def initialize(
realm: nil,
hostname: nil,
username: nil,
password: nil,
- Read upRead up
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 parse_gss_init_response
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def parse_gss_init_response(token, session_key, mechanism: 'kerberos')
mech_id, encapsulated_token = unwrap_pseudo_asn1(token)
if mech_id.value == Rex::Proto::Gss::OID_KERBEROS_5.value
tok_id = encapsulated_token[0,2]
- Read upRead up
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
ticket_options = Rex::Proto::Kerberos::Model::KdcOptionFlags.from_flags(
[
Rex::Proto::Kerberos::Model::KdcOptionFlags::FORWARDABLE,
Rex::Proto::Kerberos::Model::KdcOptionFlags::RENEWABLE,
Rex::Proto::Kerberos::Model::KdcOptionFlags::CANONICALIZE,
- Read upRead up
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 32.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
ticket_options = Rex::Proto::Kerberos::Model::KdcOptionFlags.from_flags(
[
Rex::Proto::Kerberos::Model::KdcOptionFlags::FORWARDABLE,
Rex::Proto::Kerberos::Model::KdcOptionFlags::FORWARDED,
Rex::Proto::Kerberos::Model::KdcOptionFlags::RENEWABLE,
- Read upRead up
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 32.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76