Skip to content

Commit 4c478a5

Browse files
committed
Add LDAP to the set of interactive session types
1 parent c494ad4 commit 4c478a5

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

lib/msf/core/rpc/v10/rpc_session.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ def rpc_compatible_modules(sid)
531531
postgresql
532532
mysql
533533
smb
534+
ldap
534535
].freeze
535536

536537
def _find_module(_mtype, mname)
@@ -545,7 +546,7 @@ def _valid_interactive_session(sid)
545546
error(500, "Unknown Session ID #{sid}") if session.nil?
546547

547548
unless INTERACTIVE_SESSION_TYPES.include?(session.type)
548-
error(500, "Use `interactive_read` and `interactive_write` for sessions of #{session.type} type")
549+
error(500, "`interactive_read` and `interactive_write` not available for #{session.type} sessions")
549550
end
550551

551552
session

lib/rex/post/ldap/ui/console/command_dispatcher/client.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,12 @@ def cmd_query_help
104104
end
105105

106106
def cmd_getuid
107-
username = client.ldapwhoami
107+
begin
108+
username = client.ldapwhoami
109+
rescue Net::LDAP::Error => e
110+
print_error(e.message)
111+
return
112+
end
108113
username.delete_prefix!('u:')
109114
print_status("Server username: #{username}")
110115
end

lib/rex/proto/ldap/client.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,16 @@ def discover_base_dn
121121
end
122122

123123
# Monkeypatch upstream library to support the extended Whoami request. Delete
124-
# this after https://github.com/ruby-ldap/ruby-net-ldap/pull/425 is landed.
124+
# this after https://github.com/ruby-ldap/ruby-net-ldap/pull/425 is released.
125125
# This is not the only occurrence of a patch for this functionality.
126126
def ldapwhoami(args = {})
127127
instrument "ldapwhoami.net_ldap", args do |payload|
128128
@result = use_connection(args, &:ldapwhoami)
129-
@result.success? ? @result.extended_response : nil
129+
if @result.success?
130+
@result.extended_response
131+
else
132+
raise Net::LDAP::Error, "#{peerinfo} LDAP Error: #{@result.error_message}"
133+
end
130134
end
131135
end
132136
end

0 commit comments

Comments
 (0)