Esempio n. 1
0
        public NTStatus FsCtlPipeTranscieve(object handle, byte[] input, out byte[] output, int maxOutputLength)
        {
            output = null;
            TransactionTransactNamedPipeRequest subcommand = new TransactionTransactNamedPipeRequest();

            subcommand.FID       = (ushort)handle;
            subcommand.WriteData = input;

            TransactionRequest request = new TransactionRequest();

            request.Setup               = subcommand.GetSetup();
            request.TransParameters     = subcommand.GetParameters();
            request.TransData           = subcommand.GetData(m_client.Unicode);
            request.TotalDataCount      = (ushort)request.TransData.Length;
            request.TotalParameterCount = (ushort)request.TransParameters.Length;
            request.MaxParameterCount   = TransactionTransactNamedPipeResponse.ParametersLength;
            request.MaxDataCount        = (ushort)maxOutputLength;
            request.Name = @"\PIPE\";

            TrySendMessage(request);
            SMB1Message reply = m_client.WaitForMessage(CommandName.SMB_COM_TRANSACTION);

            if (reply != null)
            {
                if (reply.Header.Status == NTStatus.STATUS_SUCCESS && reply.Commands[0] is TransactionResponse)
                {
                    TransactionResponse response = (TransactionResponse)reply.Commands[0];
                    TransactionTransactNamedPipeResponse subcommandResponse = new TransactionTransactNamedPipeResponse(response.TransData);
                    output = subcommandResponse.ReadData;
                }
                return(reply.Header.Status);
            }
            return(NTStatus.STATUS_INVALID_SMB);
        }
Esempio n. 2
0
        public void FsCtlPipeTranscieve(NtHandle handle, byte[] input, out byte[]?output, int maxOutputLength)
        {
            TransactionTransactNamedPipeRequest subcommand = new TransactionTransactNamedPipeRequest
            {
                FID       = ((Smb1Handle)handle).FID,
                WriteData = input
            };

            TransactionRequest request = new TransactionRequest
            {
                Setup           = subcommand.GetSetup(),
                TransParameters = subcommand.GetParameters(),
                TransData       = subcommand.GetData(m_client.Unicode)
            };

            request.TotalDataCount      = (ushort)request.TransData.Length;
            request.TotalParameterCount = (ushort)request.TransParameters.Length;
            request.MaxParameterCount   = TransactionTransactNamedPipeResponse.ParametersLength;
            request.MaxDataCount        = (ushort)maxOutputLength;
            request.Name = @"\PIPE\";

            TrySendMessage(request);
            SMB1Message reply = m_client.WaitForMessage(CommandName.SMB_COM_TRANSACTION);

            if (reply.Header.Status != NTStatus.STATUS_SUCCESS || !(reply.Commands[0] is TransactionResponse transactionResponse))
            {
                throw new NtStatusException(reply.Header.Status);
            }

            TransactionTransactNamedPipeResponse subcommandResponse = new TransactionTransactNamedPipeResponse(transactionResponse.TransData);

            output = subcommandResponse.ReadData;
        }