Skip to content

Commit

Permalink
Merge pull request #1179 from ly4k/master
Browse files Browse the repository at this point in the history
Disable anonymous logon in ntlmrelayx
  • Loading branch information
0xdeaddood authored Oct 21, 2021
2 parents c0ec610 + 1c3fdae commit 1b74b06
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions impacket/examples/ntlmrelayx/servers/smbrelayserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ def __init__(self,config):
else:
smbConfig.set("global", "SMB2Support", "False")

smbConfig.set("global", "anonymous_logon", "False")

if self.config.outputFile is not None:
smbConfig.set('global','jtr_dump_path',self.config.outputFile)

Expand Down
15 changes: 14 additions & 1 deletion impacket/smbserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2978,9 +2978,13 @@ def smb2SessionSetup(connId, smbServer, recvPacket):
# No credentials provided, let's grant access
if authenticateMessage['flags'] & ntlm.NTLMSSP_NEGOTIATE_ANONYMOUS:
isAnonymus = True
if smbServer._SMBSERVER__anonymousLogon == False:
errorCode = STATUS_ACCESS_DENIED
else:
errorCode = STATUS_SUCCESS
else:
isGuest = True
errorCode = STATUS_SUCCESS
errorCode = STATUS_SUCCESS

if errorCode == STATUS_SUCCESS:
connData['Authenticated'] = True
Expand Down Expand Up @@ -3961,6 +3965,9 @@ def __init__(self, server_address, handler_class=SMBSERVERHandler, config_parser
# SMB2 Support flag = default not active
self.__SMB2Support = False

# Allow anonymous logon
self.__anonymousLogon = True

# Our list of commands we will answer, by default the NOT IMPLEMENTED one
self.__smbCommandsHandler = SMBCommands()
self.__smbTrans2Handler = TRANS2Commands()
Expand Down Expand Up @@ -4601,6 +4608,12 @@ def processConfigFile(self, configFile=None):
else:
self.__SMB2Support = False


if self.__serverConfig.has_option("global", "anonymous_logon"):
self.__anonymousLogon = self.__serverConfig.getboolean("global", "anonymous_logon")
else:
self.__anonymousLogon = True

if self.__logFile != 'None':
logging.basicConfig(filename=self.__logFile,
level=logging.DEBUG,
Expand Down

0 comments on commit 1b74b06

Please sign in to comment.