diff --git a/SMBLibrary/Exceptions/InvalidRequestException.cs b/SMBLibrary/Exceptions/InvalidRequestException.cs deleted file mode 100644 index fe36b41..0000000 --- a/SMBLibrary/Exceptions/InvalidRequestException.cs +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright (C) 2014 Tal Aloni . 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) - { - } - } -} diff --git a/SMBLibrary/NetBios/NBTConnectionReceiveBuffer.cs b/SMBLibrary/NetBios/NBTConnectionReceiveBuffer.cs index 3cd6cb2..d1ceb65 100644 --- a/SMBLibrary/NetBios/NBTConnectionReceiveBuffer.cs +++ b/SMBLibrary/NetBios/NBTConnectionReceiveBuffer.cs @@ -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 /// /// - /// 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; diff --git a/SMBLibrary/NetBios/SessionPackets/SessionPacket.cs b/SMBLibrary/NetBios/SessionPackets/SessionPacket.cs index ca0e3c5..aabaad4 100644 --- a/SMBLibrary/NetBios/SessionPackets/SessionPacket.cs +++ b/SMBLibrary/NetBios/SessionPackets/SessionPacket.cs @@ -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")); } } } diff --git a/SMBLibrary/SMB1/Commands/CheckDirectoryRequest.cs b/SMBLibrary/SMB1/Commands/CheckDirectoryRequest.cs index 00a2afc..af74c66 100644 --- a/SMBLibrary/SMB1/Commands/CheckDirectoryRequest.cs +++ b/SMBLibrary/SMB1/Commands/CheckDirectoryRequest.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2017 Tal Aloni . 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); } diff --git a/SMBLibrary/SMB1/Commands/CreateDirectoryRequest.cs b/SMBLibrary/SMB1/Commands/CreateDirectoryRequest.cs index 2573937..c68a818 100644 --- a/SMBLibrary/SMB1/Commands/CreateDirectoryRequest.cs +++ b/SMBLibrary/SMB1/Commands/CreateDirectoryRequest.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2017 Tal Aloni . 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); } diff --git a/SMBLibrary/SMB1/Commands/DeleteDirectoryRequest.cs b/SMBLibrary/SMB1/Commands/DeleteDirectoryRequest.cs index cb824ba..642fe65 100644 --- a/SMBLibrary/SMB1/Commands/DeleteDirectoryRequest.cs +++ b/SMBLibrary/SMB1/Commands/DeleteDirectoryRequest.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2017 Tal Aloni . 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); } diff --git a/SMBLibrary/SMB1/Commands/DeleteRequest.cs b/SMBLibrary/SMB1/Commands/DeleteRequest.cs index 108cc88..6145f29 100644 --- a/SMBLibrary/SMB1/Commands/DeleteRequest.cs +++ b/SMBLibrary/SMB1/Commands/DeleteRequest.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2017 Tal Aloni . 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); } diff --git a/SMBLibrary/SMB1/Commands/NegotiateRequest.cs b/SMBLibrary/SMB1/Commands/NegotiateRequest.cs index a524a75..ad0fcbe 100644 --- a/SMBLibrary/SMB1/Commands/NegotiateRequest.cs +++ b/SMBLibrary/SMB1/Commands/NegotiateRequest.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2017 Tal Aloni . 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); diff --git a/SMBLibrary/SMB1/Commands/QueryInformationRequest.cs b/SMBLibrary/SMB1/Commands/QueryInformationRequest.cs index b700201..a47c6ec 100644 --- a/SMBLibrary/SMB1/Commands/QueryInformationRequest.cs +++ b/SMBLibrary/SMB1/Commands/QueryInformationRequest.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2017 Tal Aloni . 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); } diff --git a/SMBLibrary/SMB1/Commands/ReadResponse.cs b/SMBLibrary/SMB1/Commands/ReadResponse.cs index e1c701d..7fe9cc7 100644 --- a/SMBLibrary/SMB1/Commands/ReadResponse.cs +++ b/SMBLibrary/SMB1/Commands/ReadResponse.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2017 Tal Aloni . 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); diff --git a/SMBLibrary/SMB1/Commands/RenameRequest.cs b/SMBLibrary/SMB1/Commands/RenameRequest.cs index b642963..03d2b28 100644 --- a/SMBLibrary/SMB1/Commands/RenameRequest.cs +++ b/SMBLibrary/SMB1/Commands/RenameRequest.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2017 Tal Aloni . 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) { diff --git a/SMBLibrary/SMB1/Commands/SMB1Command.cs b/SMBLibrary/SMB1/Commands/SMB1Command.cs index bb0f5d8..8f2b4ed 100644 --- a/SMBLibrary/SMB1/Commands/SMB1Command.cs +++ b/SMBLibrary/SMB1/Commands/SMB1Command.cs @@ -142,7 +142,7 @@ namespace SMBLibrary.SMB1 } else { - throw new InvalidRequestException(); + throw new InvalidDataException(); } } case CommandName.SMB_COM_LOGOFF_ANDX: diff --git a/SMBLibrary/SMB1/Commands/SetInformationRequest.cs b/SMBLibrary/SMB1/Commands/SetInformationRequest.cs index e033b43..00fa2ba 100644 --- a/SMBLibrary/SMB1/Commands/SetInformationRequest.cs +++ b/SMBLibrary/SMB1/Commands/SetInformationRequest.cs @@ -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); } diff --git a/SMBLibrary/SMB1/Commands/WriteRequest.cs b/SMBLibrary/SMB1/Commands/WriteRequest.cs index 0c1702e..d81e0f4 100644 --- a/SMBLibrary/SMB1/Commands/WriteRequest.cs +++ b/SMBLibrary/SMB1/Commands/WriteRequest.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2017 Tal Aloni . 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); diff --git a/SMBLibrary/SMB1/NTTransactSubcommands/NTTransactSubcommand.cs b/SMBLibrary/SMB1/NTTransactSubcommands/NTTransactSubcommand.cs index f8aacfa..56b67fe 100644 --- a/SMBLibrary/SMB1/NTTransactSubcommands/NTTransactSubcommand.cs +++ b/SMBLibrary/SMB1/NTTransactSubcommands/NTTransactSubcommand.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2017 Tal Aloni . 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(); } } } diff --git a/SMBLibrary/SMB1/SMB1Message.cs b/SMBLibrary/SMB1/SMB1Message.cs index 135062a..5843071 100644 --- a/SMBLibrary/SMB1/SMB1Message.cs +++ b/SMBLibrary/SMB1/SMB1Message.cs @@ -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); } diff --git a/SMBLibrary/SMB1/Transaction2Subcommands/Transaction2Subcommand.cs b/SMBLibrary/SMB1/Transaction2Subcommands/Transaction2Subcommand.cs index 9eb3f13..ce7b6c2 100644 --- a/SMBLibrary/SMB1/Transaction2Subcommands/Transaction2Subcommand.cs +++ b/SMBLibrary/SMB1/Transaction2Subcommands/Transaction2Subcommand.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2017 Tal Aloni . 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(); } } } diff --git a/SMBLibrary/SMB1/TransactionSubcommands/TransactionSubcommand.cs b/SMBLibrary/SMB1/TransactionSubcommands/TransactionSubcommand.cs index a65cefa..54019a6 100644 --- a/SMBLibrary/SMB1/TransactionSubcommands/TransactionSubcommand.cs +++ b/SMBLibrary/SMB1/TransactionSubcommands/TransactionSubcommand.cs @@ -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(); } } } diff --git a/SMBLibrary/SMBLibrary.csproj b/SMBLibrary/SMBLibrary.csproj index c1eedbb..10fb2e4 100644 --- a/SMBLibrary/SMBLibrary.csproj +++ b/SMBLibrary/SMBLibrary.csproj @@ -60,7 +60,6 @@ - diff --git a/SMBLibrary/Server/SMB1/NTTransactHelper.cs b/SMBLibrary/Server/SMB1/NTTransactHelper.cs index 5290e8f..69d14b5 100644 --- a/SMBLibrary/Server/SMB1/NTTransactHelper.cs +++ b/SMBLibrary/Server/SMB1/NTTransactHelper.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); diff --git a/SMBLibrary/Server/SMB1/TransactionHelper.cs b/SMBLibrary/Server/SMB1/TransactionHelper.cs index db3ebd3..5caa89c 100644 --- a/SMBLibrary/Server/SMB1/TransactionHelper.cs +++ b/SMBLibrary/Server/SMB1/TransactionHelper.cs @@ -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);