Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LDAP to the set of interactive session types #19809

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/msf/core/rpc/v10/rpc_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ def rpc_compatible_modules(sid)
postgresql
mysql
smb
ldap
].freeze

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

unless INTERACTIVE_SESSION_TYPES.include?(session.type)
error(500, "Use `interactive_read` and `interactive_write` for sessions of #{session.type} type")
error(500, "`interactive_read` and `interactive_write` not available for #{session.type} sessions")
end

session
Expand Down
7 changes: 6 additions & 1 deletion lib/rex/post/ldap/ui/console/command_dispatcher/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ def cmd_query_help
end

def cmd_getuid
username = client.ldapwhoami
begin
username = client.ldapwhoami
rescue Net::LDAP::Error => e
print_error(e.message)
return
end
username.delete_prefix!('u:')
print_status("Server username: #{username}")
end
Expand Down
8 changes: 6 additions & 2 deletions lib/rex/proto/ldap/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,16 @@ def discover_base_dn
end

# Monkeypatch upstream library to support the extended Whoami request. Delete
# this after https://github.com/ruby-ldap/ruby-net-ldap/pull/425 is landed.
# this after https://github.com/ruby-ldap/ruby-net-ldap/pull/425 is released.
# This is not the only occurrence of a patch for this functionality.
def ldapwhoami(args = {})
instrument "ldapwhoami.net_ldap", args do |payload|
@result = use_connection(args, &:ldapwhoami)
@result.success? ? @result.extended_response : nil
if @result.success?
@result.extended_response
else
raise Net::LDAP::Error, "#{peerinfo} LDAP Error: #{@result.error_message}"
end
end
end
end
Expand Down
Loading