public string CheckIAmAlive() { IAmAlive alive = new IAmAlive() { IAmAlive1 = new IAmAliveType() { IAmAlive = true, Reason = "" } }; var securityHeader = new SecurityHeaderType(); var header = new Header(); ppjInterfaceClient client = GetClient(); IAmAlive response = client.IAmAlive(ref securityHeader, ref header, alive); if (response.IAmAlive1 != null) { //return WriteIAmAliveToListBox(response); return(response.IAmAlive1.Reason); } else { return("Ingen svar fra kontrolrum - IAmAlive"); } }
/// <summary> /// Decode Client Auto Detect Response PDU /// </summary> /// <param name="data"></param> /// <param name="decryptedUserData"></param> /// <param name="type"></param> /// <returns></returns> public StackPacket DecodeClientAutoDetectResponsePDU(byte[] data, byte[] decryptedUserData, SecurityHeaderType type) { Client_Auto_Detect_Response_PDU pdu = new Client_Auto_Detect_Response_PDU(); int dataIndex = 0; pdu.commonHeader = ParseMcsCommonHeader(data, ref dataIndex, type); int userDataIndex = 0; pdu.autodetectRspPduData = ParseNetworkDetectionResponse(decryptedUserData, ref userDataIndex); // ETW Provider Dump Message if (type != SecurityHeaderType.Basic) { // RDP Standard Security string messageName = "RDPBCGR:" + pdu.GetType().Name; ExtendedLogger.DumpMessage(messageName, RdpbcgrUtility.DumpLevel_Layer3, pdu.GetType().Name, decryptedUserData); } // Check if data length exceeded expectation VerifyDataLength(decryptedUserData.Length, userDataIndex, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED); return pdu; }
public GetReservationsRequest(SecurityHeaderType Security, RequestHeaderType RequestHeader, dacGetReservationsInput dacGetReservationsInput) { this.Security = Security; this.RequestHeader = RequestHeader; this.dacGetReservationsInput = dacGetReservationsInput; }
public RefundRequest(SecurityHeaderType Security, RequestHeaderType RequestHeader, dacRefund_Input dacRefund_Input) { this.Security = Security; this.RequestHeader = RequestHeader; this.dacRefund_Input = dacRefund_Input; }
public (bool, string) UpdateJournal(Journal journal) { updateJournal updateJournal = new updateJournal(); updateJournal.Message = GetMessage(journal.Incident); updateJournal.Journal = new JournalType(); updateJournal.Journal.Identification = GetJournalType(journal).Identification; updateJournal.Journal.Patient = new PatientType(); updateJournal.Journal.Patient.FirstName = journal.Name; updateJournal.Journal.Patient.LastName = journal.Lastname; updateJournal.Journal.Patient.SocialSecurityNumber = journal.Cpr; updateJournal.Journal.IncidentIdentification = GetIncidentType(journal.Incident).Identification; ppjInterfaceClient client = GetClient(); var securityHeader = new SecurityHeaderType(); var header = new Header(); var response = client.updateJournal(ref securityHeader, ref header, updateJournal); if (response.Error != null) { return(response.Type == ControlType.POSITIVE, response.Error.Description); } else { return(response.Type == ControlType.POSITIVE, ""); } }
public GetStatusRequest(SecurityHeaderType Security, RequestHeaderType RequestHeader, dacGetStatusInput dacGetStatusInput) { this.Security = Security; this.RequestHeader = RequestHeader; this.dacGetStatusInput = dacGetStatusInput; }
public (bool, string) CloseIncident(Incident incident) { closeIncident closeIncident = new closeIncident(); closeIncident.Message = GetMessage(incident); closeIncident.IncidentIdentification = new IdentificationType { Identification = incident.ID.ToString(), IdentificationSchema = "UUID" }; ppjInterfaceClient client = GetClient(); var securityHeader = new SecurityHeaderType(); var header = new Header(); var response = client.closeIncident(ref securityHeader, ref header, closeIncident); if (response.Error != null) { return(response.Type == ControlType.POSITIVE, response.Error.Description); } else { return(response.Type == ControlType.POSITIVE, ""); } }
public System.Threading.Tasks.Task<SendResponse> SendAsync(SecurityHeaderType Security, RequestHeaderType RequestHeader, dacInput dacInput) { SendRequest inValue = new SendRequest(); inValue.Security = Security; inValue.RequestHeader = RequestHeader; inValue.dacInput = dacInput; return ((SendV01)(this)).SendAsync(inValue); }
private SecurityHeaderType GetSecurityHeaderType() { SecurityHeaderType securityHeader = new SecurityHeaderType(); DateTime created = DateTime.Now; string creationDate; creationDate = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ"); string nonce = nonce = (new Random().Next(0, int.MaxValue)).ToString(); byte[] hashedPassword; hashedPassword = GetSHA1(_credentials.SoapSecurity.Password); // https://github.com/povilaspanavas/RoyalMailShippingApiV2/issues/1 // after hippasus raised issue, I've changed the encoding (previously was using Default). Ran the tests and it worked // However, wouldn't work for ive server. So, the concatednatedDigestInput uses Default. But encodedNonce uses UK one. // Now it works on our live server, and in tests. string concatednatedDigestInput = string.Concat(nonce, creationDate, Encoding.Default.GetString(hashedPassword)); //string concatednatedDigestInput = string.Concat(nonce, creationDate, encoding.GetString(hashedPassword)); byte[] digest; digest = GetSHA1(concatednatedDigestInput); string passwordDigest; passwordDigest = Convert.ToBase64String(digest); var encoding = Encoding.GetEncoding("iso-8859-1"); string encodedNonce = Convert.ToBase64String(encoding.GetBytes(nonce)); XmlDocument doc = new XmlDocument(); using (XmlWriter writer = doc.CreateNavigator().AppendChild()) { writer.WriteStartDocument(); writer.WriteStartElement("Security"); writer.WriteStartElement("UsernameToken", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"); writer.WriteElementString("Username", _credentials.SoapSecurity.Username); writer.WriteElementString("Password", passwordDigest); writer.WriteElementString("Nonce", encodedNonce); writer.WriteElementString("Created", creationDate); writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); } doc.DocumentElement.RemoveAllAttributes(); System.Xml.XmlElement[] headers = doc.DocumentElement.ChildNodes.Cast <XmlElement>().ToArray <XmlElement>(); securityHeader.Any = headers; return(securityHeader); }
public System.Threading.Tasks.Task <GetStatusResponse> GetStatusAsync(SecurityHeaderType Security, RequestHeaderType RequestHeader, dacGetStatusInput dacGetStatusInput) { GetStatusRequest inValue = new GetStatusRequest(); inValue.Security = Security; inValue.RequestHeader = RequestHeader; inValue.dacGetStatusInput = dacGetStatusInput; return(((GetStatusV02)(this)).GetStatusAsync(inValue)); }
static private SecurityHeaderType CreateSecurityHeader(string usernameAuthenticate, string passwordAuthenticate) { SecurityHeaderType securityHeader = new SecurityHeaderType() { Any = CreateUserNameToken(usernameAuthenticate, passwordAuthenticate) }; return(securityHeader); }
public System.Threading.Tasks.Task <CancelResponse> CancelAsync(SecurityHeaderType Security, RequestHeaderType RequestHeader, Input Input) { CancelRequest inValue = new CancelRequest(); inValue.Security = Security; inValue.RequestHeader = RequestHeader; inValue.Input = Input; return(((CancelV01)(this)).CancelAsync(inValue)); }
public System.Threading.Tasks.Task <ReserveResponse> ReserveAsync(SecurityHeaderType Security, RequestHeaderType RequestHeader, dacInput dacInput) { ReserveRequest inValue = new ReserveRequest(); inValue.Security = Security; inValue.RequestHeader = RequestHeader; inValue.dacInput = dacInput; return(((ReserveV01)(this)).ReserveAsync(inValue)); }
public dacOutput Send(ref SecurityHeaderType Security, RequestHeaderType RequestHeader, dacInput dacInput) { SendRequest inValue = new SendRequest(); inValue.Security = Security; inValue.RequestHeader = RequestHeader; inValue.dacInput = dacInput; SendResponse retVal = ((SendV01)(this)).Send(inValue); Security = retVal.Security; return retVal.dacOutput; }
public dacGetStatusOutput GetStatus(ref SecurityHeaderType Security, RequestHeaderType RequestHeader, dacGetStatusInput dacGetStatusInput) { GetStatusRequest inValue = new GetStatusRequest(); inValue.Security = Security; inValue.RequestHeader = RequestHeader; inValue.dacGetStatusInput = dacGetStatusInput; GetStatusResponse retVal = ((GetStatusV02)(this)).GetStatus(inValue); Security = retVal.Security; return(retVal.dacGetStatusOutput); }
public dacOutput Reserve(ref SecurityHeaderType Security, RequestHeaderType RequestHeader, dacInput dacInput) { ReserveRequest inValue = new ReserveRequest(); inValue.Security = Security; inValue.RequestHeader = RequestHeader; inValue.dacInput = dacInput; ReserveResponse retVal = ((ReserveV01)(this)).Reserve(inValue); Security = retVal.Security; return(retVal.dacOutput); }
public dacRefund_Output RequestPayment(ref SecurityHeaderType Security, RequestHeaderType RequestHeader, dacRefund_Input dacRefund_Input) { RequestPaymentRequest inValue = new RequestPaymentRequest(); inValue.Security = Security; inValue.RequestHeader = RequestHeader; inValue.dacRefund_Input = dacRefund_Input; RequestPaymentResponse retVal = ((RequestPaymentV01)(this)).RequestPayment(inValue); Security = retVal.Security; return(retVal.dacRefund_Output); }
static int ConnectSample() { PmsXchangeService service = new PmsXchangeService(); System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); //The security header is untyped due to the lax processing instruction System.Xml.XmlElement token = doc.CreateElement("UsernameToken"); System.Xml.XmlElement password = doc.CreateElement("Password"); System.Xml.XmlElement username = doc.CreateElement("Username"); System.Xml.XmlText usernameText = doc.CreateTextNode("SPIOrangeTest"); System.Xml.XmlText passwordText = doc.CreateTextNode("YOURPASSWORD"); username.AppendChild(usernameText); password.AppendChild(passwordText); token.AppendChild(username); token.AppendChild(password); System.Xml.XmlElement[] elements = new System.Xml.XmlElement[] { token }; SecurityHeaderType type = new SecurityHeaderType(); service.Security = type; service.Security.Any = elements; OTA_ReadRQ otaReadRQ = new OTA_ReadRQ(); otaReadRQ.Version = 1.0M; OTA_ReadRQReadRequests rr = new OTA_ReadRQReadRequests(); OTA_ReadRQReadRequestsHotelReadRequest hotelR = new OTA_ReadRQReadRequestsHotelReadRequest(); hotelR.HotelCode = "123"; object[] ob = new object[] { hotelR }; rr.Items = ob; OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteria crit = new OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteria(); OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteriaSelectionType selType = OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteriaSelectionType.Undelivered; crit.SelectionType = selType; crit.SelectionTypeSpecified = true; hotelR.SelectionCriteria = crit; otaReadRQ.ReadRequests = rr; // Retrieve the response Console.WriteLine("About to make request :::"); OTA_ResRetrieveRS resRetrieveRS = service.ReadRQ(otaReadRQ); Console.WriteLine("Received response :::"); //Do further work .... // .... return(0); }
public Output Cancel(ref SecurityHeaderType Security, RequestHeaderType RequestHeader, Input Input) { CancelRequest inValue = new CancelRequest(); inValue.Security = Security; inValue.RequestHeader = RequestHeader; inValue.Input = Input; CancelResponse retVal = ((CancelV01)(this)).Cancel(inValue); Security = retVal.Security; return(retVal.Output); }
public (bool, string) UpdateTask(Preparedness preparedness) { updateTask updateTask = new updateTask { Message = GetMessage(preparedness.Incident), TaskIdentification = GetTaskType(preparedness).Identification, Task = new TaskType { IncidentIdentification = GetIncidentType(preparedness.Incident).Identification, } }; updateTask.Task.Identification = GetTaskType(preparedness).Identification; updateTask.Task.Vehicle = GetTaskType(preparedness).Vehicle; updateTask.Task.PriorityToIncident = preparedness.EmergencyCode.Code; //Status for Task updateTaskStatus updateTaskStatus = new updateTaskStatus { TaskIdentification = GetTaskType(preparedness).Identification, Message = GetMessage(preparedness.Incident), Status = new TaskStatusType { Code = GetConvertedEnums(preparedness), Time = DateTime.UtcNow.ToString("yyyy'-'MM'-'ddTHH':'mm':'ss':'fff") } }; ppjInterfaceClient client = GetClient(); var securityHeader = new SecurityHeaderType(); var header = new Header(); var response = client.updateTask(ref securityHeader, ref header, updateTask); var tastStatusResponse = client.updateTaskStatus(ref securityHeader, ref header, updateTaskStatus); if (response.Error != null || tastStatusResponse.Error != null) { return(response.Type == ControlType.POSITIVE, response.Error.Description); } else { return(response.Type == ControlType.POSITIVE, ""); } }
public String GetPrescriptions(String cpr) { SecurityHeaderType sec = _sosiUtil.MakeSecurity(); Header header = _sosiUtil.MakeHeader(); GetPrescriptionRequest_2015_06_01 request = new GetPrescriptionRequest_2015_06_01 { GetPrescriptionRequest = new GetPrescriptionRequestType { Item = new PersonIdentifierType() { Value = cpr, source = "CPR" }, Items = new object[] { new IncludeOpenPrescriptionsType() }, IncludeEffectuations = true }, Header = header, Security = sec, WhitelistingHeader = MakeWhitelistingHeader() }; PrescriptionReplicationStatusType prescriptionReplicationStatus; GetPrescriptionResponseType responseType; var timingList = _fmkClient.GetPrescription_2015_06_01(sec, header, null, request.WhitelistingHeader, null, request.GetPrescriptionRequest, out prescriptionReplicationStatus, out responseType); fmkclient.net.fmk20150601.GetPrescriptionResponse_2015_06_01 response = new GetPrescriptionResponse_2015_06_01(timingList, prescriptionReplicationStatus, responseType); var sww = new StringWriter(); var writer = XmlWriter.Create(sww); var x = new XmlSerializer(response.GetType()); x.Serialize(writer, response); return(sww.ToString()); }
public (bool, string) CloseTask(Preparedness preparedness) { closeTask closeTask = new closeTask { Message = GetMessage(preparedness.Incident), TaskIdentification = GetTaskType(preparedness).Identification }; ppjInterfaceClient client = GetClient(); var securityHeader = new SecurityHeaderType(); var header = new Header(); var response = client.closeTask(ref securityHeader, ref header, closeTask); if (response.Error != null) { return(response.Type == ControlType.POSITIVE, response.Error.Description); } else { return(response.Type == ControlType.POSITIVE, ""); } }
/// <summary> /// Decode Auto-Reconnect Status PDU /// </summary> /// <param name="data">data to be parsed</param> /// <param name="decryptedUserData">decrypted user data</param> /// <param name="type">security header type</param> /// <returns>decoded Auto-Reconnect Status PDU</returns> public StackPacket DecodeAutoReconnectStatusPDU( byte[] data, byte[] decryptedUserData, SecurityHeaderType type) { Server_Auto_Reconnect_Status_Pdu pdu = new Server_Auto_Reconnect_Status_Pdu(); // data index int dataIndex = 0; // AutoReconnectStatusPDU: commonHeader pdu.commonHeader = ParseMcsCommonHeader(data, ref dataIndex, type); // user data index int userDataIndex = 0; // AutoReconnectStatusPDU: arcStatusPduData pdu.arcStatusPduData = ParseTsAutoReconnectStatusPdu(decryptedUserData, ref userDataIndex); // Check if data length exceeded expectation VerifyDataLength(decryptedUserData.Length, userDataIndex, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED); return pdu; }
public (bool, string) UpdateIncident(Incident incident) { updateIncident updateIncident = new updateIncident { Message = GetMessage(incident), Incident = new IncidentType() }; updateIncident.Incident = GetIncidentType(incident); updateIncident.Incident.Address = new Address { StreetName = incident.Address, HouseNumber = incident.Number, City = incident.City, ZipCode = incident.PostNr, }; updateIncident.Incident.IncidentDescription = incident.Description; ppjInterfaceClient client = GetClient(); var securityHeader = new SecurityHeaderType(); var header = new Header(); var response = client.updateIncident(ref securityHeader, ref header, updateIncident); if (response.Error != null) { //Return the code in ServiceLog in DB and message for the log return(response.Type == ControlType.POSITIVE, response.Error.Description); } else { //Return the code in ServiceLog in DB and message for the log return(response.Type == ControlType.POSITIVE, ""); } }
public CancelResponse(SecurityHeaderType Security, Output Output) { this.Security = Security; this.Output = Output; }
public RequestPaymentResponse(SecurityHeaderType Security, dacRefund_Output dacRefund_Output) { this.Security = Security; this.dacRefund_Output = dacRefund_Output; }
/// <summary> /// Switch Decode MCS Data PDU /// </summary> /// <param name="data">data to be parsed</param> /// <param name="decryptedUserData">decrypted user data</param> /// <param name="securityHeaderType">security header type</param> /// <returns>decoded MCS Data PDU</returns> private StackPacket SwitchDecodeMcsDataPDU( byte[] data, byte[] decryptedUserData, SecurityHeaderType securityHeaderType) { // Parser index int currentIndex = 0; // Share data header TS_SHAREDATAHEADER dataHeader = ParseTsShareDataHeader(decryptedUserData, ref currentIndex); // Switch decoder by pduType2 StackPacket pdu = null; switch (dataHeader.pduType2) { // Control PDU case pduType2_Values.PDUTYPE2_CONTROL: pdu = DecodeControlPDU(data, decryptedUserData, securityHeaderType); break; case pduType2_Values.PDUTYPE2_INPUT: pdu = DecodeSlowPathInputEventPDU(data, decryptedUserData, securityHeaderType); break; // Synchronize PDU case pduType2_Values.PDUTYPE2_SYNCHRONIZE: pdu = DecodeSynchronizePDU(data, decryptedUserData, securityHeaderType); break; case pduType2_Values.PDUTYPE2_REFRESH_RECT: pdu = DecodeRefreshRectPDU(data, decryptedUserData, securityHeaderType); break; case pduType2_Values.PDUTYPE2_SUPPRESS_OUTPUT: pdu = DecodeSuppressOutputPDU(data, decryptedUserData, securityHeaderType); break; case pduType2_Values.PDUTYPE2_SHUTDOWN_REQUEST: pdu = DecodeShutdownRequestPDU(data, decryptedUserData, securityHeaderType); break; case pduType2_Values.PDUTYPE2_FONTLIST: pdu = DecodeFontListPDU(data, decryptedUserData, securityHeaderType); break; case pduType2_Values.PDUTYPE2_BITMAPCACHE_PERSISTENT_LIST: pdu = DecodePersistentKeyListPDU(data, decryptedUserData, securityHeaderType); break; case pduType2_Values.PDUTYPE2_FRAME_ACKNOWLEDGE: pdu = DecodeFrameAcknowledgePDU(data, decryptedUserData, securityHeaderType); break; default: throw new FormatException(ConstValue.ERROR_MESSAGE_ENUM_UNRECOGNIZED); } return pdu; }
/// <summary> /// Decode Server Status Info PDU /// </summary> /// <param name="data">data to be parsed</param> /// <param name="decryptedUserData">decrypted user data</param> /// <param name="type">security header type</param> /// <returns>decoded Server Status Info PDU</returns> public StackPacket DecodeStatusInfoPDU( byte[] data, byte[] decryptedUserData, SecurityHeaderType type) { Server_Status_Info_Pdu pdu = new Server_Status_Info_Pdu(); // data index int dataIndex = 0; // StatusInfoPDU: commonHeader pdu.commonHeader = ParseMcsCommonHeader(data, ref dataIndex, type); // user data index int userDataIndex = 0; // StatusInfoPDU: shareDataHeader pdu.shareDataHeader = ParseTsShareDataHeader(decryptedUserData, ref userDataIndex); // StatusInfoPDU: statusCode pdu.statusCode = (StatusCode_Values)ParseUInt32(decryptedUserData, ref userDataIndex, false); // Check if data length exceeded expectation VerifyDataLength(decryptedUserData.Length, userDataIndex, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED); return pdu; }
/// <summary> /// [TD Reference 2.2.2.3] /// Decode Server Shutdown Request Denied PDU /// </summary> /// <param name="data">data to be parsed</param> /// <param name="decryptedUserData">decrypted user data to be parsed</param> /// <param name="type">security header type</param> /// <returns>decoded Shutdown Request Denied PDU</returns> public StackPacket DecodeShutdownRequestDeniedPDU( byte[] data, byte[] decryptedUserData, SecurityHeaderType type) { Server_Shutdown_Request_Denied_Pdu pdu = new Server_Shutdown_Request_Denied_Pdu(); // data index int dataIndex = 0; // ShutdownRequestDeniedPDU: commonHeader pdu.commonHeader = ParseMcsCommonHeader(data, ref dataIndex, type); // user data index int userDataIndex = 0; // ShutdownRequestDeniedPDU: pdu.shutdownRequestDeniedPduData = ParseTsShutdownDeniedPdu(decryptedUserData, ref userDataIndex); // Check if data length exceeded expectation VerifyDataLength(decryptedUserData.Length, userDataIndex, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED); return pdu; }
/// <summary> /// Decode Standard Security Server Redirection PDU. /// </summary> /// <param name="data">data to be parsed</param> /// <param name="decryptedUserData">decrypted user data to be parsed</param> /// <param name="type">security header type</param> /// <returns>decoded Server Redirection PDU</returns> public StackPacket DecodeServerRedirectionPDU( byte[] data, byte[] decryptedUserData, SecurityHeaderType type) { Server_Redirection_Pdu pdu = new Server_Redirection_Pdu(); // data index int dataIndex = 0; UpdateSecurityHeaderType(ref type); // Server_Redirection_Pdu: commonHeader pdu.commonHeader = ParseMcsCommonHeader(data, ref dataIndex, type); // user data index int userDataIndex = 0; // Server_Redirection_PDU: serverRedirectionPdu pdu.serverRedirectionPdu = ParseRdpServerRedirectionPacket(decryptedUserData, ref userDataIndex); // Check if data length exceeded expectation VerifyDataLength(decryptedUserData.Length, userDataIndex, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED); return pdu; }
/// <summary> /// Decode Server Heartbeat PDU /// </summary> /// <param name="data"></param> /// <param name="decryptedUserData"></param> /// <param name="type"></param> /// <returns></returns> public StackPacket DecodeServerHeartbeatPDU( byte[] data, byte[] decryptedUserData, SecurityHeaderType type) { Server_Heartbeat_PDU pdu = new Server_Heartbeat_PDU(); // data index int dataIndex = 0; // Server_Heartbeat_PDU: commonHeader pdu.commonHeader = ParseMcsCommonHeader(data, ref dataIndex, type); // user data index int userDataIndex = 0; if (type == SecurityHeaderType.None) { pdu.commonHeader.securityHeader = ParseTsSecurityHeaderBasic(decryptedUserData, ref userDataIndex); } // reserved pdu.reserved = ParseByte(decryptedUserData, ref userDataIndex); // reserved pdu.period = ParseByte(decryptedUserData, ref userDataIndex); // reserved pdu.count1 = ParseByte(decryptedUserData, ref userDataIndex); // reserved pdu.count2 = ParseByte(decryptedUserData, ref userDataIndex); // Check if data length exceeded expectation VerifyDataLength(decryptedUserData.Length, userDataIndex, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED); return pdu; }
/// <summary> /// Decode Enhanced Security Server Redirection PDU. /// </summary> /// <param name="data">data to be parsed</param> /// <param name="decryptedUserData">decrypted user data to be parsed</param> /// <param name="type">security header type</param> /// <returns>decoded Server Redirection PDU</returns> public StackPacket DecodeEnhancedServerRedirectionPDU( byte[] data, byte[] decryptedUserData, SecurityHeaderType type) { Enhanced_Security_Server_Redirection_Pdu pdu = new Enhanced_Security_Server_Redirection_Pdu(); // data index int dataIndex = 0; // Server_Redirection_Pdu: commonHeader pdu.commonHeader = ParseMcsCommonHeader(data, ref dataIndex, type); // user data index int userDataIndex = 0; pdu.shareControlHeader = ParseTsShareControlHeader(decryptedUserData, ref userDataIndex); pdu.pad = ParseUInt16(decryptedUserData, ref userDataIndex, false); // Server_Redirection_PDU: serverRedirectionPdu pdu.serverRedirectionPdu = ParseRdpServerRedirectionPacket(decryptedUserData, ref userDataIndex); // check if there's paddings int remainBytes = decryptedUserData.Length - userDataIndex; if (remainBytes > 0) { pdu.pad1Octet = GetBytes(decryptedUserData, ref userDataIndex, remainBytes); } // Check if data length exceeded expectation VerifyDataLength(decryptedUserData.Length, userDataIndex, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED); return pdu; }
/// <summary> /// Decrypt Send Data Indication /// </summary> /// <param name="userData">user data</param> /// <param name="securityHeaderType">security header type</param> /// <returns>decrypted user data</returns> private byte[] DecryptSendDataIndication(byte[] userData, SecurityHeaderType securityHeaderType) { // Parse security header int index = 0; TS_SECURITY_HEADER header = ParseTsSecurityHeader(userData, ref index, securityHeaderType); // If header is absent, data is not encrypted, return directly if (null == header) { return userData; } // Get remain data with security header removed int remainLength = userData.Length - index; byte[] remainData = GetBytes(userData, ref index, remainLength); // Header is present, but still data is not encrypted, return directly bool isEncryptFlagExist = IsFlagExist((UInt16)header.flags, (UInt16)TS_SECURITY_HEADER_flags_Values.SEC_ENCRYPT); bool isRedirectFlagExist = IsFlagExist((UInt16)header.flags, (UInt16)TS_SECURITY_HEADER_flags_Values.SEC_REDIRECTION_PKT); if ((!isEncryptFlagExist) && (!isRedirectFlagExist)) { return remainData; } if (isRedirectFlagExist) { SecurityHeaderType oldType = securityHeaderType; UpdateSecurityHeaderType(ref securityHeaderType); if (oldType != securityHeaderType) { index = 0; header = ParseTsSecurityHeader(userData, ref index, securityHeaderType); remainLength = userData.Length - index; remainData = GetBytes(userData, ref index, remainLength); } } // Get data signature (Fips/NonFips only) byte[] signature; switch (securityHeaderType) { case SecurityHeaderType.NonFips: TS_SECURITY_HEADER1 nonFipsHeader = (TS_SECURITY_HEADER1)header; signature = nonFipsHeader.dataSignature; break; case SecurityHeaderType.Fips: TS_SECURITY_HEADER2 fipsHeader = (TS_SECURITY_HEADER2)header; signature = fipsHeader.dataSignature; break; case SecurityHeaderType.Basic: signature = null; break; case SecurityHeaderType.None: signature = null; break; default: throw new FormatException(ConstValue.ERROR_MESSAGE_ENUM_UNRECOGNIZED); } // Check if "Salted MAC Generation" was used in PDU generation bool isSalted = IsFlagExist((UInt16)header.flags, (UInt16)TS_SECURITY_HEADER_flags_Values.SEC_SECURE_CHECKSUM); // Decryption byte[] decryptedData = null; if (!clientContext.Decrypt(remainData, signature, isSalted, out decryptedData)) { // If decryption failed throw new FormatException(ConstValue.ERROR_MESSAGE_DECRYPTION_FAILED); } return decryptedData; }
/// <summary> /// Decode Virtual Channel PDU /// </summary> /// <param name="data">data to be parsed</param> /// <param name="decryptedUserData">decrypted user data</param> /// <param name="type">security header type</param> /// <returns>decoded Virtual Channel PDU</returns> public StackPacket DecodeVirtualChannelPDU( byte[] data, byte[] decryptedUserData, SecurityHeaderType type) { Virtual_Channel_RAW_Server_Pdu pdu = new Virtual_Channel_RAW_Server_Pdu(); // data index int dataIndex = 0; // Virtual_Channel_RAW_Pdu: commonHeader pdu.commonHeader = ParseMcsCommonHeader(data, ref dataIndex, type); // user data index int userDataIndex = 0; // Virtual_Channel_RAW_PDU: channelPduHeader pdu.channelPduHeader = ParseChannelPduHeader(decryptedUserData, ref userDataIndex); // Virtual_Channel_RAW_PDU: virtualChannelData int remainLength = decryptedUserData.Length - Marshal.SizeOf(pdu.channelPduHeader); pdu.virtualChannelData = GetBytes(decryptedUserData, ref userDataIndex, remainLength); // Check if data length exceeded expectation VerifyDataLength(decryptedUserData.Length, userDataIndex, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED); return pdu; }
/// <summary> /// [TD Reference 3.2.5.3.20] /// Decode Control PDU - Cooperate /// </summary> /// <param name="data">data to be parsed</param> /// <param name="decryptedUserData">decrypted user data to be parsed</param> /// <param name="type">security header type</param> /// <returns>decoded Control PDU</returns> public StackPacket DecodeControlPDU( byte[] data, byte[] decryptedUserData, SecurityHeaderType type) { // data index int dataIndex = 0; // ControlPDU: commonHeader SlowPathPduCommonHeader commonHeader = ParseMcsCommonHeader(data, ref dataIndex, type); // user data index int userDataIndex = 0; // ControlPDU: controlPduData TS_CONTROL_PDU controlPduData = ParseTsControlPdu(decryptedUserData, ref userDataIndex); // Get pdu by action type StackPacket pdu; if (controlPduData.action == action_Values.CTRLACTION_COOPERATE) { // Control PDU - cooperate Server_Control_Pdu_Cooperate cooperatePdu = new Server_Control_Pdu_Cooperate(); cooperatePdu.commonHeader = commonHeader; cooperatePdu.controlPduData = controlPduData; pdu = cooperatePdu; } else if (controlPduData.action == action_Values.CTRLACTION_GRANTED_CONTROL) { // Control PDU - granted control Server_Control_Pdu_Granted_Control grantedPdu = new Server_Control_Pdu_Granted_Control(); grantedPdu.commonHeader = commonHeader; grantedPdu.controlPduData = controlPduData; pdu = grantedPdu; } else { throw new FormatException(ConstValue.ERROR_MESSAGE_ENUM_UNRECOGNIZED); } // Check if data length exceeded expectation VerifyDataLength(decryptedUserData.Length, userDataIndex, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED); return pdu; }
/// <summary> /// Decode Virtual Channel PDU /// </summary> /// <param name="data">data to be parsed</param> /// <param name="decryptedUserData">decrypted user data</param> /// <param name="type">security header type</param> /// <returns>decoded Virtual Channel PDU</returns> public StackPacket DecodeVirtualChannelPDU( byte[] data, byte[] decryptedUserData, SecurityHeaderType type) { Virtual_Channel_RAW_Pdu pdu = new Virtual_Channel_RAW_Pdu(); // data index int dataIndex = 0; // Virtual_Channel_RAW_Pdu: commonHeader pdu.commonHeader = ParseMcsCommonHeader(data, ref dataIndex, type); // user data index int userDataIndex = 0; // Virtual_Channel_RAW_PDU: channelPduHeader pdu.channelPduHeader = ParseChannelPduHeader(decryptedUserData, ref userDataIndex); // Virtual_Channel_RAW_PDU: virtualChannelData int remainLength = decryptedUserData.Length - Marshal.SizeOf(pdu.channelPduHeader); pdu.virtualChannelData = GetBytes(decryptedUserData, ref userDataIndex, remainLength); /* // ETW Provider Dump Message if (pdu.commonHeader.securityHeader != null) { // RDP Standard Security string messageName = "RDPBCGR:" + pdu.GetType().Name; ExtendedLogger.DumpMessage(messageName, RdpbcgrUtility.DumpLevel_Layer3, pdu.GetType().Name, decryptedUserData); } * */ // Check if data length exceeded expectation VerifyDataLength(decryptedUserData.Length, userDataIndex, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED); return pdu; }
/// <summary> /// Decode Client Info PDU /// </summary> /// <param name="data">data to be parsed</param> /// <param name="decryptedUserData">decrypted user data</param> /// <param name="type">the security header type</param> /// <returns>Decoded Client Info PDU</returns> public StackPacket DecodeClientInfoPdu( byte[] data, byte[] decryptedUserData, SecurityHeaderType type) { int currentIndex = 0; Client_Info_Pdu pdu = new Client_Info_Pdu(); pdu.commonHeader = ParseMcsCommonHeader(data, ref currentIndex, type); int userDataIndex = 0; pdu.infoPacket = ParseClientInfo(decryptedUserData, ref userDataIndex); // ETW Provider Dump Message if (type != SecurityHeaderType.Basic) { // RDP Standard Security string messageName = "RDPBCGR:" + pdu.GetType().Name; ExtendedLogger.DumpMessage(messageName, RdpbcgrUtility.DumpLevel_Layer3, pdu.GetType().Name, decryptedUserData); } // Check if data length exceeded expectation VerifyDataLength(decryptedUserData.Length, userDataIndex, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED); return pdu; }
/// <summary> /// Decode Synchronize PDU /// </summary> /// <param name="data">data to be parsed</param> /// <param name="decryptedUserData">decrypted user data to be parsed</param> /// <param name="type">security header type</param> /// <returns>decoded Synchronize PDU</returns> public StackPacket DecodeSynchronizePDU( byte[] data, byte[] decryptedUserData, SecurityHeaderType type) { Client_Synchronize_Pdu pdu = new Client_Synchronize_Pdu(); // data index int dataIndex = 0; // SynchronizePDU: commonHeader pdu.commonHeader = ParseMcsCommonHeader(data, ref dataIndex, type); // user data index int userDataIndex = 0; // SynchronizePDU: synchronizePduData pdu.synchronizePduData = ParseTsSynchronizePdu(decryptedUserData, ref userDataIndex); // ETW Provider Dump Message if (pdu.commonHeader.securityHeader != null) { // RDP Standard Security string messageName = "RDPBCGR:" + pdu.GetType().Name; ExtendedLogger.DumpMessage(messageName, RdpbcgrUtility.DumpLevel_Layer3, pdu.GetType().Name, decryptedUserData); } // Check if data length exceeded expectation VerifyDataLength(decryptedUserData.Length, userDataIndex, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED); return pdu; }
/// <summary> /// Parse MCS Common Header /// (parser index is updated according to parsed length) /// </summary> /// <param name="data">data to be parsed</param> /// <param name="currentIndex">current parser index</param> /// <param name="securityHeaderType">security header type</param> /// <returns>MCS Common Header</returns> private SlowPathPduCommonHeader ParseMcsCommonHeader( byte[] data, ref int currentIndex, SecurityHeaderType securityHeaderType) { SlowPathPduCommonHeader header = new SlowPathPduCommonHeader(); // McsCommonHeader: TpktHeader header.tpktHeader = ParseTpktHeader(data, ref currentIndex); // McsCommonHeader: x224Data header.x224Data = ParseX224Data(data, ref currentIndex); // McsCommonHeader: type header.type = ParseByte(data, ref currentIndex); // McsCommonHeader: initiator header.initiator = (UInt16)(ParseUInt16(data, ref currentIndex, true) + ConstValue.CHANNEL_INITIATOR_FILTER); // McsCommonHeader: channelId header.channelId = ParseUInt16(data, ref currentIndex, true); // McsCommonHeader: level(dataPriority & segmentation) header.level = ParseByte(data, ref currentIndex); // McsCommonHeader: user data length byte length1 = ParseByte(data, ref currentIndex); if ((length1 & 0x80) == 0x80) { byte length2 = ParseByte(data, ref currentIndex); header.userDataLength = (uint)(((length1 & 0x7F) << 8) + length2); } else { header.userDataLength = length1; } // McsCommonHeader: securityHeader header.securityHeader = ParseTsSecurityHeader(data, ref currentIndex, securityHeaderType); return header; }
/// <summary> /// Decode Slow-Path Update PDU including Slow-Path Graphics Update PDU and Slow-Path Pointer Update PDU. /// </summary> /// <param name="data">data to be parsed</param> /// <param name="decryptedUserData">decrypted user data to be parsed</param> /// <param name="type">security header type</param> /// <returns>decoded Slow-Path Update PDU</returns> public StackPacket DecodeSlowPathInputEventPDU( byte[] data, byte[] decryptedUserData, SecurityHeaderType type) { TS_INPUT_PDU pdu = new TS_INPUT_PDU(); // data index int dataIndex = 0; // SlowPathOutputPDU: commonHeader pdu.commonHeader = ParseMcsCommonHeader(data, ref dataIndex, type); // user data index int userDataIndex = 0; // SlowPathOutputPDU: slowPathUpdates pdu.shareDataHeader = ParseTsShareDataHeader(decryptedUserData, ref userDataIndex); pdu.numberEvents = ParseUInt16(decryptedUserData, ref userDataIndex, false); pdu.pad2Octets = ParseUInt16(decryptedUserData, ref userDataIndex, false); pdu.slowPathInputEvents = new Collection<TS_INPUT_EVENT>(); // ETW Provider Dump Message if (pdu.commonHeader.securityHeader != null) { // RDP Standard Security string messageName = "RDPBCGR:" + pdu.GetType().Name; ExtendedLogger.DumpMessage(messageName, RdpbcgrUtility.DumpLevel_Layer3, pdu.GetType().Name, decryptedUserData); } while (userDataIndex < decryptedUserData.Length) { pdu.slowPathInputEvents.Add(ParseSlowPathInputEvent(decryptedUserData, ref userDataIndex)); } // Check if data length exceeded expectation VerifyDataLength(decryptedUserData.Length, userDataIndex, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED); return pdu; }
/// <summary> /// Decode Server Initiate multitransport request /// </summary> /// <param name="data">data to be parsed</param> /// <param name="decryptedUserData">decrypted user data</param> /// <param name="type">security header type</param> /// <returns>decoded Server Initiate multitransport request</returns> public StackPacket DecodeServerInitiateMultitransportRequest( byte[] data, byte[] decryptedUserData, SecurityHeaderType type) { Server_Initiate_Multitransport_Request_PDU pdu = new Server_Initiate_Multitransport_Request_PDU(); // data index int dataIndex = 0; // Virtual_Channel_RAW_Pdu: commonHeader pdu.commonHeader = ParseMcsCommonHeader(data, ref dataIndex, type); // user data index int userDataIndex = 0; if (type == SecurityHeaderType.None) { pdu.commonHeader.securityHeader = ParseTsSecurityHeaderBasic(decryptedUserData, ref userDataIndex); } // requestId pdu.requestId = ParseUInt32(decryptedUserData, ref userDataIndex, false); // request protocol pdu.requestedProtocol = (Multitransport_Protocol_value)ParseUInt16(decryptedUserData, ref userDataIndex, false); // reserved pdu.reserved = ParseUInt16(decryptedUserData, ref userDataIndex, false); // security cookie pdu.securityCookie = GetBytes(decryptedUserData, ref userDataIndex, 16); // Check if data length exceeded expectation VerifyDataLength(decryptedUserData.Length, userDataIndex, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED); return pdu; }
/// <summary> /// Switch Decode MCS Send Data Request PDU /// </summary> /// <param name="data">data to be parsed</param> /// <param name="decryptedUserData">decrypted user data</param> /// <param name="securityHeaderType">security header type</param> /// <returns>decoded MCS Send Data Request PDU</returns> private StackPacket SwitchDecodeMcsSendDataRequestPDU( byte[] data, byte[] decryptedUserData, SecurityHeaderType securityHeaderType) { // Parse "share control header" int currentIndex = 0; TS_SHARECONTROLHEADER header = ParseTsShareControlHeader(decryptedUserData, ref currentIndex); ShareControlHeaderType shareControlHeaderType = GetShareControlHeaderType(header); // Switch decoder by share control header type StackPacket pdu = null; switch (shareControlHeaderType) { // Confirm Active PDU case ShareControlHeaderType.PDUTYPE_CONFIRMACTIVEPDU: pdu = DecodeConfirmActivePDU(data, decryptedUserData, securityHeaderType); break; // Data PDU case ShareControlHeaderType.PDUTYPE_DATAPDU: pdu = SwitchDecodeMcsDataPDU(data, decryptedUserData, securityHeaderType); break; case (ShareControlHeaderType)9: pdu = DecodeClientInfoPdu(data, decryptedUserData, securityHeaderType); break; default: throw new FormatException(ConstValue.ERROR_MESSAGE_ENUM_UNRECOGNIZED); } return pdu; }
/// <summary> /// Decode Set Keyboard Indicators PDU /// </summary> /// <param name="data">data to be parsed</param> /// <param name="decryptedUserData">decrypted user data to be parsed</param> /// <param name="type">security header type</param> /// <returns>decoded Set Keyboard Indicators PDU</returns> public StackPacket DecodeSetKeyboardIndicatorsPDU( byte[] data, byte[] decryptedUserData, SecurityHeaderType type) { Server_Set_Keyboard_Indicators_Pdu pdu = new Server_Set_Keyboard_Indicators_Pdu(); // data index int dataIndex = 0; // SetKeyboardIndicatorsPDU: commonHeader pdu.commonHeader = ParseMcsCommonHeader(data, ref dataIndex, type); // user data index int userDataIndex = 0; // SetKeyboardIndicatorsPDU: setKeyBdIndicatorsPduData pdu.setKeyBdIndicatorsPduData = ParseTsSetKeyboardIndicatorsPdu(decryptedUserData, ref userDataIndex); // Check if data length exceeded expectation VerifyDataLength(decryptedUserData.Length, userDataIndex, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED); return pdu; }
public GetReservationsResponse(SecurityHeaderType Security, dacGetReservationsOutput dacGetReservationsOutput) { this.Security = Security; this.dacGetReservationsOutput = dacGetReservationsOutput; }
/// <summary> /// Decode Slow-Path Update PDU including Slow-Path Graphics Update PDU and Slow-Path Pointer Update PDU. /// </summary> /// <param name="data">data to be parsed</param> /// <param name="decryptedUserData">decrypted user data to be parsed</param> /// <param name="type">security header type</param> /// <returns>decoded Slow-Path Update PDU</returns> public StackPacket DecodeSlowPathUpdatePDU( byte[] data, byte[] decryptedUserData, SecurityHeaderType type) { SlowPathOutputPdu pdu = new SlowPathOutputPdu(); // data index int dataIndex = 0; // SlowPathOutputPDU: commonHeader pdu.commonHeader = ParseMcsCommonHeader(data, ref dataIndex, type); // user data index int userDataIndex = 0; // SlowPathOutputPDU: slowPathUpdates pdu.slowPathUpdates = ParseSlowPathUpdates(decryptedUserData, ref userDataIndex); // Check if data length exceeded expectation VerifyDataLength(decryptedUserData.Length, userDataIndex, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED); return pdu; }
/// <summary> /// Decode Monitor Layout PDU /// </summary> /// <param name="data">data to be parsed</param> /// <param name="decryptedUserData">decrypted user data to be parsed</param> /// <param name="type">security header type</param> /// <returns>decoded Monitor Layout PDU</returns> public StackPacket DecodeMonitorLayoutPDU( byte[] data, byte[] decryptedUserData, SecurityHeaderType type) { TS_MONITOR_LAYOUT_PDU pdu = new TS_MONITOR_LAYOUT_PDU(); // data index int dataIndex = 0; // TS_MONITOR_LAYOUT_PDU: commonHeader pdu.commonHeader = ParseMcsCommonHeader(data, ref dataIndex, type); // user data index int userDataIndex = 0; // TS_MONITOR_LAYOUT_PDU: shareDataHeader pdu.shareDataHeader = ParseTsShareDataHeader(decryptedUserData, ref userDataIndex); // TS_MONITOR_LAYOUT_PDU: monitorCount pdu.monitorCount = ParseUInt32(decryptedUserData, ref userDataIndex, false); // TS_MONITOR_LAYOUT_PDU: monitorDefArray pdu.monitorDefArray = new TS_MONITOR_DEF[pdu.monitorCount]; for (int i = 0; i < pdu.monitorDefArray.Length; i++) { pdu.monitorDefArray[i] = ParseTsMonitorDef(decryptedUserData, ref userDataIndex); } // Check if data length exceeded expectation VerifyDataLength(decryptedUserData.Length, userDataIndex, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED); return pdu; }
public ReserveResponse(SecurityHeaderType Security, dacOutput dacOutput) { this.Security = Security; this.dacOutput = dacOutput; }
/// <summary> /// Switch Decode MCS Send Data Indication PDU /// </summary> /// <param name="data">data to be parsed</param> /// <param name="decryptedUserData">decrypted user data</param> /// <param name="securityHeaderType">security header type</param> /// <returns>decoded MCS Send Data Indication PDU</returns> private StackPacket SwitchDecodeMcsSendDataIndicationPDU( byte[] data, byte[] decryptedUserData, SecurityHeaderType securityHeaderType) { // Parse "share control header" int currentIndex = 0; TS_SHARECONTROLHEADER header = ParseTsShareControlHeader(decryptedUserData, ref currentIndex); ShareControlHeaderType shareControlHeaderType = GetShareControlHeaderType(header); // Switch decoder by share control header type StackPacket pdu = null; switch (shareControlHeaderType) { // Demand Active PDU case ShareControlHeaderType.PDUTYPE_DEMANDACTIVEPDU: pdu = DecodeDemandActivePDU(data, decryptedUserData, securityHeaderType); break; // Deactivate All PDU case ShareControlHeaderType.PDUTYPE_DEACTIVATEALLPDU: pdu = DecodeDeactivateAllPDU(data, decryptedUserData, securityHeaderType); break; // Data PDU case ShareControlHeaderType.PDUTYPE_DATAPDU: pdu = SwitchDecodeMcsDataPDU(data, decryptedUserData, securityHeaderType); break; // Server Redirection PDU case ShareControlHeaderType.PDUTYPE_SERVER_REDIR_PKT: pdu = DecodeEnhancedServerRedirectionPDU(data, decryptedUserData, securityHeaderType); break; default: throw new FormatException(ConstValue.ERROR_MESSAGE_ENUM_UNRECOGNIZED); } return pdu; }
/// <summary> /// Decode Persistent Key List PDU /// </summary> /// <param name="data">data to be parsed</param> /// <param name="decryptedUserData">decrypted user data to be parsed</param> /// <param name="type">security header type</param> /// <returns>decoded Control PDU</returns> public StackPacket DecodeFrameAcknowledgePDU( byte[] data, byte[] decryptedUserData, SecurityHeaderType type) { TS_FRAME_ACKNOWLEDGE_PDU pdu = new TS_FRAME_ACKNOWLEDGE_PDU(); // data index int dataIndex = 0; // SlowPathOutputPDU: commonHeader pdu.commonHeader = ParseMcsCommonHeader(data, ref dataIndex, type); // user data index int userDataIndex = 0; // Share Data Header pdu.shareDataHeader = ParseTsShareDataHeader(decryptedUserData, ref userDataIndex); //frame id pdu.frameID = ParseUInt32(decryptedUserData, ref userDataIndex, false); // ETW Provider Dump Message if (pdu.commonHeader.securityHeader != null) { // RDP Standard Security string messageName = "RDPBCGR:" + pdu.GetType().Name; ExtendedLogger.DumpMessage(messageName, RdpbcgrUtility.DumpLevel_Layer3, pdu.GetType().Name, decryptedUserData); } // Check if data length exceeded expectation VerifyDataLength(decryptedUserData.Length, userDataIndex, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED); return pdu; }
/// <summary> /// For Standard Redirection PDU type, an encryption is needed. /// So if there's encryptionLevel is ENCRYPTION_LEVEL_LOW, update the securityHeaderType according to TD. /// </summary> /// <param name="securityHeaderType">security header type</param> private void UpdateSecurityHeaderType(ref SecurityHeaderType securityHeaderType) { // Redirection PDU need to decrypt if (clientContext.RdpEncryptionLevel == EncryptionLevel.ENCRYPTION_LEVEL_LOW) { if (clientContext.RdpEncryptionMethod == EncryptionMethods.ENCRYPTION_METHOD_40BIT || clientContext.RdpEncryptionMethod == EncryptionMethods.ENCRYPTION_METHOD_56BIT || clientContext.RdpEncryptionMethod == EncryptionMethods.ENCRYPTION_METHOD_128BIT) { securityHeaderType = SecurityHeaderType.NonFips; } else if (clientContext.RdpEncryptionMethod == EncryptionMethods.ENCRYPTION_METHOD_FIPS) { securityHeaderType = SecurityHeaderType.Fips; } else { securityHeaderType = SecurityHeaderType.None; } } }
public CancelRequest(SecurityHeaderType Security, RequestHeaderType RequestHeader, Input Input) { this.Security = Security; this.RequestHeader = RequestHeader; this.Input = Input; }
public StackPacket DecodeServerAutoDetectRequestPDU( byte[] data, byte[] decryptedUserData, SecurityHeaderType type) { Server_Auto_Detect_Request_PDU pdu = new Server_Auto_Detect_Request_PDU(); // data index int dataIndex = 0; // Server_Heartbeat_PDU: commonHeader pdu.commonHeader = ParseMcsCommonHeader(data, ref dataIndex, type); // user data index int userDataIndex = 0; if (type == SecurityHeaderType.None) { pdu.commonHeader.securityHeader = ParseTsSecurityHeaderBasic(decryptedUserData, ref userDataIndex); } pdu.autoDetectReqData = ParseNetworkDectectRequest(decryptedUserData, ref userDataIndex); return pdu; }
/// <summary> /// [TD Reference 3.2.5.3.12] /// Decode License Error PDU - Valid Client /// </summary> /// <param name="data">data to be parsed</param> /// <param name="decryptedUserData">decrypted user data to be parsed</param> /// <param name="type">security header type</param> /// <returns>decoded License Error PDU</returns> public StackPacket DecodeLicenseErrorPDU( byte[] data, byte[] decryptedUserData, SecurityHeaderType type) { Server_License_Error_Pdu_Valid_Client pdu = new Server_License_Error_Pdu_Valid_Client(); // data index int currentIndex = 0; // LicenseErrorPDU: commonHeader pdu.commonHeader = ParseMcsCommonHeader(data, ref currentIndex, type); // user data index int userDataIndex = 0; // LicenseErrorPDU: preamble pdu.preamble = ParseLicensePreamble(decryptedUserData, ref userDataIndex); if (pdu.preamble.bMsgType == bMsgType_Values.ERROR_ALERT) { // LicenseErrorPDU: validClientMessage pdu.validClientMessage = ParseLicenseErrorMessage(decryptedUserData, ref userDataIndex); // has received ERROR_ALERT packet, change client context status clientContext.IsWaitingLicenseErrorPdu = false; } else { // RDPELE Type PDU RdpelePdu elePdu = new RdpelePdu(clientContext); elePdu.commonHeader = pdu.commonHeader; elePdu.rdpeleData = decryptedUserData; return elePdu; } // Check if data length exceeded expectation VerifyDataLength(decryptedUserData.Length, userDataIndex, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED); return pdu; }
/// <summary> /// Decode Suppress Output PDU. /// </summary> /// <param name="data">data to be parsed</param> /// <param name="decryptedUserData">decrypted user data to be parsed</param> /// <param name="type">security header type</param> /// <returns>decoded Suppress Output PDU</returns> public StackPacket DecodeSuppressOutputPDU( byte[] data, byte[] decryptedUserData, SecurityHeaderType type) { Client_Suppress_Output_Pdu pdu = new Client_Suppress_Output_Pdu(); int dataIndex = 0; pdu.commonHeader = ParseMcsCommonHeader(data, ref dataIndex, type); int userDataIndex = 0; pdu.suppressOutputPduData = ParseTsSuppressOutputPdu(decryptedUserData, ref userDataIndex); // ETW Provider Dump Message if (pdu.commonHeader.securityHeader != null) { // RDP Standard Security string messageName = "RDPBCGR:" + pdu.GetType().Name; ExtendedLogger.DumpMessage(messageName, RdpbcgrUtility.DumpLevel_Layer3, pdu.GetType().Name, decryptedUserData); } VerifyDataLength(decryptedUserData.Length, userDataIndex, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED); return pdu; }
public GetStatusResponse(SecurityHeaderType Security, dacGetStatusOutput dacGetStatusOutput) { this.Security = Security; this.dacGetStatusOutput = dacGetStatusOutput; }
/// <summary> /// Parse Security Header /// (parser index is updated according to parsed length) /// </summary> /// <param name="data">data to be parsed</param> /// <param name="currentIndex">current parser index</param> /// <param name="headerType">security header type</param> /// <returns>Security Header</returns> private TS_SECURITY_HEADER ParseTsSecurityHeader( byte[] data, ref int currentIndex, SecurityHeaderType headerType) { // parse security header by type TS_SECURITY_HEADER header; switch (headerType) { // without header case SecurityHeaderType.None: header = null; break; // basic header case SecurityHeaderType.Basic: header = ParseTsSecurityHeaderBasic(data, ref currentIndex); break; // non-fips header case SecurityHeaderType.NonFips: header = ParseTsSecurityHeaderNonFips(data, ref currentIndex); break; // fips header case SecurityHeaderType.Fips: header = ParseTsSecurityHeaderFips(data, ref currentIndex); break; default: throw new FormatException(ConstValue.ERROR_MESSAGE_ENUM_UNRECOGNIZED); } return header; }
/// <summary> /// Check if the PDU is a Standard Redirection PDU. /// </summary> /// <param name="userData">user data</param> /// <param name="securityHeaderType">security header type</param> /// <returns>If the PDU is a Standard Redirection PDU.</returns> private bool IsStandardRedirectionPdu(byte[] userData, SecurityHeaderType securityHeaderType) { // Parse security header int index = 0; TS_SECURITY_HEADER header = ParseTsSecurityHeader(userData, ref index, securityHeaderType); if (null == header) { return false; } return IsFlagExist((UInt16)header.flags, (UInt16)TS_SECURITY_HEADER_flags_Values.SEC_REDIRECTION_PKT); }
/// <summary> /// Switch Decode MCS Data PDU /// </summary> /// <param name="data">data to be parsed</param> /// <param name="decryptedUserData">decrypted user data</param> /// <param name="securityHeaderType">security header type</param> /// <returns>decoded MCS Data PDU</returns> private StackPacket SwitchDecodeMcsDataPDU( byte[] data, byte[] decryptedUserData, SecurityHeaderType securityHeaderType) { // Parser index int currentIndex = 0; // Share data header TS_SHAREDATAHEADER dataHeader = ParseTsShareDataHeader(decryptedUserData, ref currentIndex); // Switch decoder by pduType2 StackPacket pdu = null; switch (dataHeader.pduType2) { // Synchronize PDU case pduType2_Values.PDUTYPE2_SYNCHRONIZE: pdu = DecodeSynchronizePDU(data, decryptedUserData, securityHeaderType); break; // Control PDU case pduType2_Values.PDUTYPE2_CONTROL: pdu = DecodeControlPDU(data, decryptedUserData, securityHeaderType); break; // Font Map PDU case pduType2_Values.PDUTYPE2_FONTMAP: pdu = DecodeFontMapPDU(data, decryptedUserData, securityHeaderType); break; // Shutdown-Denied PDU case pduType2_Values.PDUTYPE2_SHUTDOWN_DENIED: pdu = DecodeShutdownRequestDeniedPDU(data, decryptedUserData, securityHeaderType); break; // Set Error Info PDU case pduType2_Values.PDUTYPE2_SET_ERROR_INFO_PDU: pdu = DecodeSetErrorInfoPDU(data, decryptedUserData, securityHeaderType); break; // Save Session Info PDU case pduType2_Values.PDUTYPE2_SAVE_SESSION_INFO: pdu = DecodeSaveSessionInfoPDU(data, decryptedUserData, securityHeaderType); break; // Play Sound PDU case pduType2_Values.PDUTYPE2_PLAY_SOUND: pdu = DecodePlaySoundPDU(data, decryptedUserData, securityHeaderType); break; // Set Keyboard Indicators PDU case pduType2_Values.PDUTYPE2_SET_KEYBOARD_INDICATORS: pdu = DecodeSetKeyboardIndicatorsPDU(data, decryptedUserData, securityHeaderType); break; // Set Keyboard IME Status PDU case pduType2_Values.PDUTYPE2_SET_KEYBOARD_IME_STATUS: pdu = DecodeSetKeyboardImeStatusPDU(data, decryptedUserData, securityHeaderType); break; // Update PDU case pduType2_Values.PDUTYPE2_UPDATE: pdu = DecodeSlowPathUpdatePDU(data, decryptedUserData, securityHeaderType); break; // Pointer PDU case pduType2_Values.PDUTYPE2_POINTER: pdu = DecodeSlowPathUpdatePDU(data, decryptedUserData, securityHeaderType); break; // Status Info PDU case pduType2_Values.PDUTYPE2_STATUS_INFO_PDU: pdu = DecodeStatusInfoPDU(data, decryptedUserData, securityHeaderType); break; // Monitor Layout PDU case pduType2_Values.PDUTYPE2_MONITOR_LAYOUT_PDU: pdu = DecodeMonitorLayoutPDU(data, decryptedUserData, securityHeaderType); break; // Monitor Layout PDU case pduType2_Values.PDUTYPE2_ARC_STATUS_PDU: pdu = DecodeAutoReconnectStatusPDU(data, decryptedUserData, securityHeaderType); break; default: throw new FormatException(ConstValue.ERROR_MESSAGE_ENUM_UNRECOGNIZED); } return pdu; }