HTTP to LDAP Relay Module#21323
Conversation
|
Thanks for your pull request! As part of our landing process, we manually verify that all modules work as expected. We've added the |
|
Thanks for your pull request! Before this can be merged, we need the following documentation for your module: |
|
Thanks for your pull request! As part of our landing process, we manually verify that all modules work as expected. We've added the |
There was a problem hiding this comment.
Pull request overview
Adds a new auxiliary HTTP-to-LDAP NTLM relay capability to Metasploit, including a reusable HTTP relay server mixin and an HTTP NTLM relay client state machine, plus module documentation.
Changes:
- Introduces
auxiliary/server/relay/http_to_ldapto relay HTTP NTLM auth to one or more LDAP targets and open an LDAP session on success. - Adds
Msf::Exploit::Remote::HTTP::RelayServerand an HTTP NTLMServerClientimplementation to handle NTLM/SPNEGO over HTTP and multi-target relaying via redirects. - Adds end-user documentation for setup, verification steps, and an example scenario.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 12 comments.
| File | Description |
|---|---|
| modules/auxiliary/server/relay/http_to_ldap.rb | New auxiliary module wiring the HTTP relay server into LDAP session creation. |
| lib/msf/core/exploit/remote/http/relay_server.rb | New HTTP relay server mixin (service startup, request dispatch, client tracking). |
| lib/msf/core/exploit/remote/http/relay/ntlm/server_client.rb | New per-client HTTP NTLM relay state machine (Type1/2/3 + SPNEGO unwrap + redirects). |
| documentation/modules/auxiliary/server/relay/http_to_ldap.md | New module documentation and usage scenario. |
smcintyre-r7
left a comment
There was a problem hiding this comment.
Something funny is going on here because this warning is firing saying that the operation won't work... but then it does. I'm guessing the message may be over-fitted, it might have only been necessary in the past when SMB was the transport instead of HTTP. Either way, we should fix it so it's not throwing a warning that it's going to fail when it succeeds.
msf auxiliary(server/relay/http_to_ldap) > sessions
Active sessions
===============
No active sessions.
msf auxiliary(server/relay/http_to_ldap) > run
[*] Auxiliary module running as background job 3.
msf auxiliary(server/relay/http_to_ldap) >
[*] Using URL: http://192.168.250.227:8080/ozlrcvyt
[*] Server started.
[*] Received GET request for /test from 192.168.159.128:37466
[*] Processing request in state unauthenticated from 192.168.159.128
[*] Detected GSS-SPNEGO wrapping around the type1 NTLM message
[*] Received Type 1 message from 192.168.159.128, attempting to relay...
[*] Attempting to relay to ldap://192.168.159.10:389
[*] Dropping MIC and removing flags: `Always Sign`, `Sign` and `Key Exchange`
[*] Received type2 from target ldap://192.168.159.10:389, attempting to relay back to client
[*] Received GET request for /test from 192.168.159.128:37466
[*] Processing request in state awaiting_type3 from 192.168.159.128
[*] Detected GSS-SPNEGO wrapping around the type3 NTLM message
[*] Received Type 3 message from 192.168.159.128, attempting to relay...
[*] Dropping MIC and removing flags: `Always Sign`, `Sign` and `Key Exchange`
[!] Relay client's NTLM type 3 message is NTLMv2, relaying to LDAP will not work
[+] Successfully relayed NTLM authentication to LDAP!
[+] Relay succeeded
[*] Target list exhausted for 192.168.159.128. Closing connection.
msf auxiliary(server/relay/http_to_ldap) > sessions
Active sessions
===============
Id Name Type Information Connection
-- ---- ---- ----------- ----------
5 ldap LDAP smcintyre @ 192.168.159.10:389 192.168.159.128:42495 -> 192.168.159.10:389 (192.168.159.10)
msf auxiliary(server/relay/http_to_ldap) >
smcintyre-r7
left a comment
There was a problem hiding this comment.
Just two more small changes before we land this.
Remove unnecessary code Remove commented out code Added documentation Responded to Spencer and Copilot Add anonymous identity check Doc update Warning surpression Renamed ldap_client to relayed_connection Comments
3f061ce to
4847d88
Compare
smcintyre-r7
left a comment
There was a problem hiding this comment.
Changes look good to me now. I tested this pretty extensively now using this updated gss_tester script. Things work with/without NTLMv2, with/without GSS etc. I was targeting a Windows Server 2019 DC, and the LmCompatibility requirements I noted have been incorporated into the docs.
Release NotesThis adds a new NTLM relay module that relays from HTTP to LDAP. On success, an authenticated LDAP session is opened which allows the operator to interact with the LDAP service in the context of the relayed identity. |
This PR adds an auxiliary relay module
http_to_ldapwhich allows operators to relay HTTP NTLM authentication to an LDAP server. If successful the module opens an LDAP session. This module supports relaying one HTTP authentication attempt to multiple LDAP servers. After attempting to relay to one target, the relay server sends a 307 to the client and if the client is configured to repond to redirects, the client resends the NTLMSSP_NEGOTIATE request to the relay server. Multi relay will not work if the client does not respond to redirects.The module supports relaying NTLM authentication which has been wrapped in GSS-SPNEGO. HTTP authentication info is sent in the
WWW-Authenticateheader. In the auth header base64 encoded NTLM messages are denoted with the NTLM prefix, while GSS wrapped NTLM messages are denoted with the Negotiate prefix. Note that in some cases non-GSS wrapped NTLM auth can be prefixed with Negotiate.Verification
The Domain Computer will need to be configured to use NTLMv1 by setting the following registry key to a value less than or equal to 2:
msfconsoleuse auxiliary/server/relay/http_to_ldapRHOSTSTesting
Run the module, send http auth request to the relay server, profit:
HTTP Clients
There were a number of different clients used to test the module, listing here for visibility
Invoke-WebRequest / Curl.exe
C# executable
From SpectreOpts
SharpHTTP.exe
GSS python script
I tried a number of different clients in order to test the NTLMv1 wrapped in GSS. Ran into a variety of issues which led me to the following python script:
gss_tester.py