internal static void process_authreq(RdpPacket data) { byte[] destinationArray = new byte[10]; byte[] outData = new byte[10]; byte[] buffer3 = new byte[20]; byte[] buffer4 = new byte[30]; byte[] signature = new byte[0x10]; RC4 rc = new RC4(); byte[] buffer6 = null; if (!parse_authreq(data)) { throw new RDFatalException("Authentication request is incorrect!"); } Array.Copy(m_In_Token, 0, destinationArray, 0, 10); buffer6 = new byte[m_LicenceKey.Length]; Array.Copy(m_LicenceKey, 0, buffer6, 0, m_LicenceKey.Length); rc.engineInitDecrypt(buffer6); rc.crypt(m_In_Token, 0, 10, outData, 0); byte[] sourceArray = generate_hwid(); Array.Copy(outData, 0, buffer4, 0, 10); Array.Copy(sourceArray, 0, buffer4, 10, 20); signature = Secure.sign(m_Licence_Sign_Key, 0x10, 0x10, buffer4, buffer4.Length); Array.Copy(m_LicenceKey, 0, buffer6, 0, m_LicenceKey.Length); rc.engineInitEncrypt(buffer6); rc.crypt(sourceArray, 0, 20, buffer3, 0); send_authresp(destinationArray, buffer3, signature); }
internal static byte[] update(byte[] key, byte[] update_key) { byte[] buffer = new byte[20]; byte[] destinationArray = new byte[m_KeyLength]; byte[] sourceArray = new byte[key.Length]; MemoryStream stream = new MemoryStream(); stream.Write(update_key, 0, m_KeyLength); stream.Write(m_Pad_54, 0, 40); stream.Write(key, 0, m_KeyLength); stream.Position = 0L; buffer = SHA1.ComputeHash(stream); stream = new MemoryStream(); stream.Write(update_key, 0, m_KeyLength); stream.Write(m_Pad_92, 0, 0x30); stream.Write(buffer, 0, 20); stream.Position = 0L; sourceArray = MD5.ComputeHash(stream); Array.Copy(sourceArray, 0, destinationArray, 0, m_KeyLength); RC4 rc = new RC4(); rc.engineInitDecrypt(destinationArray); sourceArray = rc.crypt(sourceArray, 0, m_KeyLength); if (m_KeyLength == 8) { Sign.make40bit(sourceArray); } return(sourceArray); }
public static RdpPacket DecryptPacket(RdpPacket packet) { packet.Position += 8L; byte[] buffer = new byte[packet.Length - packet.Position]; packet.Read(buffer, 0, buffer.Length); if (dec_count == 0x1000) { m_Decrypt_Key = update(m_Decrypt_Key, m_Sec_Decrypt_Update_Key); byte[] destinationArray = new byte[m_KeyLength]; Array.Copy(m_Decrypt_Key, 0, destinationArray, 0, m_KeyLength); m_RC4_Dec.engineInitDecrypt(destinationArray); dec_count = 0; } dec_count++; byte[] buffer3 = m_RC4_Dec.crypt(buffer); packet = new RdpPacket(); packet.Write(buffer3, 0, buffer3.Length); packet.Position = 0L; return(packet); }
internal static void process_issue(RdpPacket data) { int count = 0; RC4 rc = new RC4(); byte[] destinationArray = new byte[m_LicenceKey.Length]; Array.Copy(m_LicenceKey, 0, destinationArray, 0, m_LicenceKey.Length); data.ReadLittleEndian16(); count = data.ReadLittleEndian16(); if ((data.Position + count) <= data.Length) { rc.engineInitDecrypt(destinationArray); byte[] buffer = new byte[count]; data.Read(buffer, 0, count); rc.crypt(buffer, 0, count, buffer, 0); } }