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)(RDPClient.modulus_size + 8)); packet.Write(rsa_data, 0, RDPClient.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); }
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_connection_request(byte[] loadBalanceToken, bool bAutoReconnect) { int num; RDPClient.dec_count = 0; RDPClient.enc_count = 0; Network.ConnectionStage = RDPClient.eConnectionStage.Negotiating; if (RDPClient.enableNLA) { sendConnectNegotiation(3, loadBalanceToken); num = receiveConnectNegotiation(); if (num == 0x10000000) { Network.Close(); Network.Connect(RDPClient.Host, RDPClient.Port); sendConnectNegotiation(0, loadBalanceToken); num = receiveConnectNegotiation(); if (num != 0) { throw new RDFatalException("Security negotiation failed!"); } } else { if (((num & 1) != 0) || ((num & 2) != 0)) { Network.ConnectionStage = RDPClient.eConnectionStage.Securing; Network.ConnectSSL(); } if ((num & 2) != 0) { Network.ConnectionStage = RDPClient.eConnectionStage.Authenticating; CredSSP.Negotiate(Network.GetSSLPublicKey()); } } } else { sendConnectNegotiation(0, loadBalanceToken); num = receiveConnectNegotiation(); if (num != 0) { throw new RDFatalException("Security negotiation failed!"); } } Network.ConnectionStage = RDPClient.eConnectionStage.Establishing; IsoLayer.SendTPKT(sendConnectInitial(sendMcsData(true, Channels.RegisteredChannels.Count, num))); receiveConnectResponse(); send_ErectDomainRequest(); send_AttachUserRequest(); RDPClient.McsUserID = receive_AttachUserConfirm(); send_ChannelJoinRequest(RDPClient.McsUserID + MCS_USERCHANNEL_BASE); receive_ChannelJoinConfirm(); send_ChannelJoinRequest(MSC_GLOBAL_CHANNEL); receive_ChannelJoinConfirm(); foreach (IVirtualChannel channel in Channels.RegisteredChannels) { send_ChannelJoinRequest(channel.ChannelID); receive_ChannelJoinConfirm(); } int num2 = 0x40; if (Secure.RDPEncrypted()) { Network.ConnectionStage = RDPClient.eConnectionStage.SecureAndLogin; RdpPacket packet = Secure.establishKey(); packet.Position = 0L; IsoLayer.SendMCS(packet, MSC_GLOBAL_CHANNEL); num2 |= SEC_ENCRYPT; } else { Network.ConnectionStage = RDPClient.eConnectionStage.Login; } IsoLayer.SendMCS_GlobalChannel(getLoginInfo(RDPClient.Domain, RDPClient.Username, RDPClient.Password, "", "", bAutoReconnect), num2); }