-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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 new Ldap session type #19058
Add new Ldap session type #19058
Conversation
a7ba39c
to
3257a29
Compare
We recently added the Shadow Credentials module in #19051 and I think that was after this branch was created. Would you mind pulling in those changes and adding LDAP session support to that module when the time comes? |
3257a29
to
6bbbae7
Compare
16e969d
to
cd4b2ca
Compare
9827e4a
to
03f4ce7
Compare
lib/rex/post/ldap/ui/console.rb
Outdated
# Runs the specified command wrapper in something to catch exceptions. | ||
# | ||
def run_command(dispatcher, method, arguments) | ||
# TODO: double check these are the correct errors to handle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
module Ui | ||
### | ||
# | ||
# Core SMB client commands |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Core SMB client commands | |
# Core LDAP client commands |
# | ||
# Shares | ||
# | ||
def name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix please
@@ -45,7 +45,7 @@ def initialize(opts = {}) | |||
# @raise [RuntimeError] if the connection can not be created | |||
def connect | |||
return connection if connection | |||
|
|||
raise ArgumentError, 'Missing remote address' unless self.host && self.port |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Maybe a better fix in Rex is needed here
03f4ce7
to
771c183
Compare
if datastore['CreateSession'] | ||
print_status("#{sessions.size} LDAP #{sessions.size == 1 ? 'session was' : 'sessions were'} opened successfully.") | ||
else | ||
print_status('You can open an LDAP session with these credentials and %grnCreateSession%clr set to true') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print_status('You can open an LDAP session with these credentials and %grnCreateSession%clr set to true') | |
print_status('You can open an LDAP session with these credentials and %grnCreateSession%clr set to true') if framework.features.enabled?(Msf::FeatureManager::LDAP_SESSION_TYPE) |
I'm confused by I can readily create an smb session, but it fails when I give it to the ldap_query module, which makes sense? Am I missing something? |
I think either he's saying to test that SMB sessions still work with SMB modules, or it's a typo and it should have been LDAP and not SMB. Either way, an SMB session isn't compatible with the |
Apologies I lifted the testing steps from the SMB PR to make sure we were testing these new sessions in all the same ways, I've updated the verification steps now to read LDAP instead of SMB |
When I use
|
Same result for
|
I was unable to replicate these errors in the light of day; we think it might be because the session timed out and then silently failed. |
Did some poking arpund on this, seems that the default idle timeout for ldap connections is 15 minutes, after leaving a session idle for 15+ minutes I was able to replicate the issue you reported and I've added in some extra handling for inactive sessions and killing them when they are next interacted with At some point we'll probably want some sort of keep alive function so the sessions can stay around longer but I think we don't need it for MVP
|
14deefb
to
68f7334
Compare
f3a8b35
Release notesThis adds an LDAP session type allowing users and modules to interact directly with LDAP servers without uploading a payload. |
Similar to adding the SMB session type here #18539 and here #18596 but for LDAP sessions/modules that can take advantage of re-using an ldap session
This PR adds in a new session type for LDAP following on from the recently added SQL and SMB sessions
Verification Steps:
Enable the new LDAP session feature
features set ldap_session_type true
Run
auxiliary/scanner/ldap/ldap_login
against an ldap server to get a session (an example of running an ldap container can be found in the ldap acceptance tests heremetasploit-framework/.github/workflows/ldap_acceptance.yml
Lines 67 to 71 in 33ffc14
Interact with the session with
sessions -i <session_id>
and withsessions -i -1
Run the
query
command (example queries used by theldap_query
module found here https://github.com/rapid7/metasploit-framework/blob/97f75c19e43bff214ec408854f30b0144a0a2347/data/auxiliary/gather/ldap_query/ldap_queries_default.yaml )Run
bg
to background the sessionuse auxiliary/gather/ldap_query
and thenset SESSION <session_id>
run the module and you should get successful results backExit the session with
exit
from within the session context and viasessions -K
/sessions -k <session_id>
make sure the feature is off first
features set ldap_session_type false
Run through the standard usage of the modules, ensure the
SESSION
datastore option is not visible and the modules succeedTurn the feature on
features set ldap_session_type true
Run through the modules again creating or using an LDAP session type where applicable, the results should be identical to the modules standard usage
Ensure authentication with
LDAP::Auth=kerberos
works with theldap_login
module and that that session works with another module e.g. ldap_query