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

ntlmrelayx.py: Log initial authentication in multi-target mode #1602

Merged
Merged
Changes from 1 commit
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
16 changes: 14 additions & 2 deletions impacket/examples/ntlmrelayx/servers/smbrelayserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@
from impacket.smbserver import getFileTime, decodeSMBString, encodeSMBString
from impacket.smb3structs import SMB2Error

def auth_callback(smbServer, connData, domain_name, user_name, host_name):
user = user_name
if domain_name:
user = domain_name + "/" + user_name
if not user:
user = "unknown"

print(f"[*] Received connection from {user} at {host_name}, connection will be relayed after re-authentication")
rtpt-erikgeiser marked this conversation as resolved.
Show resolved Hide resolved


class SMBRelayServer(Thread):
def __init__(self,config):
Thread.__init__(self)
Expand All @@ -58,7 +68,7 @@ def __init__(self,config):
#Username we auth as gets stored here later
self.authUser = None
self.proxyTranslator = None


# Here we write a mini config for the server
smbConfig = ConfigParser.ConfigParser()
Expand Down Expand Up @@ -100,6 +110,8 @@ def __init__(self,config):
smbport = 445

self.server = SMBSERVER((config.interfaceIp,smbport), config_parser = smbConfig)
if not self.config.disableMulti:
self.server.auth_callback = auth_callback
rtpt-erikgeiser marked this conversation as resolved.
Show resolved Hide resolved
logging.getLogger('impacket.smbserver').setLevel(logging.CRITICAL)

self.server.processConfigFile()
Expand Down Expand Up @@ -166,7 +178,7 @@ def SmbNegotiate(self, connId, smbServer, recvPacket, isSMB1=False):
respPacket['TreeID'] = 0

respSMBCommand = smb3.SMB2Negotiate_Response()

# Just for the Nego Packet, then disable it
respSMBCommand['SecurityMode'] = smb3.SMB2_NEGOTIATE_SIGNING_ENABLED

Expand Down