Skip to content

Commit ad10cb8

Browse files
committed
Shorten the gss portion of the hardcore alias
Drop keys whose values are empty to shorten the string
1 parent 024bdae commit ad10cb8

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/rex/proto/smb/server.rb

+11-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,17 @@ def inspect
4646
def self.hardcore_alias(*args, **kwargs)
4747
gss_alias = ''
4848
if (gss_provider = kwargs[:gss_provider])
49-
gss_alias << "#{gss_provider.class}(allow_anonymous=#{gss_provider.allow_anonymous}, allow_guests=#{gss_provider.allow_guests}"
50-
gss_alias << ", default_domain=#{gss_provider.default_domain}" if gss_provider.respond_to?(:default_domain)
51-
gss_alias << ", ntlm_type3_status=#{gss_provider.ntlm_type3_status&.name}" if gss_provider.respond_to?(:ntlm_type3_status)
49+
gss_alias << "#{gss_provider.class}("
50+
attrs = {}
51+
if gss_provider.is_a?(RubySMB::Gss::Provider::NTLM)
52+
allows = []
53+
allows << 'ANONYMOUS' if gss_provider.allow_anonymous
54+
allows << 'GUESTS' if gss_provider.allow_guests
55+
attrs['allow'] = allows.join('|') unless allows.empty?
56+
attrs['default_domain'] = gss_provider.default_domain if gss_provider.respond_to?(:default_domain) && gss_provider.default_domain.present?
57+
attrs['ntlm_status'] = gss_provider.ntlm_type3_status.name if gss_provider.respond_to?(:ntlm_type3_status) && gss_provider.ntlm_type3_status.present?
58+
end
59+
gss_alias << attrs.map { |k,v| "#{k}=#{v}"}.join(', ')
5260
gss_alias << ')'
5361
end
5462
"#{(args[0] || '')}-#{(args[1] || '')}-#{args[3] || ''}-#{gss_alias}"

0 commit comments

Comments
 (0)