Skip to content

Commit

Permalink
Shorten the gss portion of the hardcore alias
Browse files Browse the repository at this point in the history
Drop keys whose values are empty to shorten the string
  • Loading branch information
zeroSteiner committed Jan 9, 2024
1 parent 024bdae commit ad10cb8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/rex/proto/smb/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,17 @@ def inspect
def self.hardcore_alias(*args, **kwargs)
gss_alias = ''
if (gss_provider = kwargs[:gss_provider])
gss_alias << "#{gss_provider.class}(allow_anonymous=#{gss_provider.allow_anonymous}, allow_guests=#{gss_provider.allow_guests}"
gss_alias << ", default_domain=#{gss_provider.default_domain}" if gss_provider.respond_to?(:default_domain)
gss_alias << ", ntlm_type3_status=#{gss_provider.ntlm_type3_status&.name}" if gss_provider.respond_to?(:ntlm_type3_status)
gss_alias << "#{gss_provider.class}("
attrs = {}
if gss_provider.is_a?(RubySMB::Gss::Provider::NTLM)
allows = []
allows << 'ANONYMOUS' if gss_provider.allow_anonymous
allows << 'GUESTS' if gss_provider.allow_guests
attrs['allow'] = allows.join('|') unless allows.empty?
attrs['default_domain'] = gss_provider.default_domain if gss_provider.respond_to?(:default_domain) && gss_provider.default_domain.present?
attrs['ntlm_status'] = gss_provider.ntlm_type3_status.name if gss_provider.respond_to?(:ntlm_type3_status) && gss_provider.ntlm_type3_status.present?
end
gss_alias << attrs.map { |k,v| "#{k}=#{v}"}.join(', ')
gss_alias << ')'
end
"#{(args[0] || '')}-#{(args[1] || '')}-#{args[3] || ''}-#{gss_alias}"
Expand Down

0 comments on commit ad10cb8

Please sign in to comment.