Skip to content

Commit 2bc1767

Browse files
committed
Call LDAP whoami when the username is not present
1 parent 44f79f5 commit 2bc1767

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/msf/base/sessions/ldap.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,17 @@ def bootstrap(datastore = {}, handler = nil)
4242
session = self
4343
session.init_ui(user_input, user_output)
4444

45-
@info = "LDAP #{datastore['USERNAME']} @ #{@peer_info}"
45+
username = datastore['USERNAME']
46+
if username.blank?
47+
begin
48+
whoami = client.ldapwhoami
49+
rescue Net::LDAP::Error => e
50+
ilog('ldap session opened with no username and the target does not support the LDAP whoami extension')
51+
else
52+
username = whoami.delete_prefix('u:').split('\\').last
53+
end
54+
end
55+
@info = "LDAP #{username} @ #{@peer_info}"
4656
end
4757

4858
def execute_file(full_path, args)

0 commit comments

Comments
 (0)