浏览代码

SMB1: Return STATUS_NOT_IMPLEMENTED when receiving Remote Administration Protocol requests

Tal Aloni 8 年之前
父节点
当前提交
fddc896cf6

+ 1 - 6
SMBLibrary/SMB1/TransactionSubcommands/TransactionSubcommand.cs

@@ -1,4 +1,4 @@
-/* Copyright (C) 2014 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
+/* Copyright (C) 2014-2017 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
  * 
  * You can redistribute this program and/or modify it under the terms of
  * the GNU Lesser Public License as published by the Free Software Foundation,
@@ -68,11 +68,6 @@ namespace SMBLibrary.SMB1
                         return new TransactionCallNamedPipeRequest(setup, data);
                 }
             }
-            else if (setup.Length == 0 && data.Length == 0)
-            {
-                // [MS-RAP] Remote Administration Protocol request
-                throw new NotImplementedException("Remote Administration Protocol request");
-            }
             throw new InvalidRequestException();
         }
     }

+ 8 - 0
SMBLibrary/Server/SMB1/TransactionHelper.cs

@@ -92,6 +92,14 @@ namespace SMBLibrary.Server.SMB1
 
         internal static SMB1Command GetCompleteTransactionResponse(SMB1Header header, string name, byte[] requestSetup, byte[] requestParameters, byte[] requestData, ISMBShare share, SMB1ConnectionState state, List<SMB1Command> sendQueue)
         {
+            if (String.Equals(name, @"\pipe\lanman", StringComparison.InvariantCultureIgnoreCase))
+            {
+                // [MS-RAP] Remote Administration Protocol request
+                state.LogToServer(Severity.Debug, "Remote Administration Protocol requests are not implemented");
+                header.Status = NTStatus.STATUS_NOT_IMPLEMENTED;
+                return new ErrorResponse(CommandName.SMB_COM_TRANSACTION);
+            }
+
             TransactionSubcommand subcommand = TransactionSubcommand.GetSubcommandRequest(requestSetup, requestParameters, requestData, header.UnicodeFlag);
             TransactionSubcommand subcommandResponse = null;