internal static void send_authresp(byte[] token, byte[] crypt_hwid, byte[] signature) { int num = 0x80; int num2 = 0x3a; RdpPacket packet = new RdpPacket(); packet.WriteLittleEndian32(num); packet.WriteByte(0x15); packet.WriteByte(2); packet.WriteLittleEndian16((short)num2); packet.WriteLittleEndian16((short)1); packet.WriteLittleEndian16((short)10); packet.Write(token, 0, 10); packet.WriteLittleEndian16((short)1); packet.WriteLittleEndian16((short)20); packet.Write(crypt_hwid, 0, 20); packet.Write(signature, 0, 0x10); IsoLayer.SendMCS(packet, MCS.MSC_GLOBAL_CHANNEL); }
internal static void send_request(byte[] client_random, byte[] rsa_data, byte[] username, byte[] host) { int num = 0x80; int num2 = (username.Length == 0) ? 0 : (username.Length + 1); int num3 = (host.Length == 0) ? 0 : (host.Length + 1); int num4 = (0x80 + num2) + num3; RdpPacket packet = new RdpPacket(); packet.WriteLittleEndian32(num); packet.WriteByte(0x13); packet.WriteByte(2); packet.WriteLittleEndian16((short)num4); packet.WriteLittleEndian32(1); packet.WriteLittleEndianU32(0xff010000); packet.Write(client_random, 0, 0x20); packet.WriteLittleEndian16((short)0); packet.WriteLittleEndian16((short)(Secure.modulus_size + 8)); packet.Write(rsa_data, 0, Secure.modulus_size); packet.Position += 8L; packet.WriteLittleEndian16((short)15); packet.WriteLittleEndian16((short)num2); if (num2 != 0) { packet.Write(username, 0, num2 - 1); packet.WriteByte(0); } packet.WriteLittleEndian16((short)0x10); packet.WriteLittleEndian16((short)num3); if (num3 != 0) { packet.Write(host, 0, num3 - 1); packet.WriteByte(0); } IsoLayer.SendMCS(packet, MCS.MSC_GLOBAL_CHANNEL); }
/// <summary> /// Negotiation Start /// </summary> /// <param name="loadBalanceToken">null</param> /// <param name="bAutoReconnect">false</param> internal static void sendСonnectionRequest(byte[] loadBalanceToken, bool bAutoReconnect) { int num; Secure.dec_count = 0; Secure.enc_count = 0; Network.ConnectionStage = Network.eConnectionStage.Negotiating; if (Options.enableNLA) { // Client X.224 Connection Request PDU sendConnectNegotiation( NegotiationProtocol.PROTOCOL_RDP | NegotiationProtocol.PROTOCOL_SSL | NegotiationProtocol.PROTOCOL_HYBRID, loadBalanceToken); // Server X.224 Connection Confirm PDU num = receiveConnectNegotiation(); if (num == Main.SecureValue3) // SSL подключение запрещено настройками сервера { Network.Close(); Network.Connect(Options.Host, Options.Port); // Client X.224 Connection Request PDU sendConnectNegotiation(NegotiationProtocol.PROTOCOL_RDP, loadBalanceToken); // Server X.224 Connection Confirm PDU num = receiveConnectNegotiation(); if (num != 0) { throw new RDFatalException("Security negotiation failed!"); } } else // SSL подключение разрешено { if (((num & 1) != 0) || ((num & 2) != 0)) { Network.ConnectionStage = Network.eConnectionStage.Securing; Network.ConnectSSL(); } if ((num & 2) != 0) { Network.ConnectionStage = Network.eConnectionStage.Authenticating; CredSSP.Negotiate(Network.GetSSLPublicKey()); } } } else { // Client X.224 Connection Request PDU sendConnectNegotiation(NegotiationProtocol.PROTOCOL_RDP, loadBalanceToken); // Server X.224 Connection Confirm PDU num = receiveConnectNegotiation(); if (num != 0) { throw new RDFatalException("Security negotiation failed!"); } } Network.ConnectionStage = Network.eConnectionStage.Establishing; // Client MCS Connect Initial PDU IsoLayer.SendTPKT(sendConnectInitial(sendMcsData(true, Channels.RegisteredChannels.Count, num))); // Server MCS Connect Response PDU with GCC Conference Create Response receiveConnectResponse(); // Client MCS Erect Domain Request PDU send_ErectDomainRequest(); // Client MCS Attach User Request PDU send_AttachUserRequest(); // Server MCS Attach User Confirm PDU McsUserID = receive_AttachUserConfirm(); // Open User channel send_ChannelJoinRequest(McsUserID + MCS_USERCHANNEL_BASE); // Client MCS Channel Join Request PDU receive_ChannelJoinConfirm(); // Server MCS Channel Join Confirm PDU // Open Global channel send_ChannelJoinRequest(MSC_GLOBAL_CHANNEL); receive_ChannelJoinConfirm(); // Open over channels foreach (var channel in Channels.RegisteredChannels) { if (serverSupportedChannels.Contains(channel.ChannelID)) { send_ChannelJoinRequest(channel.ChannelID); receive_ChannelJoinConfirm(); Debug.WriteLine("Client open over channel: " + channel.ChannelID.ToString()); } } int num2 = 0x40; if (Secure.RDPEncrypted()) { Network.ConnectionStage = Network.eConnectionStage.SecureAndLogin; RdpPacket packet = Secure.establishKey(); packet.Position = 0L; IsoLayer.SendMCS(packet, MSC_GLOBAL_CHANNEL); num2 |= 8; } else { Network.ConnectionStage = Network.eConnectionStage.Login; } // Client Info PDU IsoLayer.SendToGlobalChannel(getLoginInfo(Options.Domain, Options.Username, Options.Password, "", "", bAutoReconnect), num2); }