Skip to content

Commit

Permalink
Merge pull request #1602 from rtpt-erikgeiser:ntlmrelayx_log_initial_…
Browse files Browse the repository at this point in the history
…authentication
  • Loading branch information
rtpt-erikgeiser authored Sep 28, 2023
1 parent 9c8f344 commit 06217f0
Showing 1 changed file with 14 additions and 2 deletions.
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"

LOG.info(f"Received connection from {user} at {host_name}, connection will be relayed after re-authentication")


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.setAuthCallback(auth_callback)
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

0 comments on commit 06217f0

Please sign in to comment.