mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-08-04 15:01:28 +02:00
Use InvalidDataException instead of InvalidRequestException
This commit is contained in:
parent
9a2b1949f0
commit
62cea47d96
21 changed files with 48 additions and 72 deletions
|
@ -1,23 +0,0 @@
|
|||
/* Copyright (C) 2014 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,
|
||||
* either version 3 of the License, or (at your option) any later version.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace SMBLibrary
|
||||
{
|
||||
public class InvalidRequestException : Exception
|
||||
{
|
||||
public InvalidRequestException() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public InvalidRequestException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Utilities;
|
||||
|
||||
namespace SMBLibrary.NetBios
|
||||
|
@ -55,7 +56,6 @@ namespace SMBLibrary.NetBios
|
|||
/// HasCompletePacket must be called and return true before calling DequeuePacket
|
||||
/// </summary>
|
||||
/// <exception cref="System.IO.InvalidDataException"></exception>
|
||||
/// <exception cref="SMBLibrary.InvalidRequestException"></exception>
|
||||
public SessionPacket DequeuePacket()
|
||||
{
|
||||
SessionPacket packet;
|
||||
|
@ -65,7 +65,7 @@ namespace SMBLibrary.NetBios
|
|||
}
|
||||
catch (IndexOutOfRangeException ex)
|
||||
{
|
||||
throw new System.IO.InvalidDataException("Invalid NetBIOS session packet", ex);
|
||||
throw new InvalidDataException("Invalid NetBIOS session packet", ex);
|
||||
}
|
||||
RemovePacketBytes();
|
||||
return packet;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Utilities;
|
||||
|
||||
namespace SMBLibrary.NetBios
|
||||
|
@ -80,7 +81,7 @@ namespace SMBLibrary.NetBios
|
|||
case SessionPacketTypeName.SessionKeepAlive:
|
||||
return new SessionKeepAlivePacket(buffer, offset);
|
||||
default:
|
||||
throw new InvalidRequestException("Invalid NetBIOS session packet type: 0x" + type.ToString("X"));
|
||||
throw new InvalidDataException("Invalid NetBIOS session packet type: 0x" + type.ToString("X"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using Utilities;
|
||||
|
||||
namespace SMBLibrary.SMB1
|
||||
|
@ -32,7 +32,7 @@ namespace SMBLibrary.SMB1
|
|||
BufferFormat = ByteReader.ReadByte(this.SMBData, 0);
|
||||
if (BufferFormat != SupportedBufferFormat)
|
||||
{
|
||||
throw new InvalidRequestException("Unsupported Buffer Format");
|
||||
throw new InvalidDataException("Unsupported Buffer Format");
|
||||
}
|
||||
DirectoryName = SMB1Helper.ReadSMBString(this.SMBData, 1, isUnicode);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using Utilities;
|
||||
|
||||
namespace SMBLibrary.SMB1
|
||||
|
@ -34,7 +34,7 @@ namespace SMBLibrary.SMB1
|
|||
BufferFormat = ByteReader.ReadByte(this.SMBData, 0);
|
||||
if (BufferFormat != SupportedBufferFormat)
|
||||
{
|
||||
throw new InvalidRequestException("Unsupported Buffer Format");
|
||||
throw new InvalidDataException("Unsupported Buffer Format");
|
||||
}
|
||||
DirectoryName = SMB1Helper.ReadSMBString(this.SMBData, 1, isUnicode);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using Utilities;
|
||||
|
||||
namespace SMBLibrary.SMB1
|
||||
|
@ -31,7 +31,7 @@ namespace SMBLibrary.SMB1
|
|||
BufferFormat = ByteReader.ReadByte(this.SMBData, 0);
|
||||
if (BufferFormat != SupportedBufferFormat)
|
||||
{
|
||||
throw new InvalidRequestException("Unsupported Buffer Format");
|
||||
throw new InvalidDataException("Unsupported Buffer Format");
|
||||
}
|
||||
DirectoryName = SMB1Helper.ReadSMBString(this.SMBData, 1, isUnicode);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using Utilities;
|
||||
|
||||
namespace SMBLibrary.SMB1
|
||||
|
@ -36,7 +36,7 @@ namespace SMBLibrary.SMB1
|
|||
BufferFormat = ByteReader.ReadByte(this.SMBData, 0);
|
||||
if (BufferFormat != SupportedBufferFormat)
|
||||
{
|
||||
throw new InvalidRequestException("Unsupported Buffer Format");
|
||||
throw new InvalidDataException("Unsupported Buffer Format");
|
||||
}
|
||||
FileName = SMB1Helper.ReadSMBString(this.SMBData, 1, isUnicode);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using Utilities;
|
||||
|
||||
namespace SMBLibrary.SMB1
|
||||
|
@ -32,7 +32,7 @@ namespace SMBLibrary.SMB1
|
|||
byte bufferFormat = ByteReader.ReadByte(this.SMBData, ref dataOffset);
|
||||
if (bufferFormat != SupportedBufferFormat)
|
||||
{
|
||||
throw new InvalidRequestException("Unsupported Buffer Format");
|
||||
throw new InvalidDataException("Unsupported Buffer Format");
|
||||
}
|
||||
string dialect = ByteReader.ReadNullTerminatedAnsiString(this.SMBData, dataOffset);
|
||||
Dialects.Add(dialect);
|
||||
|
|
|
@ -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,
|
||||
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using Utilities;
|
||||
|
||||
namespace SMBLibrary.SMB1
|
||||
|
@ -34,7 +34,7 @@ namespace SMBLibrary.SMB1
|
|||
BufferFormat = ByteReader.ReadByte(this.SMBData, 0);
|
||||
if (BufferFormat != SupportedBufferFormat)
|
||||
{
|
||||
throw new InvalidRequestException("Unsupported Buffer Format");
|
||||
throw new InvalidDataException("Unsupported Buffer Format");
|
||||
}
|
||||
FileName = SMB1Helper.ReadSMBString(this.SMBData, 1, isUnicode);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using Utilities;
|
||||
|
||||
namespace SMBLibrary.SMB1
|
||||
|
@ -39,7 +39,7 @@ namespace SMBLibrary.SMB1
|
|||
BufferFormat = ByteReader.ReadByte(this.SMBData, 0);
|
||||
if (BufferFormat != SupportedBufferFormat)
|
||||
{
|
||||
throw new InvalidRequestException("Unsupported Buffer Format");
|
||||
throw new InvalidDataException("Unsupported Buffer Format");
|
||||
}
|
||||
ushort CountOfBytesRead = LittleEndianConverter.ToUInt16(this.SMBData, 1);
|
||||
Bytes = ByteReader.ReadBytes(this.SMBData, 3, CountOfBytesRead);
|
||||
|
|
|
@ -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,
|
||||
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using Utilities;
|
||||
|
||||
namespace SMBLibrary.SMB1
|
||||
|
@ -40,13 +40,13 @@ namespace SMBLibrary.SMB1
|
|||
BufferFormat1 = ByteReader.ReadByte(this.SMBData, ref dataOffset);
|
||||
if (BufferFormat1 != SupportedBufferFormat)
|
||||
{
|
||||
throw new InvalidRequestException("Unsupported Buffer Format");
|
||||
throw new InvalidDataException("Unsupported Buffer Format");
|
||||
}
|
||||
OldFileName = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);
|
||||
BufferFormat2 = ByteReader.ReadByte(this.SMBData, ref dataOffset);
|
||||
if (BufferFormat2 != SupportedBufferFormat)
|
||||
{
|
||||
throw new InvalidRequestException("Unsupported Buffer Format");
|
||||
throw new InvalidDataException("Unsupported Buffer Format");
|
||||
}
|
||||
if (isUnicode)
|
||||
{
|
||||
|
|
|
@ -142,7 +142,7 @@ namespace SMBLibrary.SMB1
|
|||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidRequestException();
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
}
|
||||
case CommandName.SMB_COM_LOGOFF_ANDX:
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using Utilities;
|
||||
|
||||
namespace SMBLibrary.SMB1
|
||||
|
@ -41,7 +41,7 @@ namespace SMBLibrary.SMB1
|
|||
BufferFormat = ByteReader.ReadByte(this.SMBData, 0);
|
||||
if (BufferFormat != SupportedBufferFormat)
|
||||
{
|
||||
throw new InvalidRequestException("Unsupported Buffer Format");
|
||||
throw new InvalidDataException("Unsupported Buffer Format");
|
||||
}
|
||||
FileName = SMB1Helper.ReadSMBString(this.SMBData, 1, isUnicode);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using Utilities;
|
||||
|
||||
namespace SMBLibrary.SMB1
|
||||
|
@ -46,7 +46,7 @@ namespace SMBLibrary.SMB1
|
|||
BufferFormat = ByteReader.ReadByte(this.SMBData, 0);
|
||||
if (BufferFormat != SupportedBufferFormat)
|
||||
{
|
||||
throw new InvalidRequestException("Unsupported Buffer Format");
|
||||
throw new InvalidDataException("Unsupported Buffer Format");
|
||||
}
|
||||
ushort dataLength = LittleEndianConverter.ToUInt16(this.SMBData, 1);
|
||||
Data = ByteReader.ReadBytes(this.SMBData, 3, dataLength);
|
||||
|
|
|
@ -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,
|
||||
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using Utilities;
|
||||
|
||||
namespace SMBLibrary.SMB1
|
||||
|
@ -52,7 +52,7 @@ namespace SMBLibrary.SMB1
|
|||
case NTTransactSubcommandName.NT_TRANSACT_QUERY_SECURITY_DESC:
|
||||
return new NTTransactQuerySecurityDescriptorRequest(parameters);
|
||||
}
|
||||
throw new InvalidRequestException();
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Utilities;
|
||||
|
||||
namespace SMBLibrary.SMB1
|
||||
|
@ -99,7 +98,7 @@ namespace SMBLibrary.SMB1
|
|||
{
|
||||
if (!SMB1Header.IsValidSMB1Header(buffer))
|
||||
{
|
||||
throw new InvalidRequestException("Invalid SMB header signature");
|
||||
throw new InvalidDataException("Invalid SMB header signature");
|
||||
}
|
||||
return new SMB1Message(buffer);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using Utilities;
|
||||
|
||||
namespace SMBLibrary.SMB1
|
||||
|
@ -66,7 +66,7 @@ namespace SMBLibrary.SMB1
|
|||
return new Transaction2GetDfsReferralRequest(parameters, data);
|
||||
}
|
||||
}
|
||||
throw new InvalidRequestException();
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using Utilities;
|
||||
|
||||
namespace SMBLibrary.SMB1
|
||||
|
@ -68,7 +68,7 @@ namespace SMBLibrary.SMB1
|
|||
return new TransactionCallNamedPipeRequest(setup, data);
|
||||
}
|
||||
}
|
||||
throw new InvalidRequestException();
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,6 @@
|
|||
<Compile Include="Enums\SMBTransportType.cs" />
|
||||
<Compile Include="Enums\Win32Error.cs" />
|
||||
<Compile Include="EnumStructures\AccessMask.cs" />
|
||||
<Compile Include="Exceptions\InvalidRequestException.cs" />
|
||||
<Compile Include="Exceptions\UnsupportedInformationLevelException.cs" />
|
||||
<Compile Include="Helpers\FileTimeHelper.cs" />
|
||||
<Compile Include="NetBios\NameServicePackets\Enums\NameRecordType.cs" />
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using SMBLibrary.SMB1;
|
||||
using Utilities;
|
||||
|
||||
|
@ -52,7 +52,7 @@ namespace SMBLibrary.Server.SMB1
|
|||
ProcessStateObject processState = state.GetProcessState(header.PID);
|
||||
if (processState == null)
|
||||
{
|
||||
throw new InvalidRequestException();
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
ByteWriter.WriteBytes(processState.TransactionParameters, (int)request.ParameterDisplacement, request.TransParameters);
|
||||
ByteWriter.WriteBytes(processState.TransactionData, (int)request.DataDisplacement, request.TransData);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using SMBLibrary.SMB1;
|
||||
using SMBLibrary.RPC;
|
||||
using SMBLibrary.Services;
|
||||
|
@ -71,7 +71,7 @@ namespace SMBLibrary.Server.SMB1
|
|||
ProcessStateObject processState = state.GetProcessState(header.PID);
|
||||
if (processState == null)
|
||||
{
|
||||
throw new InvalidRequestException();
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
ByteWriter.WriteBytes(processState.TransactionParameters, request.ParameterDisplacement, request.TransParameters);
|
||||
ByteWriter.WriteBytes(processState.TransactionData, request.DataDisplacement, request.TransData);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue